diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8505228651ef67eb4626e2109d49e60deb9aa357..93d2633799940040281e1ecf925c30b88b172ea9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -61,24 +61,45 @@ android:theme="@style/AppTheme.Light" /> <activity - android:name=".ui.coresettings.ChatListListActivity" + android:name=".ui.coresettings.chatlist.ChatListListActivity" android:label="Edit Chat Lists" android:launchMode="singleTask" android:parentActivityName=".ui.chat.MainActivity" android:theme="@style/AppTheme.Light" /> <activity - android:name=".ui.coresettings.ChatListEditActivity" + android:name=".ui.coresettings.chatlist.ChatListEditActivity" android:label="Edit Chat List" android:launchMode="singleTask" - android:parentActivityName=".ui.coresettings.ChatListListActivity" + android:parentActivityName=".ui.coresettings.chatlist.ChatListListActivity" android:theme="@style/AppTheme.Light" /> <activity - android:name=".ui.coresettings.ChatListCreateActivity" + android:name=".ui.coresettings.chatlist.ChatListCreateActivity" android:label="Create Chat List" android:launchMode="singleTask" - android:parentActivityName=".ui.coresettings.ChatListListActivity" + android:parentActivityName=".ui.coresettings.chatlist.ChatListListActivity" + android:theme="@style/AppTheme.Light" /> + + <activity + android:name=".ui.coresettings.network.NetworkListActivity" + android:label="Edit Networks" + android:launchMode="singleTask" + android:parentActivityName=".ui.chat.MainActivity" + android:theme="@style/AppTheme.Light" /> + + <activity + android:name=".ui.coresettings.network.NetworkEditActivity" + android:label="Edit Network" + android:launchMode="singleTask" + android:parentActivityName=".ui.coresettings.network.NetworkListActivity" + android:theme="@style/AppTheme.Light" /> + + <activity + android:name=".ui.coresettings.network.NetworkCreateActivity" + android:label="Create Network" + android:launchMode="singleTask" + android:parentActivityName=".ui.coresettings.network.NetworkListActivity" android:theme="@style/AppTheme.Light" /> <activity diff --git a/app/src/main/java/de/kuschku/libquassel/client/NetworkManager.java b/app/src/main/java/de/kuschku/libquassel/client/NetworkManager.java index 51e23bbdeb1a25d01cd6361aa6a5ac7cd1217adc..5a44a499e1fb493a52ab34d24d65bb6bce95dca6 100644 --- a/app/src/main/java/de/kuschku/libquassel/client/NetworkManager.java +++ b/app/src/main/java/de/kuschku/libquassel/client/NetworkManager.java @@ -26,6 +26,7 @@ import android.support.annotation.NonNull; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Observable; @@ -33,12 +34,28 @@ import java.util.Observable; import de.kuschku.libquassel.syncables.types.impl.Network; import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; import de.kuschku.util.observables.lists.ObservableSet; +import de.kuschku.util.observables.lists.ObservableSortedList; public class NetworkManager extends Observable { @NonNull private final Map<Integer, QNetwork> networks = new HashMap<>(); @NonNull - private final ObservableSet<QNetwork> list = new ObservableSet<>(); + private final ObservableSortedList<QNetwork> list = new ObservableSortedList<>(QNetwork.class, new ObservableSortedList.ItemComparator<QNetwork>() { + @Override + public int compare(QNetwork o1, QNetwork o2) { + return o1.networkName().compareTo(o2.networkName()); + } + + @Override + public boolean areContentsTheSame(QNetwork oldItem, QNetwork newItem) { + return oldItem == newItem; + } + + @Override + public boolean areItemsTheSame(QNetwork item1, QNetwork item2) { + return item1.networkId() == item2.networkId(); + } + }); @NonNull private final Client client; @@ -73,12 +90,7 @@ public class NetworkManager extends Observable { } @NonNull - public ObservableSet<QNetwork> list() { + public ObservableSortedList<QNetwork> networks() { return list; } - - @NonNull - public List<QNetwork> networks() { - return new ArrayList<>(networks.values()); - } } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java index 93c2d49b2d88e146dca1039126bb2d13acbd1072..3bc130a64f8853b0e5b2fb13c6d9bd140a0a620e 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/NetworkInfo.java @@ -346,4 +346,30 @@ public class NetworkInfo extends Observable { result = 31 * result + (rejoinChannels ? 1 : 0); return result; } + + @Override + public String toString() { + return "NetworkInfo{" + + "networkId=" + networkId + + ", networkName='" + networkName + '\'' + + ", identity=" + identity + + ", codecForServer='" + codecForServer + '\'' + + ", codecForEncoding='" + codecForEncoding + '\'' + + ", codecForDecoding='" + codecForDecoding + '\'' + + ", serverList=" + serverList + + ", useRandomServer=" + useRandomServer + + ", perform=" + perform + + ", useAutoIdentify=" + useAutoIdentify + + ", autoIdentifyService='" + autoIdentifyService + '\'' + + ", autoIdentifyPassword='" + autoIdentifyPassword + '\'' + + ", useSasl=" + useSasl + + ", saslAccount='" + saslAccount + '\'' + + ", saslPassword='" + saslPassword + '\'' + + ", useAutoReconnect=" + useAutoReconnect + + ", autoReconnectInterval=" + autoReconnectInterval + + ", autoReconnectRetries=" + autoReconnectRetries + + ", unlimitedReconnectRetries=" + unlimitedReconnectRetries + + ", rejoinChannels=" + rejoinChannels + + '}'; + } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java index 97cc472faa143dce16a93336f1fc1e6c10fa0c3c..3cfbc335e18d2a1a0083388b53fb80b3a710c83f 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/MainActivity.java @@ -87,7 +87,8 @@ import de.kuschku.quasseldroid_ng.ui.chat.drawer.BufferViewConfigAdapter; import de.kuschku.quasseldroid_ng.ui.chat.fragment.ChatFragment; import de.kuschku.quasseldroid_ng.ui.chat.fragment.LoadingFragment; import de.kuschku.quasseldroid_ng.ui.chat.util.Status; -import de.kuschku.quasseldroid_ng.ui.coresettings.ChatListListActivity; +import de.kuschku.quasseldroid_ng.ui.coresettings.chatlist.ChatListListActivity; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.NetworkListActivity; import de.kuschku.quasseldroid_ng.ui.settings.SettingsActivity; import de.kuschku.quasseldroid_ng.ui.setup.CoreSetupActivity; import de.kuschku.util.accounts.Account; @@ -266,6 +267,9 @@ public class MainActivity extends BoundActivity { case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; + case R.id.action_networks: + startActivity(new Intent(this, NetworkListActivity.class)); + return true; default: return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkViewHolder.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkViewHolder.java index 7283e7c58257b26e6420ee2b94e636fa75b5346b..d83248e206f1aae613830b5230a98705f7409fcf 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkViewHolder.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/drawer/NetworkViewHolder.java @@ -44,7 +44,7 @@ public class NetworkViewHolder extends ParentViewHolder { @LayoutRes public static int layout() { - return R.layout.widget_network; + return R.layout.widget_drawer_network; } public void bind(AppContext context, NetworkItem item) { diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListCreateActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListCreateActivity.java similarity index 97% rename from app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListCreateActivity.java rename to app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListCreateActivity.java index b737e81431467714408123513d67dd2e34da29fc..437e0a40d9f8c3af42d0795cb9b4285c64448f2d 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListCreateActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListCreateActivity.java @@ -19,7 +19,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -package de.kuschku.quasseldroid_ng.ui.coresettings; +package de.kuschku.quasseldroid_ng.ui.coresettings.chatlist; import android.os.Bundle; import android.support.annotation.Nullable; @@ -80,7 +80,7 @@ public class ChatListCreateActivity extends BoundActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_chat_list_edit); + setContentView(R.layout.activity_chatlist_edit); ButterKnife.bind(this); setSupportActionBar(toolbar); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListEditActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListEditActivity.java similarity index 97% rename from app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListEditActivity.java rename to app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListEditActivity.java index 4c30404bbe240783bb7a51728dd1226f7ac8f10d..0dc94a3993e6ce982e19800c7ad009872284dfdc 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListEditActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListEditActivity.java @@ -19,7 +19,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -package de.kuschku.quasseldroid_ng.ui.coresettings; +package de.kuschku.quasseldroid_ng.ui.coresettings.chatlist; import android.content.Intent; import android.os.Bundle; @@ -27,7 +27,6 @@ import android.support.annotation.Nullable; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; -import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; @@ -87,7 +86,7 @@ public class ChatListEditActivity extends BoundActivity { id = intent.getIntExtra("id", -1); - setContentView(R.layout.activity_chat_list_edit); + setContentView(R.layout.activity_chatlist_edit); ButterKnife.bind(this); setSupportActionBar(toolbar); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListListActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListListActivity.java similarity index 96% rename from app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListListActivity.java rename to app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListListActivity.java index cbbcad6902841b55bfaec91b0ef0c59e531f258d..d76f35b14caab7f778db5fcbffa8ae307be4d3bc 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/ChatListListActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/chatlist/ChatListListActivity.java @@ -19,19 +19,17 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -package de.kuschku.quasseldroid_ng.ui.coresettings; +package de.kuschku.quasseldroid_ng.ui.coresettings.chatlist; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; -import android.support.v7.widget.AppCompatButton; import android.support.v7.widget.AppCompatImageButton; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -63,7 +61,7 @@ public class ChatListListActivity extends BoundActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_chat_list_list); + setContentView(R.layout.activity_chatlist_list); ButterKnife.bind(this); list.setLayoutManager(new LinearLayoutManager(this)); diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkCreateActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkCreateActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..680eae60a4d04c67748dda23560b746684f23471 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkCreateActivity.java @@ -0,0 +1,325 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.quasseldroid_ng.ui.coresettings.network; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.widget.SwitchCompat; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.Transformation; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.Spinner; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.util.servicebound.BoundActivity; + +public class NetworkCreateActivity extends BoundActivity { + + @Bind(R.id.toolbar) + Toolbar toolbar; + + + @Bind(R.id.networkName) + EditText networkName; + + @Bind(R.id.identity) + Spinner identity; + + @Bind(R.id.rejoinChannels) + CheckBox rejoinChannels; + + @Bind(R.id.useCustomCodecs) + SwitchCompat useCustomCodecs; + @Bind(R.id.groupCustomCodecs) + ViewGroup groupCustomCodecs; + @Bind(R.id.codecForServer) + EditText codecForServer; + @Bind(R.id.codecForEncoding) + EditText codecForEncoding; + @Bind(R.id.codecForDecoding) + EditText codecForDecoding; + + @Bind(R.id.useAutoIdentify) + SwitchCompat useAutoIdentify; + @Bind(R.id.groupAutoIdentify) + ViewGroup groupAutoIdentify; + @Bind(R.id.autoIdentifyService) + EditText autoIdentifyService; + @Bind(R.id.autoIdentifyPassword) + EditText autoIdentifyPassword; + + @Bind(R.id.useSasl) + SwitchCompat useSasl; + @Bind(R.id.groupSasl) + ViewGroup groupSasl; + @Bind(R.id.saslAccount) + EditText saslAccount; + @Bind(R.id.saslPassword) + EditText saslPassword; + + @Bind(R.id.useAutoReconnect) + SwitchCompat useAutoReconnect; + @Bind(R.id.groupAutoReconnect) + ViewGroup groupAutoReconnect; + @Bind(R.id.autoReconnectInterval) + EditText autoReconnectInterval; + @Bind(R.id.autoReconnectRetries) + EditText autoReconnectRetries; + @Bind(R.id.unlimitedAutoReconnectRetries) + CheckBox unlimitedAutoReconnectRetries; + + int id; + private NetworkInfo networkInfo; + + public static void expand(final ViewGroup v) { + v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + final int targetHeight = v.getMeasuredHeight(); + + // Older versions of android (pre API 21) cancel animations for views with a height of 0. + v.getLayoutParams().height = 1; + v.setVisibility(View.VISIBLE); + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + v.getLayoutParams().height = interpolatedTime == 1 + ? ViewGroup.LayoutParams.WRAP_CONTENT + : (int)(targetHeight * interpolatedTime); + v.setAlpha(interpolatedTime); + v.requestLayout(); + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + // 1dp/ms + a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density)); + v.startAnimation(a); + } + + public static void collapse(final ViewGroup v) { + final int initialHeight = v.getMeasuredHeight(); + + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + if(interpolatedTime == 1){ + v.setVisibility(View.GONE); + }else{ + v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime); + v.setAlpha(1 - interpolatedTime); + v.requestLayout(); + } + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density)); + v.startAnimation(a); + } + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + if (intent == null) { + finish(); + return; + } + + id = intent.getIntExtra("id", -1); + + setContentView(R.layout.activity_network_edit); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + useCustomCodecs.setOnCheckedChangeListener(this::updateCustomCodecsVisible); + updateCustomCodecsVisible(null, useCustomCodecs.isChecked()); + + useAutoIdentify.setOnCheckedChangeListener(this::updateAutoIdentifyVisible); + updateAutoIdentifyVisible(null, useAutoIdentify.isChecked()); + + useSasl.setOnCheckedChangeListener(this::updateSaslVisible); + updateSaslVisible(null, useSasl.isChecked()); + + useAutoReconnect.setOnCheckedChangeListener(this::updateAutoReconnectVisible); + updateAutoReconnectVisible(null, useAutoReconnect.isChecked()); + } + + private void updateCustomCodecsVisible(CompoundButton button, boolean visible) { + codecForServer.setEnabled(visible); + codecForEncoding.setEnabled(visible); + codecForDecoding.setEnabled(visible); + + updateViewGroupStatus(groupCustomCodecs, visible); + } + + private void updateAutoIdentifyVisible(CompoundButton button, boolean visible) { + autoIdentifyService.setEnabled(visible); + autoIdentifyPassword.setEnabled(visible); + + updateViewGroupStatus(groupAutoIdentify, visible); + } + + private void updateSaslVisible(CompoundButton button, boolean visible) { + saslAccount.setEnabled(visible); + saslPassword.setEnabled(visible); + + updateViewGroupStatus(groupSasl, visible); + } + + private void updateAutoReconnectVisible(CompoundButton button, boolean visible) { + autoReconnectInterval.setEnabled(visible); + autoReconnectRetries.setEnabled(visible); + unlimitedAutoReconnectRetries.setEnabled(visible); + + updateViewGroupStatus(this.groupAutoReconnect, visible); + } + + private void updateViewGroupStatus(final ViewGroup group, boolean visible) { + if (visible) { + group.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + final int targetHeight = group.getMeasuredHeight(); + + group.getLayoutParams().height = 1; + group.setVisibility(View.VISIBLE); + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + group.getLayoutParams().height = interpolatedTime == 1 + ? ViewGroup.LayoutParams.WRAP_CONTENT + : (int)(targetHeight * interpolatedTime); + group.requestLayout(); + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + a.setDuration((int)(targetHeight / group.getContext().getResources().getDisplayMetrics().density)); + group.startAnimation(a); + } else { + final int initialHeight = group.getMeasuredHeight(); + + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + if(interpolatedTime == 1){ + group.setVisibility(View.GONE); + }else{ + group.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime); + group.requestLayout(); + } + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + a.setDuration((int)(initialHeight / group.getContext().getResources().getDisplayMetrics().density)); + group.startAnimation(a); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.editor, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.action_confirm: { + if (networkInfo != null) { + NetworkInfo after = new NetworkInfo( + 0, + networkName.getText().toString(), + 0, + useCustomCodecs.isChecked() ? this.codecForServer.getText().toString() : null, + useCustomCodecs.isChecked() ? this.codecForEncoding.getText().toString() : null, + useCustomCodecs.isChecked() ? this.codecForDecoding.getText().toString() : null, + null, + true, + null, + useAutoIdentify.isChecked(), + autoIdentifyService.getText().toString(), + autoIdentifyPassword.getText().toString(), + useSasl.isChecked(), + saslAccount.getText().toString(), + saslPassword.getText().toString(), + useAutoReconnect.isChecked(), + Integer.parseInt(autoReconnectInterval.getText().toString()), + Short.parseShort(autoReconnectRetries.getText().toString()), + unlimitedAutoReconnectRetries.isChecked(), + rejoinChannels.isChecked() + ); + + Log.d("DEBUG", "After: " + after); + + finish(); + } + } return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onConnected() { + + } + + @Override + protected void onDisconnected() { + + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkEditActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkEditActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..b1846571cb2eb58ee67ce526f190ddfcc1aa27d4 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkEditActivity.java @@ -0,0 +1,315 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.quasseldroid_ng.ui.coresettings.network; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.widget.SwitchCompat; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.Transformation; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.EditText; +import android.widget.Spinner; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.util.servicebound.BoundActivity; + +public class NetworkEditActivity extends BoundActivity { + + @Bind(R.id.toolbar) + Toolbar toolbar; + + + @Bind(R.id.networkName) + EditText networkName; + + @Bind(R.id.identity) + Spinner identity; + + @Bind(R.id.rejoinChannels) + CheckBox rejoinChannels; + + @Bind(R.id.useCustomCodecs) + SwitchCompat useCustomCodecs; + @Bind(R.id.groupCustomCodecs) + ViewGroup groupCustomCodecs; + @Bind(R.id.codecForServer) + EditText codecForServer; + @Bind(R.id.codecForEncoding) + EditText codecForEncoding; + @Bind(R.id.codecForDecoding) + EditText codecForDecoding; + + @Bind(R.id.useAutoIdentify) + SwitchCompat useAutoIdentify; + @Bind(R.id.groupAutoIdentify) + ViewGroup groupAutoIdentify; + @Bind(R.id.autoIdentifyService) + EditText autoIdentifyService; + @Bind(R.id.autoIdentifyPassword) + EditText autoIdentifyPassword; + + @Bind(R.id.useSasl) + SwitchCompat useSasl; + @Bind(R.id.groupSasl) + ViewGroup groupSasl; + @Bind(R.id.saslAccount) + EditText saslAccount; + @Bind(R.id.saslPassword) + EditText saslPassword; + + @Bind(R.id.useAutoReconnect) + SwitchCompat useAutoReconnect; + @Bind(R.id.groupAutoReconnect) + ViewGroup groupAutoReconnect; + @Bind(R.id.autoReconnectInterval) + EditText autoReconnectInterval; + @Bind(R.id.autoReconnectRetries) + EditText autoReconnectRetries; + @Bind(R.id.unlimitedAutoReconnectRetries) + CheckBox unlimitedAutoReconnectRetries; + + int id; + private NetworkInfo networkInfo; + + public static void expand(final ViewGroup v) { + v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + final int targetHeight = v.getMeasuredHeight(); + + // Older versions of android (pre API 21) cancel animations for views with a height of 0. + v.getLayoutParams().height = 1; + v.setVisibility(View.VISIBLE); + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + v.getLayoutParams().height = interpolatedTime == 1 + ? ViewGroup.LayoutParams.WRAP_CONTENT + : (int)(targetHeight * interpolatedTime); + v.setAlpha(interpolatedTime); + v.requestLayout(); + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + // 1dp/ms + a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density)); + v.startAnimation(a); + } + + public static void collapse(final ViewGroup v) { + final int initialHeight = v.getMeasuredHeight(); + + Animation a = new Animation() + { + @Override + protected void applyTransformation(float interpolatedTime, Transformation t) { + if(interpolatedTime == 1){ + v.setVisibility(View.GONE); + }else{ + v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime); + v.setAlpha(1 - interpolatedTime); + v.requestLayout(); + } + } + + @Override + public boolean willChangeBounds() { + return true; + } + }; + + a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density)); + v.startAnimation(a); + } + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + if (intent == null) { + finish(); + return; + } + + id = intent.getIntExtra("id", -1); + + setContentView(R.layout.activity_network_edit); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + useCustomCodecs.setOnCheckedChangeListener(this::updateCustomCodecsVisible); + updateCustomCodecsVisible(null, useCustomCodecs.isChecked()); + + useAutoIdentify.setOnCheckedChangeListener(this::updateAutoIdentifyVisible); + updateAutoIdentifyVisible(null, useAutoIdentify.isChecked()); + + useSasl.setOnCheckedChangeListener(this::updateSaslVisible); + updateSaslVisible(null, useSasl.isChecked()); + + useAutoReconnect.setOnCheckedChangeListener(this::updateAutoReconnectVisible); + updateAutoReconnectVisible(null, useAutoReconnect.isChecked()); + } + + private void updateCustomCodecsVisible(CompoundButton button, boolean visible) { + codecForServer.setEnabled(visible); + codecForEncoding.setEnabled(visible); + codecForDecoding.setEnabled(visible); + + NetworkEditActivity.this.updateViewGroupStatus(groupCustomCodecs, visible); + } + + private void updateAutoIdentifyVisible(CompoundButton button, boolean visible) { + autoIdentifyService.setEnabled(visible); + autoIdentifyPassword.setEnabled(visible); + + updateViewGroupStatus(groupAutoIdentify, visible); + } + + private void updateSaslVisible(CompoundButton button, boolean visible) { + saslAccount.setEnabled(visible); + saslPassword.setEnabled(visible); + + updateViewGroupStatus(groupSasl, visible); + } + + private void updateAutoReconnectVisible(CompoundButton button, boolean visible) { + autoReconnectInterval.setEnabled(visible); + autoReconnectRetries.setEnabled(visible); + unlimitedAutoReconnectRetries.setEnabled(visible); + + updateViewGroupStatus(this.groupAutoReconnect, visible); + } + + private void updateViewGroupStatus(ViewGroup group, boolean visible) { + if (visible) { + expand(group); + } else { + collapse(group); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.editor, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.action_confirm: { + if (networkInfo != null) { + NetworkInfo after = new NetworkInfo( + networkInfo.networkId(), + networkName.getText().toString(), + //FIXME: IMPLEMENT + networkInfo.identity(), + useCustomCodecs.isChecked() ? this.codecForServer.getText().toString() : null, + useCustomCodecs.isChecked() ? this.codecForEncoding.getText().toString() : null, + useCustomCodecs.isChecked() ? this.codecForDecoding.getText().toString() : null, + //FIXME: IMPLEMENT + networkInfo.serverList(), + networkInfo.useRandomServer(), + //FIXME: IMPLEMENT + networkInfo.perform(), + useAutoIdentify.isChecked(), + autoIdentifyService.getText().toString(), + autoIdentifyPassword.getText().toString(), + useSasl.isChecked(), + saslAccount.getText().toString(), + saslPassword.getText().toString(), + useAutoReconnect.isChecked(), + Integer.parseInt(autoReconnectInterval.getText().toString()), + Short.parseShort(autoReconnectRetries.getText().toString()), + unlimitedAutoReconnectRetries.isChecked(), + rejoinChannels.isChecked() + ); + + Log.d("DEBUG", "Before: " + networkInfo); + Log.d("DEBUG", "After: " + after); + Log.d("DEBUG", "Eq: " + networkInfo.equals(after)); + + finish(); + } + } return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onConnected() { + setNetwork(context.client().networkManager().network(id).networkInfo()); + } + + private void setNetwork(NetworkInfo networkInfo) { + this.networkInfo = networkInfo; + + if (this.networkInfo != null) { + networkName.setText(networkInfo.networkName()); + useCustomCodecs.setChecked(networkInfo.codecForServer() != null || networkInfo.codecForEncoding() != null || networkInfo.codecForDecoding() != null); + codecForServer.setText(networkInfo.codecForServer()); + codecForEncoding.setText(networkInfo.codecForEncoding()); + codecForDecoding.setText(networkInfo.codecForDecoding()); + useAutoIdentify.setChecked(networkInfo.useAutoIdentify()); + autoIdentifyService.setText(networkInfo.autoIdentifyService()); + autoIdentifyPassword.setText(networkInfo.autoIdentifyPassword()); + useSasl.setChecked(networkInfo.useSasl()); + saslAccount.setText(networkInfo.saslAccount()); + saslPassword.setText(networkInfo.saslPassword()); + useAutoReconnect.setChecked(networkInfo.useAutoReconnect()); + autoReconnectInterval.setText(String.valueOf(networkInfo.autoReconnectInterval())); + autoReconnectRetries.setText(String.valueOf(networkInfo.autoReconnectRetries())); + unlimitedAutoReconnectRetries.setChecked(networkInfo.unlimitedReconnectRetries()); + rejoinChannels.setChecked(networkInfo.rejoinChannels()); + + updateCustomCodecsVisible(null, useCustomCodecs.isChecked()); + updateAutoIdentifyVisible(null, useAutoIdentify.isChecked()); + updateSaslVisible(null, useSasl.isChecked()); + updateAutoReconnectVisible(null, useAutoReconnect.isChecked()); + } + } + + @Override + protected void onDisconnected() { + setNetwork(null); + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkListActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkListActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..2ae9ec975df2796ac456d357ab69bdb8a41a6f7b --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/NetworkListActivity.java @@ -0,0 +1,170 @@ +/* + * QuasselDroid - Quassel client for Android + * Copyright (C) 2016 Janne Koschinski + * Copyright (C) 2016 Ken Børge Viktil + * Copyright (C) 2016 Magnus Fjell + * Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.kuschku.quasseldroid_ng.ui.coresettings.network; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.widget.AppCompatImageButton; +import android.support.v7.widget.DefaultItemAnimator; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.libquassel.client.NetworkManager; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewConfig; +import de.kuschku.libquassel.syncables.types.interfaces.QBufferViewManager; +import de.kuschku.libquassel.syncables.types.interfaces.QNetwork; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.util.observables.callbacks.wrappers.AdapterUICallbackWrapper; +import de.kuschku.util.servicebound.BoundActivity; + +public class NetworkListActivity extends BoundActivity { + + NetworkManager manager; + + @Bind(R.id.list) + RecyclerView list; + + @Bind(R.id.add) + FloatingActionButton add; + + @Bind(R.id.toolbar) + Toolbar toolbar; + + ChatListAdapter adapter; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_network_list); + ButterKnife.bind(this); + + list.setLayoutManager(new LinearLayoutManager(this)); + list.setItemAnimator(new DefaultItemAnimator()); + adapter = new ChatListAdapter(); + list.setAdapter(adapter); + + add.setOnClickListener(view -> { + startActivity(new Intent(this, NetworkCreateActivity.class)); + }); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @Override + protected void onConnected() { + manager = context.client().networkManager(); + adapter.setManager(manager); + } + + @Override + protected void onDisconnected() { + manager = null; + adapter.setManager(null); + } + + private class ChatListAdapter extends RecyclerView.Adapter<NetworkViewHolder> { + NetworkManager manager; + AdapterUICallbackWrapper wrapper = new AdapterUICallbackWrapper(this); + + public void setManager(NetworkManager manager) { + if (this.manager != null) + this.manager.networks().addCallback(wrapper); + + this.manager = manager; + + if (this.manager != null) + this.manager.networks().addCallback(wrapper); + } + + @Override + public NetworkViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + View view = inflater.inflate(R.layout.widget_settings_network, parent, false); + return new NetworkViewHolder(view); + } + + @Override + public void onBindViewHolder(NetworkViewHolder holder, int position) { + holder.bind(manager != null ? manager.networks().get(position) : null); + } + + @Override + public int getItemCount() { + return manager == null ? 0 : manager.networks().size(); + } + } + + interface OnQNetworkClickListener { + void onClick(QNetwork network); + } + + interface OnQNetworkDeleteListener { + void onDelete(QNetwork network); + } + + OnQNetworkClickListener clickListener = network -> { + if (network != null) { + Intent intent = new Intent(this, NetworkEditActivity.class); + intent.putExtra("id", network.networkId()); + startActivity(intent); + } + }; + + OnQNetworkDeleteListener deleteListener = network -> { + if (manager != null && network != null) { + context.client().removeNetwork(network.networkId()); + } + }; + + class NetworkViewHolder extends RecyclerView.ViewHolder { + + @Bind(R.id.network_name) + TextView name; + + @Bind(R.id.network_delete) + AppCompatImageButton delete; + + private QNetwork network; + + public NetworkViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + itemView.setOnClickListener(view -> clickListener.onClick(network)); + delete.setOnClickListener(view -> deleteListener.onDelete(network)); + } + + public void bind(QNetwork network) { + this.network = network; + name.setText(network == null ? "" : network.networkName()); + } + } +} diff --git a/app/src/main/res/layout/activity_chat_list_edit.xml b/app/src/main/res/layout/activity_chatlist_edit.xml similarity index 93% rename from app/src/main/res/layout/activity_chat_list_edit.xml rename to app/src/main/res/layout/activity_chatlist_edit.xml index 3627587429f55ef1f932b628b23fe87ce0341d3e..2fe00f61e9ad0eabab00ac7ec15bf79d69e5cf27 100644 --- a/app/src/main/res/layout/activity_chat_list_edit.xml +++ b/app/src/main/res/layout/activity_chatlist_edit.xml @@ -25,7 +25,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:orientation="vertical" + android:background="?attr/colorBackground"> <android.support.design.widget.AppBarLayout android:id="@+id/appBar" @@ -66,8 +67,6 @@ android:layout_width="match_parent" android:layout_height="72dp" android:orientation="vertical" - android:paddingLeft="5dp" - android:paddingRight="5dp" android:paddingTop="16dp"> <TextView @@ -76,8 +75,8 @@ android:layout_gravity="center_vertical" android:textSize="12sp" android:paddingBottom="8dp" - android:paddingLeft="2dp" - android:paddingRight="2dp" + android:paddingLeft="3dp" + android:paddingRight="3dp" android:text="Network"/> <android.support.v7.widget.AppCompatSpinner @@ -130,8 +129,6 @@ android:layout_width="match_parent" android:layout_height="72dp" android:orientation="vertical" - android:paddingLeft="5dp" - android:paddingRight="5dp" android:paddingTop="16dp"> <TextView @@ -140,8 +137,8 @@ android:layout_gravity="center_vertical" android:textSize="12sp" android:paddingBottom="8dp" - android:paddingLeft="2dp" - android:paddingRight="2dp" + android:paddingLeft="3dp" + android:paddingRight="3dp" android:text="Minimum Activity"/> <android.support.v7.widget.AppCompatSpinner diff --git a/app/src/main/res/layout/activity_chatlist_list.xml b/app/src/main/res/layout/activity_chatlist_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..633e507ffa82f927aa08484bb555fd902461c4c5 --- /dev/null +++ b/app/src/main/res/layout/activity_chatlist_list.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ QuasselDroid - Quassel client for Android + ~ Copyright (C) 2016 Janne Koschinski + ~ Copyright (C) 2016 Ken Børge Viktil + ~ Copyright (C) 2016 Magnus Fjell + ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + ~ + ~ This program is free software: you can redistribute it and/or modify it + ~ under the terms of the GNU General Public License as published by the Free + ~ Software Foundation, either version 3 of the License, or (at your option) + ~ any later version. + ~ + ~ This program is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ~ GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. + --> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:background="?attr/colorBackground"> + + <android.support.design.widget.AppBarLayout + android:id="@+id/appBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize"/> + + </android.support.design.widget.AppBarLayout> + + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.RecyclerView + android:id="@+id/list" + android:layout_width="match_parent" + android:layout_height="match_parent" + /> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/add" + android:layout_width="56dp" + android:layout_height="56dp" + android:layout_gravity="end|bottom" + android:layout_marginBottom="16dp" + android:layout_marginEnd="16dp" + android:layout_marginRight="16dp" + android:src="@drawable/ic_plus_dark"/> + </FrameLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_network_edit.xml b/app/src/main/res/layout/activity_network_edit.xml new file mode 100644 index 0000000000000000000000000000000000000000..3f46e15a9700ff231e3c92d46a59b49a39a6c4ab --- /dev/null +++ b/app/src/main/res/layout/activity_network_edit.xml @@ -0,0 +1,291 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ QuasselDroid - Quassel client for Android + ~ Copyright (C) 2016 Janne Koschinski + ~ Copyright (C) 2016 Ken Børge Viktil + ~ Copyright (C) 2016 Magnus Fjell + ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + ~ + ~ This program is free software: you can redistribute it and/or modify it + ~ under the terms of the GNU General Public License as published by the Free + ~ Software Foundation, either version 3 of the License, or (at your option) + ~ any later version. + ~ + ~ This program is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ~ GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. + --> + + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/colorBackground" + android:orientation="vertical"> + + <android.support.design.widget.AppBarLayout + android:id="@+id/appBar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize"/> + + </android.support.design.widget.AppBarLayout> + + <ScrollView + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="16dp"> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/networkName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="networkName"/> + + </android.support.design.widget.TextInputLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="72dp" + android:orientation="vertical" + android:paddingTop="16dp"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:paddingBottom="8dp" + android:paddingLeft="3dp" + android:paddingRight="3dp" + android:text="identity" + android:textSize="12sp"/> + + <android.support.v7.widget.AppCompatSpinner + android:id="@+id/identity" + style="@style/Base.Widget.AppCompat.Spinner.Underlined" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:paddingBottom="8dp"/> + + </LinearLayout> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/rejoinChannels" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="rejoinChannels"/> + + <android.support.v7.widget.SwitchCompat + android:id="@+id/useCustomCodecs" + style="?attr/switchPreferenceStyle" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Custom Codecs" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + + <LinearLayout + android:id="@+id/groupCustomCodecs" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/codecForServer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="codecForServer"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/codecForEncoding" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="codecForEncoding"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/codecForDecoding" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="codecForDecoding"/> + + </android.support.design.widget.TextInputLayout> + + </LinearLayout> + + <android.support.v7.widget.SwitchCompat + android:id="@+id/useAutoIdentify" + style="?attr/switchPreferenceStyle" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Auto Identify" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + + <LinearLayout + android:id="@+id/groupAutoIdentify" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/autoIdentifyService" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="autoIdentifyService"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/autoIdentifyPassword" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="autoIdentifyPassword"/> + + </android.support.design.widget.TextInputLayout> + + </LinearLayout> + + <android.support.v7.widget.SwitchCompat + android:id="@+id/useSasl" + style="?attr/switchPreferenceStyle" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="SASL" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + <LinearLayout + android:id="@+id/groupSasl" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/saslAccount" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="saslAccount"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/saslPassword" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="saslPassword"/> + + </android.support.design.widget.TextInputLayout> + </LinearLayout> + + <android.support.v7.widget.SwitchCompat + android:id="@+id/useAutoReconnect" + style="?attr/switchPreferenceStyle" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Auto Reconnect" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + <LinearLayout + android:id="@+id/groupAutoReconnect" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/autoReconnectInterval" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="autoReconnectInterval" + android:inputType="number"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.v7.widget.AppCompatCheckBox + android:id="@+id/unlimitedAutoReconnectRetries" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="unlimitedAutoReconnectRetries"/> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/autoReconnectRetries" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="autoReconnectRetries" + android:inputType="number"/> + + </android.support.design.widget.TextInputLayout> + + </LinearLayout> + + </LinearLayout> + + </ScrollView> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_chat_list_list.xml b/app/src/main/res/layout/activity_network_list.xml similarity index 96% rename from app/src/main/res/layout/activity_chat_list_list.xml rename to app/src/main/res/layout/activity_network_list.xml index 6865ea5eb708a0ad962c6c9b2da83aa5a90d471a..c7c7de60c9a28ae87401c5f1875c94fc06205387 100644 --- a/app/src/main/res/layout/activity_chat_list_list.xml +++ b/app/src/main/res/layout/activity_network_list.xml @@ -24,7 +24,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical"> + android:orientation="vertical" + android:background="?attr/colorBackground"> <android.support.design.widget.AppBarLayout android:id="@+id/appBar" diff --git a/app/src/main/res/layout/widget_network.xml b/app/src/main/res/layout/widget_drawer_network.xml similarity index 72% rename from app/src/main/res/layout/widget_network.xml rename to app/src/main/res/layout/widget_drawer_network.xml index ab5ee3e78b2c132298e7f1bd0d494c783c697db3..0078a594068dd253b13d1a95a4a42f650a07b22d 100644 --- a/app/src/main/res/layout/widget_network.xml +++ b/app/src/main/res/layout/widget_drawer_network.xml @@ -20,16 +20,16 @@ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="@dimen/material_drawer_item_primary" - android:background="?attr/selectableItemBackground" - android:clickable="true" - android:orientation="horizontal" - android:paddingEnd="@dimen/material_drawer_vertical_padding" - android:paddingLeft="@dimen/material_drawer_vertical_padding" - android:paddingRight="@dimen/material_drawer_vertical_padding" - android:paddingStart="@dimen/material_drawer_vertical_padding"> + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="@dimen/material_drawer_item_primary" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:orientation="horizontal" + android:paddingEnd="@dimen/material_drawer_vertical_padding" + android:paddingLeft="@dimen/material_drawer_vertical_padding" + android:paddingRight="@dimen/material_drawer_vertical_padding" + android:paddingStart="@dimen/material_drawer_vertical_padding"> <LinearLayout android:layout_width="0dp" @@ -52,4 +52,4 @@ </LinearLayout> -</LinearLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_settings_network.xml b/app/src/main/res/layout/widget_settings_network.xml new file mode 100644 index 0000000000000000000000000000000000000000..ff16756bda26ead89cf7e1fcba39bce9b5aa7883 --- /dev/null +++ b/app/src/main/res/layout/widget_settings_network.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ QuasselDroid - Quassel client for Android + ~ Copyright (C) 2016 Janne Koschinski + ~ Copyright (C) 2016 Ken Børge Viktil + ~ Copyright (C) 2016 Magnus Fjell + ~ Copyright (C) 2016 Martin Sandsmark <martin.sandsmark@kde.org> + ~ + ~ This program is free software: you can redistribute it and/or modify it + ~ under the terms of the GNU General Public License as published by the Free + ~ Software Foundation, either version 3 of the License, or (at your option) + ~ any later version. + ~ + ~ This program is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ~ GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License along + ~ with this program. If not, see <http://www.gnu.org/licenses/>. + --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="56dp" + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:orientation="horizontal" + android:paddingLeft="16dp" + android:paddingRight="16dp"> + + <LinearLayout + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_margin="@dimen/material_drawer_item_profile_icon_padding_right" + android:layout_weight="1" + android:gravity="center_vertical|start" + android:orientation="vertical"> + + <TextView + android:id="@+id/network_name" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:fontFamily="sans-serif-medium" + android:gravity="center_vertical|start" + android:lines="1" + android:singleLine="true" + android:textSize="16sp" /> + </LinearLayout> + + <android.support.v7.widget.AppCompatImageButton + android:id="@+id/network_delete" + style="?attr/buttonStyleSmall" + android:layout_width="@dimen/material_drawer_item_profile_icon_width" + android:layout_height="@dimen/material_drawer_item_profile_icon_width" + android:layout_gravity="center_vertical" + android:background="?attr/selectableItemBackgroundBorderless" + android:src="@drawable/ic_delete_light" /> +</LinearLayout> diff --git a/app/src/main/res/menu/chat.xml b/app/src/main/res/menu/chat.xml index 07869e2e90886e8faaa6c1cf45b7143839210fff..fee48247c7db1334e013ff351e9cd4292e15498a 100644 --- a/app/src/main/res/menu/chat.xml +++ b/app/src/main/res/menu/chat.xml @@ -36,6 +36,14 @@ android:id="@+id/action_settings" android:title="@string/label_settings" app:showAsAction="never" /> + <item + android:id="@+id/action_networks" + android:title="Networks" + app:showAsAction="never" /> + <item + android:id="@+id/action_identities" + android:title="Identities" + app:showAsAction="never" /> <item android:id="@+id/action_reauth" android:title="@string/label_disconnect"