diff --git a/app/build.gradle b/app/build.gradle index 9ec02a7ea47771269300db9476813a2196544b3e..c8f0f071a1385176a1f82aee0995ee2110fa562a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ def rawVersionName = "0.2.0" android { compileSdkVersion 24 - buildToolsVersion "24.0.0" + buildToolsVersion "24.0.2" defaultConfig { applicationId "com.iskrembilen.quasseldroid" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cfb07f52d855f40d7651c19249297cd712770f8e..999982773b52c65940bb97bf1a1abdf0e034cbbd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -109,6 +109,34 @@ android:parentActivityName=".ui.coresettings.network.NetworkEditActivity" android:theme="@style/AppTheme.Light"/> + <activity + android:name=".ui.coresettings.identity.IdentityListActivity" + android:label="Edit Networks" + android:launchMode="singleTask" + android:parentActivityName=".ui.chat.MainActivity" + android:theme="@style/AppTheme.Light"/> + + <activity + android:name=".ui.coresettings.identity.IdentityEditActivity" + android:label="Edit Identity" + android:launchMode="singleTask" + android:parentActivityName=".ui.coresettings.identity.IdentityListActivity" + android:theme="@style/AppTheme.Light"/> + + <activity + android:name=".ui.coresettings.identity.IdentityCreateActivity" + android:label="Create Identity" + android:launchMode="singleTask" + android:parentActivityName=".ui.coresettings.identity.IdentityListActivity" + android:theme="@style/AppTheme.Light"/> + + <activity + android:name=".ui.coresettings.identity.nick.IdentityNickListActivity" + android:label="Edit Nicks" + android:launchMode="singleTask" + android:parentActivityName=".ui.coresettings.identity.IdentityEditActivity" + android:theme="@style/AppTheme.Light"/> + <activity android:name=".ui.coresettings.network.server.NetworkServerEditActivity" android:label="Edit NetworkServer" diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java index 5f947850d635ce5473b77e2f0145b3b557e8b1d1..13711485007d9651e1ff81e6fdf4b68c08bc2b77 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/SyncableObject.java @@ -38,7 +38,6 @@ import de.kuschku.util.backports.Objects; import de.kuschku.util.observables.callbacks.GeneralObservable; import static de.kuschku.util.AndroidAssert.assertNotNull; -import static de.kuschku.util.AndroidAssert.assertTrue; import static junit.framework.Assert.assertEquals; public abstract class SyncableObject<T> extends GeneralObservable<T> implements QSyncableObject<T> { @@ -54,14 +53,12 @@ public abstract class SyncableObject<T> extends GeneralObservable<T> implements } public void sync(@NonNull String methodName, @NonNull Object[] params) { - assertTrue(initialized); assertNotNull(provider); provider.dispatch(new SyncFunction<>(getClassName(), getObjectName(), methodName, toVariantList(params))); } public void sync(@NonNull String methodName, @NonNull String[] strings, @NonNull Object[] objects) { - assertTrue(initialized); assertNotNull(provider); assertEquals(strings.length, objects.length); @@ -105,7 +102,6 @@ public abstract class SyncableObject<T> extends GeneralObservable<T> implements } public void rpc(@NonNull String procedureName, @NonNull List<QVariant> params) { - assertTrue(initialized); assertNotNull(provider); RpcCallFunction function = new RpcCallFunction(procedureName, params); diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java index 03d9accf07c49a7bcb63b8fb5d93d9705d2ab200..2a2897279108bdc6cfca2f32a047b51507574266 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/abstracts/AIdentity.java @@ -23,7 +23,10 @@ package de.kuschku.libquassel.syncables.types.abstracts; import java.util.List; +import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.IdentitySerializer; import de.kuschku.libquassel.syncables.types.SyncableObject; +import de.kuschku.libquassel.syncables.types.impl.Identity; import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; public abstract class AIdentity extends SyncableObject<QIdentity> implements QIdentity { @@ -160,4 +163,10 @@ public abstract class AIdentity extends SyncableObject<QIdentity> implements QId _setSslCert(encoded); syncVar("setSslCert", encoded); } + + @Override + public void update(Identity identity) { + _copyFrom(identity); + syncVar("update", new QVariant<>("Identity", IdentitySerializer.get().toVariantMap(identity))); + } } diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java index 6d14bd3e98b80536198b89c279bf82fa65a7d3bf..b8c46c5ab98a787f877872f0a1b78401cd5bbf5f 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/impl/Identity.java @@ -31,6 +31,7 @@ import java.util.Map; import de.kuschku.libquassel.BusProvider; import de.kuschku.libquassel.client.Client; import de.kuschku.libquassel.primitives.types.QVariant; +import de.kuschku.libquassel.syncables.serializers.IdentitySerializer; import de.kuschku.libquassel.syncables.types.abstracts.AIdentity; import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; @@ -79,6 +80,29 @@ public class Identity extends AIdentity { this.quitReason = quitReason; } + public static Identity createDefault() { + return new Identity( + -1, + "", + "Quassel IRC User", + Collections.singletonList("quassel"), + "", + false, + "Gone fishing.", + true, + false, + 10, + "Not here. No, really. not here!", + false, + false, + "All Quassel clients vanished from the face of the earth...", + false, + "quassel", + "Kindergarten is elsewhere!", + "http://quassel-irc.org - Chat comfortably. Anywhere.", + "http://quassel-irc.org - Chat comfortably. Anywhere." + ); + } @Override public void setToDefaults() { @@ -378,10 +402,12 @@ public class Identity extends AIdentity { @Override public void _update(Map<String, QVariant> from) { + _copyFrom(IdentitySerializer.get().fromDatastream(from)); } @Override public void _update(QIdentity from) { + _copyFrom(from); } @Override diff --git a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java index b13b97fc07056f793c669a5e897662059fd3e897..d859077137d5bac0c8c1b33235b078710cf613a8 100644 --- a/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java +++ b/app/src/main/java/de/kuschku/libquassel/syncables/types/interfaces/QIdentity.java @@ -26,6 +26,7 @@ import android.support.annotation.Nullable; import java.util.List; import de.kuschku.libquassel.syncables.Synced; +import de.kuschku.libquassel.syncables.types.impl.Identity; public interface QIdentity extends QObservable<QIdentity> { void setToDefaults(); @@ -189,4 +190,7 @@ public interface QIdentity extends QObservable<QIdentity> { void setSslCert(final String encoded); void _setSslCert(final String encoded); + + @Synced + void update(Identity identity); } 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 f973ec221175747124a1c9976a41d6656f4b6bfd..477e5b33fd64394b8862ac1776949749246ebcfb 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,6 +87,7 @@ 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.chatlist.ChatListListActivity; +import de.kuschku.quasseldroid_ng.ui.coresettings.identity.IdentityListActivity; 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; @@ -269,6 +270,9 @@ public class MainActivity extends BoundActivity { case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; + case R.id.action_identities: + startActivity(new Intent(this, IdentityListActivity.class)); + return true; case R.id.action_networks: startActivity(new Intent(this, NetworkListActivity.class)); return true; diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityCreateActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityCreateActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..dc6dcc8e8e1babb6a39a15b74b5e81308ec87c7f --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityCreateActivity.java @@ -0,0 +1,197 @@ +/* + * 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.identity; + +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.view.Menu; +import android.view.MenuItem; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; + +import java.util.ArrayList; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.libquassel.syncables.types.impl.Identity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.NetworkServerListActivity; +import de.kuschku.util.servicebound.BoundActivity; +import de.kuschku.util.ui.AnimationHelper; + +public class IdentityCreateActivity extends BoundActivity { + + @Bind(R.id.toolbar) + Toolbar toolbar; + + @Bind(R.id.identityName) + EditText identityName; + + @Bind(R.id.realName) + EditText realName; + + @Bind(R.id.ident) + EditText ident; + + @Bind(R.id.nicks) + Button nicks; + + @Bind(R.id.kickReason) + EditText kickReason; + + @Bind(R.id.partReason) + EditText partReason; + + @Bind(R.id.quitReason) + EditText quitReason; + + @Bind(R.id.awayReason) + EditText awayReason; + + @Bind(R.id.useAwayOnDetach) + SwitchCompat useAwayOnDetach; + + @Bind(R.id.groupAwayOnDetach) + ViewGroup groupAwayOnDetach; + + @Bind(R.id.awayOnDetachReason) + EditText awayOnDetachReason; + + private ArrayList<String> nickList; + private QIdentity identity = Identity.createDefault(); + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_identity_edit); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + useAwayOnDetach.setOnCheckedChangeListener(this::updateAwayOnDetachReasonVisible); + updateAwayOnDetachReasonVisible(null, useAwayOnDetach.isChecked()); + + nicks.setOnClickListener(v -> { + Intent intent1 = new Intent(IdentityCreateActivity.this, NetworkServerListActivity.class); + intent1.putStringArrayListExtra("nicks", nickList); + startActivityForResult(intent1, 0, null); + }); + + initializeDefaults(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + ArrayList<String> nickList = data.getStringArrayListExtra("nicks"); + if (nickList != null) + this.nickList = nickList; + } + + private void updateAwayOnDetachReasonVisible(CompoundButton button, boolean visible) { + awayOnDetachReason.setEnabled(visible); + + IdentityCreateActivity.this.updateViewGroupStatus(groupAwayOnDetach, visible); + } + + private void updateViewGroupStatus(ViewGroup group, boolean visible) { + if (visible) { + AnimationHelper.expand(group); + } else { + AnimationHelper.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 (identity != null) { + Identity newIdentity = Identity.createDefault(); + newIdentity._copyFrom(identity); + + if (!identity.identityName().equals(identityName.getText().toString())) + newIdentity._setIdentityName(identityName.getText().toString()); + + if (!identity.realName().equals(realName.getText().toString())) + newIdentity._setRealName(realName.getText().toString()); + + if (!identity.ident().equals(ident.getText().toString())) + newIdentity._setIdent(ident.getText().toString()); + + if (!identity.nicks().equals(nickList)) + newIdentity._setNicks(nickList); + + if (!identity.kickReason().equals(kickReason.getText().toString())) + newIdentity._setKickReason(kickReason.getText().toString()); + + if (!identity.partReason().equals(partReason.getText().toString())) + newIdentity._setPartReason(partReason.getText().toString()); + + if (!identity.quitReason().equals(quitReason.getText().toString())) + newIdentity._setQuitReason(quitReason.getText().toString()); + + if (!identity.awayReason().equals(awayReason.getText().toString())) + newIdentity._setAwayReason(awayReason.getText().toString()); + + if (!identity.detachAwayEnabled() == useAwayOnDetach.isChecked()) + newIdentity.setDetachAwayEnabled(useAwayOnDetach.isChecked()); + + if (!identity.detachAwayReason().equals(awayOnDetachReason.getText().toString())) + newIdentity._setDetachAwayReason(awayOnDetachReason.getText().toString()); + + context.client().createIdentity(newIdentity); + + finish(); + } + } return true; + default: + return super.onOptionsItemSelected(item); + } + } + + private void initializeDefaults() { + this.identityName.setText(identity.identityName()); + this.realName.setText(identity.realName()); + this.ident.setText(identity.ident()); + this.nickList = new ArrayList<>(identity.nicks()); + this.kickReason.setText(identity.kickReason()); + this.partReason.setText(identity.partReason()); + this.quitReason.setText(identity.quitReason()); + this.awayReason.setText(identity.awayReason()); + this.useAwayOnDetach.setChecked(identity.detachAwayEnabled()); + this.awayOnDetachReason.setText(identity.detachAwayReason()); + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityEditActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityEditActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..39d1d5fa05b63a3b5da24eabbaa5c1681ea0de1c --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityEditActivity.java @@ -0,0 +1,239 @@ +/* + * 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.identity; + +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.view.Menu; +import android.view.MenuItem; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.CompoundButton; +import android.widget.EditText; + +import java.util.ArrayList; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.libquassel.syncables.types.impl.Identity; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.coresettings.identity.nick.IdentityNickListActivity; +import de.kuschku.util.servicebound.BoundActivity; +import de.kuschku.util.ui.AnimationHelper; + +public class IdentityEditActivity extends BoundActivity { + + @Bind(R.id.toolbar) + Toolbar toolbar; + + @Bind(R.id.identityName) + EditText identityName; + + @Bind(R.id.realName) + EditText realName; + + @Bind(R.id.ident) + EditText ident; + + @Bind(R.id.nicks) + Button nicks; + + @Bind(R.id.kickReason) + EditText kickReason; + + @Bind(R.id.partReason) + EditText partReason; + + @Bind(R.id.quitReason) + EditText quitReason; + + @Bind(R.id.awayReason) + EditText awayReason; + + @Bind(R.id.useAwayOnDetach) + SwitchCompat useAwayOnDetach; + + @Bind(R.id.groupAwayOnDetach) + ViewGroup groupAwayOnDetach; + + @Bind(R.id.awayOnDetachReason) + EditText awayOnDetachReason; + + int id; + private QIdentity identity; + private ArrayList<String> nickList; + + @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_identity_edit); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + useAwayOnDetach.setOnCheckedChangeListener(this::updateAwayOnDetachReasonVisible); + updateAwayOnDetachReasonVisible(null, useAwayOnDetach.isChecked()); + + nicks.setOnClickListener(v -> { + Intent intent1 = new Intent(IdentityEditActivity.this, IdentityNickListActivity.class); + intent1.putStringArrayListExtra("nicks", nickList); + startActivityForResult(intent1, 0, null); + }); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (data != null) { + ArrayList<String> nickList = data.getStringArrayListExtra("nicks"); + if (nickList != null) + this.nickList = nickList; + } + } + + private void updateAwayOnDetachReasonVisible(CompoundButton button, boolean visible) { + awayOnDetachReason.setEnabled(visible); + + IdentityEditActivity.this.updateViewGroupStatus(groupAwayOnDetach, visible); + } + + private void updateViewGroupStatus(ViewGroup group, boolean visible) { + if (visible) { + AnimationHelper.expand(group); + } else { + AnimationHelper.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 (identity != null) { + Identity newIdentity = Identity.createDefault(); + newIdentity._copyFrom(identity); + + if (!identity.identityName().equals(identityName.getText().toString())) + newIdentity._setIdentityName(identityName.getText().toString()); + + if (!identity.realName().equals(realName.getText().toString())) + newIdentity._setRealName(realName.getText().toString()); + + if (!identity.ident().equals(ident.getText().toString())) + newIdentity._setIdent(ident.getText().toString()); + + if (!identity.nicks().equals(nickList)) + newIdentity._setNicks(nickList); + + if (!identity.kickReason().equals(kickReason.getText().toString())) + newIdentity._setKickReason(kickReason.getText().toString()); + + if (!identity.partReason().equals(partReason.getText().toString())) + newIdentity._setPartReason(partReason.getText().toString()); + + if (!identity.quitReason().equals(quitReason.getText().toString())) + newIdentity._setQuitReason(quitReason.getText().toString()); + + if (!identity.awayReason().equals(awayReason.getText().toString())) + newIdentity._setAwayReason(awayReason.getText().toString()); + + if (!identity.detachAwayEnabled() == useAwayOnDetach.isChecked()) + newIdentity.setDetachAwayEnabled(useAwayOnDetach.isChecked()); + + if (!identity.detachAwayReason().equals(awayOnDetachReason.getText().toString())) + newIdentity._setDetachAwayReason(awayOnDetachReason.getText().toString()); + + if (!newIdentity.equals(identity)) + identity.update(newIdentity); + + finish(); + } + } return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onConnected() { + setIdentity(context.client().identityManager().identity(id)); + } + + private void setIdentity(QIdentity identity) { + QIdentity oldIdentity = this.identity; + this.identity = identity; + + if (oldIdentity == null || identityName.getText().toString().equals(oldIdentity.identityName())) + this.identityName.setText(identity.identityName()); + + if (oldIdentity == null || realName.getText().toString().equals(oldIdentity.realName())) + this.realName.setText(identity.realName()); + + if (oldIdentity == null || ident.getText().toString().equals(oldIdentity.ident())) + this.ident.setText(identity.ident()); + + if (oldIdentity == null || nickList.equals(new ArrayList<>(oldIdentity.nicks()))) + this.nickList = new ArrayList<>(identity.nicks()); + + if (oldIdentity == null || kickReason.getText().toString().equals(oldIdentity.kickReason())) + this.kickReason.setText(identity.kickReason()); + + if (oldIdentity == null || partReason.getText().toString().equals(oldIdentity.partReason())) + this.partReason.setText(identity.partReason()); + + if (oldIdentity == null || quitReason.getText().toString().equals(oldIdentity.quitReason())) + this.quitReason.setText(identity.quitReason()); + + if (oldIdentity == null || awayReason.getText().toString().equals(oldIdentity.awayReason())) + this.awayReason.setText(identity.awayReason()); + + if (oldIdentity == null || useAwayOnDetach.isChecked() == oldIdentity.detachAwayEnabled()) + this.useAwayOnDetach.setChecked(identity.detachAwayEnabled()); + + if (oldIdentity == null || awayOnDetachReason.getText().toString().equals(oldIdentity.identityName())) + this.awayOnDetachReason.setText(identity.detachAwayReason()); + } + + @Override + protected void onDisconnected() { + setIdentity(null); + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityListActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityListActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..a8862096125330dc9f56cc5d61050d57e038666a --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/IdentityListActivity.java @@ -0,0 +1,153 @@ +/* + * 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.identity; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; +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.IdentityManager; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.NetworkCreateActivity; +import de.kuschku.util.observables.callbacks.wrappers.AdapterUICallbackWrapper; +import de.kuschku.util.servicebound.BoundActivity; + +public class IdentityListActivity extends BoundActivity { + + IdentityManager manager; + + @Bind(R.id.list) + RecyclerView list; + + @Bind(R.id.add) + FloatingActionButton add; + + @Bind(R.id.toolbar) + Toolbar toolbar; + + ChatListAdapter adapter; + OnQIdentityClickListener clickListener = identity -> { + if (identity != null) { + Intent intent = new Intent(this, IdentityEditActivity.class); + intent.putExtra("id", identity.id()); + startActivity(intent); + } + }; + + @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().identityManager(); + adapter.setManager(manager); + } + + @Override + protected void onDisconnected() { + manager = null; + adapter.setManager(null); + } + + interface OnQIdentityClickListener { + void onClick(QIdentity network); + } + + private class ChatListAdapter extends RecyclerView.Adapter<IdentityViewHolder> { + IdentityManager manager; + AdapterUICallbackWrapper wrapper = new AdapterUICallbackWrapper(this); + + public void setManager(IdentityManager manager) { + if (this.manager != null) + this.manager.identities().addCallback(wrapper); + + this.manager = manager; + + if (this.manager != null) + this.manager.identities().addCallback(wrapper); + } + + @Override + public IdentityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + View view = inflater.inflate(R.layout.widget_settings_network, parent, false); + return new IdentityViewHolder(view); + } + + @Override + public void onBindViewHolder(IdentityViewHolder holder, int position) { + holder.bind(manager != null ? manager.identities().get(position) : null); + } + + @Override + public int getItemCount() { + return manager == null ? 0 : manager.identities().size(); + } + } + + class IdentityViewHolder extends RecyclerView.ViewHolder { + + @Bind(R.id.network_name) + TextView name; + + private QIdentity identity; + + public IdentityViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + itemView.setOnClickListener(view -> clickListener.onClick(identity)); + } + + public void bind(QIdentity identity) { + this.identity = identity; + name.setText(identity == null ? "" : identity.identityName()); + } + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickAdapter.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..552350bda42b004dd7a19af60e2d2dc94b77f6d8 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickAdapter.java @@ -0,0 +1,123 @@ +/* + * 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.identity.nick; + +import android.graphics.Color; +import android.support.v4.view.MotionEventCompat; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.Collections; +import java.util.List; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.helper.ItemTouchHelperAdapter; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.helper.ItemTouchHelperViewHolder; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.helper.OnStartDragListener; +import de.kuschku.util.annotationbind.AutoBinder; + +public class IdentityNickAdapter + extends RecyclerView.Adapter<IdentityNickAdapter.IdentityNickViewHolder> implements ItemTouchHelperAdapter { + + private final List<String> nicks; + private final OnStartDragListener dragStartListener; + private IdentityNickListActivity.OnIdentityNickClickListener onItemClickListener; + + public IdentityNickAdapter(List<String> nicks, OnStartDragListener dragStartListener) { + this.nicks = nicks; + this.dragStartListener = dragStartListener; + } + + @Override + public IdentityNickViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + LayoutInflater inflater = LayoutInflater.from(parent.getContext()); + View view = inflater.inflate(R.layout.widget_identitynick, parent, false); + return new IdentityNickViewHolder(view); + } + + @Override + public void onBindViewHolder(IdentityNickViewHolder holder, int position) { + holder.bind(nicks.get(position)); + holder.drag_handle.setOnTouchListener((v, event) -> { + if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { + dragStartListener.onStartDrag(holder); + holder.itemView.setSelected(true); + } + return false; + }); + } + + @Override + public int getItemCount() { + return nicks.size(); + } + + @Override + public boolean onItemMove(int fromPosition, int toPosition) { + Collections.swap(nicks, fromPosition, toPosition); + notifyItemMoved(fromPosition, toPosition); + return true; + } + + public void setOnItemClickListener(IdentityNickListActivity.OnIdentityNickClickListener onItemClickListener) { + this.onItemClickListener = onItemClickListener; + } + + class IdentityNickViewHolder extends RecyclerView.ViewHolder implements ItemTouchHelperViewHolder { + + @Bind(R.id.text) + TextView text; + + @Bind(R.id.drag_handle) + ImageView drag_handle; + + private String nick; + + public IdentityNickViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + itemView.setOnClickListener(v -> onItemClickListener.onClick(nick)); + } + + public void bind(String nick) { + this.nick = nick; + text.setText(nick == null ? "" : nick); + } + + @Override + public void onItemSelected() { + itemView.setBackgroundColor(AutoBinder.obtainColor(R.attr.colorBackground, itemView.getContext().getTheme())); + } + + @Override + public void onItemClear() { + itemView.setBackgroundColor(Color.TRANSPARENT); + } + } +} diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickListActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickListActivity.java new file mode 100644 index 0000000000000000000000000000000000000000..4fefd191cec569c6a25d9beb633381d2979a96a9 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/identity/nick/IdentityNickListActivity.java @@ -0,0 +1,160 @@ +/* + * 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.identity.nick; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; +import android.support.v7.widget.helper.ItemTouchHelper; +import android.view.Menu; +import android.view.MenuItem; + +import com.afollestad.materialdialogs.MaterialDialog; + +import java.util.ArrayList; + +import butterknife.Bind; +import butterknife.ButterKnife; +import de.kuschku.quasseldroid_ng.R; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.helper.OnStartDragListener; +import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.helper.SimpleItemTouchHelperCallback; +import de.kuschku.util.observables.callbacks.wrappers.AdapterUICallbackWrapper; +import de.kuschku.util.observables.lists.ObservableList; +import de.kuschku.util.servicebound.BoundActivity; + +public class IdentityNickListActivity extends BoundActivity implements OnStartDragListener { + + @Bind(R.id.list) + RecyclerView list; + + @Bind(R.id.add) + FloatingActionButton add; + + @Bind(R.id.toolbar) + Toolbar toolbar; + + IdentityNickAdapter adapter; + ItemTouchHelper itemTouchHelper; + ObservableList<String> nicks; + OnIdentityNickClickListener clickListener = nick -> { + MaterialDialog dialog = new MaterialDialog.Builder(this) + .input("", nick, false, (dialog1, input) -> { + + }) + .positiveText("Save") + .negativeText("Cancel") + .positiveColor(context.themeUtil().res.colorAccent) + .negativeColor(context.themeUtil().res.colorForeground) + .onPositive((dialog1, which) -> { + String text = dialog1.getInputEditText().getText().toString().trim(); + nicks.set(nicks.indexOf(nick), text); + }) + .build(); + dialog.show(); + }; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_network_list); + ButterKnife.bind(this); + + Intent intent = getIntent(); + ArrayList<String> nickList; + if (intent != null && (nickList = intent.getStringArrayListExtra("nicks")) != null) { + nicks = new ObservableList<>(nickList); + } else { + nicks = new ObservableList<>(); + } + + adapter = new IdentityNickAdapter(nicks, this); + nicks.addCallback(new AdapterUICallbackWrapper(adapter)); + + list.setAdapter(adapter); + list.setHasFixedSize(true); + list.setLayoutManager(new LinearLayoutManager(this)); + adapter.setOnItemClickListener(clickListener); + + ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter); + itemTouchHelper = new ItemTouchHelper(callback); + itemTouchHelper.attachToRecyclerView(list); + + add.setOnClickListener(v -> { + MaterialDialog dialog = new MaterialDialog.Builder(this) + .input("", "", false, (dialog1, input) -> { + + }) + .positiveText("Save") + .negativeText("Cancel") + .positiveColor(context.themeUtil().res.colorAccent) + .negativeColor(context.themeUtil().res.colorForeground) + .onPositive((dialog1, which) -> { + String nick = dialog1.getInputEditText().getText().toString().trim(); + if (!nicks.contains(nick)) + nicks.add(nick); + }) + .build(); + dialog.show(); + }); + + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + @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: { + Intent intent = new Intent(); + intent.putStringArrayListExtra("nicks", nicks); + setResult(RESULT_OK, intent); + finish(); + } return true; + default: + return super.onOptionsItemSelected(item); + } + } + + @Override + protected void onPause() { + super.onPause(); + } + + @Override + public void onStartDrag(RecyclerView.ViewHolder viewHolder) { + itemTouchHelper.startDrag(viewHolder); + } + + interface OnIdentityNickClickListener { + void onClick(String nick); + } +} 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 index 4d0eb3deada47b217a23d9b12f0e7199be96bdfa..f6818cd282bdd24d75efe778b3d178e8181e6703 100644 --- 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 @@ -45,6 +45,7 @@ import butterknife.Bind; import butterknife.ButterKnife; import de.kuschku.libquassel.objects.types.NetworkServer; import de.kuschku.libquassel.syncables.types.impl.NetworkInfo; +import de.kuschku.libquassel.syncables.types.interfaces.QIdentity; import de.kuschku.quasseldroid_ng.R; import de.kuschku.quasseldroid_ng.ui.coresettings.identity.IdentitySpinnerAdapter; import de.kuschku.quasseldroid_ng.ui.coresettings.network.server.NetworkServerListActivity; @@ -173,7 +174,7 @@ public class NetworkCreateActivity extends BoundActivity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (resultCode == RESULT_OK) { + if (data != null) { switch (requestCode) { case REQUEST_PERFORM: { @@ -277,7 +278,13 @@ public class NetworkCreateActivity extends BoundActivity { @Override protected void onConnected() { + QIdentity identity = (QIdentity) this.identity.getSelectedItem(); spinnerAdapter.setIdentityManager(context.client().identityManager()); + this.identity.setSelection(getIdentityPosition(identity)); + } + + private int getIdentityPosition(QIdentity identity) { + return context.client().identityManager().identities().indexOf(identity); } @Override 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 index a9d8cca6060e5b6653459a7fb54959314a6cf476..5f40386a8ea8610fcdbb76c674fa78a49e7e013b 100644 --- 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 @@ -166,17 +166,21 @@ public class NetworkEditActivity extends BoundActivity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) { - case REQUEST_PERFORM: { - - } break; - case REQUEST_SERVER_LIST: { - Parcelable[] servers = data.getParcelableArrayExtra("servers"); - Log.d("DEBUG", Arrays.toString(servers)); - if (servers != null) { - serverList = NetworkServerSerializeHelper.deserialize(servers); + if (data != null) { + switch (requestCode) { + case REQUEST_PERFORM: { + + } + break; + case REQUEST_SERVER_LIST: { + Parcelable[] servers = data.getParcelableArrayExtra("servers"); + Log.d("DEBUG", Arrays.toString(servers)); + if (servers != null) { + serverList = NetworkServerSerializeHelper.deserialize(servers); + } } - } break; + break; + } } } @@ -271,37 +275,66 @@ public class NetworkEditActivity extends BoundActivity { @Override protected void onConnected() { - setNetwork(context.client().networkManager().network(id)); spinnerAdapter.setIdentityManager(context.client().identityManager()); + setNetwork(context.client().networkManager().network(id)); } private void setNetwork(QNetwork network) { + NetworkInfo oldInfo = this.network == null ? null : this.network.networkInfo(); this.network = network; NetworkInfo networkInfo = this.network.networkInfo(); if (networkInfo != null) { - networkName.setText(networkInfo.networkName()); - identity.setSelection(getIdentityPosition(networkInfo)); - 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()); + if (oldInfo == null || oldInfo.networkName().equals(networkName.getText().toString())) + networkName.setText(networkInfo.networkName()); + + if (oldInfo == null || getIdentityPosition(oldInfo) == identity.getSelectedItemPosition()) + identity.setSelection(getIdentityPosition(networkInfo)); + + if (oldInfo == null || (oldInfo.codecForServer() != null || oldInfo.codecForEncoding() != null || oldInfo.codecForDecoding() != null) == useCustomCodecs.isChecked()) + useCustomCodecs.setChecked(networkInfo.codecForServer() != null || networkInfo.codecForEncoding() != null || networkInfo.codecForDecoding() != null); + + if (oldInfo == null || oldInfo.codecForServer().equals(codecForServer.getText().toString())) + codecForServer.setText(networkInfo.codecForServer()); + + if (oldInfo == null || oldInfo.codecForEncoding().equals(codecForEncoding.getText().toString())) + codecForEncoding.setText(networkInfo.codecForEncoding()); + + if (oldInfo == null || oldInfo.codecForDecoding().equals(codecForDecoding.getText().toString())) + codecForDecoding.setText(networkInfo.codecForDecoding()); + + if (oldInfo == null || oldInfo.useAutoIdentify() == useAutoIdentify.isChecked()) + useAutoIdentify.setChecked(networkInfo.useAutoIdentify()); + + if (oldInfo == null || oldInfo.autoIdentifyService().equals(autoIdentifyService.getText().toString())) + autoIdentifyService.setText(networkInfo.autoIdentifyService()); + + if (oldInfo == null || oldInfo.autoIdentifyPassword().equals(autoIdentifyPassword.getText().toString())) + autoIdentifyPassword.setText(networkInfo.autoIdentifyPassword()); + + if (oldInfo == null || oldInfo.useSasl() == useSasl.isChecked()) + useSasl.setChecked(networkInfo.useSasl()); + + if (oldInfo == null || oldInfo.saslAccount().equals(saslAccount.getText().toString())) + saslAccount.setText(networkInfo.saslAccount()); + + if (oldInfo == null || oldInfo.saslPassword().equals(saslPassword.getText().toString())) + saslPassword.setText(networkInfo.saslPassword()); + + if (oldInfo == null || oldInfo.useAutoReconnect() == useAutoReconnect.isChecked()) + useAutoReconnect.setChecked(networkInfo.useAutoReconnect()); + + if (oldInfo == null || oldInfo.autoReconnectInterval() == NumberHelper.parseInt(autoReconnectInterval.getText().toString(), 0)) + autoReconnectInterval.setText(String.valueOf(networkInfo.autoReconnectInterval())); + + if (oldInfo == null || oldInfo.autoReconnectRetries() == NumberHelper.parseInt(autoReconnectRetries.getText().toString(), 0)) + autoReconnectRetries.setText(String.valueOf(networkInfo.autoReconnectRetries())); + + if (oldInfo == null || oldInfo.unlimitedReconnectRetries() == unlimitedAutoReconnectRetries.isChecked()) + unlimitedAutoReconnectRetries.setChecked(networkInfo.unlimitedReconnectRetries()); + + if (oldInfo == null || oldInfo.rejoinChannels() == rejoinChannels.isChecked()) + rejoinChannels.setChecked(networkInfo.rejoinChannels()); } } @@ -312,7 +345,7 @@ public class NetworkEditActivity extends BoundActivity { @Override protected void onDisconnected() { - setNetwork(null); spinnerAdapter.setIdentityManager(null); + setNetwork(null); } } diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/server/NetworkServerListActivity.java b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/server/NetworkServerListActivity.java index 9fd1ae7764a844009a21a86456040440d8ec4473..3cb32d334df186f8475266d1854de29ab4bf9c4e 100644 --- a/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/server/NetworkServerListActivity.java +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/ui/coresettings/network/server/NetworkServerListActivity.java @@ -133,8 +133,7 @@ public class NetworkServerListActivity extends BoundActivity implements OnStartD if (id == -1) { servers.add(server); } else { - servers.remove(id); - servers.add(id, server); + servers.set(id, server); } } super.onActivityResult(requestCode, resultCode, data); diff --git a/app/src/main/res/layout/activity_identity_edit.xml b/app/src/main/res/layout/activity_identity_edit.xml new file mode 100644 index 0000000000000000000000000000000000000000..b67fd114ff977c1cf062bc72c220255361795fa8 --- /dev/null +++ b/app/src/main/res/layout/activity_identity_edit.xml @@ -0,0 +1,200 @@ +<?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/identityName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="identityName"/> + + </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/realName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="realName"/> + + </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/ident" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="ident"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.v7.widget.ButtonBarLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.v7.widget.AppCompatButton + android:id="@+id/nicks" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Edit Nicks"/> + + </android.support.v7.widget.ButtonBarLayout> + + <TextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Messages" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/kickReason" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="kickReason"/> + + </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/partReason" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="partReason"/> + + </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/quitReason" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="quitReason"/> + + </android.support.design.widget.TextInputLayout> + + <TextView + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Away" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + <android.support.design.widget.TextInputLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <android.support.design.widget.TextInputEditText + android:id="@+id/awayReason" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="awayReason"/> + + </android.support.design.widget.TextInputLayout> + + <android.support.v7.widget.SwitchCompat + android:id="@+id/useAwayOnDetach" + style="?attr/switchPreferenceStyle" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + android:text="Away on Detach" + android:textColor="?attr/colorAccent" + android:textSize="14sp"/> + + <LinearLayout + android:id="@+id/groupAwayOnDetach" + 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/awayOnDetachReason" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="awayOnDetachReason"/> + + </android.support.design.widget.TextInputLayout> + + </LinearLayout> + + </LinearLayout> + + </ScrollView> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/activity_nick_list.xml b/app/src/main/res/layout/activity_nick_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..3c90be389c441895b08bbd586d7bea6073120cd8 --- /dev/null +++ b/app/src/main/res/layout/activity_nick_list.xml @@ -0,0 +1,65 @@ +<?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" + xmlns:app="http://schemas.android.com/apk/res-auto" + 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> + + <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:tint="@color/colorFillDark" + app:srcCompat="@drawable/ic_add"/> + </FrameLayout> +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_identitynick.xml b/app/src/main/res/layout/widget_identitynick.xml new file mode 100644 index 0000000000000000000000000000000000000000..0ca338914e909485aa0a8453d5f1c1fa23ea9639 --- /dev/null +++ b/app/src/main/res/layout/widget_identitynick.xml @@ -0,0 +1,52 @@ +<?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="?selectableItemBackground" + android:clickable="true" + android:orientation="horizontal" + android:paddingLeft="?listPreferredItemPaddingLeft" + android:paddingRight="?listPreferredItemPaddingRight"> + + <ImageView + android:id="@+id/drag_handle" + android:layout_width="24dp" + android:layout_height="24dp" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_reorder" + android:tint="?attr/colorFill"/> + + <TextView + android:id="@+id/text" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:layout_weight="1" + android:gravity="center_vertical|start" + android:lines="1" + android:singleLine="true" + android:textSize="16sp"/> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_networkserver.xml b/app/src/main/res/layout/widget_networkserver.xml index 001c8357709a6b72cfe76b13d3c3a15ed443e27a..05321aa97052de9e39c626f29527249457ce0e1b 100644 --- a/app/src/main/res/layout/widget_networkserver.xml +++ b/app/src/main/res/layout/widget_networkserver.xml @@ -51,8 +51,8 @@ <ImageView android:id="@+id/drag_handle" - android:layout_width="36dp" - android:layout_height="36dp" + android:layout_width="24dp" + android:layout_height="24dp" android:layout_gravity="center_vertical" android:src="@drawable/ic_reorder" android:tint="?attr/colorFill"/>