From 60ae269870ee25db325cd4bef6e54065a9d3d224 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 14 Dec 2017 19:28:52 +0100 Subject: [PATCH] removed password repeat field in favor of show password field --- build.gradle | 6 +- .../conversations/ui/EditAccountActivity.java | 42 +----- .../siacs/conversations/ui/XmppActivity.java | 10 +- src/main/res/layout/activity_edit_account.xml | 135 +++++++++--------- src/main/res/layout/dialog_show_password.xml | 22 --- src/main/res/menu/editaccount.xml | 5 - src/main/res/values/strings.xml | 2 - 7 files changed, 83 insertions(+), 139 deletions(-) delete mode 100644 src/main/res/layout/dialog_show_password.xml diff --git a/build.gradle b/build.gradle index b1ed2c231..c7c5c05c0 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,9 @@ repositories { maven { url 'https://maven.google.com' } + maven { + url "https://jitpack.io" + } } configurations { @@ -37,8 +40,8 @@ dependencies { compile "com.android.support:appcompat-v7:$supportLibVersion" compile "com.android.support:support-emoji:$supportLibVersion" freeCompile "com.android.support:support-emoji-bundled:$supportLibVersion" - compile 'org.bouncycastle:bcmail-jdk15on:1.52' compile 'org.jitsi:org.otr4j:0.22' + compile 'org.bouncycastle:bcmail-jdk15on:1.56' compile 'org.gnu.inet:libidn:1.15' compile 'com.google.zxing:core:3.2.1' compile 'com.google.zxing:android-integration:3.2.1' @@ -50,6 +53,7 @@ dependencies { compile 'com.makeramen:roundedimageview:2.3.0' compile "com.wefika:flowlayout:0.4.1" compile 'net.ypresto.androidtranscoder:android-transcoder:0.2.0' + compile 'com.github.scottyab:showhidepasswordedittext:0.8' } diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index ca4cf6c7f..cd5a2276d 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -74,7 +74,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private static final int REQUEST_DATA_SAVER = 0x37af244; private AutoCompleteTextView mAccountJid; private EditText mPassword; - private EditText mPasswordConfirm; private CheckBox mRegisterNew; private Button mCancelButton; private Button mSaveButton; @@ -130,7 +129,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat @Override public void onClick(final View v) { final String password = mPassword.getText().toString(); - final String passwordConfirm = mPasswordConfirm.getText().toString(); final boolean wasDisabled = mAccount != null && mAccount.getStatus() == Account.State.DISABLED; if (!mInitMode && passwordChangedInMagicCreateMode()) { @@ -219,13 +217,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat mAccountJid.requestFocus(); return; } - if (registerNewAccount) { - if (!password.equals(passwordConfirm)) { - mPasswordConfirm.setError(getString(R.string.passwords_do_not_match)); - mPasswordConfirm.requestFocus(); - return; - } - } if (mAccount != null) { if (mInitMode && mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { mAccount.setOption(Account.OPTION_MAGIC_CREATE, mAccount.getPassword().contains(password)); @@ -234,7 +225,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat mAccount.setPort(numericPort); mAccount.setHostname(hostname); mAccountJid.setError(null); - mPasswordConfirm.setError(null); mAccount.setPassword(password); mAccount.setOption(Account.OPTION_REGISTER, registerNewAccount); if (!xmppConnectionService.updateAccount(mAccount)) { @@ -523,7 +513,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.mAccountJidLabel = (TextView) findViewById(R.id.account_jid_label); this.mPassword = (EditText) findViewById(R.id.account_password); this.mPassword.addTextChangedListener(this.mTextWatcher); - this.mPasswordConfirm = (EditText) findViewById(R.id.account_password_confirm); this.mAvatar = (ImageView) findViewById(R.id.avater); this.mAvatar.setOnClickListener(this.mAvatarClickListener); this.mRegisterNew = (CheckBox) findViewById(R.id.account_register_new); @@ -580,13 +569,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } final OnCheckedChangeListener OnCheckedShowConfirmPassword = new OnCheckedChangeListener() { @Override - public void onCheckedChanged(final CompoundButton buttonView, - final boolean isChecked) { - if (isChecked) { - mPasswordConfirm.setVisibility(View.VISIBLE); - } else { - mPasswordConfirm.setVisibility(View.GONE); - } + public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { updateSaveButton(); } }; @@ -603,7 +586,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list); final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more); final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server); - final MenuItem showPassword = menu.findItem(R.id.action_show_password); final MenuItem renewCertificate = menu.findItem(R.id.action_renew_certificate); final MenuItem mamPrefs = menu.findItem(R.id.action_mam_prefs); final MenuItem changePresence = menu.findItem(R.id.action_change_presence); @@ -629,13 +611,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat mamPrefs.setVisible(false); changePresence.setVisible(false); } - - if (mAccount != null) { - showPassword.setVisible(mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) - && !mAccount.isOptionSet(Account.OPTION_REGISTER)); - } else { - showPassword.setVisible(false); - } return super.onCreateOptionsMenu(menu); } @@ -786,9 +761,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat case R.id.action_change_presence: changePresence(); break; - case R.id.action_show_password: - showPassword(); - break; } return super.onOptionsItemSelected(item); } @@ -863,7 +835,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) { this.mRegisterNew.setVisibility(View.VISIBLE); this.mRegisterNew.setChecked(true); - this.mPasswordConfirm.setText(this.mAccount.getPassword()); } else { this.mRegisterNew.setVisibility(View.GONE); this.mRegisterNew.setChecked(false); @@ -1131,17 +1102,6 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat xmppConnectionService.fetchMamPreferences(mAccount, this); } - private void showPassword() { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - View view = getLayoutInflater().inflate(R.layout.dialog_show_password, null); - TextView password = (TextView) view.findViewById(R.id.password); - password.setText(mAccount.getPassword()); - builder.setTitle(R.string.password); - builder.setView(view); - builder.setPositiveButton(R.string.cancel, null); - builder.create().show(); - } - @Override public void onKeyStatusUpdated(AxolotlService.FetchStatus report) { refreshUi(); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index a531fe8cf..319c2e61a 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -426,8 +426,9 @@ public abstract class XmppActivity extends Activity { protected boolean isOptimizingBattery() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); - return !pm.isIgnoringBatteryOptimizations(getPackageName()); + final PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); + return pm == null + && !pm.isIgnoringBatteryOptimizations(getPackageName()); } else { return false; } @@ -435,8 +436,9 @@ public abstract class XmppActivity extends Activity { protected boolean isAffectedByDataSaver() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - return cm.isActiveNetworkMetered() + final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + return cm != null + && cm.isActiveNetworkMetered() && cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED; } else { return false; diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index ba7e289f0..f61777bf3 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -29,6 +29,7 @@ android:background="?attr/infocard_border" android:orientation="vertical" android:padding="@dimen/infocard_padding"> + + + - + android:layout_height="match_parent" + android:minHeight="56sp"> + + + + + + + + + + + - - - - @@ -174,6 +172,7 @@ android:orientation="vertical" android:padding="@dimen/infocard_padding" android:visibility="gone"> + + +