From 20d6f2cc5c96627920a645d72d6dc0bd8bcb7029 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 1 Apr 2018 22:37:13 +0200 Subject: fix change password activity for magic created accounts --- .../messenger/services/XmppConnectionService.java | 19 +- .../messenger/ui/ChangePasswordActivity.java | 2 +- .../pixart/messenger/ui/EditAccountActivity.java | 2 +- src/main/res/layout/activity_edit_account.xml | 929 +++++++++++---------- 4 files changed, 479 insertions(+), 473 deletions(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 716a39434..25ecf8506 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -2103,17 +2103,14 @@ public class XmppConnectionService extends Service { public void updateAccountPasswordOnServer(final Account account, final String newPassword, final OnAccountPasswordChanged callback) { final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword); - sendIqPacket(account, iq, new OnIqPacketReceived() { - @Override - public void onIqPacketReceived(final Account account, final IqPacket packet) { - if (packet.getType() == IqPacket.TYPE.RESULT) { - account.setPassword(newPassword); - account.setOption(Account.OPTION_MAGIC_CREATE, false); - databaseBackend.updateAccount(account); - callback.onPasswordChangeSucceeded(); - } else { - callback.onPasswordChangeFailed(); - } + sendIqPacket(account, iq, (a, packet) -> { + if (packet.getType() == IqPacket.TYPE.RESULT) { + a.setPassword(newPassword); + a.setOption(Account.OPTION_MAGIC_CREATE, false); + databaseBackend.updateAccount(a); + callback.onPasswordChangeSucceeded(); + } else { + callback.onPasswordChangeFailed(); } }); } diff --git a/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java b/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java index 5f1b5ba94..9525513aa 100644 --- a/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ChangePasswordActivity.java @@ -50,7 +50,7 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti void onBackendConnected() { this.mAccount = extractAccount(getIntent()); if (this.mAccount != null && this.mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { - this.mCurrentPassword.setVisibility(View.GONE); + this.mCurrentPasswordLayout.setVisibility(View.GONE); } else { this.mCurrentPassword.setVisibility(View.VISIBLE); } diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 9a1eb696c..036ddabab 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -1014,7 +1014,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.binding.accountJid.setEnabled(editable); this.binding.accountJid.setFocusable(editable); this.binding.accountJid.setFocusableInTouchMode(editable); - + if (mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) || !mAccount.isOptionSet(Account.OPTION_LOGGED_IN_SUCCESSFULLY)) { this.binding.accountPasswordLayout.setPasswordVisibilityToggleEnabled(true); } else { diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index 90dd1b194..0c64832f5 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -20,7 +20,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - + android:padding="@dimen/card_padding_regular"> - + - + android:layout_below="@+id/avater" + android:orientation="vertical"> - - + android:hint="@string/account_settings_jabber_id"> - + + - - + app:passwordToggleDrawable="@drawable/visibility_toggle_drawable" + app:passwordToggleEnabled="true" + app:passwordToggleTint="?android:textColorSecondary"> - - - - - - - - - + android:hint="@string/password" + android:inputType="textPassword" /> + + android:id="@+id/name_port" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:orientation="horizontal" + android:weightSum="1"> - + + + + + + + + + android:layout_weight="0.2" + android:orientation="vertical"> - - + android:hint="@string/account_settings_port"> + + + + - - - - - - - - + + + + - - + android:orientation="vertical"> - - -