mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
Create key: repeat passphrase
This commit is contained in:
parent
052cdfa392
commit
fcc535a573
@ -26,6 +26,7 @@ import android.util.Patterns;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
@ -42,6 +43,7 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
AutoCompleteTextView mNameEdit;
|
||||
AutoCompleteTextView mEmailEdit;
|
||||
EditText mPassphraseEdit;
|
||||
EditText mPassphraseEditAgain;
|
||||
View mCreateButton;
|
||||
|
||||
public static final String ARG_NAME = "name";
|
||||
@ -69,7 +71,7 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
mNameEdit = (AutoCompleteTextView) view.findViewById(R.id.name);
|
||||
mEmailEdit = (AutoCompleteTextView) view.findViewById(R.id.email);
|
||||
mPassphraseEdit = (EditText) view.findViewById(R.id.passphrase);
|
||||
// TODO: second passphrase field
|
||||
mPassphraseEditAgain = (EditText) view.findViewById(R.id.passphrase_again);
|
||||
mCreateButton = view.findViewById(R.id.create_key_button);
|
||||
|
||||
// initial values
|
||||
@ -149,7 +151,8 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
private void createKeyCheck() {
|
||||
if (isEditTextNotEmpty(getActivity(), mNameEdit)
|
||||
&& isEditTextNotEmpty(getActivity(), mEmailEdit)
|
||||
&& isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
||||
&& isEditTextNotEmpty(getActivity(), mPassphraseEdit)
|
||||
&& areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) {
|
||||
|
||||
CreateKeyFinalFragment frag =
|
||||
CreateKeyFinalFragment.newInstance(
|
||||
@ -157,10 +160,24 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
mEmailEdit.getText().toString(),
|
||||
mPassphraseEdit.getText().toString()
|
||||
);
|
||||
|
||||
hideKeyboard();
|
||||
mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideKeyboard() {
|
||||
InputMethodManager inputManager = (InputMethodManager) getActivity()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
//check if no view has focus:
|
||||
View v = getActivity().getCurrentFocus();
|
||||
if (v == null)
|
||||
return;
|
||||
|
||||
inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if text of given EditText is not empty. If it is empty an error is
|
||||
* set and the EditText gets the focus.
|
||||
@ -182,4 +199,17 @@ public class CreateKeyInputFragment extends Fragment {
|
||||
return output;
|
||||
}
|
||||
|
||||
private static boolean areEditTextsEqual(Context context, EditText editText1, EditText editText2) {
|
||||
boolean output = true;
|
||||
if (!editText1.getText().toString().equals(editText2.getText().toString())) {
|
||||
editText2.setError(context.getString(R.string.create_key_passphrases_not_equal));
|
||||
editText2.requestFocus();
|
||||
output = false;
|
||||
} else {
|
||||
editText2.setError(null);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,11 +121,6 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
||||
return frag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates dialog
|
||||
*/
|
||||
|
@ -82,7 +82,7 @@
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Creating the key can take up to 3 Minutes, be patient!"
|
||||
android:textColor="@color/result_orange"
|
||||
android:textColor="@color/result_red"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:id="@+id/textView" />
|
||||
|
||||
|
@ -45,15 +45,24 @@
|
||||
android:inputType="textEmailAddress" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passphrase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:inputType="textPassword"
|
||||
android:hint="@string/label_passphrase"
|
||||
android:ems="10"
|
||||
android:id="@+id/passphrase"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/passphrase_again"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:inputType="textPassword"
|
||||
android:hint="@string/label_passphrase_again"
|
||||
android:ems="10"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
@ -106,7 +106,7 @@
|
||||
<string name="label_file">File</string>
|
||||
<string name="label_no_passphrase">No Passphrase</string>
|
||||
<string name="label_passphrase">Passphrase</string>
|
||||
<string name="label_passphrase_again">Again</string>
|
||||
<string name="label_passphrase_again">Repeat Passphrase</string>
|
||||
<string name="label_algorithm">Algorithm</string>
|
||||
<string name="label_ascii_armor">ASCII Armor</string>
|
||||
<string name="label_conceal_pgp_application">Let others know that you\'re using OpenKeychain</string>
|
||||
@ -488,9 +488,10 @@
|
||||
</string-array>
|
||||
|
||||
<!-- Create key -->
|
||||
<string name="create_key_text">Enter Full Name, Email and Passphrase!</string>
|
||||
<string name="create_key_text">Enter Full Name, Email and a Passphrase.</string>
|
||||
<string name="create_key_upload">Upload key to keyserver</string>
|
||||
<string name="create_key_empty">This field is required</string>
|
||||
<string name="create_key_passphrases_not_equal">Passphrases are not equal</string>
|
||||
|
||||
<!-- View key -->
|
||||
<string name="view_key_revoked">This key has been revoked!</string>
|
||||
|
Loading…
Reference in New Issue
Block a user