fix change password activity for magic created accounts

This commit is contained in:
Daniel Gultsch 2018-03-04 20:37:42 +01:00
parent 1ae6042ca8
commit 194b8d419b
3 changed files with 49 additions and 42 deletions

View file

@ -1859,17 +1859,14 @@ public class XmppConnectionService extends Service {
public void updateAccountPasswordOnServer(final Account account, final String newPassword, final OnAccountPasswordChanged callback) { public void updateAccountPasswordOnServer(final Account account, final String newPassword, final OnAccountPasswordChanged callback) {
final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword); final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword);
sendIqPacket(account, iq, new OnIqPacketReceived() { sendIqPacket(account, iq, (a, packet) -> {
@Override if (packet.getType() == IqPacket.TYPE.RESULT) {
public void onIqPacketReceived(final Account account, final IqPacket packet) { a.setPassword(newPassword);
if (packet.getType() == IqPacket.TYPE.RESULT) { a.setOption(Account.OPTION_MAGIC_CREATE, false);
account.setPassword(newPassword); databaseBackend.updateAccount(a);
account.setOption(Account.OPTION_MAGIC_CREATE, false); callback.onPasswordChangeSucceeded();
databaseBackend.updateAccount(account); } else {
callback.onPasswordChangeSucceeded(); callback.onPasswordChangeFailed();
} else {
callback.onPasswordChangeFailed();
}
} }
}); });
} }

View file

@ -50,7 +50,7 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
void onBackendConnected() { void onBackendConnected() {
this.mAccount = extractAccount(getIntent()); this.mAccount = extractAccount(getIntent());
if (this.mAccount != null && this.mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { if (this.mAccount != null && this.mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) {
this.mCurrentPassword.setVisibility(View.GONE); this.mCurrentPasswordLayout.setVisibility(View.GONE);
} else { } else {
this.mCurrentPassword.setVisibility(View.VISIBLE); this.mCurrentPassword.setVisibility(View.VISIBLE);
} }

View file

@ -152,41 +152,51 @@
android:layout_marginTop="@dimen/activity_vertical_margin" android:layout_marginTop="@dimen/activity_vertical_margin"
android:visibility="gone"> android:visibility="gone">
<RelativeLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/card_padding_regular"> android:orientation="vertical">
<TextView <LinearLayout
android:id="@+id/os_optimization_headline" android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/battery_optimizations_enabled" android:orientation="vertical"
android:textAppearance="@style/TextAppearance.AppCompat.Title"/> android:padding="@dimen/card_padding_regular">
<TextView <TextView
android:id="@+id/os_optimization_body" android:id="@+id/os_optimization_headline"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/os_optimization_headline" android:text="@string/battery_optimizations_enabled"
android:layout_marginBottom="8dp" android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
android:layout_marginTop="8dp"
android:text="@string/battery_optimizations_enabled_explained"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
<Button <TextView
android:id="@+id/os_optimization_disable" android:id="@+id/os_optimization_body"
style="?android:attr/borderlessButtonStyle" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/battery_optimizations_enabled_explained"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_gravity="right"
android:layout_alignParentEnd="true" android:gravity="right">
android:layout_alignParentRight="true"
android:layout_below="@+id/os_optimization_body" <Button
android:layout_marginRight="-8dp" android:id="@+id/os_optimization_disable"
android:text="@string/disable" style="?android:attr/borderlessButtonStyle"
android:textColor="@color/accent"/> android:layout_width="wrap_content"
</RelativeLayout> android:layout_height="wrap_content"
android:minWidth="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/disable"
android:textColor="@color/accent"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
@ -565,9 +575,9 @@
android:id="@+id/other_device_keys_title" android:id="@+id/other_device_keys_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/list_padding"
android:text="@string/other_devices" android:text="@string/other_devices"
android:textAppearance="@style/TextAppearance.AppCompat.Title" android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
android:layout_margin="@dimen/list_padding"/>
<LinearLayout <LinearLayout
android:id="@+id/other_device_keys" android:id="@+id/other_device_keys"