aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog
diff options
context:
space:
mode:
authormar-v-in <github@rvin.mooo.com>2014-07-06 02:24:34 +0200
committermar-v-in <github@rvin.mooo.com>2014-07-06 02:24:34 +0200
commitfdf6411d5f059a2cde6bb32841895d5bf501ebe8 (patch)
treede8f6434ad00dd2a688160204aa5762b49f14b99 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog
parent1b0666e9de5caea14997a3e638a6209b45c97d60 (diff)
parent3363507be48e6ee77341fc8d637528610dc5136f (diff)
downloadopen-keychain-fdf6411d5f059a2cde6bb32841895d5bf501ebe8.tar.gz
open-keychain-fdf6411d5f059a2cde6bb32841895d5bf501ebe8.tar.bz2
open-keychain-fdf6411d5f059a2cde6bb32841895d5bf501ebe8.zip
Merge branch 'master' into improve-file-more
Conflicts: OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java OpenKeychain/src/main/res/layout/encrypt_content.xml
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java165
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java7
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java67
4 files changed, 55 insertions, 192 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java
deleted file mode 100644
index c27266e3f..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.sufficientlysecure.keychain.ui.dialog;
-
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.os.Message;
-import android.os.Messenger;
-import android.os.RemoteException;
-import android.support.v4.app.DialogFragment;
-import android.text.TextUtils;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.WindowManager;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
-import android.widget.TextView;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.util.Log;
-
-public class AddUserIdDialogFragment extends DialogFragment implements EditText.OnEditorActionListener {
- private static final String ARG_MESSENGER = "messenger";
-
- public static final int MESSAGE_OKAY = 1;
-
- public static final String MESSAGE_DATA_USER_ID = "user_id";
-
- private Messenger mMessenger;
-
- EditText mName;
- EditText mAddress;
- EditText mComment;
-
- /**
- * Creates new instance of this dialog fragment
- */
- public static AddUserIdDialogFragment newInstance(Messenger messenger) {
- AddUserIdDialogFragment frag = new AddUserIdDialogFragment();
- Bundle args = new Bundle();
- args.putParcelable(ARG_MESSENGER, messenger);
-
- frag.setArguments(args);
-
- return frag;
- }
-
- /**
- * Creates dialog
- */
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- mMessenger = getArguments().getParcelable(ARG_MESSENGER);
-
- CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(getActivity());
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.add_user_id_dialog, null);
- alert.setView(view);
- alert.setTitle("Add Identity");
-
- mName = (EditText) view.findViewById(R.id.name);
- mAddress = (EditText) view.findViewById(R.id.address);
- mComment = (EditText) view.findViewById(R.id.comment);
-
- alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int id) {
- done();
- }
- });
-
- alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
-
-
- return alert.show();
- }
-
- @Override
- public void onActivityCreated(Bundle arg0) {
- super.onActivityCreated(arg0);
- // Show soft keyboard automatically
- mName.requestFocus();
- getDialog().getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
- mComment.setOnEditorActionListener(this);
- }
-
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (EditorInfo.IME_ACTION_DONE == actionId) {
- done();
- return true;
- }
- return false;
- }
-
- private void done() {
- String name = mName.getText().toString();
- String email = mAddress.getText().toString();
- String comment = mComment.getText().toString();
-
- String userId = null;
- if (!TextUtils.isEmpty(name)) {
- userId = name;
- if (!TextUtils.isEmpty(comment)) {
- userId += " (" + comment + ")";
- }
- if (!TextUtils.isEmpty(email)) {
- userId += " <" + email + ">";
- }
- }
- Bundle data = new Bundle();
- data.putString(MESSAGE_DATA_USER_ID, userId);
- sendMessageToHandler(MESSAGE_OKAY, data);
-
- this.dismiss();
- }
-
- /**
- * Send message back to handler which is initialized in a activity
- *
- * @param what Message integer you want to send
- */
- private void sendMessageToHandler(Integer what, Bundle data) {
- Message msg = Message.obtain();
- msg.what = what;
- if (data != null) {
- msg.setData(data);
- }
-
- try {
- mMessenger.send(msg);
- } catch (RemoteException e) {
- Log.w(Constants.TAG, "Exception sending message, Is handler present?", e);
- } catch (NullPointerException e) {
- Log.w(Constants.TAG, "Messenger is null!", e);
- }
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java
index 6c012cb94..920743a9b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java
@@ -51,8 +51,6 @@ public class CreateKeyDialogFragment extends DialogFragment {
private static final String ARG_EDITOR_CHILD_COUNT = "child_count";
- private int mNewKeySize;
- private Choice mNewKeyAlgorithmChoice;
private OnAlgorithmSelectedListener mAlgorithmSelectedListener;
private Spinner mAlgorithmSpinner;
private Spinner mKeySizeSpinner;
@@ -131,9 +129,9 @@ public class CreateKeyDialogFragment extends DialogFragment {
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface di, int id) {
di.dismiss();
- mNewKeyAlgorithmChoice = (Choice) mAlgorithmSpinner.getSelectedItem();
- mNewKeySize = getProperKeyLength(mNewKeyAlgorithmChoice.getId(), getSelectedKeyLength());
- mAlgorithmSelectedListener.onAlgorithmSelected(mNewKeyAlgorithmChoice, mNewKeySize);
+ Choice newKeyAlgorithmChoice = (Choice) mAlgorithmSpinner.getSelectedItem();
+ int newKeySize = getProperKeyLength(newKeyAlgorithmChoice.getId(), getSelectedKeyLength());
+ mAlgorithmSelectedListener.onAlgorithmSelected(newKeyAlgorithmChoice, newKeySize);
}
}
);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java
index f0ca73f0d..5eba3a463 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java
@@ -26,6 +26,7 @@ import android.os.RemoteException;
import android.support.v4.app.DialogFragment;
import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.util.Log;
public class EditUserIdDialogFragment extends DialogFragment {
@@ -57,9 +58,9 @@ public class EditUserIdDialogFragment extends DialogFragment {
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(getActivity());
- CharSequence[] array = {"change to primary user id", "revoke"};
+ CharSequence[] array = getResources().getStringArray(R.array.edit_key_edit_user_id);
- builder.setTitle("select action!");
+ builder.setTitle(R.string.edit_key_edit_user_id_title);
builder.setItems(array, new DialogInterface.OnClickListener() {
@Override
@@ -76,7 +77,7 @@ public class EditUserIdDialogFragment extends DialogFragment {
}
}
});
- builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
+ builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dismiss();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java
index 04bec3282..93da48b75 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java
@@ -26,12 +26,15 @@ import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.support.v4.app.DialogFragment;
+import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
@@ -44,6 +47,7 @@ import org.sufficientlysecure.keychain.util.Log;
public class SetPassphraseDialogFragment extends DialogFragment implements OnEditorActionListener {
private static final String ARG_MESSENGER = "messenger";
private static final String ARG_TITLE = "title";
+ private static final String ARG_OLD_PASSPHRASE = "old_passphrase";
public static final int MESSAGE_OKAY = 1;
@@ -52,6 +56,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
private Messenger mMessenger;
private EditText mPassphraseEditText;
private EditText mPassphraseAgainEditText;
+ private CheckBox mNoPassphraseCheckBox;
/**
* Creates new instance of this dialog fragment
@@ -60,11 +65,12 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
* @param messenger to communicate back after setting the passphrase
* @return
*/
- public static SetPassphraseDialogFragment newInstance(Messenger messenger, int title) {
+ public static SetPassphraseDialogFragment newInstance(Messenger messenger, String oldPassphrase, int title) {
SetPassphraseDialogFragment frag = new SetPassphraseDialogFragment();
Bundle args = new Bundle();
args.putInt(ARG_TITLE, title);
args.putParcelable(ARG_MESSENGER, messenger);
+ args.putString(ARG_OLD_PASSPHRASE, oldPassphrase);
frag.setArguments(args);
@@ -80,6 +86,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
int title = getArguments().getInt(ARG_TITLE);
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
+ String oldPassphrase = getArguments().getString(ARG_OLD_PASSPHRASE);
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
@@ -92,6 +99,21 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
mPassphraseEditText = (EditText) view.findViewById(R.id.passphrase_passphrase);
mPassphraseAgainEditText = (EditText) view.findViewById(R.id.passphrase_passphrase_again);
+ mNoPassphraseCheckBox = (CheckBox) view.findViewById(R.id.passphrase_no_passphrase);
+
+ if (TextUtils.isEmpty(oldPassphrase)) {
+ mNoPassphraseCheckBox.setChecked(true);
+ mPassphraseEditText.setEnabled(false);
+ mPassphraseAgainEditText.setEnabled(false);
+ }
+
+ mNoPassphraseCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ mPassphraseEditText.setEnabled(!isChecked);
+ mPassphraseAgainEditText.setEnabled(!isChecked);
+ }
+ });
alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@@ -99,24 +121,31 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi
public void onClick(DialogInterface dialog, int id) {
dismiss();
- String passphrase1 = mPassphraseEditText.getText().toString();
- String passphrase2 = mPassphraseAgainEditText.getText().toString();
- if (!passphrase1.equals(passphrase2)) {
- Toast.makeText(
- activity,
- getString(R.string.error_message,
- getString(R.string.passphrases_do_not_match)), Toast.LENGTH_SHORT)
- .show();
- return;
- }
-
- if (passphrase1.equals("")) {
- Toast.makeText(
- activity,
- getString(R.string.error_message,
- getString(R.string.passphrase_must_not_be_empty)),
- Toast.LENGTH_SHORT).show();
- return;
+ String passphrase1;
+ if (mNoPassphraseCheckBox.isChecked()) {
+ passphrase1 = "";
+ } else {
+ passphrase1 = mPassphraseEditText.getText().toString();
+ String passphrase2 = mPassphraseAgainEditText.getText().toString();
+ if (!passphrase1.equals(passphrase2)) {
+ Toast.makeText(
+ activity,
+ getString(R.string.error_message,
+ getString(R.string.passphrases_do_not_match)), Toast.LENGTH_SHORT
+ )
+ .show();
+ return;
+ }
+
+ if (passphrase1.equals("")) {
+ Toast.makeText(
+ activity,
+ getString(R.string.error_message,
+ getString(R.string.passphrase_must_not_be_empty)),
+ Toast.LENGTH_SHORT
+ ).show();
+ return;
+ }
}
// return resulting data back to activity