From 5af4f6b63f366d0ece4fcab5c513036e163b1432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 5 Apr 2014 22:55:32 +0200 Subject: [PATCH 1/5] Fix nfc, make edit activity like a modal dialog, move all menu actions into view activity --- .../keychain/provider/ProviderHelper.java | 17 ++- .../keychain/ui/EditKeyActivity.java | 101 +++++------------- .../keychain/ui/ViewKeyActivity.java | 30 ++++-- .../keychain/ui/ViewKeyActivityJB.java | 20 ++-- .../keychain/ui/ViewKeyMainFragment.java | 12 --- .../res/layout/view_key_main_fragment.xml | 3 +- .../src/main/res/menu/key_edit.xml | 24 ----- 7 files changed, 66 insertions(+), 141 deletions(-) delete mode 100644 OpenPGP-Keychain/src/main/res/menu/key_edit.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 581ddb378..3d1d663c7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -23,10 +23,7 @@ import android.content.ContentValues; import android.content.Context; import android.content.OperationApplicationException; import android.database.Cursor; -import android.database.CursorWindow; -import android.database.CursorWrapper; import android.database.DatabaseUtils; -import android.database.sqlite.SQLiteCursor; import android.net.Uri; import android.os.RemoteException; @@ -42,8 +39,8 @@ import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.remote.AccountSettings; @@ -72,6 +69,7 @@ public class ProviderHelper { public static Object getGenericData(Context context, Uri uri, String column, int type) { return getGenericData(context, uri, new String[] { column }, new int[] { type }).get(column); } + public static HashMap getGenericData(Context context, Uri uri, String[] proj, int[] types) { Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null); @@ -100,11 +98,13 @@ public class ProviderHelper { public static Object getUnifiedData(Context context, long masterKeyId, String column, int type) { return getUnifiedData(context, masterKeyId, new String[] { column }, new int[] { type }).get(column); } + public static HashMap getUnifiedData(Context context, long masterKeyId, String[] proj, int[] types) { return getGenericData(context, KeyRings.buildUnifiedKeyRingUri(Long.toString(masterKeyId)), proj, types); } - /** Find the master key id related to a given query. The id will either be extracted from the + /** + * Find the master key id related to a given query. The id will either be extracted from the * query, which should work for all specific /key_rings/ queries, or will be queried if it can't. */ public static long getMasterKeyId(Context context, Uri queryUri) { @@ -333,12 +333,6 @@ public class ProviderHelper { return ContentProviderOperation.newInsert(uri).withValues(values).build(); } - public static boolean hasSecretKeyByMasterKeyId(Context context, long masterKeyId) { - Uri queryUri = KeyRingData.buildSecretKeyRingUri(Long.toString(masterKeyId)); - // see if we can get our master key id back from the uri - return getMasterKeyId(context, queryUri) == masterKeyId; - } - public static ArrayList getKeyRingsAsArmoredString(Context context, long[] masterKeyIds) { ArrayList output = new ArrayList(); @@ -398,6 +392,7 @@ public class ProviderHelper { return null; } } + private static Cursor getCursorWithSelectedKeyringMasterKeyIds(Context context, long[] masterKeyIds) { Cursor cursor = null; if (masterKeyIds != null && masterKeyIds.length > 0) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 60bababd1..6e6a7e47a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -31,8 +31,6 @@ import android.os.Messenger; import android.support.v4.app.ActivityCompat; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -47,22 +45,20 @@ import com.devspark.appmsg.AppMsg; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; -import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.widget.Editor; @@ -142,9 +138,24 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mExportHelper = new ExportHelper(this); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setIcon(android.R.color.transparent); - getSupportActionBar().setHomeButtonEnabled(true); + // Inflate a "Done"/"Cancel" custom action bar view + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.btn_save, R.drawable.ic_action_save, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Save + saveClicked(); + } + }, R.string.menu_key_edit_cancel, R.drawable.ic_action_cancel, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Cancel + cancelClicked(); + } + } + ); mUserIds = new Vector(); mKeys = new Vector(); @@ -281,62 +292,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.key_edit, menu); - //totally get rid of some actions for new keys - if (mDataUri == null) { - MenuItem mButton = menu.findItem(R.id.menu_key_edit_export_file); - mButton.setVisible(false); - mButton = menu.findItem(R.id.menu_key_edit_delete); - mButton.setVisible(false); - } - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - cancelClicked(); - // TODO: why isn't this triggered on my tablet - one of many ui problems - // I've had with this device. A code compatibility issue or a Samsung fail? - return true; - case R.id.menu_key_edit_cancel: - cancelClicked(); - return true; - case R.id.menu_key_edit_export_file: - if (needsSaving()) { - Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); - } else { - long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); - mExportHelper.showExportKeysDialog( - new long[] { masterKeyId }, Constants.Path.APP_DIR_FILE_SEC, true); - return true; - } - return true; - case R.id.menu_key_edit_delete: - Uri convertUri = KeyRingData.buildSecretKeyRingUri(mDataUri); - // Message is received after key is deleted - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { - setResult(RESULT_CANCELED); - finish(); - } - }}; - mExportHelper.deleteKey(convertUri, returnHandler); - return true; - - case R.id.menu_key_edit_save: - saveClicked(); - return true; - } - return super.onOptionsItemSelected(item); - } - @SuppressWarnings("unchecked") private void finallyEdit(final long masterKeyId) { if (masterKeyId != 0) { @@ -525,16 +480,16 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } if (passphrase == null) { PassphraseDialogFragment.show(this, masterKeyId, - new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - mCurrentPassphrase = PassphraseCacheService.getCachedPassphrase( - EditKeyActivity.this, masterKeyId); - checkEmptyIDsWanted(); + new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + mCurrentPassphrase = PassphraseCacheService.getCachedPassphrase( + EditKeyActivity.this, masterKeyId); + checkEmptyIDsWanted(); + } } - } - }); + }); } else { mCurrentPassphrase = passphrase; checkEmptyIDsWanted(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 7b9ba4b2d..7f4e97937 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -31,6 +31,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.widget.Toast; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -44,6 +45,7 @@ import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment; import java.util.ArrayList; +import java.util.HashMap; public class ViewKeyActivity extends ActionBarActivity { @@ -119,12 +121,7 @@ public class ViewKeyActivity extends ActionBarActivity { uploadToKeyserver(mDataUri); return true; case R.id.menu_key_view_export_file: - long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); - mExportHelper.showExportKeysDialog( - new long[] { masterKeyId } , Constants.Path.APP_DIR_FILE_PUB, - // TODO this doesn't work? - ((ViewKeyMainFragment) mTabsAdapter.getItem(0)).isSecretAvailable() - ); + exportToFile(mDataUri); return true; case R.id.menu_key_view_share_default_fingerprint: shareKey(mDataUri, true); @@ -152,6 +149,21 @@ public class ViewKeyActivity extends ActionBarActivity { return super.onOptionsItemSelected(item); } + private void exportToFile(Uri dataUri) { + Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri); + + HashMap data = ProviderHelper.getGenericData(this, + baseUri, + new String[]{KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.KeyRings.HAS_SECRET}, + new int[]{ProviderHelper.FIELD_TYPE_INTEGER, ProviderHelper.FIELD_TYPE_INTEGER}); + + mExportHelper.showExportKeysDialog( + new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)}, + Constants.Path.APP_DIR_FILE_PUB, + ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) == 1) + ); + } + private void uploadToKeyserver(Uri dataUri) { Intent uploadIntent = new Intent(this, UploadKeyActivity.class); uploadIntent.setData(dataUri); @@ -177,7 +189,7 @@ public class ViewKeyActivity extends ActionBarActivity { byte[] data = (byte[]) ProviderHelper.getGenericData( this, KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - if(data != null) { + if (data != null) { String fingerprint = PgpKeyHelper.convertFingerprintToHex(data); content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; } else { @@ -189,7 +201,7 @@ public class ViewKeyActivity extends ActionBarActivity { // get public keyring as ascii armored string long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri); ArrayList keyringArmored = ProviderHelper.getKeyRingsAsArmoredString( - this, new long[]{ masterKeyId }); + this, new long[]{masterKeyId}); content = keyringArmored.get(0); @@ -220,7 +232,7 @@ public class ViewKeyActivity extends ActionBarActivity { // get public keyring as ascii armored string long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri); ArrayList keyringArmored = ProviderHelper.getKeyRingsAsArmoredString( - this, new long[]{ masterKeyId }); + this, new long[]{masterKeyId}); ClipboardReflection.copyToClipboard(this, keyringArmored.get(0)); Toast.makeText(getApplicationContext(), R.string.key_copied_to_clipboard, Toast.LENGTH_LONG) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java index 6ce7d9aa8..6dc0413bb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivityJB.java @@ -1,6 +1,5 @@ /* * Copyright (C) 2013-2014 Dominik Schürmann - * Copyright (C) 2013 Bahtiar 'kalkin' Gadimov * * 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 @@ -19,7 +18,6 @@ package org.sufficientlysecure.keychain.ui; import android.annotation.TargetApi; -import android.net.Uri; import android.nfc.NdefMessage; import android.nfc.NdefRecord; import android.nfc.NfcAdapter; @@ -31,6 +29,9 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.widget.Toast; + +import com.devspark.appmsg.AppMsg; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -42,7 +43,6 @@ import java.io.IOException; public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMessageCallback, OnNdefPushCompleteCallback { - // NFC private NfcAdapter mNfcAdapter; private byte[] mSharedKeyringBytes; private static final int NFC_SENT = 1; @@ -50,6 +50,8 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + initNfc(); } /** @@ -81,17 +83,15 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess * guarantee that this activity starts when receiving a beamed message. For now, this code * uses the tag dispatch system. */ - // get public keyring as byte array - long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); try { - mSharedKeyringBytes = ProviderHelper.getPGPPublicKeyRing(this, masterKeyId).getEncoded(); + // get public keyring as byte array + mSharedKeyringBytes = ProviderHelper.getPGPKeyRing(this, mDataUri).getEncoded(); NdefMessage msg = new NdefMessage(NdefRecord.createMime(Constants.NFC_MIME, mSharedKeyringBytes), NdefRecord.createApplicationRecord(Constants.PACKAGE_NAME)); return msg; } catch(IOException e) { - // not much trouble, but leave a note - Log.e(Constants.TAG, "Error parsing keyring: ", e); + Log.e(Constants.TAG, "Error parsing keyring", e); return null; } } @@ -114,8 +114,8 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess public void handleMessage(Message msg) { switch (msg.what) { case NFC_SENT: - Toast.makeText(getApplicationContext(), R.string.nfc_successfull, Toast.LENGTH_LONG) - .show(); + AppMsg.makeText(ViewKeyActivityJB.this, R.string.nfc_successfull, + AppMsg.STYLE_INFO).show(); break; } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 830c5fcae..010124862 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -81,9 +81,6 @@ public class ViewKeyMainFragment extends Fragment implements private Uri mDataUri; - // for activity - private boolean mSecretAvailable = false; - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.view_key_main_fragment, container, false); @@ -231,8 +228,6 @@ public class ViewKeyMainFragment extends Fragment implements mComment.setText(mainUserId[2]); if (data.getInt(INDEX_UNIFIED_HAS_SECRET) != 0) { - mSecretAvailable = true; - mSecretKey.setTextColor(getResources().getColor(R.color.emphasis)); mSecretKey.setText(R.string.secret_key_yes); @@ -247,8 +242,6 @@ public class ViewKeyMainFragment extends Fragment implements } }); } else { - mSecretAvailable = false; - mSecretKey.setTextColor(Color.BLACK); mSecretKey.setText(getResources().getString(R.string.secret_key_no)); @@ -337,11 +330,6 @@ public class ViewKeyMainFragment extends Fragment implements } } - /** Returns true if the key current displayed is known to have a secret key. */ - public boolean isSecretAvailable() { - return mSecretAvailable; - } - private void encryptToContact(Uri dataUri) { // TODO preselect from uri? should be feasible without trivial query long keyId = ProviderHelper.getMasterKeyId(getActivity(), dataUri); diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml index aa48252ce..e3448c39f 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml @@ -192,8 +192,7 @@ + android:layout_height="wrap_content" /> diff --git a/OpenPGP-Keychain/src/main/res/menu/key_edit.xml b/OpenPGP-Keychain/src/main/res/menu/key_edit.xml deleted file mode 100644 index f9f7f8f0a..000000000 --- a/OpenPGP-Keychain/src/main/res/menu/key_edit.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 8ce837dbe4d8a2e1e69d581a7c877719558209e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 5 Apr 2014 23:07:49 +0200 Subject: [PATCH 2/5] Rework menu items --- .../main/res/drawable-hdpi/ic_action_cloud.png | Bin 0 -> 450 bytes .../main/res/drawable-mdpi/ic_action_cloud.png | Bin 0 -> 335 bytes .../main/res/drawable-xhdpi/ic_action_cloud.png | Bin 0 -> 538 bytes .../main/res/drawable-xxhdpi/ic_action_cloud.png | Bin 0 -> 760 bytes OpenPGP-Keychain/src/main/res/menu/key_list.xml | 4 +--- .../src/main/res/menu/key_list_multi.xml | 3 +++ OpenPGP-Keychain/src/main/res/menu/key_view.xml | 13 +++++++++---- OpenPGP-Keychain/src/main/res/values/strings.xml | 4 +--- 8 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_cloud.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_cloud.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_cloud.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_cloud.png diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_cloud.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..3daa641317f3c138f855636663f3fa6fa037a7ad GIT binary patch literal 450 zcmV;z0X_bSP)QGiz=FB_;47>pw6EDzrC~Ib>NSV7PQo3|y=3L2@P!uV~jemyoNmo{WoStJ} z+qY3f2qAZuwfuJ?DwoG{zN&Py}_DsmqKdv-wl4NLP+0yaKBY+ zrE!u%NQZnxgbsIz+mZV>h&8^uM4B}&QfO&uJ#H|&rL`1NsdF0rEV9Q3(rK^z@|C7| z8JR~%hwB4kJ_8UhJI=;ob&$=LLTamf^-$s*5pwudQzc2PF`Yh;_4Xtuy((9X4JtG=(s}DqyzD@`vuYvKC!LhTs+LI{kNhVF@i1F8 ss{X`WyHNk1a)J;-2qA}1B}lL?P7vv7Vr1)Cl4W3K7S?Pue~xYSH|e`F z3|nr9dss3Wick7bs1WDc={%!jiw&d4&jpcuOw$}Cm)`e+r zjxKGG?0@getv$xvxwnB(S+5(D3EG<^Ij1xo3h@#SS-HdQpa#%? e4QdPu2N>cmT9-}pyyXJ)JcFmJpUXO@geCx|<9SN} literal 0 HcmV?d00001 diff --git a/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_cloud.png b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..0769899fdbad6ee962f025d9b90c6afb6968c9b6 GIT binary patch literal 538 zcmV+#0_FXQP);&u(exK%nV`%!*k>?%a+`&*WF$B{E|0amiBh< zbMMz01cVSm2qAkubPPM6<8rI(WT}4T8-^@qw`dX9VmI0~nQqJo*P6#1{5JCtcgb+f= cf$}TB08H;|XHn#;nE(I)07*qoM6N<$f_nq&Qvd(} literal 0 HcmV?d00001 diff --git a/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_cloud.png b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_cloud.png new file mode 100644 index 0000000000000000000000000000000000000000..f97084dbe5414f08e68aa9e9a37dd92c67ca71f0 GIT binary patch literal 760 zcmV~Kzeo}mB%prqXBK=PIwL;DJR3$G z1%ECN(?D;xu_UZW!2bnb&-z*5x78$kh;b(Dv>g2727>Qw<9;9G4A^Zk_%}hy8al){ z&+~OvRo5{k;8}~unpu6{q&HTkK6C<%?;c;4t8!3#fCS*Yg#@Sz3GS86INj)vA1QNn z<1VeQSS6bPtM|`Z`kP7{CtEIer6q5j+#Von^XnSTR_(pOj~?3 zJfeN^)cTa95|FvLOs!u@s}G3G%=#7*(4lu$O~us*Sk*!wqXB%oup6JX8Anh@SLYMtx> z3u6CA*+~NQ_79dKxAwWEB}5f;=`#fr;I#^Pe;-g))z3W7zsb{=Zu?t7Vy8EBeeN^? z_mc2J#{PhUf8qNk!S9TdretdEd8(HxwDMcn{^xp^fIEq}xf%8_k--0OfB#XC{s#a6 q0000000000000000O+IN0t^6qG@}XQX{WpZ0000 - - + android:title="@string/menu_export_all_keys" /> diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml b/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml index 50f83026c..087521177 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml @@ -5,14 +5,17 @@ android:id="@+id/menu_key_list_multi_export" android:icon="@drawable/ic_action_import_export" android:title="@string/menu_export_key" /> + + + + @@ -64,13 +65,17 @@ android:title="@string/menu_export_key_to_server" /> + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index cd280d7b7..a57063441 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -78,8 +78,6 @@ Import from QR Code Import Import from NFC - Export all public keys - Export all secret keys Export to file Delete key Create key @@ -104,7 +102,7 @@ Encrypt to… Select all Add keys - Export keys + Export all keys Sign From 49bf040dae15b9d52245fe2313ff610ddc8448c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 5 Apr 2014 23:23:36 +0200 Subject: [PATCH 3/5] Use PgpKeyHelper.splitUserId in EncryptAsymmetricFragment --- .../ui/EncryptAsymmetricFragment.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 6e84211cc..8400cf397 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -190,21 +190,20 @@ public class EncryptAsymmetricFragment extends Fragment { mMainUserId.setText(""); mMainUserIdRest.setText(""); } else { - String uid = getResources().getString(R.string.user_id_no_name); - String uidExtra = ""; // See if we can get a user_id from a unified query - String user_id = (String) ProviderHelper.getUnifiedData( + String userIdResult = (String) ProviderHelper.getUnifiedData( getActivity(), mSecretKeyId, KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING); - if(user_id != null) { - String chunks[] = user_id.split(" <", 2); - uid = chunks[0]; - if (chunks.length > 1) { - uidExtra = "<" + chunks[1]; - } + String[] userId = PgpKeyHelper.splitUserId(userIdResult); + if (userId[0] != null) { + mMainUserId.setText(userId[0]); + } else { + mMainUserId.setText(getResources().getString(R.string.user_id_no_name)); + } + if (userId[1] != null) { + mMainUserIdRest.setText(userId[1]); + } else { + mMainUserIdRest.setText(""); } - - mMainUserId.setText(uid); - mMainUserIdRest.setText(uidExtra); mSign.setChecked(true); } } From d0c6971273f76ce0766f90ea9fb6dacbeb5dd3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 5 Apr 2014 23:40:11 +0200 Subject: [PATCH 4/5] Remove import activity from drawer, make it reachable from key list only --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 7 +++-- .../keychain/Constants.java | 5 +-- .../keychain/ui/DrawerActivity.java | 3 +- .../keychain/ui/ImportKeysActivity.java | 8 ++--- .../keychain/ui/KeyListActivity.java | 9 ++++-- .../keychain/ui/KeyListFragment.java | 2 +- .../keychain/ui/ViewKeyActivity.java | 2 +- .../src/main/res/menu/key_list.xml | 31 +++++++------------ 8 files changed, 32 insertions(+), 35 deletions(-) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index e588817e7..835d708b5 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -98,12 +98,12 @@ android:name=".ui.SelectPublicKeyActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_select_recipients" - android:launchMode="singleTop"> + android:launchMode="singleTop" /> + android:launchMode="singleTop" /> + navigationAdapter = ArrayAdapter.createFromResource(context, @@ -128,7 +129,6 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa handleActions(savedInstanceState, getIntent()); } - protected void handleActions(Bundle savedInstanceState, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 1bc6d4ee1..8db643583 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -53,7 +53,7 @@ public class KeyListActivity extends DrawerActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_key_list_import: - callIntentForDrawerItem(Constants.DrawerItems.IMPORT_KEYS); + importKeys(); return true; case R.id.menu_key_list_create: @@ -65,7 +65,7 @@ public class KeyListActivity extends DrawerActivity { return true; case R.id.menu_key_list_export: - mExportHelper.showExportKeysDialog(null, Constants.Path.APP_DIR_FILE_PUB, true); + mExportHelper.showExportKeysDialog(null, Constants.Path.APP_DIR_FILE, true); return true; default: @@ -73,6 +73,11 @@ public class KeyListActivity extends DrawerActivity { } } + private void importKeys() { + Intent intent = new Intent(this, ImportKeysActivity.class); + startActivityForResult(intent, 0); + } + private void createKey() { Intent intent = new Intent(this, EditKeyActivity.class); intent.setAction(EditKeyActivity.ACTION_CREATE_KEY); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 1d8f7c8ad..425f5f036 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -193,7 +193,7 @@ public class KeyListFragment extends Fragment ids = mAdapter.getCurrentSelectedMasterKeyIds(); ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); mExportHelper.showExportKeysDialog( - ids, Constants.Path.APP_DIR_FILE_PUB, mAdapter.isAnySecretSelected()); + ids, Constants.Path.APP_DIR_FILE, mAdapter.isAnySecretSelected()); break; } case R.id.menu_key_list_multi_select_all: { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 7f4e97937..cce34139c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -159,7 +159,7 @@ public class ViewKeyActivity extends ActionBarActivity { mExportHelper.showExportKeysDialog( new long[]{(Long) data.get(KeychainContract.KeyRings.MASTER_KEY_ID)}, - Constants.Path.APP_DIR_FILE_PUB, + Constants.Path.APP_DIR_FILE, ((Long) data.get(KeychainContract.KeyRings.HAS_SECRET) == 1) ); } diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list.xml b/OpenPGP-Keychain/src/main/res/menu/key_list.xml index 9f285388b..3f80b616d 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_list.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_list.xml @@ -10,27 +10,10 @@ app:showAsAction="collapseActionView|ifRoom" /> - - - - - - - - + android:title="@string/menu_add_keys" /> + + + + From 22a6bfb98580f541010681712d126d0cc8dd2834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 5 Apr 2014 23:43:07 +0200 Subject: [PATCH 5/5] Use AppMsg in edit key --- .../keychain/ui/EditKeyActivity.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 6e6a7e47a..689da04c0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -38,7 +38,6 @@ import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.LinearLayout; -import android.widget.Toast; import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; @@ -306,7 +305,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } else { Log.e(Constants.TAG, "Keyring not found with masterKeyId: " + masterKeyId); - Toast.makeText(this, R.string.error_no_secret_key_found, Toast.LENGTH_LONG).show(); + AppMsg.makeText(this, R.string.error_no_secret_key_found, AppMsg.STYLE_ALERT).show(); // TODO } if (masterKey != null) { @@ -495,8 +494,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener checkEmptyIDsWanted(); } } catch (PgpGeneralException e) { - Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - Toast.LENGTH_SHORT).show(); + AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()), + AppMsg.STYLE_ALERT).show(); } } else { AppMsg.makeText(this, R.string.error_change_something_first, AppMsg.STYLE_ALERT).show(); @@ -541,8 +540,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } catch (PgpGeneralException e) { Log.e(Constants.TAG, getString(R.string.error_message, e.getMessage())); - Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - Toast.LENGTH_SHORT).show(); + AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()), AppMsg.STYLE_ALERT).show(); } finallySaveClicked(); } @@ -618,8 +616,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener startService(intent); } catch (PgpGeneralException e) { Log.e(Constants.TAG, getString(R.string.error_message, e.getMessage())); - Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - Toast.LENGTH_SHORT).show(); + AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()), + AppMsg.STYLE_ALERT).show(); } }