code cleanup for change password stuff
This commit is contained in:
		
							parent
							
								
									0c22a8d1c6
								
							
						
					
					
						commit
						193d2645e6
					
				|  | @ -94,8 +94,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate | ||||||
| 			final String passwordConfirm = mPasswordConfirm.getText().toString(); | 			final String passwordConfirm = mPasswordConfirm.getText().toString(); | ||||||
| 			if (registerNewAccount || changePassword) { | 			if (registerNewAccount || changePassword) { | ||||||
| 				if (!password.equals(passwordConfirm)) { | 				if (!password.equals(passwordConfirm)) { | ||||||
| 					mPasswordConfirm | 					mPasswordConfirm.setError(getString(R.string.passwords_do_not_match)); | ||||||
| 						.setError(getString(R.string.passwords_do_not_match)); |  | ||||||
| 					mPasswordConfirm.requestFocus(); | 					mPasswordConfirm.requestFocus(); | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
|  | @ -210,18 +209,26 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
| 		public void afterTextChanged(final Editable s) { | 		public void afterTextChanged(final Editable s) { | ||||||
|  | 			toggleChangePasswordCheckbox(); | ||||||
|  | 		} | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 	private void toggleChangePasswordCheckbox() { | ||||||
| 		final boolean registrationReady = mAccount != null && | 		final boolean registrationReady = mAccount != null && | ||||||
| 				mAccount.isOnlineAndConnected() && | 				mAccount.isOnlineAndConnected() && | ||||||
| 				mAccount.getXmppConnection().getFeatures().register(); | 				mAccount.getXmppConnection().getFeatures().register(); | ||||||
| 			if (jidToEdit != null && mAccount != null && registrationReady && | 		if (passwordFieldEdited() && registrationReady) { | ||||||
| 					!mAccount.getPassword().equals(s.toString()) && !"".equals(s.toString())) { |  | ||||||
| 			mChangePassword.setVisibility(View.VISIBLE); | 			mChangePassword.setVisibility(View.VISIBLE); | ||||||
| 		} else { | 		} else { | ||||||
| 			mChangePassword.setVisibility(View.INVISIBLE); | 			mChangePassword.setVisibility(View.INVISIBLE); | ||||||
| 			mChangePassword.setChecked(false); | 			mChangePassword.setChecked(false); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	}; | 
 | ||||||
|  | 	private boolean passwordFieldEdited() { | ||||||
|  | 		final String password = this.mPassword.getText().toString(); | ||||||
|  | 		return jidToEdit != null && mAccount != null && !password.isEmpty() && !mAccount.getPassword().equals(password); | ||||||
|  | 	} | ||||||
| 	private final OnClickListener mAvatarClickListener = new OnClickListener() { | 	private final OnClickListener mAvatarClickListener = new OnClickListener() { | ||||||
| 		@Override | 		@Override | ||||||
| 		public void onClick(final View view) { | 		public void onClick(final View view) { | ||||||
|  | @ -448,8 +455,8 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate | ||||||
| 			this.mChangePassword.setVisibility(View.GONE); | 			this.mChangePassword.setVisibility(View.GONE); | ||||||
| 			this.mChangePassword.setChecked(false); | 			this.mChangePassword.setChecked(false); | ||||||
| 		} | 		} | ||||||
| 		if (this.mAccount.getStatus() == Account.State.ONLINE | 		if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) { | ||||||
| 				&& !this.mFetchingAvatar) { | 			toggleChangePasswordCheckbox(); | ||||||
| 			this.mStats.setVisibility(View.VISIBLE); | 			this.mStats.setVisibility(View.VISIBLE); | ||||||
| 			this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection() | 			this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection() | ||||||
| 						.getLastSessionEstablished())); | 						.getLastSessionEstablished())); | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ | ||||||
|                     android:layout_width="wrap_content" |                     android:layout_width="wrap_content" | ||||||
|                     android:layout_height="wrap_content" |                     android:layout_height="wrap_content" | ||||||
|                     android:layout_marginTop="8dp" |                     android:layout_marginTop="8dp" | ||||||
|                     android:text="@string/change_password" |                     android:text="@string/change_password_on_server" | ||||||
|                     android:textColor="@color/primarytext" |                     android:textColor="@color/primarytext" | ||||||
|                     android:textSize="?attr/TextSizeBody" /> |                     android:textSize="?attr/TextSizeBody" /> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ | ||||||
|     <string name="contact_blocked">Contact blocked</string> |     <string name="contact_blocked">Contact blocked</string> | ||||||
|     <string name="remove_bookmark_text">Would you like to remove %s as a bookmark? The conversation associated with this bookmark will not be removed.</string> |     <string name="remove_bookmark_text">Would you like to remove %s as a bookmark? The conversation associated with this bookmark will not be removed.</string> | ||||||
|     <string name="register_account">Register new account on server</string> |     <string name="register_account">Register new account on server</string> | ||||||
|     <string name="change_password">Change password</string> |     <string name="change_password_on_server">Change password on server</string> | ||||||
|     <string name="share_with">Share with</string> |     <string name="share_with">Share with</string> | ||||||
|     <string name="start_conversation">Start Conversation</string> |     <string name="start_conversation">Start Conversation</string> | ||||||
|     <string name="invite_contact">Invite Contact</string> |     <string name="invite_contact">Invite Contact</string> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Daniel Gultsch
						Daniel Gultsch