aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-04 23:16:51 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-04 23:16:51 +0200
commitbad8aeea781bad8db11d8d2df9cfc7ca579f6adc (patch)
tree5b2fe6b54e6fdc7f6b7d9b2ed772414ba2fcf83e /OpenKeychain/src
parent0ffa1b94ded0bb89c0f1b0f3ed48562646bde3fc (diff)
downloadopen-keychain-bad8aeea781bad8db11d8d2df9cfc7ca579f6adc.tar.gz
open-keychain-bad8aeea781bad8db11d8d2df9cfc7ca579f6adc.tar.bz2
open-keychain-bad8aeea781bad8db11d8d2df9cfc7ca579f6adc.zip
implement preliminary MultiCertifyActivity (most heavy lifting is done)
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/AndroidManifest.xml4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyActivity.java40
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyFragment.java398
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/MultiUserIdsAdapter.java161
-rw-r--r--OpenKeychain/src/main/res/layout/certify_key_item.xml71
-rw-r--r--OpenKeychain/src/main/res/layout/multi_certify_key_activity.xml22
-rw-r--r--OpenKeychain/src/main/res/layout/multi_certify_key_fragment.xml102
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml2
10 files changed, 822 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml
index 68153af34..959e1cf08 100644
--- a/OpenKeychain/src/main/AndroidManifest.xml
+++ b/OpenKeychain/src/main/AndroidManifest.xml
@@ -424,6 +424,10 @@
android:value=".ui.ViewKeyActivity" />
</activity>
<activity
+ android:name=".ui.MultiCertifyKeyActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
+ android:label="@string/title_certify_key" />
+ <activity
android:name=".ui.ImportKeysActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_import_keys"
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
index 33f51cbf9..6127002bb 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
@@ -89,7 +89,6 @@ public class KeychainContract {
.parse("content://" + CONTENT_AUTHORITY);
public static final String BASE_KEY_RINGS = "key_rings";
- public static final String BASE_DATA = "data";
public static final String PATH_UNIFIED = "unified";
@@ -243,6 +242,10 @@ public class KeychainContract {
public static final String CONTENT_ITEM_TYPE
= "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.provider.user_ids";
+ public static Uri buildUserIdsUri() {
+ return CONTENT_URI.buildUpon().appendPath(PATH_USER_IDS).build();
+ }
+
public static Uri buildUserIdsUri(long masterKeyId) {
return CONTENT_URI.buildUpon().appendPath(Long.toString(masterKeyId)).appendPath(PATH_USER_IDS).build();
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
index 80f4610a4..d40287690 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
@@ -51,6 +51,7 @@ public class KeychainProvider extends ContentProvider {
private static final int KEY_RINGS_UNIFIED = 101;
private static final int KEY_RINGS_PUBLIC = 102;
private static final int KEY_RINGS_SECRET = 103;
+ private static final int KEY_RINGS_USER_IDS = 104;
private static final int KEY_RING_UNIFIED = 200;
private static final int KEY_RING_KEYS = 201;
@@ -85,17 +86,22 @@ public class KeychainProvider extends ContentProvider {
* <pre>
* key_rings/unified
* key_rings/public
+ * key_rings/secret
+ * key_rings/user_ids
* </pre>
*/
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS
- + "/" + KeychainContract.PATH_UNIFIED,
+ + "/" + KeychainContract.PATH_UNIFIED,
KEY_RINGS_UNIFIED);
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS
- + "/" + KeychainContract.PATH_PUBLIC,
+ + "/" + KeychainContract.PATH_PUBLIC,
KEY_RINGS_PUBLIC);
matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS
- + "/" + KeychainContract.PATH_SECRET,
+ + "/" + KeychainContract.PATH_SECRET,
KEY_RINGS_SECRET);
+ matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS
+ + "/" + KeychainContract.PATH_USER_IDS,
+ KEY_RINGS_USER_IDS);
/**
* find by criteria other than master key id
@@ -450,6 +456,7 @@ public class KeychainProvider extends ContentProvider {
break;
}
+ case KEY_RINGS_USER_IDS:
case KEY_RING_USER_IDS: {
HashMap<String, String> projectionMap = new HashMap<String, String>();
projectionMap.put(UserIds._ID, Tables.USER_IDS + ".oid AS _id");
@@ -470,13 +477,18 @@ public class KeychainProvider extends ContentProvider {
+ Tables.CERTS + "." + Certs.RANK
+ " AND " + Tables.CERTS + "." + Certs.VERIFIED + " > 0"
+ ")");
- groupBy = Tables.USER_IDS + "." + UserIds.RANK;
+ groupBy = Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID
+ + ", " + Tables.USER_IDS + "." + UserIds.RANK;
- qb.appendWhere(Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " = ");
- qb.appendWhereEscapeString(uri.getPathSegments().get(1));
+ // If we are searching for a particular keyring's ids, add where
+ if (match == KEY_RING_USER_IDS) {
+ qb.appendWhere(Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " = ");
+ qb.appendWhereEscapeString(uri.getPathSegments().get(1));
+ }
if (TextUtils.isEmpty(sortOrder)) {
- sortOrder = Tables.USER_IDS + "." + UserIds.RANK + " ASC";
+ sortOrder = Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " ASC"
+ + "," + Tables.USER_IDS + "." + UserIds.RANK + " ASC";
}
break;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyActivity.java
new file mode 100644
index 000000000..6b882f7ce
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyActivity.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ * Copyright (C) 2011 Senecaso
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sufficientlysecure.keychain.ui;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+
+import org.sufficientlysecure.keychain.R;
+
+/**
+ * Signs the specified public key with the specified secret master key
+ */
+public class MultiCertifyKeyActivity extends ActionBarActivity {
+
+ public static final String EXTRA_KEY_IDS = "extra_key_ids";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.multi_certify_key_activity);
+ }
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyFragment.java
new file mode 100644
index 000000000..03cd6c431
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MultiCertifyKeyFragment.java
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * 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;
+
+import android.app.Activity;
+import android.app.ProgressDialog;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.graphics.PorterDuff;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.Parcel;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.app.NavUtils;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.ScrollView;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.pgp.KeyRing;
+import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
+import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
+import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
+import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
+import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
+import org.sufficientlysecure.keychain.service.KeychainIntentService;
+import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
+import org.sufficientlysecure.keychain.service.PassphraseCacheService;
+import org.sufficientlysecure.keychain.service.results.CertifyResult;
+import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
+import org.sufficientlysecure.keychain.service.results.SingletonResult;
+import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter;
+import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
+import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
+import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
+import org.sufficientlysecure.keychain.ui.util.Notify;
+import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
+import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
+import org.sufficientlysecure.keychain.util.Log;
+import org.sufficientlysecure.keychain.util.Preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class MultiCertifyKeyFragment extends LoaderFragment
+ implements LoaderManager.LoaderCallbacks<Cursor> {
+
+ private FragmentActivity mActivity;
+
+ private CheckBox mUploadKeyCheckbox;
+ private ScrollView mScrollView;
+ ListView mUserIds;
+
+ private CertifyKeySpinner mCertifyKeySpinner;
+
+ private long[] mPubMasterKeyIds;
+
+ private long mSignMasterKeyId = Constants.key.none;
+
+ public static final String[] USER_IDS_PROJECTION = new String[]{
+ UserIds._ID,
+ UserIds.MASTER_KEY_ID,
+ UserIds.USER_ID,
+ UserIds.IS_PRIMARY,
+ UserIds.IS_REVOKED
+ };
+ private static final int INDEX_MASTER_KEY_ID = 1;
+ private static final int INDEX_USER_ID = 2;
+ private static final int INDEX_IS_PRIMARY = 3;
+ private static final int INDEX_IS_REVOKED = 4;
+
+ private MultiUserIdsAdapter mUserIdsAdapter;
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // Start out with a progress indicator.
+ setContentShown(false);
+
+ mPubMasterKeyIds = mActivity.getIntent().getLongArrayExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS);
+ if (mPubMasterKeyIds == null) {
+ Log.e(Constants.TAG, "List of key ids to certify missing!");
+ mActivity.finish();
+ return;
+ }
+
+ mUserIdsAdapter = new MultiUserIdsAdapter(mActivity, null, 0);
+ mUserIds.setAdapter(mUserIdsAdapter);
+
+ getLoaderManager().initLoader(0, null, this);
+
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
+ View root = super.onCreateView(inflater, superContainer, savedInstanceState);
+
+ // is this "the android way"?
+ mActivity = getActivity();
+
+ View view = inflater.inflate(R.layout.multi_certify_key_fragment, getContainer());
+
+ mCertifyKeySpinner = (CertifyKeySpinner) view.findViewById(R.id.certify_key_spinner);
+ mUploadKeyCheckbox = (CheckBox) view.findViewById(R.id.sign_key_upload_checkbox);
+ mScrollView = (ScrollView) view.findViewById(R.id.certify_scroll_view);
+ mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
+
+ // make certify image gray, like action icons
+ ImageView vActionCertifyImage =
+ (ImageView) view.findViewById(R.id.certify_key_action_certify_image);
+ vActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
+ PorterDuff.Mode.SRC_IN);
+
+ mCertifyKeySpinner.setOnKeyChangedListener(new KeySpinner.OnKeyChangedListener() {
+ @Override
+ public void onKeyChanged(long masterKeyId) {
+ mSignMasterKeyId = masterKeyId;
+ }
+ });
+
+ View vCertifyButton = view.findViewById(R.id.certify_key_certify_button);
+ vCertifyButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (mSignMasterKeyId == Constants.key.none) {
+ Notify.showNotify(mActivity, getString(R.string.select_key_to_certify),
+ Notify.Style.ERROR);
+ scrollUp();
+ } else {
+ initiateCertifying();
+ }
+ }
+ });
+
+ return root;
+ }
+
+ private void scrollUp() {
+ mScrollView.post(new Runnable() {
+ public void run() {
+ mScrollView.fullScroll(ScrollView.FOCUS_UP);
+ }
+ });
+ }
+
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ Uri uri = UserIds.buildUserIdsUri();
+
+ String selection, ids[];
+ {
+ // generate placeholders and string selection args
+ ids = new String[mPubMasterKeyIds.length];
+ StringBuilder placeholders = new StringBuilder("?");
+ for (int i = 0; i < mPubMasterKeyIds.length; i++) {
+ ids[i] = Long.toString(mPubMasterKeyIds[i]);
+ if (i != 0) {
+ placeholders.append(",?");
+ }
+ }
+ // put together selection string
+ selection = UserIds.IS_REVOKED + " = 0" + " AND "
+ + Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID
+ + " IN (" + placeholders + ")";
+ }
+
+ return new CursorLoader(mActivity, uri,
+ USER_IDS_PROJECTION, selection, ids,
+ Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " ASC"
+ + "," + Tables.USER_IDS + "." + UserIds.USER_ID + " ASC");
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+
+ MatrixCursor matrix = new MatrixCursor(new String[] {
+ "_id", "user_data", "grouped"
+ });
+ data.moveToFirst();
+
+ long lastMasterKeyId = 0;
+ String lastName = "";
+ ArrayList<String> uids = new ArrayList<String>();
+
+ boolean header = true;
+
+ // Iterate over all rows
+ while (!data.isAfterLast()) {
+ long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
+ String userId = data.getString(INDEX_USER_ID);
+ String[] pieces = KeyRing.splitUserId(userId);
+
+ // Two cases:
+
+ boolean grouped = masterKeyId == lastMasterKeyId;
+ boolean subGrouped = data.isFirst() || grouped && lastName.equals(pieces[0]);
+ // Remember for next loop
+ lastName = pieces[0];
+
+ Log.d(Constants.TAG, Long.toString(masterKeyId, 16) + (grouped ? "grouped" : "not grouped"));
+
+ if (!subGrouped) {
+ // 1. This name should NOT be grouped with the previous, so we flush the buffer
+
+ /*/ Special case: only a single user id (first && last)
+ if (data.isFirst()) {
+ lastMasterKeyId = masterKeyId;
+ uids.add(userId);
+ }*/
+
+ Parcel p = Parcel.obtain();
+ p.writeStringList(uids);
+ byte[] d = p.marshall();
+ p.recycle();
+
+ matrix.addRow(new Object[] {
+ lastMasterKeyId, d, header ? 1 : 0
+ });
+ // indicate that we have a header for this masterKeyId
+ header = false;
+
+ // Now clear the buffer, and add the new user id, for the next round
+ uids.clear();
+
+ }
+
+ // 2. This name should be grouped with the previous, just add to buffer
+ uids.add(userId);
+ lastMasterKeyId = masterKeyId;
+
+ // If this one wasn't grouped, the next one's gotta be a header
+ if (!grouped) {
+ header = true;
+ }
+
+ // Regardless of the outcome, move to next entry
+ data.moveToNext();
+
+ }
+
+ // If there is anything left in the buffer, flush it one last time
+ if (!uids.isEmpty()) {
+
+ Parcel p = Parcel.obtain();
+ p.writeStringList(uids);
+ byte[] d = p.marshall();
+ p.recycle();
+
+ matrix.addRow(new Object[]{
+ lastMasterKeyId, d, header ? 1 : 0
+ });
+
+ }
+
+ mUserIdsAdapter.swapCursor(matrix);
+ setContentShown(true, isResumed());
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {
+ mUserIdsAdapter.swapCursor(null);
+ }
+
+ /**
+ * handles the UI bits of the signing process on the UI thread
+ */
+ private void initiateCertifying() {
+ // get the user's passphrase for this key (if required)
+ String passphrase;
+ try {
+ passphrase = PassphraseCacheService.getCachedPassphrase(mActivity, mSignMasterKeyId, mSignMasterKeyId);
+ } catch (PassphraseCacheService.KeyNotFoundException e) {
+ Log.e(Constants.TAG, "Key not found!", e);
+ mActivity.finish();
+ return;
+ }
+ if (passphrase == null) {
+ PassphraseDialogFragment.show(mActivity, mSignMasterKeyId,
+ new Handler() {
+ @Override
+ public void handleMessage(Message message) {
+ if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
+ startCertifying();
+ }
+ }
+ }
+ );
+ // bail out; need to wait until the user has entered the passphrase before trying again
+ } else {
+ startCertifying();
+ }
+ }
+
+ /**
+ * kicks off the actual signing process on a background thread
+ */
+ private void startCertifying() {
+ // Bail out if there is not at least one user id selected
+ ArrayList<String> userIds = mUserIdsAdapter.getSelectedUserIds();
+ if (userIds.isEmpty()) {
+ Notify.showNotify(mActivity, "No identities selected!",
+ Notify.Style.ERROR);
+ return;
+ }
+
+ // Send all information needed to service to sign key in other thread
+ Intent intent = new Intent(mActivity, KeychainIntentService.class);
+
+ intent.setAction(KeychainIntentService.ACTION_CERTIFY_KEYRING);
+
+ // fill values for this action
+ CertifyActionsParcel parcel = new CertifyActionsParcel(mSignMasterKeyId);
+
+ for (long keyId : mPubMasterKeyIds) {
+ parcel.add(new CertifyAction(keyId, null));
+ }
+
+ Bundle data = new Bundle();
+ data.putParcelable(KeychainIntentService.CERTIFY_PARCEL, parcel);
+ intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
+
+ // Message is received after signing is done in KeychainIntentService
+ KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity,
+ getString(R.string.progress_certifying), ProgressDialog.STYLE_SPINNER, true) {
+ public void handleMessage(Message message) {
+ // handle messages by standard KeychainIntentServiceHandler first
+ super.handleMessage(message);
+
+ if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
+
+ Bundle data = message.getData();
+ CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
+
+ Intent intent = new Intent();
+ intent.putExtra(CertifyResult.EXTRA_RESULT, result);
+ mActivity.setResult(CertifyKeyActivity.RESULT_OK, intent);
+
+ // check if we need to send the key to the server or not
+ if (mUploadKeyCheckbox.isChecked()) {
+ // upload the newly signed key to the keyserver
+ // TODO implement
+ // uploadKey();
+ } else {
+ mActivity.finish();
+ }
+ }
+ }
+ };
+
+ // Create a new Messenger for the communication back
+ Messenger messenger = new Messenger(saveHandler);
+ intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
+
+ // show progress dialog
+ saveHandler.showProgressDialog(mActivity);
+
+ // start service with intent
+ mActivity.startService(intent);
+ }
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/MultiUserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/MultiUserIdsAdapter.java
new file mode 100644
index 000000000..2e1752dce
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/MultiUserIdsAdapter.java
@@ -0,0 +1,161 @@
+/*
+ * 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.adapter;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.os.Parcel;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.support.v4.widget.CursorAdapter;
+import android.widget.TextView;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.pgp.KeyRing;
+import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
+import org.sufficientlysecure.keychain.util.Log;
+
+import java.util.ArrayList;
+
+public class MultiUserIdsAdapter extends CursorAdapter {
+ private LayoutInflater mInflater;
+ private final ArrayList<Boolean> mCheckStates;
+
+ public MultiUserIdsAdapter(Context context, Cursor c, int flags) {
+ super(context, c, flags);
+ mInflater = LayoutInflater.from(context);
+ mCheckStates = new ArrayList<Boolean>();
+ }
+
+ @Override
+ public Cursor swapCursor(Cursor newCursor) {
+ mCheckStates.clear();
+ if (newCursor != null) {
+ int count = newCursor.getCount();
+ mCheckStates.ensureCapacity(count);
+ // initialize to true (use case knowledge: we usually want to sign all uids)
+ for (int i = 0; i < count; i++) {
+ mCheckStates.add(true);
+ }
+ }
+
+ return super.swapCursor(newCursor);
+ }
+
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ return mInflater.inflate(R.layout.certify_key_item, null);
+ }
+
+ @Override
+ public void bindView(View view, Context context, Cursor cursor) {
+ View vHeader = view.findViewById(R.id.user_id_header);
+ TextView vHeaderId = (TextView) view.findViewById(R.id.user_id_header_id);
+ TextView vName = (TextView) view.findViewById(R.id.user_id_item_name);
+ TextView vAddresses = (TextView) view.findViewById(R.id.user_id_item_addresses);
+
+ byte[] data = cursor.getBlob(1);
+ int isHeader = cursor.getInt(2);
+ Parcel p = Parcel.obtain();
+ p.unmarshall(data, 0, data.length);
+ p.setDataPosition(0);
+ ArrayList<String> uids = p.createStringArrayList();
+ p.recycle();
+
+ if (isHeader == 1) {
+ long masterKeyId = cursor.getLong(0);
+ vHeader.setVisibility(View.VISIBLE);
+ vHeaderId.setText(KeyFormattingUtils.beautifyKeyId(masterKeyId));
+ } else {
+ vHeader.setVisibility(View.GONE);
+ }
+
+ { // first one
+ String userId = uids.get(0);
+ String[] splitUserId = KeyRing.splitUserId(userId);
+ if (splitUserId[0] != null) {
+ vName.setText(splitUserId[0]);
+ } else {
+ vName.setText(R.string.user_id_no_name);
+ }
+ }
+
+ StringBuilder lines = new StringBuilder();
+ for (String uid : uids) {
+ String[] splitUserId = KeyRing.splitUserId(uid);
+ if (splitUserId[1] == null) {
+ continue;
+ }
+ lines.append(splitUserId[1]);
+ if (splitUserId[2] != null) {
+ lines.append(" (").append(splitUserId[2]).append(")");
+ }
+ lines.append('\n');
+ }
+
+ // If we have any data here, show it
+ if (lines.length() > 0) {
+ // delete last newline
+ lines.setLength(lines.length() - 1);
+ vAddresses.setVisibility(View.VISIBLE);
+ vAddresses.setText(lines);
+ } else {
+ vAddresses.setVisibility(View.GONE);
+ }
+
+ final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.user_id_item_check_box);
+ final int position = cursor.getPosition();
+ vCheckBox.setOnCheckedChangeListener(null);
+ vCheckBox.setChecked(mCheckStates.get(position));
+ vCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ mCheckStates.set(position, b);
+ }
+ });
+ vCheckBox.setClickable(false);
+
+ View vUidBody = view.findViewById(R.id.user_id_body);
+ vUidBody.setClickable(true);
+ vUidBody.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ vCheckBox.toggle();
+ }
+ });
+
+ }
+
+ public ArrayList<String> getSelectedUserIds() {
+ ArrayList<String> result = new ArrayList<String>();
+ for (int i = 0; i < mCheckStates.size(); i++) {
+ if (mCheckStates.get(i)) {
+ mCursor.moveToPosition(i);
+ result.add(mCursor.getString(0));
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/OpenKeychain/src/main/res/layout/certify_key_item.xml b/OpenKeychain/src/main/res/layout/certify_key_item.xml
new file mode 100644
index 000000000..297e0944b
--- /dev/null
+++ b/OpenKeychain/src/main/res/layout/certify_key_item.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="vertical"
+ android:singleLine="true">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/user_id_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:singleLine="true"
+ android:clickable="true">
+
+ <TextView
+ android:id="@+id/user_id_header_id"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="0123 4567 890a bcde"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ </LinearLayout>
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/user_id_body"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:orientation="horizontal"
+ android:singleLine="true"
+ android:layout_marginLeft="15dip">
+
+ <CheckBox
+ android:id="@+id/user_id_item_check_box"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:clickable="false"
+ android:focusable="false" />
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_gravity="center_vertical"
+ android:layout_width="0dip"
+ android:layout_marginLeft="8dp"
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="4dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <TextView
+ android:id="@+id/user_id_item_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="alice@example.com"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/user_id_item_addresses"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="alice@example.com\na-lyc@example.com"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:layout_marginLeft="20dip"
+ />
+
+ </LinearLayout>
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/OpenKeychain/src/main/res/layout/multi_certify_key_activity.xml b/OpenKeychain/src/main/res/layout/multi_certify_key_activity.xml
new file mode 100644
index 000000000..c3eaed9a8
--- /dev/null
+++ b/OpenKeychain/src/main/res/layout/multi_certify_key_activity.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <include layout="@layout/notify_area" />
+
+ <FrameLayout
+ android:id="@+id/content_frame"
+ android:layout_marginLeft="@dimen/drawer_content_padding"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <fragment
+ android:id="@+id/multi_certify_key_fragment"
+ android:name="org.sufficientlysecure.keychain.ui.MultiCertifyKeyFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+ </FrameLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/multi_certify_key_fragment.xml b/OpenKeychain/src/main/res/layout/multi_certify_key_fragment.xml
new file mode 100644
index 000000000..c55be78fb
--- /dev/null
+++ b/OpenKeychain/src/main/res/layout/multi_certify_key_fragment.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ScrollView
+ android:id="@+id/certify_scroll_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp"
+ android:orientation="vertical">
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_certification_key" />
+
+ <org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner
+ android:id="@+id/certify_key_spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_uids_to_certify" />
+
+ <org.sufficientlysecure.keychain.ui.widget.FixedListView
+ android:id="@+id/view_key_user_ids"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_upload_key" />
+
+ <CheckBox
+ android:id="@+id/sign_key_upload_checkbox"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="4dp"
+ android:layout_marginTop="4dp"
+ android:checked="false"
+ android:text="@string/label_send_key" />
+
+ <TextView
+ style="@style/SectionHeader"
+ android:layout_width="wrap_content"
+ android:layout_height="0dp"
+ android:layout_marginTop="14dp"
+ android:text="@string/section_actions"
+ android:layout_weight="1" />
+
+ <LinearLayout
+ android:id="@+id/certify_key_certify_button"
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:clickable="true"
+ android:paddingRight="4dp"
+ android:layout_marginBottom="8dp"
+ style="@style/SelectableItem"
+ android:orientation="horizontal">
+
+ <TextView
+ android:paddingLeft="8dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_width="0dip"
+ android:layout_height="match_parent"
+ android:text="@string/key_view_action_certify"
+ android:layout_weight="1"
+ android:gravity="center_vertical" />
+
+ <ImageView
+ android:id="@+id/certify_key_action_certify_image"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:padding="8dp"
+ android:src="@drawable/status_signature_verified_cutout"
+ android:layout_gravity="center_vertical" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+</LinearLayout>
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 93a6d0da1..438f976e3 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -134,7 +134,7 @@
<string name="label_name">"Name"</string>
<string name="label_comment">"Comment"</string>
<string name="label_email">"Email"</string>
- <string name="label_send_key">"Upload key to selected keyserver after certification"</string>
+ <string name="label_send_key">"Synchronize key with public keyservers"</string>
<string name="label_fingerprint">"Fingerprint"</string>
<string name="expiry_date_dialog_title">"Set expiry date"</string>
<string name="label_first_keyserver_is_used">"(First keyserver listed is preferred)"</string>