use show password widget in Change Password Activity
This commit is contained in:
parent
a817a96c58
commit
df37e34e02
|
@ -21,20 +21,15 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
|
||||||
if (mAccount != null) {
|
if (mAccount != null) {
|
||||||
final String currentPassword = mCurrentPassword.getText().toString();
|
final String currentPassword = mCurrentPassword.getText().toString();
|
||||||
final String newPassword = mNewPassword.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())) {
|
if (!mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && !currentPassword.equals(mAccount.getPassword())) {
|
||||||
mCurrentPassword.requestFocus();
|
mCurrentPassword.requestFocus();
|
||||||
mCurrentPassword.setError(getString(R.string.account_status_unauthorized));
|
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()) {
|
} else if (newPassword.trim().isEmpty()) {
|
||||||
mNewPassword.requestFocus();
|
mNewPassword.requestFocus();
|
||||||
mNewPassword.setError(getString(R.string.password_should_not_be_empty));
|
mNewPassword.setError(getString(R.string.password_should_not_be_empty));
|
||||||
} else {
|
} else {
|
||||||
mCurrentPassword.setError(null);
|
mCurrentPassword.setError(null);
|
||||||
mNewPassword.setError(null);
|
mNewPassword.setError(null);
|
||||||
mNewPasswordConfirm.setError(null);
|
|
||||||
xmppConnectionService.updateAccountPasswordOnServer(mAccount, newPassword, ChangePasswordActivity.this);
|
xmppConnectionService.updateAccountPasswordOnServer(mAccount, newPassword, ChangePasswordActivity.this);
|
||||||
mChangePasswordButton.setEnabled(false);
|
mChangePasswordButton.setEnabled(false);
|
||||||
mChangePasswordButton.setTextColor(getSecondaryTextColor());
|
mChangePasswordButton.setTextColor(getSecondaryTextColor());
|
||||||
|
@ -46,7 +41,6 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
|
||||||
private TextView mCurrentPasswordLabel;
|
private TextView mCurrentPasswordLabel;
|
||||||
private EditText mCurrentPassword;
|
private EditText mCurrentPassword;
|
||||||
private EditText mNewPassword;
|
private EditText mNewPassword;
|
||||||
private EditText mNewPasswordConfirm;
|
|
||||||
private Account mAccount;
|
private Account mAccount;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,19 +59,13 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_change_password);
|
setContentView(R.layout.activity_change_password);
|
||||||
Button mCancelButton = (Button) findViewById(R.id.left_button);
|
Button mCancelButton = findViewById(R.id.left_button);
|
||||||
mCancelButton.setOnClickListener(new View.OnClickListener() {
|
mCancelButton.setOnClickListener(view -> finish());
|
||||||
@Override
|
this.mChangePasswordButton = findViewById(R.id.right_button);
|
||||||
public void onClick(View view) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.mChangePasswordButton = (Button) findViewById(R.id.right_button);
|
|
||||||
this.mChangePasswordButton.setOnClickListener(this.mOnChangePasswordButtonClicked);
|
this.mChangePasswordButton.setOnClickListener(this.mOnChangePasswordButtonClicked);
|
||||||
this.mCurrentPasswordLabel = (TextView) findViewById(R.id.current_password_label);
|
this.mCurrentPasswordLabel = findViewById(R.id.current_password_label);
|
||||||
this.mCurrentPassword = (EditText) findViewById(R.id.current_password);
|
this.mCurrentPassword = findViewById(R.id.current_password);
|
||||||
this.mNewPassword = (EditText) findViewById(R.id.new_password);
|
this.mNewPassword = findViewById(R.id.new_password);
|
||||||
this.mNewPasswordConfirm = (EditText) findViewById(R.id.new_password_confirm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,25 +81,19 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPasswordChangeSucceeded() {
|
public void onPasswordChangeSucceeded() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show();
|
Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPasswordChangeFailed() {
|
public void onPasswordChangeFailed() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mNewPassword.setError(getString(R.string.could_not_change_password));
|
mNewPassword.setError(getString(R.string.could_not_change_password));
|
||||||
mChangePasswordButton.setEnabled(true);
|
mChangePasswordButton.setEnabled(true);
|
||||||
mChangePasswordButton.setTextColor(getPrimaryTextColor());
|
mChangePasswordButton.setTextColor(getPrimaryTextColor());
|
||||||
mChangePasswordButton.setText(R.string.change_password);
|
mChangePasswordButton.setText(R.string.change_password);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout 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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/color_background_secondary">
|
android:background="?attr/color_background_secondary">
|
||||||
|
@ -8,16 +9,17 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_above="@+id/button_bar">
|
android:layout_above="@+id/button_bar">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
|
||||||
android:background="?attr/infocard_border"
|
android:background="?attr/infocard_border"
|
||||||
android:padding="@dimen/infocard_padding"
|
android:orientation="vertical"
|
||||||
android:orientation="vertical">
|
android:padding="@dimen/infocard_padding">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/current_password_label"
|
android:id="@+id/current_password_label"
|
||||||
|
@ -27,16 +29,22 @@
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
<EditText
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:minHeight="64sp">
|
||||||
|
|
||||||
|
<com.scottyab.showhidepasswordedittext.ShowHidePasswordEditText
|
||||||
android:id="@+id/current_password"
|
android:id="@+id/current_password"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:hint="@string/password"
|
android:hint="@string/password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textColorHint="?attr/color_text_secondary"
|
android:textColorHint="?attr/color_text_secondary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -45,33 +53,24 @@
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
<EditText
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:minHeight="56sp">
|
||||||
|
|
||||||
|
<com.scottyab.showhidepasswordedittext.ShowHidePasswordEditText
|
||||||
android:id="@+id/new_password"
|
android:id="@+id/new_password"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_alignParentTop="true"
|
||||||
android:hint="@string/password"
|
android:hint="@string/password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textColorHint="?attr/color_text_secondary"
|
android:textColorHint="?attr/color_text_secondary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"
|
||||||
|
app:tint_color="?attr/color_text_secondary"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/account_settings_confirm_password"
|
|
||||||
android:textColor="?attr/color_text_primary"
|
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/new_password_confirm"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="@string/password"
|
|
||||||
android:inputType="textPassword"
|
|
||||||
android:textColor="?attr/color_text_primary"
|
|
||||||
android:textColorHint="?attr/color_text_secondary"
|
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue