From c52828d247d188ef7c1ba47865cf0f386c9baf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Jun 2014 13:33:50 +0200 Subject: [PATCH 1/8] add buttons in edit key --- .../src/main/res/layout/edit_key_fragment.xml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/OpenKeychain/src/main/res/layout/edit_key_fragment.xml b/OpenKeychain/src/main/res/layout/edit_key_fragment.xml index dbc0c3941..9d63ea38a 100644 --- a/OpenKeychain/src/main/res/layout/edit_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/edit_key_fragment.xml @@ -9,6 +9,30 @@ android:paddingLeft="16dp" android:paddingRight="16dp"> + + + + + + + + + + + + From 106e1fcf0344ddf98f65b7c7adc706da19faef7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Jun 2014 16:03:03 +0200 Subject: [PATCH 2/8] Rename adapter --- .../keychain/ui/CertifyKeyActivity.java | 8 +++---- .../keychain/ui/EditKeyFragment.java | 17 +++++++------- .../keychain/ui/ViewKeyKeysFragment.java | 8 +++---- .../keychain/ui/ViewKeyMainFragment.java | 8 +++---- ...eyKeysAdapter.java => SubkeysAdapter.java} | 4 ++-- ...serIdsAdapter.java => UserIdsAdapter.java} | 23 ++++++++++++++----- 6 files changed, 39 insertions(+), 29 deletions(-) rename OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/{ViewKeyKeysAdapter.java => SubkeysAdapter.java} (98%) rename OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/{ViewKeyUserIdsAdapter.java => UserIdsAdapter.java} (90%) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 6c74818a5..db00d5f69 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -53,7 +53,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -75,7 +75,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements private long mMasterKeyId = 0; private ListView mUserIds; - private ViewKeyUserIdsAdapter mUserIdsAdapter; + private UserIdsAdapter mUserIdsAdapter; private static final int LOADER_ID_KEYRING = 0; private static final int LOADER_ID_USER_IDS = 1; @@ -143,7 +143,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements mUserIds = (ListView) findViewById(R.id.view_key_user_ids); - mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0, true); + mUserIdsAdapter = new UserIdsAdapter(this, null, 0, true); mUserIds.setAdapter(mUserIdsAdapter); mUserIds.setOnItemClickListener(mUserIdsAdapter); @@ -175,7 +175,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements case LOADER_ID_USER_IDS: { Uri uri = UserIds.buildUserIdsUri(mDataUri); return new CursorLoader(this, uri, - ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_SELECTION, null, null); + UserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_SELECTION, null, null); } } return null; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index 9231ce142..b3516f5d6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -34,9 +34,8 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter; -import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; +import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.util.Log; public class EditKeyFragment extends LoaderFragment implements @@ -50,8 +49,8 @@ public class EditKeyFragment extends LoaderFragment implements private static final int LOADER_ID_USER_IDS = 0; private static final int LOADER_ID_KEYS = 1; - private ViewKeyUserIdsAdapter mUserIdsAdapter; - private ViewKeyKeysAdapter mKeysAdapter; + private UserIdsAdapter mUserIdsAdapter; + private SubkeysAdapter mKeysAdapter; private Uri mDataUri; @@ -128,9 +127,9 @@ public class EditKeyFragment extends LoaderFragment implements // }); - mUserIdsAdapter = new ViewKeyUserIdsAdapter(getActivity(), null, 0); + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIds.setAdapter(mUserIdsAdapter); - mKeysAdapter = new ViewKeyKeysAdapter(getActivity(), null, 0); + mKeysAdapter = new SubkeysAdapter(getActivity(), null, 0); mKeys.setAdapter(mKeysAdapter); // Prepare the loaders. Either re-connect with an existing ones, @@ -146,13 +145,13 @@ public class EditKeyFragment extends LoaderFragment implements case LOADER_ID_USER_IDS: { Uri baseUri = KeychainContract.UserIds.buildUserIdsUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); } case LOADER_ID_KEYS: { Uri baseUri = KeychainContract.Keys.buildKeysUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - ViewKeyKeysAdapter.KEYS_PROJECTION, null, null, null); + SubkeysAdapter.KEYS_PROJECTION, null, null, null); } default: diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java index e01a0140c..4be572b4e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyKeysFragment.java @@ -31,7 +31,7 @@ import android.widget.ListView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; -import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter; +import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; import org.sufficientlysecure.keychain.util.Log; @@ -42,7 +42,7 @@ public class ViewKeyKeysFragment extends LoaderFragment implements private ListView mKeys; - private ViewKeyKeysAdapter mKeysAdapter; + private SubkeysAdapter mKeysAdapter; private Uri mDataUri; @@ -75,7 +75,7 @@ public class ViewKeyKeysFragment extends LoaderFragment implements Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - mKeysAdapter = new ViewKeyKeysAdapter(getActivity(), null, 0); + mKeysAdapter = new SubkeysAdapter(getActivity(), null, 0); mKeys.setAdapter(mKeysAdapter); // Prepare the loaders. Either re-connect with an existing ones, @@ -87,7 +87,7 @@ public class ViewKeyKeysFragment extends LoaderFragment implements setContentShown(false); Uri baseUri = Keys.buildKeysUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - ViewKeyKeysAdapter.KEYS_PROJECTION, null, null, null); + SubkeysAdapter.KEYS_PROJECTION, null, null, null); } public void onLoadFinished(Loader loader, Cursor data) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index bd29f3820..dd48f193c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -38,7 +38,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.util.Log; import java.util.Date; @@ -63,7 +63,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements // conservative attitude private boolean mHasEncrypt = true; - private ViewKeyUserIdsAdapter mUserIdsAdapter; + private UserIdsAdapter mUserIdsAdapter; private Uri mDataUri; @@ -124,7 +124,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements } }); - mUserIdsAdapter = new ViewKeyUserIdsAdapter(getActivity(), null, 0); + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIds.setAdapter(mUserIdsAdapter); // Prepare the loaders. Either re-connect with an existing ones, @@ -154,7 +154,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements case LOADER_ID_USER_IDS: { Uri baseUri = UserIds.buildUserIdsUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); } default: diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java similarity index 98% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java rename to OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java index dae287bbc..6d8455589 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java @@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import java.util.Date; -public class ViewKeyKeysAdapter extends CursorAdapter { +public class SubkeysAdapter extends CursorAdapter { private LayoutInflater mInflater; private int mIndexKeyId; @@ -69,7 +69,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { Keys.FINGERPRINT }; - public ViewKeyKeysAdapter(Context context, Cursor c, int flags) { + public SubkeysAdapter(Context context, Cursor c, int flags) { super(context, c, flags); mInflater = LayoutInflater.from(context); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java similarity index 90% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java rename to OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 763752edc..77da1d0e3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -34,10 +34,11 @@ import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract.Certs; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import java.util.ArrayList; -public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.OnItemClickListener { +public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemClickListener { private LayoutInflater mInflater; private int mIndexUserId, mIndexRank; @@ -45,6 +46,8 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView. private final ArrayList mCheckStates; + private SaveKeyringParcel mSaveKeyringParcel; + public static final String[] USER_IDS_PROJECTION = new String[]{ UserIds._ID, UserIds.USER_ID, @@ -54,18 +57,27 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView. UserIds.IS_REVOKED }; - public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { + public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes, + SaveKeyringParcel saveKeyringParcel) { super(context, c, flags); - mInflater = LayoutInflater.from(context); mCheckStates = showCheckBoxes ? new ArrayList() : null; + mSaveKeyringParcel = saveKeyringParcel; initIndex(c); } - public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags) { - this(context, c, flags, false); + public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { + this(context, c, flags, showCheckBoxes, null); + } + + public UserIdsAdapter(Context context, Cursor c, int flags, SaveKeyringParcel saveKeyringParcel) { + this(context, c, flags, false, saveKeyringParcel); + } + + public UserIdsAdapter(Context context, Cursor c, int flags) { + this(context, c, flags, false, null); } @Override @@ -181,7 +193,6 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView. } }); vCheckBox.setClickable(false); - } public void onItemClick(AdapterView adapter, View view, int position, long id) { From b43fb63753bc9be7a1a0b05e7369a2373f65c03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Jun 2014 18:12:04 +0200 Subject: [PATCH 3/8] new edit key: diff for existing user ids --- .../keychain/service/SaveKeyringParcel.java | 5 + .../keychain/ui/CertifyKeyActivity.java | 1 - .../keychain/ui/EditKeyFragment.java | 136 ++++++++++++++++-- .../keychain/ui/adapter/UserIdsAdapter.java | 51 +++++-- .../ui/dialog/AddUserIdDialogFragment.java | 108 ++++++++++++++ .../ui/dialog/EditUserIdDialogFragment.java | 109 ++++++++++++++ .../src/main/res/layout/edit_key_fragment.xml | 22 +-- .../main/res/layout/view_key_userids_item.xml | 9 +- 8 files changed, 405 insertions(+), 36 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index 47a6cab1d..020b808b9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -41,6 +41,11 @@ public class SaveKeyringParcel implements Parcelable { public SaveKeyringParcel(long masterKeyId, byte[] fingerprint) { mMasterKeyId = masterKeyId; mFingerprint = fingerprint; + addUserIds = new ArrayList(); + addSubKeys = new ArrayList(); + changeSubKeys = new ArrayList(); + revokeUserIds = new ArrayList(); + revokeSubKeys = new ArrayList(); } // performance gain for using Parcelable here would probably be negligible, diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index db00d5f69..7ac229b91 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -149,7 +149,6 @@ public class CertifyKeyActivity extends ActionBarActivity implements getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this); getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); - } static final String USER_IDS_SELECTION = UserIds.IS_REVOKED + " = 0"; diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index b3516f5d6..dac19a0c3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -20,6 +20,9 @@ package org.sufficientlysecure.keychain.ui; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; @@ -28,14 +31,22 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.ListView; +import android.widget.Toast; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.pgp.WrappedSecretKeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; +import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; import org.sufficientlysecure.keychain.util.Log; public class EditKeyFragment extends LoaderFragment implements @@ -43,8 +54,13 @@ public class EditKeyFragment extends LoaderFragment implements public static final String ARG_DATA_URI = "uri"; - private ListView mUserIds; - private ListView mKeys; + private ListView mUserIdsList; + private ListView mKeysList; + private ListView mUserIdsAddedList; + private ListView mKeysAddedList; + private View mChangePassphrase; + private View mAddUserId; + private View mAddKey; private static final int LOADER_ID_USER_IDS = 0; private static final int LOADER_ID_KEYS = 1; @@ -54,6 +70,8 @@ public class EditKeyFragment extends LoaderFragment implements private Uri mDataUri; + private SaveKeyringParcel mSaveKeyringParcel; + /** * Creates new instance of this fragment */ @@ -73,9 +91,13 @@ public class EditKeyFragment extends LoaderFragment implements View root = super.onCreateView(inflater, superContainer, savedInstanceState); View view = inflater.inflate(R.layout.edit_key_fragment, getContainer()); - mUserIds = (ListView) view.findViewById(R.id.edit_key_user_ids); - mKeys = (ListView) view.findViewById(R.id.edit_key_keys); -// mActionEdit = view.findViewById(R.id.view_key_action_edit); + mUserIdsList = (ListView) view.findViewById(R.id.edit_key_user_ids); + mKeysList = (ListView) view.findViewById(R.id.edit_key_keys); + mUserIdsAddedList = (ListView) view.findViewById(R.id.edit_key_user_ids_added); + mKeysAddedList = (ListView) view.findViewById(R.id.edit_key_keys_added); + mChangePassphrase = view.findViewById(R.id.edit_key_action_change_passphrase); + mAddUserId = view.findViewById(R.id.edit_key_action_add_user_id); + mAddKey = view.findViewById(R.id.edit_key_action_add_key); return root; } @@ -84,7 +106,6 @@ public class EditKeyFragment extends LoaderFragment implements public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - // Inflate a "Done"/"Cancel" custom action bar view ActionBarHelper.setTwoButtonView(((ActionBarActivity) getActivity()).getSupportActionBar(), R.string.btn_save, R.drawable.ic_action_save, @@ -114,23 +135,108 @@ public class EditKeyFragment extends LoaderFragment implements loadData(dataUri); } + private void editUserId(final String userId) { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + switch (message.what) { + case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID: + // toggle + if (mSaveKeyringParcel.changePrimaryUserId != null + && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) { + mSaveKeyringParcel.changePrimaryUserId = null; + } else { + mSaveKeyringParcel.changePrimaryUserId = userId; + } + break; + case EditUserIdDialogFragment.MESSAGE_REVOKE: + // toggle + if (mSaveKeyringParcel.revokeUserIds.contains(userId)) { + mSaveKeyringParcel.revokeUserIds.remove(userId); + } else { + mSaveKeyringParcel.revokeUserIds.add(userId); + } + break; + } + getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + EditUserIdDialogFragment dialogFragment = + EditUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog"); + } + }); + } + + private void addUserId() { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == AddUserIdDialogFragment.MESSAGE_OK) { + + } +// getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + AddUserIdDialogFragment dialogFragment = + AddUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); + } + }); + } + private void loadData(Uri dataUri) { mDataUri = dataUri; Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); -// mActionEncrypt.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// encrypt(mDataUri); -// } -// }); + try { + Uri secretUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); + WrappedSecretKeyRing keyRing = + new ProviderHelper(getActivity()).getWrappedSecretKeyRing(secretUri); + mSaveKeyringParcel = new SaveKeyringParcel(keyRing.getMasterKeyId(), + keyRing.getUncachedKeyRing().getFingerprint()); + } catch (ProviderHelper.NotFoundException e) { + Log.e(Constants.TAG, "Keyring not found: " + e.getMessage(), e); + Toast.makeText(getActivity(), R.string.error_no_secret_key_found, Toast.LENGTH_SHORT).show(); + getActivity().finish(); + } + + mAddUserId.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + addUserId(); + } + }); + + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0, mSaveKeyringParcel); + mUserIdsList.setAdapter(mUserIdsAdapter); + + mUserIdsList.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + String userId = mUserIdsAdapter.getUserId(position); + editUserId(userId); + } + }); - mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); - mUserIds.setAdapter(mUserIdsAdapter); mKeysAdapter = new SubkeysAdapter(getActivity(), null, 0); - mKeys.setAdapter(mKeysAdapter); + mKeysList.setAdapter(mKeysAdapter); // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 77da1d0e3..7a7acfe89 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -122,21 +122,23 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC TextView vAddress = (TextView) view.findViewById(R.id.address); TextView vComment = (TextView) view.findViewById(R.id.comment); ImageView vVerified = (ImageView) view.findViewById(R.id.certified); + ImageView vHasChanges = (ImageView) view.findViewById(R.id.has_changes); - String[] userId = KeyRing.splitUserId(cursor.getString(mIndexUserId)); - if (userId[0] != null) { - vName.setText(userId[0]); + String userId = cursor.getString(mIndexUserId); + String[] splitUserId = KeyRing.splitUserId(userId); + if (splitUserId[0] != null) { + vName.setText(splitUserId[0]); } else { vName.setText(R.string.user_id_no_name); } - if (userId[1] != null) { - vAddress.setText(userId[1]); + if (splitUserId[1] != null) { + vAddress.setText(splitUserId[1]); vAddress.setVisibility(View.VISIBLE); } else { vAddress.setVisibility(View.GONE); } - if (userId[2] != null) { - vComment.setText(userId[2]); + if (splitUserId[2] != null) { + vComment.setText(splitUserId[2]); vComment.setVisibility(View.VISIBLE); } else { vComment.setVisibility(View.GONE); @@ -144,9 +146,33 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // show small star icon for primary user ids boolean isPrimary = cursor.getInt(mIsPrimary) != 0; + boolean isRevoked = cursor.getInt(mIsRevoked) > 0; - if (cursor.getInt(mIsRevoked) > 0) { + // for edit key + if (mSaveKeyringParcel != null) { + boolean changeUserId = (mSaveKeyringParcel.changePrimaryUserId != null + && mSaveKeyringParcel.changePrimaryUserId.equals(userId)); + boolean revoke = (mSaveKeyringParcel.revokeUserIds.contains(userId)); + if (changeUserId) { + isPrimary = !isPrimary; + } + if (revoke) { + if (!isRevoked) { + isRevoked = true; + } + } + + if (changeUserId || revoke) { + vHasChanges.setVisibility(View.VISIBLE); + } else { + vHasChanges.setVisibility(View.GONE); + } + } else { + vHasChanges.setVisibility(View.GONE); + } + + if (isRevoked) { // set revocation icon (can this even be primary?) vVerified.setImageResource(R.drawable.key_certify_revoke); @@ -213,6 +239,11 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC return result; } + public String getUserId(int position) { + mCursor.moveToPosition(position); + return mCursor.getString(mIndexUserId); + } + @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = mInflater.inflate(R.layout.view_key_userids_item, null); @@ -224,7 +255,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // Disable selection of items for lists without checkboxes, http://stackoverflow.com/a/4075045 @Override public boolean areAllItemsEnabled() { - if (mCheckStates == null) { + if (mCheckStates == null && mSaveKeyringParcel == null) { return false; } else { return super.areAllItemsEnabled(); @@ -234,7 +265,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // Disable selection of items for lists without checkboxes, http://stackoverflow.com/a/4075045 @Override public boolean isEnabled(int position) { - if (mCheckStates == null) { + if (mCheckStates == null && mSaveKeyringParcel == null) { return false; } else { return super.isEnabled(position); 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 new file mode 100644 index 000000000..db7c38e71 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AddUserIdDialogFragment.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * 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 . + */ + +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 org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.util.Log; + +public class AddUserIdDialogFragment extends DialogFragment { + private static final String ARG_MESSENGER = "messenger"; + + public static final int MESSAGE_OK = 1; + + private Messenger mMessenger; + + /** + * 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 builder = new CustomAlertDialogBuilder(getActivity()); +// CharSequence[] array = {"change to primary user id", "revoke"}; +// +// builder.setTitle("select action!"); +// builder.setItems(array, new DialogInterface.OnClickListener() { +// +// @Override +// public void onClick(DialogInterface dialog, int which) { +// switch (which) { +// case 0: +// sendMessageToHandler(MESSAGE_CHANGE_PRIMARY_USER_ID, null); +// break; +// case 1: +// sendMessageToHandler(MESSAGE_REVOKE, null); +// break; +// default: +// break; +// } +// } +// }); +// builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { +// @Override +// public void onClick(DialogInterface dialog, int id) { +// dismiss(); +// } +// }); + + return builder.show(); + } + + /** + * 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/EditUserIdDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java new file mode 100644 index 000000000..f0ca73f0d --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/EditUserIdDialogFragment.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * 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 . + */ + +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 org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.util.Log; + +public class EditUserIdDialogFragment extends DialogFragment { + private static final String ARG_MESSENGER = "messenger"; + + public static final int MESSAGE_CHANGE_PRIMARY_USER_ID = 1; + public static final int MESSAGE_REVOKE = 2; + + private Messenger mMessenger; + + /** + * Creates new instance of this dialog fragment + */ + public static EditUserIdDialogFragment newInstance(Messenger messenger) { + EditUserIdDialogFragment frag = new EditUserIdDialogFragment(); + 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 builder = new CustomAlertDialogBuilder(getActivity()); + CharSequence[] array = {"change to primary user id", "revoke"}; + + builder.setTitle("select action!"); + builder.setItems(array, new DialogInterface.OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + switch (which) { + case 0: + sendMessageToHandler(MESSAGE_CHANGE_PRIMARY_USER_ID, null); + break; + case 1: + sendMessageToHandler(MESSAGE_REVOKE, null); + break; + default: + break; + } + } + }); + builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dismiss(); + } + }); + + return builder.show(); + } + + /** + * 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/res/layout/edit_key_fragment.xml b/OpenKeychain/src/main/res/layout/edit_key_fragment.xml index 9d63ea38a..f652269e5 100644 --- a/OpenKeychain/src/main/res/layout/edit_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/edit_key_fragment.xml @@ -13,7 +13,6 @@ style="@style/SectionHeader" android:layout_width="wrap_content" android:layout_height="0dp" - android:layout_marginBottom="4dp" android:layout_marginTop="8dp" android:text="Passphrase" android:layout_weight="1" /> @@ -37,7 +36,6 @@ style="@style/SectionHeader" android:layout_width="wrap_content" android:layout_height="0dp" - android:layout_marginBottom="4dp" android:layout_marginTop="8dp" android:text="@string/section_user_ids" android:layout_weight="1" /> @@ -45,9 +43,12 @@ + android:layout_height="wrap_content" /> + + + android:layout_height="wrap_content" /> + + - + + From 514a4c668b0e9afcfcb45832bba05799be621b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Jun 2014 18:26:17 +0200 Subject: [PATCH 4/8] new edit key: change passphrase --- .../keychain/ui/EditKeyFragment.java | 170 +++++++++++------- 1 file changed, 107 insertions(+), 63 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index dac19a0c3..ac4390eac 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -47,6 +47,7 @@ import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; public class EditKeyFragment extends LoaderFragment implements @@ -135,69 +136,6 @@ public class EditKeyFragment extends LoaderFragment implements loadData(dataUri); } - private void editUserId(final String userId) { - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - switch (message.what) { - case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID: - // toggle - if (mSaveKeyringParcel.changePrimaryUserId != null - && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) { - mSaveKeyringParcel.changePrimaryUserId = null; - } else { - mSaveKeyringParcel.changePrimaryUserId = userId; - } - break; - case EditUserIdDialogFragment.MESSAGE_REVOKE: - // toggle - if (mSaveKeyringParcel.revokeUserIds.contains(userId)) { - mSaveKeyringParcel.revokeUserIds.remove(userId); - } else { - mSaveKeyringParcel.revokeUserIds.add(userId); - } - break; - } - getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); - } - }; - - // Create a new Messenger for the communication back - final Messenger messenger = new Messenger(returnHandler); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - EditUserIdDialogFragment dialogFragment = - EditUserIdDialogFragment.newInstance(messenger); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog"); - } - }); - } - - private void addUserId() { - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == AddUserIdDialogFragment.MESSAGE_OK) { - - } -// getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this); - } - }; - - // Create a new Messenger for the communication back - final Messenger messenger = new Messenger(returnHandler); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - AddUserIdDialogFragment dialogFragment = - AddUserIdDialogFragment.newInstance(messenger); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); - } - }); - } private void loadData(Uri dataUri) { mDataUri = dataUri; @@ -217,6 +155,13 @@ public class EditKeyFragment extends LoaderFragment implements getActivity().finish(); } + mChangePassphrase.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changePassphrase(); + } + }); + mAddUserId.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -296,6 +241,105 @@ public class EditKeyFragment extends LoaderFragment implements } } + private void changePassphrase() { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) { + Bundle data = message.getData(); + + // set new returned passphrase! + String newPassphrase = data + .getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE); + +// updatePassphraseButtonText(); +// somethingChanged(); + mSaveKeyringParcel.newPassphrase = newPassphrase; + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + // set title based on isPassphraseSet() +// int title; +// if (isPassphraseSet()) { +// title = R.string.title_change_passphrase; +// } else { +// title = R.string.title_set_passphrase; +// } + + SetPassphraseDialogFragment setPassphraseDialog = SetPassphraseDialogFragment.newInstance( + messenger, R.string.title_change_passphrase); + + setPassphraseDialog.show(getActivity().getSupportFragmentManager(), "setPassphraseDialog"); + } + + private void editUserId(final String userId) { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + switch (message.what) { + case EditUserIdDialogFragment.MESSAGE_CHANGE_PRIMARY_USER_ID: + // toggle + if (mSaveKeyringParcel.changePrimaryUserId != null + && mSaveKeyringParcel.changePrimaryUserId.equals(userId)) { + mSaveKeyringParcel.changePrimaryUserId = null; + } else { + mSaveKeyringParcel.changePrimaryUserId = userId; + } + break; + case EditUserIdDialogFragment.MESSAGE_REVOKE: + // toggle + if (mSaveKeyringParcel.revokeUserIds.contains(userId)) { + mSaveKeyringParcel.revokeUserIds.remove(userId); + } else { + mSaveKeyringParcel.revokeUserIds.add(userId); + } + break; + } + getLoaderManager().getLoader(LOADER_ID_USER_IDS).forceLoad(); + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + EditUserIdDialogFragment dialogFragment = + EditUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog"); + } + }); + } + + private void addUserId() { + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == AddUserIdDialogFragment.MESSAGE_OK) { + + } + } + }; + + // Create a new Messenger for the communication back + final Messenger messenger = new Messenger(returnHandler); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + AddUserIdDialogFragment dialogFragment = + AddUserIdDialogFragment.newInstance(messenger); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "addUserIdDialog"); + } + }); + } + private void save() { getActivity().finish(); // TODO From b48f727f985f10ecc10507f8971df36d848e4f55 Mon Sep 17 00:00:00 2001 From: Tim Bray Date: Sun, 22 Jun 2014 22:37:05 -0700 Subject: [PATCH 5/8] Handle empty keybase.io query, should fix #675 --- .../keychain/keyimport/KeybaseKeyserver.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java index 29ab06264..0ca6f07fd 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/KeybaseKeyserver.java @@ -42,6 +42,9 @@ public class KeybaseKeyserver extends Keyserver { // cut off "0x" if a user is searching for a key id query = query.substring(2); } + if (query.isEmpty()) { + throw new QueryTooShortException(); + } mQuery = query; try { From e8b96d1035aebf9ac7cb642868705736735849b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Jun 2014 13:44:25 +0200 Subject: [PATCH 6/8] Disable pre-dexing, causes exceptions on some systems --- OpenKeychain/build.gradle | 6 +++++- build.gradle | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index ff6f603f4..c18c4865c 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -29,7 +29,6 @@ dependencies { testCompile 'com.squareup:fest-android:1.0.8' testCompile 'com.google.android:android:4.1.1.4' // compile dependencies are automatically also included in testCompile - } android { @@ -79,6 +78,11 @@ android { htmlReport true htmlOutput file("lint-report.html") } + + // Disable preDexing, causes com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000) on some systems + dexOptions { + preDexLibraries = false + } } // NOTE: This disables Lint! diff --git a/build.gradle b/build.gradle index e0da6b52f..fa6c7278e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { dependencies { // NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information classpath 'com.android.tools.build:gradle:0.11.1' - classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0' + classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0' } } From bfd7c03b0a363d9652432abd7a26782e52152ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Jun 2014 18:38:26 +0200 Subject: [PATCH 7/8] remove margin in import keys (leftover from nav drawer) --- OpenKeychain/src/main/res/layout/import_keys_activity.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/OpenKeychain/src/main/res/layout/import_keys_activity.xml b/OpenKeychain/src/main/res/layout/import_keys_activity.xml index fc9d21e23..b076debfe 100644 --- a/OpenKeychain/src/main/res/layout/import_keys_activity.xml +++ b/OpenKeychain/src/main/res/layout/import_keys_activity.xml @@ -1,7 +1,5 @@ From f68cf2a435f493968591cd948fe6e5400b7da435 Mon Sep 17 00:00:00 2001 From: Daniel Albert Date: Mon, 23 Jun 2014 19:10:50 +0200 Subject: [PATCH 8/8] Fixed Issue #683 which caused OK to crash upon importing keys which contain percent signs. --- .../sufficientlysecure/keychain/keyimport/HkpKeyserver.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java index 2ec9e1c07..df1a7e937 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/HkpKeyserver.java @@ -316,6 +316,12 @@ public class HkpKeyserver extends Keyserver { while (uidMatcher.find()) { String tmp = uidMatcher.group(1).trim(); if (tmp.contains("%")) { + if(tmp.contains("%%")) { + // This is a fix for issue #683 + // The server encodes a percent sign as %%, so it is swapped out with its + // urlencoded counterpart to prevent errors + tmp = tmp.replace("%%", "%25"); + } try { // converts Strings like "Universit%C3%A4t" to a proper encoding form "Universität". tmp = (URLDecoder.decode(tmp, "UTF8"));