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
|
Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show();
|
||||||
public void run() {
|
finish();
|
||||||
Toast.makeText(ChangePasswordActivity.this,R.string.password_changed,Toast.LENGTH_LONG).show();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPasswordChangeFailed() {
|
public void onPasswordChangeFailed() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
mNewPassword.setError(getString(R.string.could_not_change_password));
|
||||||
public void run() {
|
mChangePasswordButton.setEnabled(true);
|
||||||
mNewPassword.setError(getString(R.string.could_not_change_password));
|
mChangePasswordButton.setTextColor(getPrimaryTextColor());
|
||||||
mChangePasswordButton.setEnabled(true);
|
mChangePasswordButton.setText(R.string.change_password);
|
||||||
mChangePasswordButton.setTextColor(getPrimaryTextColor());
|
|
||||||
mChangePasswordButton.setText(R.string.change_password);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,110 +1,109 @@
|
||||||
<?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">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
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
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginTop="@dimen/activity_vertical_margin"
|
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
|
||||||
android:background="?attr/infocard_border"
|
|
||||||
android:padding="@dimen/infocard_padding"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/current_password_label"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginBottom="@dimen/activity_vertical_margin"
|
||||||
android:text="@string/current_password"
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:layout_marginTop="@dimen/activity_vertical_margin"
|
||||||
|
android:background="?attr/infocard_border"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/infocard_padding">
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/current_password"
|
android:id="@+id/current_password_label"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:text="@string/current_password"
|
||||||
android:hint="@string/password"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:inputType="textPassword"
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
android:textColor="?attr/color_text_primary"
|
|
||||||
android:textColorHint="?attr/color_text_secondary"
|
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:text="@string/new_password"
|
android:minHeight="64sp">
|
||||||
android:textColor="?attr/color_text_primary"
|
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
|
||||||
|
|
||||||
<EditText
|
<com.scottyab.showhidepasswordedittext.ShowHidePasswordEditText
|
||||||
android:id="@+id/new_password"
|
android:id="@+id/current_password"
|
||||||
android:layout_width="match_parent"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_height="wrap_content"
|
||||||
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"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/account_settings_confirm_password"
|
android:text="@string/new_password"
|
||||||
android:textColor="?attr/color_text_primary"
|
android:textColor="?attr/color_text_primary"
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
android:textSize="?attr/TextSizeBody"/>
|
||||||
|
|
||||||
<EditText
|
<RelativeLayout
|
||||||
android:id="@+id/new_password_confirm"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:minHeight="56sp">
|
||||||
android:hint="@string/password"
|
|
||||||
android:inputType="textPassword"
|
|
||||||
android:textColor="?attr/color_text_primary"
|
|
||||||
android:textColorHint="?attr/color_text_secondary"
|
|
||||||
android:textSize="?attr/TextSizeBody"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<LinearLayout
|
<com.scottyab.showhidepasswordedittext.ShowHidePasswordEditText
|
||||||
android:id="@+id/button_bar"
|
android:id="@+id/new_password"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_alignParentLeft="true"
|
android:hint="@string/password"
|
||||||
android:layout_alignParentRight="true">
|
android:inputType="textPassword"
|
||||||
|
android:textColor="?attr/color_text_primary"
|
||||||
|
android:textColorHint="?attr/color_text_secondary"
|
||||||
|
android:textSize="?attr/TextSizeBody"
|
||||||
|
app:tint_color="?attr/color_text_secondary"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
</LinearLayout>
|
||||||
android:id="@+id/left_button"
|
</ScrollView>
|
||||||
style="?android:attr/borderlessButtonStyle"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/cancel"/>
|
|
||||||
|
|
||||||
<View
|
<LinearLayout
|
||||||
android:layout_width="1dp"
|
android:id="@+id/button_bar"
|
||||||
android:layout_height="fill_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginBottom="7dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="7dp"
|
android:layout_alignParentBottom="true"
|
||||||
android:background="?attr/divider"/>
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentRight="true">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/right_button"
|
android:id="@+id/left_button"
|
||||||
style="?android:attr/borderlessButtonStyle"
|
style="?android:attr/borderlessButtonStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/change_password"/>
|
android:text="@string/cancel"/>
|
||||||
</LinearLayout>
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_marginBottom="7dp"
|
||||||
|
android:layout_marginTop="7dp"
|
||||||
|
android:background="?attr/divider"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/right_button"
|
||||||
|
style="?android:attr/borderlessButtonStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/change_password"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in New Issue