aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java34
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java5
-rw-r--r--OpenKeychain/src/main/res/layout/create_key_final_fragment.xml2
-rw-r--r--OpenKeychain/src/main/res/layout/create_key_input_fragment.xml11
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml5
5 files changed, 46 insertions, 11 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
index d82bf28a7..30a48e63e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java
@@ -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;
+ }
+
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
index 7981b717e..0a7fd6aee 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
@@ -121,11 +121,6 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
return frag;
}
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
/**
* Creates dialog
*/
diff --git a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml
index 458450653..ddfbb325f 100644
--- a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml
+++ b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml
@@ -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" />
diff --git a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
index 862eeb48f..ccc2f2bdd 100644
--- a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
+++ b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml
@@ -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>
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 3a5e77d38..e9a7e98dd 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -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>