diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-07-02 17:39:58 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-07-02 17:39:58 +0200 |
commit | 0454c57431f55003648f9a328a0f5a0fde6e54b6 (patch) | |
tree | 9f9da21526dd955e3dbf89d02965f292002fe6a7 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui | |
parent | 9dac8ddbac60997e16b7cb1a4fc9bad71cc0ab87 (diff) | |
parent | 8b2ae99412906041182634771a2792cfadca65cd (diff) | |
download | open-keychain-0454c57431f55003648f9a328a0f5a0fde6e54b6.tar.gz open-keychain-0454c57431f55003648f9a328a0f5a0fde6e54b6.tar.bz2 open-keychain-0454c57431f55003648f9a328a0f5a0fde6e54b6.zip |
Merge branch 'master' of github.com:open-keychain/open-keychain
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui')
3 files changed, 49 insertions, 17 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyPassphraseFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyPassphraseFragment.java index 6de5e71b3..d858fd6ec 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyPassphraseFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyPassphraseFragment.java @@ -21,6 +21,8 @@ import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.text.Editable; +import android.text.TextWatcher; import android.text.method.HideReturnsTransformationMethod; import android.text.method.PasswordTransformationMethod; import android.view.LayoutInflater; @@ -79,19 +81,10 @@ public class CreateKeyPassphraseFragment extends Fragment { return output; } - private static boolean areEditTextsEqual(Context context, EditText editText1, EditText editText2) { + private static boolean areEditTextsEqual(EditText editText1, EditText editText2) { Passphrase p1 = new Passphrase(editText1); Passphrase p2 = new Passphrase(editText2); - boolean output = (p1.equals(p2)); - - if (!output) { - editText2.setError(context.getString(R.string.create_key_passphrases_not_equal)); - editText2.requestFocus(); - } else { - editText2.setError(null); - } - - return output; + return (p1.equals(p2)); } @Override @@ -137,6 +130,35 @@ public class CreateKeyPassphraseFragment extends Fragment { } }); + TextWatcher textWatcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (!isEditTextNotEmpty(getActivity(), mPassphraseEdit)) { + mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + return; + } + + if (areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) { + mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_stat_retyped_ok, 0); + } else { + mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_stat_retyped_bad, 0); + } + + } + + @Override + public void afterTextChanged(Editable s) { + + } + }; + + mPassphraseEdit.addTextChangedListener(textWatcher); + mPassphraseEditAgain.addTextChangedListener(textWatcher); return view; } @@ -153,9 +175,15 @@ public class CreateKeyPassphraseFragment extends Fragment { } private void nextClicked() { - if (isEditTextNotEmpty(getActivity(), mPassphraseEdit) - && areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) { + if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)) { + + if (!areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) { + mPassphraseEditAgain.setError(getActivity().getApplicationContext().getString(R.string.create_key_passphrases_not_equal)); + mPassphraseEditAgain.requestFocus(); + return; + } + mPassphraseEditAgain.setError(null); // save state mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java index 20565aa7d..2ae64d90b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SettingsKeyserverFragment.java @@ -83,7 +83,6 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC String keyservers[] = getArguments().getStringArray(ARG_KEYSERVER_ARRAY); mKeyservers = new ArrayList<>(Arrays.asList(keyservers)); - saveKeyserverList(); // in case user does not make any changes mAdapter = new KeyserverListAdapter(mKeyservers); @@ -146,7 +145,7 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC if (deleted) { Notify.create(getActivity(), getActivity().getString( - R.string.keyserver_deleted, mKeyservers.get(position)), + R.string.keyserver_preference_deleted, mKeyservers.get(position)), Notify.Style.OK) .show(); deleteKeyserver(position); @@ -222,6 +221,11 @@ public class SettingsKeyserverFragment extends Fragment implements RecyclerItemC } private void deleteKeyserver(int position) { + if (mKeyservers.size() == 1) { + Notify.create(getActivity(), R.string.keyserver_preference_cannot_delete_last, + Notify.Style.ERROR).show(); + return; + } mKeyservers.remove(position); // we use this mAdapter.notifyItemRemoved(position); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java index e55f6b1ad..494ccb6d3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EmailEditText.java @@ -75,10 +75,10 @@ public class EmailEditText extends AppCompatAutoCompleteTextView { Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email); if (emailMatcher.matches()) { EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0, - R.drawable.uid_mail_ok, 0); + R.drawable.ic_stat_retyped_ok, 0); } else { EmailEditText.this.setCompoundDrawablesWithIntrinsicBounds(0, 0, - R.drawable.uid_mail_bad, 0); + R.drawable.ic_stat_retyped_bad, 0); } } else { // remove drawable if email is empty |