Create key: repeat passphrase
This commit is contained in:
@@ -26,6 +26,7 @@ import android.util.Patterns;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -42,6 +43,7 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
AutoCompleteTextView mNameEdit;
|
AutoCompleteTextView mNameEdit;
|
||||||
AutoCompleteTextView mEmailEdit;
|
AutoCompleteTextView mEmailEdit;
|
||||||
EditText mPassphraseEdit;
|
EditText mPassphraseEdit;
|
||||||
|
EditText mPassphraseEditAgain;
|
||||||
View mCreateButton;
|
View mCreateButton;
|
||||||
|
|
||||||
public static final String ARG_NAME = "name";
|
public static final String ARG_NAME = "name";
|
||||||
@@ -69,7 +71,7 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
mNameEdit = (AutoCompleteTextView) view.findViewById(R.id.name);
|
mNameEdit = (AutoCompleteTextView) view.findViewById(R.id.name);
|
||||||
mEmailEdit = (AutoCompleteTextView) view.findViewById(R.id.email);
|
mEmailEdit = (AutoCompleteTextView) view.findViewById(R.id.email);
|
||||||
mPassphraseEdit = (EditText) view.findViewById(R.id.passphrase);
|
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);
|
mCreateButton = view.findViewById(R.id.create_key_button);
|
||||||
|
|
||||||
// initial values
|
// initial values
|
||||||
@@ -149,7 +151,8 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
private void createKeyCheck() {
|
private void createKeyCheck() {
|
||||||
if (isEditTextNotEmpty(getActivity(), mNameEdit)
|
if (isEditTextNotEmpty(getActivity(), mNameEdit)
|
||||||
&& isEditTextNotEmpty(getActivity(), mEmailEdit)
|
&& isEditTextNotEmpty(getActivity(), mEmailEdit)
|
||||||
&& isEditTextNotEmpty(getActivity(), mPassphraseEdit)) {
|
&& isEditTextNotEmpty(getActivity(), mPassphraseEdit)
|
||||||
|
&& areEditTextsEqual(getActivity(), mPassphraseEdit, mPassphraseEditAgain)) {
|
||||||
|
|
||||||
CreateKeyFinalFragment frag =
|
CreateKeyFinalFragment frag =
|
||||||
CreateKeyFinalFragment.newInstance(
|
CreateKeyFinalFragment.newInstance(
|
||||||
@@ -157,10 +160,24 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
mEmailEdit.getText().toString(),
|
mEmailEdit.getText().toString(),
|
||||||
mPassphraseEdit.getText().toString()
|
mPassphraseEdit.getText().toString()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
hideKeyboard();
|
||||||
mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_RIGHT);
|
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
|
* Checks if text of given EditText is not empty. If it is empty an error is
|
||||||
* set and the EditText gets the focus.
|
* set and the EditText gets the focus.
|
||||||
@@ -182,4 +199,17 @@ public class CreateKeyInputFragment extends Fragment {
|
|||||||
return output;
|
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;
|
return frag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates dialog
|
* Creates dialog
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
android:paddingTop="16dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="8dp"
|
||||||
android:text="Creating the key can take up to 3 Minutes, be patient!"
|
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:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:id="@+id/textView" />
|
android:id="@+id/textView" />
|
||||||
|
|
||||||
|
|||||||
@@ -45,15 +45,24 @@
|
|||||||
android:inputType="textEmailAddress" />
|
android:inputType="textEmailAddress" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
|
android:id="@+id/passphrase"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
android:hint="@string/label_passphrase"
|
android:hint="@string/label_passphrase"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:id="@+id/passphrase"
|
|
||||||
android:layout_gravity="center_horizontal" />
|
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>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
<string name="label_file">File</string>
|
<string name="label_file">File</string>
|
||||||
<string name="label_no_passphrase">No Passphrase</string>
|
<string name="label_no_passphrase">No Passphrase</string>
|
||||||
<string name="label_passphrase">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_algorithm">Algorithm</string>
|
||||||
<string name="label_ascii_armor">ASCII Armor</string>
|
<string name="label_ascii_armor">ASCII Armor</string>
|
||||||
<string name="label_conceal_pgp_application">Let others know that you\'re using OpenKeychain</string>
|
<string name="label_conceal_pgp_application">Let others know that you\'re using OpenKeychain</string>
|
||||||
@@ -488,9 +488,10 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Create key -->
|
<!-- 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_upload">Upload key to keyserver</string>
|
||||||
<string name="create_key_empty">This field is required</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 -->
|
<!-- View key -->
|
||||||
<string name="view_key_revoked">This key has been revoked!</string>
|
<string name="view_key_revoked">This key has been revoked!</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user