Fix for #1357
This commit is contained in:
@@ -21,6 +21,8 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.text.method.HideReturnsTransformationMethod;
|
import android.text.method.HideReturnsTransformationMethod;
|
||||||
import android.text.method.PasswordTransformationMethod;
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -79,19 +81,10 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
|||||||
return output;
|
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 p1 = new Passphrase(editText1);
|
||||||
Passphrase p2 = new Passphrase(editText2);
|
Passphrase p2 = new Passphrase(editText2);
|
||||||
boolean output = (p1.equals(p2));
|
return (p1.equals(p2));
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
|
|
||||||
editText2.requestFocus();
|
|
||||||
} else {
|
|
||||||
editText2.setError(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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_done_grey_24dp, 0);
|
||||||
|
} else {
|
||||||
|
mPassphraseEditAgain.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_close_grey_24dp, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mPassphraseEdit.addTextChangedListener(textWatcher);
|
||||||
|
mPassphraseEditAgain.addTextChangedListener(textWatcher);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -153,9 +175,15 @@ public class CreateKeyPassphraseFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void nextClicked() {
|
private void nextClicked() {
|
||||||
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)
|
if (isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
||||||
&& areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) {
|
|
||||||
|
|
||||||
|
if (!areEditTextsEqual(mPassphraseEdit, mPassphraseEditAgain)) {
|
||||||
|
mPassphraseEditAgain.setError(getActivity().getApplicationContext().getString(R.string.create_key_passphrases_not_equal));
|
||||||
|
mPassphraseEditAgain.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPassphraseEditAgain.setError(null);
|
||||||
// save state
|
// save state
|
||||||
mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit);
|
mCreateKeyActivity.mPassphrase = new Passphrase(mPassphraseEdit);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user