From df37e34e02f3bffb07edaaa854095776b7afce50 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 15 Dec 2017 12:31:31 +0100 Subject: [PATCH] use show password widget in Change Password Activity --- .../ui/ChangePasswordActivity.java | 46 ++--- .../res/layout/activity_change_password.xml | 183 +++++++++--------- 2 files changed, 105 insertions(+), 124 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java index acc25bf4a..b51b911c0 100644 --- a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java @@ -21,20 +21,15 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti if (mAccount != null) { final String currentPassword = mCurrentPassword.getText().toString(); final String newPassword = mNewPassword.getText().toString(); - final String newPasswordConfirm = mNewPasswordConfirm.getText().toString(); if (!mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && !currentPassword.equals(mAccount.getPassword())) { mCurrentPassword.requestFocus(); mCurrentPassword.setError(getString(R.string.account_status_unauthorized)); - } else if (!newPassword.equals(newPasswordConfirm)) { - mNewPasswordConfirm.requestFocus(); - mNewPasswordConfirm.setError(getString(R.string.passwords_do_not_match)); } else if (newPassword.trim().isEmpty()) { mNewPassword.requestFocus(); mNewPassword.setError(getString(R.string.password_should_not_be_empty)); } else { mCurrentPassword.setError(null); mNewPassword.setError(null); - mNewPasswordConfirm.setError(null); xmppConnectionService.updateAccountPasswordOnServer(mAccount, newPassword, ChangePasswordActivity.this); mChangePasswordButton.setEnabled(false); mChangePasswordButton.setTextColor(getSecondaryTextColor()); @@ -46,7 +41,6 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti private TextView mCurrentPasswordLabel; private EditText mCurrentPassword; private EditText mNewPassword; - private EditText mNewPasswordConfirm; private Account mAccount; @Override @@ -65,19 +59,13 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_change_password); - Button mCancelButton = (Button) findViewById(R.id.left_button); - mCancelButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }); - this.mChangePasswordButton = (Button) findViewById(R.id.right_button); + Button mCancelButton = findViewById(R.id.left_button); + mCancelButton.setOnClickListener(view -> finish()); + this.mChangePasswordButton = findViewById(R.id.right_button); this.mChangePasswordButton.setOnClickListener(this.mOnChangePasswordButtonClicked); - this.mCurrentPasswordLabel = (TextView) findViewById(R.id.current_password_label); - this.mCurrentPassword = (EditText) findViewById(R.id.current_password); - this.mNewPassword = (EditText) findViewById(R.id.new_password); - this.mNewPasswordConfirm = (EditText) findViewById(R.id.new_password_confirm); + this.mCurrentPasswordLabel = findViewById(R.id.current_password_label); + this.mCurrentPassword = findViewById(R.id.current_password); + this.mNewPassword = findViewById(R.id.new_password); } @Override @@ -93,25 +81,19 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti @Override public void onPasswordChangeSucceeded() { - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show(); - finish(); - } + runOnUiThread(() -> { + Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show(); + finish(); }); } @Override public void onPasswordChangeFailed() { - runOnUiThread(new Runnable() { - @Override - public void run() { - mNewPassword.setError(getString(R.string.could_not_change_password)); - mChangePasswordButton.setEnabled(true); - mChangePasswordButton.setTextColor(getPrimaryTextColor()); - mChangePasswordButton.setText(R.string.change_password); - } + runOnUiThread(() -> { + mNewPassword.setError(getString(R.string.could_not_change_password)); + mChangePasswordButton.setEnabled(true); + mChangePasswordButton.setTextColor(getPrimaryTextColor()); + mChangePasswordButton.setText(R.string.change_password); }); } diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml index 886c45c65..1ec37b5a4 100644 --- a/src/main/res/layout/activity_change_password.xml +++ b/src/main/res/layout/activity_change_password.xml @@ -1,110 +1,109 @@ - - + - + - + - + - + + - + - - - + - + + -