From b90e680ff91ae12e9ae31682b1ab118d6c49ab7e Mon Sep 17 00:00:00 2001 From: Bhargav Golla Date: Mon, 10 Mar 2014 14:59:15 -0400 Subject: Lint changes after testing --- .../keychain/ui/dialog/ProgressDialogFragment.java | 1 - .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 2 ++ OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml | 11 ++--------- .../src/main/res/layout/edit_key_user_id_item.xml | 3 ++- OpenPGP-Keychain/src/main/res/layout/key_server_editor.xml | 2 +- .../src/main/res/layout/key_server_preference.xml | 2 +- OpenPGP-Keychain/src/main/res/menu/key_list_secret.xml | 2 +- OpenPGP-Keychain/src/main/res/menu/key_view.xml | 2 +- OpenPGP-Keychain/src/main/res/values-de/strings.xml | 2 +- OpenPGP-Keychain/src/main/res/values/strings.xml | 6 +++--- 10 files changed, 14 insertions(+), 19 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java index 6c62d14e0..d63d866fd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java @@ -120,7 +120,6 @@ public class ProgressDialogFragment extends DialogFragment { int messageId = getArguments().getInt(ARG_MESSAGE_ID); int style = getArguments().getInt(ARG_STYLE); boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE); - dialog.setMessage(getString(messageId)); dialog.setProgressStyle(style); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 65461cb4f..9f25fac42 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -30,6 +30,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.util.Choice; +import android.annotation.TargetApi; import android.app.DatePickerDialog; import android.app.Dialog; import android.content.Context; @@ -110,6 +111,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { setExpiryDate(null); mExpiryDateButton.setOnClickListener(new OnClickListener() { + @TargetApi(11) public void onClick(View v) { GregorianCalendar date = mExpiryDate; if (date == null) { diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml index c56ba130e..a974f6ec0 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml @@ -5,16 +5,11 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + android:fillViewport="true" + android:orientation="vertical"> - diff --git a/OpenPGP-Keychain/src/main/res/layout/edit_key_user_id_item.xml b/OpenPGP-Keychain/src/main/res/layout/edit_key_user_id_item.xml index 663949d8e..437e5ebaf 100644 --- a/OpenPGP-Keychain/src/main/res/layout/edit_key_user_id_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/edit_key_user_id_item.xml @@ -71,7 +71,8 @@ android:id="@+id/comment" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" /> + android:layout_weight="1" + android:inputType="text"/> diff --git a/OpenPGP-Keychain/src/main/res/layout/key_server_editor.xml b/OpenPGP-Keychain/src/main/res/layout/key_server_editor.xml index 058a43eaf..950978a0e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_server_editor.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_server_editor.xml @@ -13,7 +13,7 @@ diff --git a/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml b/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml index 4a09e4240..eddbe3cbf 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml @@ -14,7 +14,7 @@ android:orientation="horizontal" > Für diese Benutzer-IDs wurden keine öffentlichen Schlüssel gefunden: Für diese Benutzer-IDs existieren mehrere öffentliche Schlüssel: Bitte die Liste der Empfänger überprüfen! - Signaturüberprüfung fehlgeschlagen! Haben Sie diese App von einer anderen Quelle installiert? Wenn Sie eine Attacke ausschliessen können, sollten Sie die Registrierung der App in OpenKeychain widerrufen und die App erneut registrieren. + Signaturüberprüfung fehlgeschlagen! Haben Sie diese App von einer anderen Quelle installiert? Wenn Sie eine Attacke ausschließen können, sollten Sie die Registrierung der App in OpenKeychain widerrufen und die App erneut registrieren. Über QR Code teilen Mit \'Weiter\' durch alle QR-Codes gehen und diese nacheinander scannen. diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 3267115a2..5e2478bf5 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -310,8 +310,8 @@ - done. - cancel + Done. + Cancel saving… importing… exporting… @@ -326,7 +326,7 @@ exporting key… exporting keys… - + generating keys, this can take up to 3 minutes… generating key, this can take up to 3 minutes… generating keys, this can take up to 3 minutes… -- cgit v1.2.3 From b4022b9a24dca7914d1a008700373b773343dd47 Mon Sep 17 00:00:00 2001 From: Bhargav Golla Date: Mon, 10 Mar 2014 23:19:10 -0400 Subject: Removing unused string --- OpenPGP-Keychain/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 82dd05f1a..cd248c749 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -328,7 +328,7 @@ exporting key… exporting keys… - generating keys, this can take up to 3 minutes… + generating key, this can take up to 3 minutes… generating keys, this can take up to 3 minutes… -- cgit v1.2.3 From 15d94c51bb362898464baae0d99279b754ac9450 Mon Sep 17 00:00:00 2001 From: Bhargav Golla Date: Mon, 10 Mar 2014 23:20:30 -0400 Subject: Removing tab --- OpenPGP-Keychain/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index cd248c749..07f402802 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -328,7 +328,7 @@ exporting key… exporting keys… - + generating key, this can take up to 3 minutes… generating keys, this can take up to 3 minutes… -- cgit v1.2.3 From e909b6bb9d582dd2fec767410d039a0cf3189635 Mon Sep 17 00:00:00 2001 From: uberspot Date: Wed, 12 Mar 2014 18:48:17 +0200 Subject: change colorizing of fingerprint to use SHA1 based on apg's commit 67ffc24526 --- .../keychain/helper/OtherHelper.java | 22 ++++++++++ .../keychain/ui/ViewKeyMainFragment.java | 50 ++++++++++++++++------ 2 files changed, 60 insertions(+), 12 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java index 34d90a17f..292b5bf3d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java @@ -17,6 +17,9 @@ package org.sufficientlysecure.keychain.helper; +import java.security.DigestException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Set; @@ -58,4 +61,23 @@ public class OtherHelper { } } + /** + * Converts the given bytes to a unique RGB color using SHA1 algorithm + * @param bytes + * @return an integer array containing 3 numeric color representations (Red, Green, Black) + * @throws NoSuchAlgorithmException + * @throws DigestException + */ + public static int[] getRgbForData(byte[] bytes) throws NoSuchAlgorithmException, DigestException { + MessageDigest md = MessageDigest.getInstance("SHA1"); + + md.update(bytes); + byte[] digest = md.digest(); + + int[] result = {((int) digest[0] + 256) % 256, + ((int) digest[1] + 256) % 256, + ((int) digest[2] + 256) % 256}; + return result; + } + } 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 adb06a068..d223a259f 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 @@ -29,6 +29,7 @@ import android.support.v4.content.Loader; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.format.DateFormat; +import android.text.style.BackgroundColorSpan; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.View; @@ -40,6 +41,7 @@ import com.beardedhen.androidbootstrap.BootstrapButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -47,6 +49,8 @@ import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; import org.sufficientlysecure.keychain.util.Log; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.Date; @@ -276,18 +280,40 @@ public class ViewKeyMainFragment extends Fragment implements private SpannableStringBuilder colorizeFingerprint(String fingerprint) { SpannableStringBuilder sb = new SpannableStringBuilder(fingerprint); - ForegroundColorSpan fcs = new ForegroundColorSpan(Color.BLACK); - - // for each 4 characters of the fingerprint + 1 space - for (int i = 0; i < fingerprint.length(); i += 5) { - int minFingLength = Math.min(i + 4, fingerprint.length()); - String fourChars = fingerprint.substring(i, minFingLength); - - // Create a foreground color by converting the 4 fingerprint chars to an int hashcode - // and then converting that int to hex to use as a color - fcs = new ForegroundColorSpan( - Color.parseColor(String.format("#%06X", (0xFFFFFF & fourChars.hashCode())))); - sb.setSpan(fcs, i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + try { + // for each 4 characters of the fingerprint + 1 space + for (int i = 0; i < fingerprint.length(); i += 5) { + int minFingLength = Math.min(i + 4, fingerprint.length()); + String fourChars = fingerprint.substring(i, minFingLength); + + int raw = Integer.parseInt(fourChars, 16); + byte[] bytes = {(byte) ((raw >> 8) & 0xff - 128), (byte) (raw & 0xff - 128)}; + int[] color = OtherHelper.getRgbForData(bytes); + + // Convert rgb to brightness + int brightness = (int) (0.2126*color[0] + 0.7152*color[1] + 0.0722*color[2]); + + // Detect dark colors and invert their background to white to make them more distinguishable + if (brightness < 40) { + sb.setSpan(new BackgroundColorSpan(Color.WHITE), + i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + + // Detect bright colors and invert their background to black to make them more distinguishable + } else if (brightness > 210) { + sb.setSpan(new BackgroundColorSpan(Color.BLACK), + i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + } + + // Create a foreground color with the 3 digest integers as RGB + // and then converting that int to hex to use as a color + sb.setSpan(new ForegroundColorSpan(Color.rgb(color[0], color[1], color[2])), + i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + } + } catch (Exception e) { + Log.e(Constants.TAG, "Colorization failed", e); + // if anything goes wrong, then just display the fingerprint without colour, + // instead of partially correct colour or wrong colours + return new SpannableStringBuilder(fingerprint); } return sb; -- cgit v1.2.3 From 0b0809ec17203ea14068b064360e45e435796829 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 13 Mar 2014 00:16:11 +0100 Subject: keychainprovider cleanup, kindasorta removed code redundancy, and the query is in the switch thing now, I didn't put everything into its own separate sources (yet?). --- .../keychain/provider/KeychainProvider.java | 96 +++++++++------------- .../keychain/ui/KeyListFragment.java | 7 +- 2 files changed, 47 insertions(+), 56 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 8b0efdbbd..3782f85fd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -467,70 +467,53 @@ public class KeychainProvider extends ContentProvider { int match = mUriMatcher.match(uri); - // screw that switch - if(match == UNIFIED_KEY_RING) { + // all query() parameters, for good measure + String groupBy = null, having = null; - // join keyrings with keys and userIds - // Only get user id and key with rank 0 (main user id and main key) - qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "(" - + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "." - + KeysColumns.KEY_RING_ROW_ID + " AND " + Tables.KEYS + "." - + KeysColumns.RANK + " = '0') " + " INNER JOIN " + Tables.USER_IDS + " ON " - + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." - + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "." - + UserIdsColumns.RANK + " = '0')"); - - { - HashMap projectionMap = new HashMap(); - - projectionMap.put(KeyRingsColumns.TYPE, "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ")"); - - projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID); - projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "." - + KeyRingsColumns.KEY_RING_DATA); - projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID); - // TODO: deprecated master key id - //projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEYS + "." + KeysColumns.KEY_ID); - - projectionMap.put(KeysColumns.FINGERPRINT, Tables.KEYS + "." + KeysColumns.FINGERPRINT); - projectionMap.put(KeysColumns.IS_REVOKED, Tables.KEYS + "." + KeysColumns.IS_REVOKED); + switch (match) { + case UNIFIED_KEY_RING: - projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); + { // SELECT + // todo: outsource into getprojectionmapforthingies? don't really see the point. + HashMap projectionMap = new HashMap(); - qb.setProjectionMap(projectionMap); - } + // from keyrings table + projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID); + projectionMap.put(KeyRingsColumns.TYPE, + "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ")"); + projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "." + + KeyRingsColumns.KEY_RING_DATA); + projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, + Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID); - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; - } + // from keys table + projectionMap.put(KeysColumns.FINGERPRINT, Tables.KEYS + "." + KeysColumns.FINGERPRINT); + projectionMap.put(KeysColumns.IS_REVOKED, Tables.KEYS + "." + KeysColumns.IS_REVOKED); - // If no sort order is specified use the default - String orderBy; - if (TextUtils.isEmpty(sortOrder)) { - orderBy = Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " DESC"; - } else { - orderBy = Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " DESC, " + sortOrder; - } + // from user id table + projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); - Cursor c = qb.query(db, projection, selection, selectionArgs, - Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID, - null, orderBy); + qb.setProjectionMap(projectionMap); + } - // Tell the cursor what uri to watch, so it knows when its source data changes - c.setNotificationUri(getContext().getContentResolver(), uri); + { // FROM + // todo: outsource into buildUnifiedQuery()? see above. + // join keyrings with keys and userIds + // Only get user id and key with rank 0 (main user id and main key) + qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "(" + + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "." + + KeysColumns.KEY_RING_ROW_ID + " AND " + Tables.KEYS + "." + + KeysColumns.RANK + " = '0') " + " INNER JOIN " + Tables.USER_IDS + " ON " + + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." + + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "." + + UserIdsColumns.RANK + " = '0')"); + } - if (Constants.DEBUG) { - Log.d(Constants.TAG, - "Query: " - + qb.buildQuery(projection, selection, selectionArgs, Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID, null, - orderBy, null)); - Log.d(Constants.TAG, "Cursor: " + DatabaseUtils.dumpCursorToString(c)); - } + // GROUP BY + groupBy = Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID; - return c; - } + break; - switch (match) { case PUBLIC_KEY_RING: case SECRET_KEY_RING: qb = buildKeyRingQuery(qb, match); @@ -705,7 +688,7 @@ public class KeychainProvider extends ContentProvider { orderBy = sortOrder; } - Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); + Cursor c = qb.query(db, projection, selection, selectionArgs, groupBy, having, orderBy); // Tell the cursor what uri to watch, so it knows when its source data changes c.setNotificationUri(getContext().getContentResolver(), uri); @@ -855,6 +838,9 @@ public class KeychainProvider extends ContentProvider { // notify of changes in db getContext().getContentResolver().notifyChange(uri, null); + getContext().getContentResolver().notifyChange( + KeyRings.buildUnifiedKeyRingsUri().buildUpon().appendPath("lulz").build(), null + ); return count; } 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 5b57132d4..72af24717 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 @@ -31,6 +31,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; +import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -255,7 +256,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL static final int INDEX_TYPE = 1; static final int INDEX_UID = 3; - static final String SORT_ORDER = UserIds.USER_ID + " ASC"; + static final String SORT_ORDER = + // show secret before public key + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings.TYPE + " DESC, " + // sort by user id otherwise + + UserIds.USER_ID + " ASC"; @Override public Loader onCreateLoader(int id, Bundle args) { -- cgit v1.2.3 From b9a907df0b305350c4ccf4f44d1178a0267c1062 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 13 Mar 2014 00:29:28 +0100 Subject: remove special treatment for unified list query note: the unified query /will/ need special treatment once certs are joined in, so I am leaving this as an artifact commit for later reference or point to revert to. --- .../keychain/provider/KeychainProvider.java | 53 ++++++---------------- 1 file changed, 14 insertions(+), 39 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 3782f85fd..cc08b26bd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -377,6 +377,10 @@ public class KeychainProvider extends ContentProvider { projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); + // type attribute is special: if there is any grouping, choose secret over public type + projectionMap.put(KeyRingsColumns.TYPE, + "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ") AS " + KeyRingsColumns.TYPE); + return projectionMap; } @@ -411,9 +415,11 @@ public class KeychainProvider extends ContentProvider { * Builds default query for keyRings: KeyRings table is joined with UserIds and Keys */ private SQLiteQueryBuilder buildKeyRingQuery(SQLiteQueryBuilder qb, int match) { - // public or secret keyring - qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " = "); - qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); + if(match != UNIFIED_KEY_RING) { + // public or secret keyring + qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " = "); + qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); + } // join keyrings with keys and userIds // Only get user id and key with rank 0 (main user id and main key) @@ -472,46 +478,15 @@ public class KeychainProvider extends ContentProvider { switch (match) { case UNIFIED_KEY_RING: + qb = buildKeyRingQuery(qb, match); - { // SELECT - // todo: outsource into getprojectionmapforthingies? don't really see the point. - HashMap projectionMap = new HashMap(); - - // from keyrings table - projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID); - projectionMap.put(KeyRingsColumns.TYPE, - "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ")"); - projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "." - + KeyRingsColumns.KEY_RING_DATA); - projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, - Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID); - - // from keys table - projectionMap.put(KeysColumns.FINGERPRINT, Tables.KEYS + "." + KeysColumns.FINGERPRINT); - projectionMap.put(KeysColumns.IS_REVOKED, Tables.KEYS + "." + KeysColumns.IS_REVOKED); - - // from user id table - projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); - - qb.setProjectionMap(projectionMap); - } + // GROUP BY so we don't get duplicates + groupBy = Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID; - { // FROM - // todo: outsource into buildUnifiedQuery()? see above. - // join keyrings with keys and userIds - // Only get user id and key with rank 0 (main user id and main key) - qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "(" - + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "." - + KeysColumns.KEY_RING_ROW_ID + " AND " + Tables.KEYS + "." - + KeysColumns.RANK + " = '0') " + " INNER JOIN " + Tables.USER_IDS + " ON " - + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." - + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "." - + UserIdsColumns.RANK + " = '0')"); + if (TextUtils.isEmpty(sortOrder)) { + sortOrder = KeyRings.TYPE + " DESC, " + Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; } - // GROUP BY - groupBy = Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID; - break; case PUBLIC_KEY_RING: -- cgit v1.2.3 From 3f649d4458ef08c03bb671f78f2a65478c829400 Mon Sep 17 00:00:00 2001 From: grait Date: Tue, 11 Mar 2014 01:37:16 +0530 Subject: Export is cancellable now --- .../keychain/helper/ExportHelper.java | 30 +++++++++++++--------- .../keychain/pgp/PgpImportExport.java | 24 +++++++++++++++-- .../keychain/service/KeychainIntentService.java | 14 ++++++++-- 3 files changed, 52 insertions(+), 16 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 19dfccbde..245c5fda1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -16,17 +16,8 @@ package org.sufficientlysecure.keychain.helper; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; -import org.sufficientlysecure.keychain.util.Log; - import android.app.ProgressDialog; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -36,6 +27,16 @@ import android.os.Messenger; import android.support.v7.app.ActionBarActivity; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; +import org.sufficientlysecure.keychain.util.Log; + public class ExportHelper { protected FileDialogFragment mFileDialog; protected String mExportFilename; @@ -115,7 +116,7 @@ public class ExportHelper { Log.d(Constants.TAG, "exportKeys started"); // Send all information needed to service to export key in other thread - Intent intent = new Intent(activity, KeychainIntentService.class); + final Intent intent = new Intent(activity, KeychainIntentService.class); intent.setAction(KeychainIntentService.ACTION_EXPORT_KEYRING); @@ -135,7 +136,12 @@ public class ExportHelper { // Message is received after exporting is done in ApgService KeychainIntentServiceHandler exportHandler = new KeychainIntentServiceHandler(activity, - activity.getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) { + activity.getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL, true, new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + activity.stopService(intent); + } + }) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 138e54f71..0315650eb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -50,15 +50,28 @@ import android.os.Bundle; import android.os.Environment; public class PgpImportExport { + + public interface KeychainServiceListener{ + public boolean hasServiceStopped(); + } private Context mContext; private ProgressDialogUpdater mProgress; + private KeychainServiceListener mKeychainServiceListener; + public PgpImportExport(Context context, ProgressDialogUpdater progress) { super(); this.mContext = context; this.mProgress = progress; } + public PgpImportExport(Context context, ProgressDialogUpdater progress, KeychainServiceListener keychainListener){ + super(); + this.mContext = context; + this.mProgress = progress; + this.mKeychainServiceListener = keychainListener; + } + public void updateProgress(int message, int current, int total) { if (mProgress != null) { mProgress.setProgress(message, current, total); @@ -188,8 +201,10 @@ public class PgpImportExport { if (secretKeyRing != null) { secretKeyRing.encode(arOutStream); } - // Else if it's a public key get the PGPPublicKeyRing - // and encode that to the output + if(mKeychainServiceListener.hasServiceStopped()==true){ + arOutStream.close(); + return null; + } } else { updateProgress(i * 100 / rowIdsSize, 100); PGPPublicKeyRing publicKeyRing = @@ -198,6 +213,11 @@ public class PgpImportExport { if (publicKeyRing != null) { publicKeyRing.encode(arOutStream); } + + if(mKeychainServiceListener.hasServiceStopped() == true){ + arOutStream.close(); + return null; + } } arOutStream.close(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 93238349d..83531c8e2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -73,7 +73,7 @@ import android.os.RemoteException; * data from the activities or other apps, queues these intents, executes them, and stops itself * after doing them. */ -public class KeychainIntentService extends IntentService implements ProgressDialogUpdater { +public class KeychainIntentService extends IntentService implements ProgressDialogUpdater, PgpImportExport.KeychainServiceListener { /* extras that can be given by intent */ public static final String EXTRA_MESSENGER = "messenger"; @@ -712,10 +712,15 @@ public class KeychainIntentService extends IntentService implements ProgressDial Bundle resultData; - PgpImportExport pgpImportExport = new PgpImportExport(this, this); + PgpImportExport pgpImportExport = new PgpImportExport(this, this, this); + resultData = pgpImportExport .exportKeyRings(keyRingRowIds, keyType, outStream); + if(mIsCanceled){ + boolean isDeleted = new File(outputFile).delete(); + } + sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { sendErrorToHandler(e); @@ -903,4 +908,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial public void setProgress(int progress, int max) { setProgress(null, progress, max); } + + @Override + public boolean hasServiceStopped() { + return mIsCanceled; + } } -- cgit v1.2.3 From ccdf646c199b000ac12ad2ca7ecaaf90a01d79c7 Mon Sep 17 00:00:00 2001 From: grait Date: Tue, 11 Mar 2014 04:49:52 +0530 Subject: Export cancellable - minor changes --- .../java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java | 8 +++----- .../keychain/service/KeychainIntentService.java | 3 ++- .../sufficientlysecure/keychain/util/KeychainServiceListener.java | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 0315650eb..3ce9fa7c5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -42,6 +42,7 @@ import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.KeyServer.AddKeyException; +import org.sufficientlysecure.keychain.util.KeychainServiceListener; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; @@ -51,9 +52,6 @@ import android.os.Environment; public class PgpImportExport { - public interface KeychainServiceListener{ - public boolean hasServiceStopped(); - } private Context mContext; private ProgressDialogUpdater mProgress; @@ -201,7 +199,7 @@ public class PgpImportExport { if (secretKeyRing != null) { secretKeyRing.encode(arOutStream); } - if(mKeychainServiceListener.hasServiceStopped()==true){ + if(mKeychainServiceListener.hasServiceStopped()){ arOutStream.close(); return null; } @@ -214,7 +212,7 @@ public class PgpImportExport { publicKeyRing.encode(arOutStream); } - if(mKeychainServiceListener.hasServiceStopped() == true){ + if(mKeychainServiceListener.hasServiceStopped()){ arOutStream.close(); return null; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 83531c8e2..23f489d35 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -56,6 +56,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.InputData; +import org.sufficientlysecure.keychain.util.KeychainServiceListener; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; @@ -73,7 +74,7 @@ import android.os.RemoteException; * data from the activities or other apps, queues these intents, executes them, and stops itself * after doing them. */ -public class KeychainIntentService extends IntentService implements ProgressDialogUpdater, PgpImportExport.KeychainServiceListener { +public class KeychainIntentService extends IntentService implements ProgressDialogUpdater, KeychainServiceListener { /* extras that can be given by intent */ public static final String EXTRA_MESSENGER = "messenger"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java new file mode 100644 index 000000000..0d7513057 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java @@ -0,0 +1,5 @@ +package org.sufficientlysecure.keychain.util; + +public interface KeychainServiceListener { + boolean hasServiceStopped(); +} -- cgit v1.2.3 From 6af65a2a9b5f90b90bf8752820f40f89241d8014 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 13 Mar 2014 13:06:23 +0100 Subject: merge fixes as per comments in merge https://github.com/openpgp-keychain/openpgp-keychain/pull/403/files#r10540753 --- .../keychain/ui/KeyListFragment.java | 49 +++++++++------------- 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'OpenPGP-Keychain/src') 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 72af24717..ea5c60c53 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 @@ -33,6 +33,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -203,6 +204,20 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL showDeleteKeyDialog(mode, ids); break; } + case R.id.menu_key_list_multi_export: { + // todo: public/secret needs to be handled differently here + ids = mStickyList.getWrappedList().getCheckedItemIds(); + ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); + mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.path.APP_DIR_FILE_PUB); + break; + } + case R.id.menu_key_list_multi_select_all: { + // select all + for (int i = 0; i < mStickyList.getCount(); i++) { + mStickyList.setItemChecked(i, true); + } + break; + } } return true; } @@ -455,7 +470,7 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL /** * Implements StickyListHeadersAdapter from library */ - private class KeyListAdapter extends CursorAdapter implements StickyListHeadersAdapter { + private class KeyListAdapter extends HighlightQueryCursorAdapter implements StickyListHeadersAdapter { private LayoutInflater mInflater; private int mIndexUserId; private int mIndexIsRevoked; @@ -698,42 +713,16 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL * Change color for multi-selection */ // default color - v.setBackgroundColor(Color.TRANSPARENT); if (mSelection.get(position) != null) { // this is a selected position, change color! v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis)); + } else { + v.setBackgroundColor(Color.TRANSPARENT); } - return v; - } - // search highlight methods - - public void setSearchQuery(String searchQuery) { - mCurQuery = searchQuery; - } - - public String getSearchQuery() { - return mCurQuery; + return v; } - protected Spannable highlightSearchQuery(String text) { - Spannable highlight = Spannable.Factory.getInstance().newSpannable(text); - - if (mCurQuery != null) { - Pattern pattern = Pattern.compile("(?i)" + mCurQuery); - Matcher matcher = pattern.matcher(text); - if (matcher.find()) { - highlight.setSpan( - new ForegroundColorSpan(mContext.getResources().getColor(R.color.emphasis)), - matcher.start(), - matcher.end(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } - return highlight; - } else { - return highlight; - } - } } } -- cgit v1.2.3 From be3828c89ee7cd4775ba6b442adb59f1007619ca Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 13 Mar 2014 14:34:07 +0100 Subject: drop unified uri in favor of generic /key_rings this works well in the uri schema, and we get notifications back with no effort. ....also remove a line I committed accidentally oO --- .../keychain/provider/KeychainContract.java | 3 +-- .../keychain/provider/KeychainProvider.java | 22 +++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 706b30d05..d9356951e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -78,7 +78,6 @@ public class KeychainContract { public static final String PATH_PUBLIC = "public"; public static final String PATH_SECRET = "secret"; - public static final String PATH_UNIFIED = "unified"; public static final String PATH_BY_MASTER_KEY_ID = "master_key_id"; public static final String PATH_BY_KEY_ID = "key_id"; @@ -102,7 +101,7 @@ public class KeychainContract { public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.key_ring"; public static Uri buildUnifiedKeyRingsUri() { - return CONTENT_URI.buildUpon().appendPath(PATH_UNIFIED).build(); + return CONTENT_URI; } public static Uri buildPublicKeyRingsUri() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index cc08b26bd..1a131a689 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -96,6 +96,15 @@ public class KeychainProvider extends ContentProvider { String authority = KeychainContract.CONTENT_AUTHORITY; + /** + * unified key rings + * + *
+         * key_rings
+         * 
+ */ + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS, UNIFIED_KEY_RING); + /** * public key rings * @@ -228,16 +237,6 @@ public class KeychainProvider extends ContentProvider { matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_APPS_BY_PACKAGE_NAME); - /** - * unified key rings - *
-         *
-         * key_rings/unified
-         *
-         */
-        matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/"
-                + KeychainContract.PATH_UNIFIED, UNIFIED_KEY_RING);
-
         /**
          * data stream
          *
@@ -813,9 +812,6 @@ public class KeychainProvider extends ContentProvider {
 
         // notify of changes in db
         getContext().getContentResolver().notifyChange(uri, null);
-        getContext().getContentResolver().notifyChange(
-                KeyRings.buildUnifiedKeyRingsUri().buildUpon().appendPath("lulz").build(), null
-        );
 
         return count;
     }
-- 
cgit v1.2.3


From f055228e5bf9d43659238cef1652dc422d2690aa Mon Sep 17 00:00:00 2001
From: uberspot 
Date: Thu, 13 Mar 2014 16:09:37 +0200
Subject: add apg's change to colorizing, no more background changes needed

---
 .../keychain/ui/ViewKeyMainFragment.java           | 46 +++++++++++++++-------
 1 file changed, 31 insertions(+), 15 deletions(-)

(limited to 'OpenPGP-Keychain/src')

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 d223a259f..a43e3f5b5 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
@@ -283,31 +283,47 @@ public class ViewKeyMainFragment extends Fragment  implements
         try {
             // for each 4 characters of the fingerprint + 1 space
             for (int i = 0; i < fingerprint.length(); i += 5) {
-                int minFingLength = Math.min(i + 4, fingerprint.length());
-                String fourChars = fingerprint.substring(i, minFingLength);
+                int spanEnd = Math.min(i + 4, fingerprint.length());
+                String fourChars = fingerprint.substring(i, spanEnd);
 
                 int raw = Integer.parseInt(fourChars, 16);
                 byte[] bytes = {(byte) ((raw >> 8) & 0xff - 128), (byte) (raw & 0xff - 128)};
                 int[] color = OtherHelper.getRgbForData(bytes);
+                int r = color[0];
+                int g = color[1];
+                int b = color[2];
+
+                // we cannot change black by multiplication, so adjust it to an almost-black grey,
+                // which will then be brightened to the minimal brightness level
+                if (r == 0 && g == 0 && b == 0) {
+                    r = 1;
+                    g = 1;
+                    b = 1;
+                }
 
                 // Convert rgb to brightness
-                int brightness = (int) (0.2126*color[0] + 0.7152*color[1] + 0.0722*color[2]);
-
-                // Detect dark colors and invert their background to white to make them more distinguishable
-                if (brightness < 40) {
-                    sb.setSpan(new BackgroundColorSpan(Color.WHITE),
-                            i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
-
-                // Detect bright colors and invert their background to black to make them more distinguishable
-                } else if (brightness > 210) {
-                    sb.setSpan(new BackgroundColorSpan(Color.BLACK),
-                            i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+                double brightness = 0.2126 * r + 0.7152 * g + 0.0722 * b;
+
+                // If a color is too dark to be seen on black,
+                // then brighten it up to a minimal brightness.
+                if (brightness < 80) {
+                    double factor = 80.0 / brightness;
+                    r = Math.min(255, (int) (r * factor));
+                    g = Math.min(255, (int) (g * factor));
+                    b = Math.min(255, (int) (b * factor));
+
+                // If it is too light, then darken it to a respective maximal brightness.
+                } else if (brightness > 180) {
+                    double factor = 180.0 / brightness;
+                    r = (int) (r * factor);
+                    g = (int) (g * factor);
+                    b = (int) (b * factor);
                 }
 
                 // Create a foreground color with the 3 digest integers as RGB
                 // and then converting that int to hex to use as a color
-                sb.setSpan(new ForegroundColorSpan(Color.rgb(color[0], color[1], color[2])),
-                                            i, minFingLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+                sb.setSpan(new ForegroundColorSpan(Color.rgb(r, g, b)),
+                                            i, spanEnd, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
             }
         } catch (Exception e) {
             Log.e(Constants.TAG, "Colorization failed", e);
-- 
cgit v1.2.3


From f4370b3ac8378a92192d8d84496aa6ea1fb27b0c Mon Sep 17 00:00:00 2001
From: gogowitczak 
Date: Thu, 13 Mar 2014 15:39:38 +0100
Subject: Added possibility to specify port for KeyServer.

---
 .../keychain/util/HkpKeyServer.java                | 54 ++++++++++++----------
 1 file changed, 30 insertions(+), 24 deletions(-)

(limited to 'OpenPGP-Keychain/src')

diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
index 32266839c..b6ffa0ef0 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
@@ -18,24 +18,7 @@
 
 package org.sufficientlysecure.keychain.util;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.Locale;
-
+import android.text.Html;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
@@ -51,7 +34,14 @@ import org.sufficientlysecure.keychain.pgp.PgpHelper;
 import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
 import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
 
-import android.text.Html;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.*;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * TODO:
@@ -82,7 +72,7 @@ public class HkpKeyServer extends KeyServer {
     }
 
     private String mHost;
-    private short mPort = 11371;
+    private short mPort;
 
     // example:
     // pub 2048R/9F5C9090 2009-08-17 hostname" (eg. "pool.sks-keyservers.net"), then it will
+	 *                connect using {@link #PORT_DEFAULT}. However, port may be specified after colon
+	 *                ("hostname:port", eg. "p80.pool.sks-keyservers.net:80").
+	 */
+	public HkpKeyServer(String hostAndPort) {
+		String host = hostAndPort;
+		short port = PORT_DEFAULT;
+		final int colonPosition = hostAndPort.lastIndexOf(':');
+		if (colonPosition > 0) {
+			host = hostAndPort.substring(0, colonPosition);
+			final String portStr = hostAndPort.substring(colonPosition + 1);
+			port = Short.decode(portStr);
+		}
+		mHost = host;
+		mPort = port;
+	}
 
     public HkpKeyServer(String host, short port) {
         mHost = host;
@@ -226,7 +232,7 @@ public class HkpKeyServer extends KeyServer {
         HttpClient client = new DefaultHttpClient();
         try {
             HttpGet get = new HttpGet("http://" + mHost + ":" + mPort
-                    + "/pks/lookup?op=get&search=" + PgpKeyHelper.convertKeyIdToHex(keyId));
+                    + "/pks/lookup?op=get&search=0x" + PgpKeyHelper.convertKeyIdToHex(keyId));
 
             HttpResponse response = client.execute(get);
             if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-- 
cgit v1.2.3


From ccde4212e013ea5955cea26265423c84f4c74faf Mon Sep 17 00:00:00 2001
From: gogowitczak 
Date: Thu, 13 Mar 2014 15:53:43 +0100
Subject: Added possibility to specify port for KeyServer.

---
 .../main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'OpenPGP-Keychain/src')

diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
index b6ffa0ef0..99cac1152 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java
@@ -232,7 +232,7 @@ public class HkpKeyServer extends KeyServer {
         HttpClient client = new DefaultHttpClient();
         try {
             HttpGet get = new HttpGet("http://" + mHost + ":" + mPort
-                    + "/pks/lookup?op=get&search=0x" + PgpKeyHelper.convertKeyIdToHex(keyId));
+                    + "/pks/lookup?op=get&search=" + PgpKeyHelper.convertKeyIdToHex(keyId));
 
             HttpResponse response = client.execute(get);
             if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
-- 
cgit v1.2.3


From 471cefa71f3ea91b07d1c5f94c95e9b17cecb7a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= 
Date: Thu, 13 Mar 2014 18:27:08 +0100
Subject: Cleanup and simplification

---
 .../keychain/provider/KeychainProvider.java        |  2 +-
 .../keychain/ui/KeyListFragment.java               | 83 ++++++----------------
 2 files changed, 24 insertions(+), 61 deletions(-)

(limited to 'OpenPGP-Keychain/src')

diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
index 1a131a689..fdc4b7bda 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
@@ -414,7 +414,7 @@ public class KeychainProvider extends ContentProvider {
      * Builds default query for keyRings: KeyRings table is joined with UserIds and Keys
      */
     private SQLiteQueryBuilder buildKeyRingQuery(SQLiteQueryBuilder qb, int match) {
-        if(match != UNIFIED_KEY_RING) {
+        if (match != UNIFIED_KEY_RING) {
             // public or secret keyring
             qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " = ");
             qb.appendWhereEscapeString(Integer.toString(getKeyType(match)));
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 ea5c60c53..70ffe968d 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
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Dominik Schürmann 
+ * Copyright (C) 2013-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
@@ -19,8 +19,6 @@ package org.sufficientlysecure.keychain.ui;
 
 import java.util.HashMap;
 import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.sufficientlysecure.keychain.Constants;
 import org.sufficientlysecure.keychain.Id;
@@ -32,7 +30,6 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
 import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes;
 import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
 import org.sufficientlysecure.keychain.provider.KeychainDatabase;
-import org.sufficientlysecure.keychain.provider.ProviderHelper;
 import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter;
 import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
 import org.sufficientlysecure.keychain.util.Log;
@@ -57,13 +54,10 @@ import android.support.v4.app.Fragment;
 import android.support.v4.app.LoaderManager;
 import android.support.v4.content.CursorLoader;
 import android.support.v4.content.Loader;
-import android.support.v4.widget.CursorAdapter;
 import android.support.v4.view.MenuItemCompat;
 import android.support.v7.app.ActionBarActivity;
 import android.support.v7.widget.SearchView;
-import android.text.Spannable;
 import android.text.TextUtils;
-import android.text.style.ForegroundColorSpan;
 import android.view.ActionMode;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -270,10 +264,13 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
     };
 
     static final int INDEX_TYPE = 1;
-    static final int INDEX_UID = 3;
+    static final int INDEX_MASTER_KEY_ID = 2;
+    static final int INDEX_USER_ID = 3;
+    static final int INDEX_IS_REVOKED = 4;
+
     static final String SORT_ORDER =
-                // show secret before public key
-                KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings.TYPE + " DESC, "
+            // show secret before public key
+            KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings.TYPE + " DESC, "
                     // sort by user id otherwise
                     + UserIds.USER_ID + " ASC";
 
@@ -472,43 +469,20 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL
      */
     private class KeyListAdapter extends HighlightQueryCursorAdapter implements StickyListHeadersAdapter {
         private LayoutInflater mInflater;
-        private int mIndexUserId;
-        private int mIndexIsRevoked;
-        private int mMasterKeyId;
-
-        private String mCurQuery;
 
-        @SuppressLint("UseSparseArrays")
         private HashMap mSelection = new HashMap();
 
         public KeyListAdapter(Context context, Cursor c, int flags) {
             super(context, c, flags);
 
             mInflater = LayoutInflater.from(context);
-            initIndex(c);
         }
 
         @Override
         public Cursor swapCursor(Cursor newCursor) {
-            initIndex(newCursor);
-
             return super.swapCursor(newCursor);
         }
 
-        /**
-         * Get column indexes for performance reasons just once in constructor and swapCursor. For a
-         * performance comparison see http://stackoverflow.com/a/17999582
-         *
-         * @param cursor
-         */
-        private void initIndex(Cursor cursor) {
-            if (cursor != null) {
-                mIndexUserId = cursor.getColumnIndexOrThrow(KeychainContract.UserIds.USER_ID);
-                mIndexIsRevoked = cursor.getColumnIndexOrThrow(KeychainContract.Keys.IS_REVOKED);
-                mMasterKeyId = cursor.getColumnIndexOrThrow(KeychainContract.KeyRings.MASTER_KEY_ID);
-            }
-        }
-
         /**
          * Bind cursor data to the item list view
          * 

@@ -522,15 +496,15 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId); TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest); - String userId = cursor.getString(mIndexUserId); + String userId = cursor.getString(INDEX_USER_ID); String[] userIdSplit = PgpKeyHelper.splitUserId(userId); if (userIdSplit[0] != null) { - mainUserId.setText(highlightSearchQuery(userIdSplit[0])); + mainUserId.setText(highlightSearchQuery(userIdSplit[0])); } else { mainUserId.setText(R.string.user_id_no_name); } if (userIdSplit[1] != null) { - mainUserIdRest.setText(highlightSearchQuery(userIdSplit[1])); + mainUserIdRest.setText(highlightSearchQuery(userIdSplit[1])); mainUserIdRest.setVisibility(View.VISIBLE); } else { mainUserIdRest.setVisibility(View.GONE); @@ -541,12 +515,12 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL Button button = (Button) view.findViewById(R.id.edit); TextView revoked = (TextView) view.findViewById(R.id.revoked); - if(cursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + if (cursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { // this is a secret key - show the edit button revoked.setVisibility(View.GONE); button.setVisibility(View.VISIBLE); - final long id = cursor.getLong(mMasterKeyId); + final long id = cursor.getLong(INDEX_MASTER_KEY_ID); button.setOnClickListener(new OnClickListener() { public void onClick(View view) { Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); @@ -559,7 +533,7 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL // this is a public key - hide the edit button, show if it's revoked button.setVisibility(View.GONE); - boolean isRevoked = cursor.getInt(mIndexIsRevoked) > 0; + boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; revoked.setVisibility(isRevoked ? View.VISIBLE : View.GONE); } } @@ -567,23 +541,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL } public long getMasterKeyId(int id) { - if (!mCursor.moveToPosition(id)) { throw new IllegalStateException("couldn't move cursor to position " + id); } - return mCursor.getLong(mMasterKeyId); - - } - - public int getKeyType(int position) { - - if (!mCursor.moveToPosition(position)) { - throw new IllegalStateException("couldn't move cursor to position " + position); - } - - return mCursor.getInt(KeyListFragment.INDEX_TYPE); - + return mCursor.getLong(INDEX_MASTER_KEY_ID); } @Override @@ -621,7 +583,7 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL throw new IllegalStateException("couldn't move cursor to position " + position); } - if(mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { { // set contact count int num = mCursor.getCount(); String contactsTotal = getResources().getQuantityString(R.plurals.n_contacts, num, num); @@ -634,10 +596,10 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL } // set header text as first char in user id - String userId = mCursor.getString(KeyListFragment.INDEX_UID); + String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID); String headerText = convertView.getResources().getString(R.string.user_id_no_name); if (userId != null && userId.length() > 0) { - headerText = "" + mCursor.getString(KeyListFragment.INDEX_UID).subSequence(0, 1).charAt(0); + headerText = "" + mCursor.getString(KeyListFragment.INDEX_USER_ID).subSequence(0, 1).charAt(0); } holder.text.setText(headerText); holder.count.setVisibility(View.GONE); @@ -660,11 +622,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL } // early breakout: all secret keys are assigned id 0 - if(mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) + if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) return 1L; // otherwise, return the first character of the name as ID - String userId = mCursor.getString(KeyListFragment.INDEX_UID); + String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID); if (userId != null && userId.length() > 0) { return userId.charAt(0); } else { @@ -689,8 +651,9 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL long[] ids = new long[mSelection.size()]; int i = 0; // get master key ids - for (int pos : mSelection.keySet()) + for (int pos : mSelection.keySet()) { ids[i++] = mAdapter.getMasterKeyId(pos); + } return ids; } @@ -712,11 +675,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL /** * Change color for multi-selection */ - // default color if (mSelection.get(position) != null) { - // this is a selected position, change color! + // selected position color v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis)); } else { + // default color v.setBackgroundColor(Color.TRANSPARENT); } -- cgit v1.2.3 From cf51e5ff56070bbec52c70b36f4109484e84adb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 13 Mar 2014 18:53:21 +0100 Subject: XML cleanup and bigger filename EditText --- .../src/main/res/layout/decrypt_activity.xml | 317 +++++++++++---------- .../src/main/res/layout/encrypt_activity.xml | 13 +- .../src/main/res/layout/file_dialog.xml | 4 +- 3 files changed, 173 insertions(+), 161 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml index a974f6ec0..25c7c000c 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml @@ -5,201 +5,206 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + - + + + android:id="@+id/relativeLayout"> - - - - - - - - - - + android:src="@drawable/signed_large" /> - + android:src="@drawable/overlay_error" /> - + + + android:layout_gravity="left" + android:text="@string/label_main_user_id" + android:textAppearance="?android:attr/textAppearanceMedium" + android:layout_toRightOf="@+id/relativeLayout" /> - + + - + - + + + + + + + + + + + + - + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="4dp"> + android:layout_height="wrap_content" + android:orientation="horizontal"> + android:id="@+id/filename" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="top|left" + android:inputType="textMultiLine|textUri" + android:lines="4" + android:maxLines="10" + android:minLines="2" + android:scrollbars="vertical" /> + + + android:layout_height="wrap_content" + android:orientation="horizontal"> - - - - - - - - - - - + android:layout_gravity="center_vertical" + android:text="@string/label_delete_after_decryption" /> - + + - + - + - - + - + + diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml index dc4cf0063..4fe65e341 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml @@ -238,7 +238,12 @@ android:layout_width="0dip" android:layout_height="wrap_content" android:layout_weight="1" - android:inputType="textNoSuggestions" /> + android:gravity="top|left" + android:inputType="textMultiLine|textUri" + android:lines="4" + android:maxLines="10" + android:minLines="2" + android:scrollbars="vertical" /> + + fontawesometext:fa_icon="fa-chevron-right" /> + + android:textColor="@color/emphasis" /> -- cgit v1.2.3 From 4c5ae3cdaa525ca925b5e7229a7c02b89b8cefd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 13 Mar 2014 19:01:24 +0100 Subject: Readd create key menu items --- .../keychain/ui/KeyListActivity.java | 50 ++++++++++++++++------ OpenPGP-Keychain/src/main/res/menu/key_list.xml | 26 +++++++++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 3 files changed, 61 insertions(+), 16 deletions(-) (limited to 'OpenPGP-Keychain/src') 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 9eebbed64..684ee6959 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,19 +53,45 @@ public class KeyListActivity extends DrawerActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_key_list_import: - Intent intentImport = new Intent(this, ImportKeysActivity.class); - startActivityForResult(intentImport, 0); - - return true; - case R.id.menu_key_list_export: - // TODO fix this for unified keylist - mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.path.APP_DIR_FILE_PUB); - - return true; - default: - return super.onOptionsItemSelected(item); + case R.id.menu_key_list_import: + Intent intentImport = new Intent(this, ImportKeysActivity.class); + startActivityForResult(intentImport, 0); + + return true; + case R.id.menu_key_list_export: + // TODO fix this for unified keylist + mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.path.APP_DIR_FILE_PUB); + + return true; + case R.id.menu_key_list_create: + createKey(); + + return true; + case R.id.menu_key_list_create_expert: + createKeyExpert(); + + return true; + case R.id.menu_key_list_secret_export: + mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC); + + + default: + return super.onOptionsItemSelected(item); } } + private void createKey() { + Intent intent = new Intent(this, EditKeyActivity.class); + intent.setAction(EditKeyActivity.ACTION_CREATE_KEY); + intent.putExtra(EditKeyActivity.EXTRA_GENERATE_DEFAULT_KEYS, true); + intent.putExtra(EditKeyActivity.EXTRA_USER_IDS, ""); // show user id view + startActivityForResult(intent, 0); + } + + private void createKeyExpert() { + Intent intent = new Intent(this, EditKeyActivity.class); + intent.setAction(EditKeyActivity.ACTION_CREATE_KEY); + startActivityForResult(intent, 0); + } + } diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list.xml b/OpenPGP-Keychain/src/main/res/menu/key_list.xml index addef0c2d..10223522c 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_list.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_list.xml @@ -7,14 +7,32 @@ app:showAsAction="ifRoom|withText" android:icon="@drawable/ic_action_add_person" android:title="@string/menu_import" /> - + + + + + + + + + +

diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 1c7ead403..4b427917f 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -78,6 +78,7 @@ Import Import from NFC Export all keys + Export all secret keys Export to file Delete key Create key -- cgit v1.2.3 From 908cf8e7695b282760d7a790ae782346424e7ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 13 Mar 2014 19:08:03 +0100 Subject: Add FAQ tab to help --- .../sufficientlysecure/keychain/ui/HelpActivity.java | 19 +++++++++++-------- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java index ac8250bef..48068a6c4 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-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 @@ -17,8 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.ArrayList; - import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter; @@ -29,7 +27,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; public class HelpActivity extends ActionBarActivity { - public static final String EXTRA_SELECTED_TAB = "selectedTab"; + public static final String EXTRA_SELECTED_TAB = "selected_tab"; ViewPager mViewPager; TabsAdapter mTabsAdapter; @@ -59,19 +57,24 @@ public class HelpActivity extends ActionBarActivity { Bundle startBundle = new Bundle(); startBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_start); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_start)), - HelpHtmlFragment.class, startBundle, (selectedTab == 0) ); + HelpHtmlFragment.class, startBundle, (selectedTab == 0)); + + Bundle faqBundle = new Bundle(); + faqBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_faq); + mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_faq)), + HelpHtmlFragment.class, faqBundle, (selectedTab == 1)); Bundle nfcBundle = new Bundle(); nfcBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_nfc_beam); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_nfc_beam)), - HelpHtmlFragment.class, nfcBundle, (selectedTab == 1) ); + HelpHtmlFragment.class, nfcBundle, (selectedTab == 2)); Bundle changelogBundle = new Bundle(); changelogBundle.putInt(HelpHtmlFragment.ARG_HTML_FILE, R.raw.help_changelog); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_changelog)), - HelpHtmlFragment.class, changelogBundle, (selectedTab == 2) ); + HelpHtmlFragment.class, changelogBundle, (selectedTab == 3)); mTabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.help_tab_about)), - HelpAboutFragment.class, null, (selectedTab == 3) ); + HelpAboutFragment.class, null, (selectedTab == 4)); } } \ 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 4b427917f..77891d6c7 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -374,6 +374,7 @@ Start + FAQ NFC Beam Changelog About -- cgit v1.2.3 From 5c5e9d8e32619f47aa036b84db7196696700dba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 13 Mar 2014 19:09:54 +0100 Subject: Forgot faq file --- OpenPGP-Keychain/src/main/res/raw/help_faq.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 OpenPGP-Keychain/src/main/res/raw/help_faq.html (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/res/raw/help_faq.html b/OpenPGP-Keychain/src/main/res/raw/help_faq.html new file mode 100644 index 000000000..b3d5b3a11 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw/help_faq.html @@ -0,0 +1,12 @@ + + + + + +

TODO

+

text

+ + + -- cgit v1.2.3 From 79a8528a630d192566496a401abbbdabbbcf5d79 Mon Sep 17 00:00:00 2001 From: uberspot Date: Thu, 13 Mar 2014 19:29:21 +0200 Subject: Optimize imports in all files, remove useless whitespace in some and fix indentation --- .../keychain/service/KeychainIntentService.java | 61 +++++++--------------- .../service/KeychainIntentServiceHandler.java | 8 +-- .../keychain/service/PassphraseCacheService.java | 48 +++++++---------- .../service/remote/AppSettingsActivity.java | 23 ++++---- .../service/remote/AppSettingsFragment.java | 28 ++++------ .../keychain/service/remote/OpenPgpService.java | 1 - .../service/remote/RegisteredAppsAdapter.java | 5 +- .../service/remote/RegisteredAppsListActivity.java | 3 +- .../service/remote/RegisteredAppsListFragment.java | 9 ++-- .../keychain/service/remote/RemoteService.java | 21 ++++---- .../service/remote/RemoteServiceActivity.java | 1 - 11 files changed, 80 insertions(+), 128 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 23f489d35..f893e3488 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -17,57 +17,32 @@ package org.sufficientlysecure.keychain.service; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.List; - -import org.spongycastle.openpgp.PGPKeyRing; -import org.spongycastle.openpgp.PGPObjectFactory; -import org.spongycastle.openpgp.PGPPublicKeyRing; -import org.spongycastle.openpgp.PGPSecretKey; -import org.spongycastle.openpgp.PGPUtil; +import android.app.IntentService; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Message; +import android.os.Messenger; +import android.os.RemoteException; +import org.spongycastle.openpgp.*; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; -import org.sufficientlysecure.keychain.pgp.PgpHelper; -import org.sufficientlysecure.keychain.pgp.PgpImportExport; -import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; -import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; +import org.sufficientlysecure.keychain.pgp.*; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import org.sufficientlysecure.keychain.util.HkpKeyServer; -import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.KeychainServiceListener; -import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; +import org.sufficientlysecure.keychain.util.*; -import android.app.IntentService; -import android.content.Context; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.os.Message; -import android.os.Messenger; -import android.os.RemoteException; +import java.io.*; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.List; /** * This Service contains all important long lasting operations for APG. It receives Intents with @@ -706,7 +681,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial keyRingRowIds = ProviderHelper.getSecretKeyRingsRowIds(this); } } else { - for(long rowId : rowIds) { + for (long rowId : rowIds) { keyRingRowIds.add(rowId); } } @@ -718,8 +693,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial resultData = pgpImportExport .exportKeyRings(keyRingRowIds, keyType, outStream); - if(mIsCanceled){ - boolean isDeleted = new File(outputFile).delete(); + if (mIsCanceled) { + boolean isDeleted = new File(outputFile).delete(); } sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java index ebc002ceb..92d012c80 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java @@ -17,9 +17,6 @@ package org.sufficientlysecure.keychain.service; -import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; -import org.sufficientlysecure.keychain.R; - import android.app.Activity; import android.content.DialogInterface.OnCancelListener; import android.os.Bundle; @@ -28,6 +25,8 @@ import android.os.Message; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.widget.Toast; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; public class KeychainIntentServiceHandler extends Handler { @@ -73,7 +72,8 @@ public class KeychainIntentServiceHandler extends Handler { } public void showProgressDialog(FragmentActivity activity) { - // TODO: This is a hack!, see http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult + // TODO: This is a hack!, see + // http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult final FragmentManager manager = activity.getSupportFragmentManager(); Handler handler = new Handler(); handler.post(new Runnable() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index ce34d451d..134afbfdd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -17,10 +17,15 @@ package org.sufficientlysecure.keychain.service; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; - +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.*; +import android.util.Log; import android.util.LongSparseArray; import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPrivateKey; @@ -34,28 +39,13 @@ import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Binder; -import android.os.Bundle; -import android.os.Handler; -import android.os.HandlerThread; -import android.os.IBinder; -import android.os.Message; -import android.os.Messenger; -import android.os.RemoteException; -import android.util.Log; +import java.util.Date; +import java.util.Iterator; /** * This service runs in its own process, but is available to all other processes as the main * passphrase cache. Use the static methods addCachedPassphrase and getCachedPassphrase for * convenience. - * */ public class PassphraseCacheService extends Service { public static final String TAG = Constants.TAG + ": PassphraseCacheService"; @@ -86,7 +76,7 @@ public class PassphraseCacheService extends Service { * This caches a new passphrase in memory by sending a new command to the service. An android * service is only run once. Thus, when the service is already started, new commands just add * new events to the alarm manager for new passphrases to let them timeout in the future. - * + * * @param context * @param keyId * @param passphrase @@ -106,7 +96,7 @@ public class PassphraseCacheService extends Service { /** * Gets a cached passphrase from memory by sending an intent to the service. This method is * designed to wait until the service returns the passphrase. - * + * * @param context * @param keyId * @return passphrase or null (if no passphrase is cached for this keyId) @@ -161,7 +151,7 @@ public class PassphraseCacheService extends Service { /** * Internal implementation to get cached passphrase. - * + * * @param keyId * @return */ @@ -205,7 +195,7 @@ public class PassphraseCacheService extends Service { /** * Checks if key has a passphrase. - * + * * @param secretKeyId * @return true if it has a passphrase */ @@ -216,8 +206,8 @@ public class PassphraseCacheService extends Service { .getPGPSecretKeyRingByKeyId(context, secretKeyId); PGPSecretKey secretKey = null; boolean foundValidKey = false; - for (Iterator keys = secRing.getSecretKeys(); keys.hasNext();) { - secretKey = (PGPSecretKey)keys.next(); + for (Iterator keys = secRing.getSecretKeys(); keys.hasNext(); ) { + secretKey = (PGPSecretKey) keys.next(); if (!secretKey.isPrivateKeyEmpty()) { foundValidKey = true; break; @@ -269,7 +259,7 @@ public class PassphraseCacheService extends Service { /** * Build pending intent that is executed by alarm manager to time out a specific passphrase - * + * * @param context * @param keyId * @return @@ -337,7 +327,7 @@ public class PassphraseCacheService extends Service { /** * Called when one specific passphrase for keyId timed out - * + * * @param context * @param keyId */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java index 178b2fc67..abdfb775c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java @@ -17,12 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.Log; - import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -30,6 +24,11 @@ import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.util.Log; public class AppSettingsActivity extends ActionBarActivity { private Uri mAppUri; @@ -77,12 +76,12 @@ public class AppSettingsActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_api_settings_revoke: - revokeAccess(); - return true; - case R.id.menu_api_settings_cancel: - finish(); - return true; + case R.id.menu_api_settings_revoke: + revokeAccess(); + return true; + case R.id.menu_api_settings_cancel: + finish(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java index 64c4c5e96..a042e97d6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java @@ -17,17 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import org.spongycastle.util.encoders.Hex; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; -import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; -import org.sufficientlysecure.keychain.util.AlgorithmNames; -import org.sufficientlysecure.keychain.util.Log; - import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -40,14 +29,19 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; -import android.widget.AdapterView; +import android.widget.*; import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.Spinner; -import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.spongycastle.util.encoders.Hex; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; +import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; +import org.sufficientlysecure.keychain.util.AlgorithmNames; +import org.sufficientlysecure.keychain.util.Log; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; public class AppSettingsFragment extends Fragment implements SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java index f697faa6e..a94b19d44 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java @@ -23,7 +23,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.IBinder; import android.os.ParcelFileDescriptor; - import org.openintents.openpgp.IOpenPgpService; import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java index 477ee04d0..7a49bfefa 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java @@ -17,9 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; @@ -31,6 +28,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; public class RegisteredAppsAdapter extends CursorAdapter { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java index 3c553fff5..f6f216efd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java @@ -17,11 +17,10 @@ package org.sufficientlysecure.keychain.service.remote; +import android.os.Bundle; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.DrawerActivity; -import android.os.Bundle; - public class RegisteredAppsListActivity extends DrawerActivity { @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java index fed267a44..1a49e2e74 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - import android.content.ContentUris; import android.content.Intent; import android.database.Cursor; @@ -33,6 +29,9 @@ import android.support.v4.content.Loader; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; public class RegisteredAppsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { @@ -71,7 +70,7 @@ public class RegisteredAppsListFragment extends ListFragment implements } // These are the Contacts rows that we will retrieve. - static final String[] PROJECTION = new String[] { ApiApps._ID, ApiApps.PACKAGE_NAME }; + static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; public Loader onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java index cb556be39..365008c01 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java @@ -17,17 +17,6 @@ package org.sufficientlysecure.keychain.service.remote; -import java.util.ArrayList; -import java.util.Arrays; - -import org.openintents.openpgp.OpenPgpError; -import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.Log; - import android.app.PendingIntent; import android.app.Service; import android.content.Context; @@ -38,6 +27,16 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.Signature; import android.net.Uri; import android.os.Binder; +import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.util.OpenPgpApi; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.ArrayList; +import java.util.Arrays; /** * Abstract service class for remote APIs that handle app registration and user input. diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java index 8fb562884..88661c050 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java @@ -24,7 +24,6 @@ import android.os.Message; import android.os.Messenger; import android.support.v7.app.ActionBarActivity; import android.view.View; - import org.openintents.openpgp.util.OpenPgpApi; import org.sufficientlysecure.htmltextview.HtmlTextView; import org.sufficientlysecure.keychain.Constants; -- cgit v1.2.3 From 540aa044e242719cbcde4d8642bb918b79806bee Mon Sep 17 00:00:00 2001 From: uberspot Date: Thu, 13 Mar 2014 19:50:45 +0200 Subject: Fix code style in keychain/service/ --- .../keychain/service/KeychainIntentService.java | 41 ++++++++++++------- .../keychain/service/PassphraseCacheService.java | 4 +- .../keychain/service/remote/AppSettings.java | 46 +++++++++++----------- .../service/remote/AppSettingsActivity.java | 3 +- .../service/remote/AppSettingsFragment.java | 38 +++++++++--------- .../keychain/service/remote/OpenPgpService.java | 15 ++++--- .../service/remote/RegisteredAppsAdapter.java | 10 ++--- .../service/remote/RegisteredAppsListFragment.java | 2 +- .../keychain/service/remote/RemoteService.java | 14 ++++--- .../service/remote/RemoteServiceActivity.java | 24 ++++++----- .../remote/WrongPackageSignatureException.java | 19 ++++++++- 11 files changed, 129 insertions(+), 87 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index f893e3488..4e5812202 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -49,7 +49,8 @@ import java.util.List; * data from the activities or other apps, queues these intents, executes them, and stops itself * after doing them. */ -public class KeychainIntentService extends IntentService implements ProgressDialogUpdater, KeychainServiceListener { +public class KeychainIntentService extends IntentService + implements ProgressDialogUpdater, KeychainServiceListener { /* extras that can be given by intent */ public static final String EXTRA_MESSENGER = "messenger"; @@ -307,8 +308,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial builder.enableAsciiArmorOutput(useAsciiArmor) .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) .signatureKeyId(secretKeyId) - .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + .signatureHashAlgorithm( + Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase( + PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); builder.build().generateSignature(); } else if (signOnly) { @@ -316,21 +319,26 @@ public class KeychainIntentService extends IntentService implements ProgressDial builder.enableAsciiArmorOutput(useAsciiArmor) .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) .signatureKeyId(secretKeyId) - .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + .signatureHashAlgorithm( + Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase( + PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); builder.build().execute(); } else { Log.d(Constants.TAG, "encrypt..."); builder.enableAsciiArmorOutput(useAsciiArmor) .compressionId(compressionId) - .symmetricEncryptionAlgorithm(Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) + .symmetricEncryptionAlgorithm( + Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) .encryptionKeyIds(encryptionKeyIds) .encryptionPassphrase(encryptionPassphrase) .signatureKeyId(secretKeyId) - .signatureHashAlgorithm(Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase(PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); + .signatureHashAlgorithm( + Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase( + PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); builder.build().execute(); } @@ -522,7 +530,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial ArrayList keys = PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(SAVE_KEYRING_KEYS)); ArrayList keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES); - ArrayList keysExpiryDates = (ArrayList) data.getSerializable(SAVE_KEYRING_KEYS_EXPIRY_DATES); + ArrayList keysExpiryDates = + (ArrayList) data.getSerializable(SAVE_KEYRING_KEYS_EXPIRY_DATES); long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); @@ -577,7 +586,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial int keysTotal = 2; int keysCreated = 0; setProgress( - getApplicationContext().getResources().getQuantityString(R.plurals.progress_generating, keysTotal), + getApplicationContext().getResources(). + getQuantityString(R.plurals.progress_generating, keysTotal), keysCreated, keysTotal); PgpKeyOperation keyOperations = new PgpKeyOperation(this, this); @@ -746,7 +756,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial // need to have access to the bufferedInput, so we can reuse it for the possible // PGPObject chunks after the first one, e.g. files with several consecutive ASCII // armor blocks - BufferedInputStream bufferedInput = new BufferedInputStream(new ByteArrayInputStream(downloadedKey)); + BufferedInputStream bufferedInput = + new BufferedInputStream(new ByteArrayInputStream(downloadedKey)); try { // read all available blocks... (asc files can contain many blocks with BEGIN END) @@ -818,9 +829,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial private void sendErrorToHandler(Exception e) { // Service was canceled. Do not send error to handler. - if (this.mIsCanceled) + if (this.mIsCanceled) { return; - + } Log.e(Constants.TAG, "ApgService Exception: ", e); e.printStackTrace(); @@ -831,9 +842,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) { // Service was canceled. Do not send message to handler. - if (this.mIsCanceled) + if (this.mIsCanceled) { return; - + } Message msg = Message.obtain(); msg.arg1 = arg1; if (arg2 != null) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 134afbfdd..176d09c1a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -214,9 +214,9 @@ public class PassphraseCacheService extends Service { } } - if (!foundValidKey) + if (!foundValidKey) { return false; - + } PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( "SC").build("".toCharArray()); PGPPrivateKey testKey = secretKey.extractPrivateKey(keyDecryptor); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java index 9da4c8392..6f2d67efb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java @@ -22,12 +22,12 @@ import org.spongycastle.openpgp.PGPEncryptedData; import org.sufficientlysecure.keychain.Id; public class AppSettings { - private String packageName; - private byte[] packageSignature; - private long keyId = Id.key.none; - private int encryptionAlgorithm; - private int hashAlgorithm; - private int compression; + private String mPackageName; + private byte[] mPackageSignature; + private long mKeyId = Id.key.none; + private int mEncryptionAlgorithm; + private int mHashAlgorithm; + private int mCompression; public AppSettings() { @@ -35,60 +35,60 @@ public class AppSettings { public AppSettings(String packageName, byte[] packageSignature) { super(); - this.packageName = packageName; - this.packageSignature = packageSignature; + this.mPackageName = packageName; + this.mPackageSignature = packageSignature; // defaults: - this.encryptionAlgorithm = PGPEncryptedData.AES_256; - this.hashAlgorithm = HashAlgorithmTags.SHA512; - this.compression = Id.choice.compression.zlib; + this.mEncryptionAlgorithm = PGPEncryptedData.AES_256; + this.mHashAlgorithm = HashAlgorithmTags.SHA512; + this.mCompression = Id.choice.compression.zlib; } public String getPackageName() { - return packageName; + return mPackageName; } public void setPackageName(String packageName) { - this.packageName = packageName; + this.mPackageName = packageName; } public byte[] getPackageSignature() { - return packageSignature; + return mPackageSignature; } public void setPackageSignature(byte[] packageSignature) { - this.packageSignature = packageSignature; + this.mPackageSignature = packageSignature; } public long getKeyId() { - return keyId; + return mKeyId; } public void setKeyId(long scretKeyId) { - this.keyId = scretKeyId; + this.mKeyId = scretKeyId; } public int getEncryptionAlgorithm() { - return encryptionAlgorithm; + return mEncryptionAlgorithm; } public void setEncryptionAlgorithm(int encryptionAlgorithm) { - this.encryptionAlgorithm = encryptionAlgorithm; + this.mEncryptionAlgorithm = encryptionAlgorithm; } public int getHashAlgorithm() { - return hashAlgorithm; + return mHashAlgorithm; } public void setHashAlgorithm(int hashAlgorithm) { - this.hashAlgorithm = hashAlgorithm; + this.mHashAlgorithm = hashAlgorithm; } public int getCompression() { - return compression; + return mCompression; } public void setCompression(int compression) { - this.compression = compression; + this.mCompression = compression; } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java index abdfb775c..2ef170dec 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java @@ -40,7 +40,8 @@ public class AppSettingsActivity extends ActionBarActivity { super.onCreate(savedInstanceState); // Inflate a "Done" custom action bar - ActionBarHelper.setOneButtonView(getSupportActionBar(), R.string.api_settings_save, R.drawable.ic_action_done, + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.api_settings_save, R.drawable.ic_action_done, new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java index a042e97d6..837295018 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java @@ -47,7 +47,7 @@ public class AppSettingsFragment extends Fragment implements SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { // model - private AppSettings appSettings; + private AppSettings mAppSettings; // view private LinearLayout mAdvancedSettingsContainer; @@ -62,16 +62,16 @@ public class AppSettingsFragment extends Fragment implements private SelectSecretKeyLayoutFragment mSelectKeyFragment; - KeyValueSpinnerAdapter encryptionAdapter; - KeyValueSpinnerAdapter hashAdapter; - KeyValueSpinnerAdapter compressionAdapter; + KeyValueSpinnerAdapter mEncryptionAdapter; + KeyValueSpinnerAdapter mHashAdapter; + KeyValueSpinnerAdapter mCompressionAdapter; public AppSettings getAppSettings() { - return appSettings; + return mAppSettings; } public void setAppSettings(AppSettings appSettings) { - this.appSettings = appSettings; + this.mAppSettings = appSettings; setPackage(appSettings.getPackageName()); mPackageName.setText(appSettings.getPackageName()); @@ -87,10 +87,10 @@ public class AppSettingsFragment extends Fragment implements } mSelectKeyFragment.selectKey(appSettings.getKeyId()); - mEncryptionAlgorithm.setSelection(encryptionAdapter.getPosition(appSettings + mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings .getEncryptionAlgorithm())); - mHashAlgorithm.setSelection(hashAdapter.getPosition(appSettings.getHashAlgorithm())); - mCompression.setSelection(compressionAdapter.getPosition(appSettings.getCompression())); + mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); + mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); } /** @@ -133,14 +133,14 @@ public class AppSettingsFragment extends Fragment implements AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); - encryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), + mEncryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getEncryptionNames()); - mEncryptionAlgorithm.setAdapter(encryptionAdapter); + mEncryptionAlgorithm.setAdapter(mEncryptionAdapter); mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - appSettings.setEncryptionAlgorithm((int) id); + mAppSettings.setEncryptionAlgorithm((int) id); } @Override @@ -148,13 +148,13 @@ public class AppSettingsFragment extends Fragment implements } }); - hashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); - mHashAlgorithm.setAdapter(hashAdapter); + mHashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); + mHashAlgorithm.setAdapter(mHashAdapter); mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - appSettings.setHashAlgorithm((int) id); + mAppSettings.setHashAlgorithm((int) id); } @Override @@ -162,14 +162,14 @@ public class AppSettingsFragment extends Fragment implements } }); - compressionAdapter = new KeyValueSpinnerAdapter(getActivity(), + mCompressionAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getCompressionNames()); - mCompression.setAdapter(compressionAdapter); + mCompression.setAdapter(mCompressionAdapter); mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - appSettings.setCompression((int) id); + mAppSettings.setCompression((int) id); } @Override @@ -231,7 +231,7 @@ public class AppSettingsFragment extends Fragment implements */ @Override public void onKeySelected(long secretKeyId) { - appSettings.setKeyId(secretKeyId); + mAppSettings.setKeyId(secretKeyId); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java index a94b19d44..95dc897f0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java @@ -99,7 +99,8 @@ public class OpenPgpService extends RemoteService { intent.putExtra(RemoteServiceActivity.EXTRA_DUBLICATE_USER_IDS, dublicateUserIds); intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), PRIVATE_REQUEST_CODE_USER_IDS, intent, 0); + PendingIntent pi = PendingIntent.getActivity + (getBaseContext(), PRIVATE_REQUEST_CODE_USER_IDS, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -125,7 +126,8 @@ public class OpenPgpService extends RemoteService { intent.putExtra(RemoteServiceActivity.EXTRA_SECRET_KEY_ID, keyId); // pass params through to activity that it can be returned again later to repeat pgp operation intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), PRIVATE_REQUEST_CODE_PASSPHRASE, intent, 0); + PendingIntent pi = PendingIntent.getActivity + (getBaseContext(), PRIVATE_REQUEST_CODE_PASSPHRASE, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -207,7 +209,8 @@ public class OpenPgpService extends RemoteService { } else { Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, "Missing parameter user_ids or key_ids!")); + new OpenPgpError(OpenPgpError.GENERIC_ERROR, + "Missing parameter user_ids or key_ids!")); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); return result; } @@ -288,7 +291,8 @@ public class OpenPgpService extends RemoteService { PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); builder.assumeSymmetric(false) // no support for symmetric encryption - .enforcedKeyId(appSettings.getKeyId()) // allow only the private key for this app for decryption + // allow only the private key for this app for decryption + .enforcedKeyId(appSettings.getKeyId()) .passphrase(passphrase); // TODO: currently does not support binary signed-only content @@ -402,7 +406,8 @@ public class OpenPgpService extends RemoteService { // version code is required and needs to correspond to version code of service! if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != OpenPgpApi.API_VERSION) { Intent result = new Intent(); - OpenPgpError error = new OpenPgpError(OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!"); + OpenPgpError error = new OpenPgpError + (OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!"); result.putExtra(OpenPgpApi.RESULT_ERROR, error); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); return result; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java index 7a49bfefa..e0dc4162f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java @@ -34,13 +34,13 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; public class RegisteredAppsAdapter extends CursorAdapter { private LayoutInflater mInflater; - private PackageManager pm; + private PackageManager mPM; public RegisteredAppsAdapter(Context context, Cursor c, int flags) { super(context, c, flags); mInflater = LayoutInflater.from(context); - pm = context.getApplicationContext().getPackageManager(); + mPM = context.getApplicationContext().getPackageManager(); } @Override @@ -52,10 +52,10 @@ public class RegisteredAppsAdapter extends CursorAdapter { if (packageName != null) { // get application name try { - ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); + ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); - text.setText(pm.getApplicationLabel(ai)); - icon.setImageDrawable(pm.getApplicationIcon(ai)); + text.setText(mPM.getApplicationLabel(ai)); + icon.setImageDrawable(mPM.getApplicationIcon(ai)); } catch (final NameNotFoundException e) { // fallback text.setText(packageName); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java index 1a49e2e74..25d0c7593 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java @@ -98,4 +98,4 @@ public class RegisteredAppsListFragment extends ListFragment implements mAdapter.swapCursor(null); } -} \ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java index 365008c01..6a883316a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java @@ -83,7 +83,8 @@ public abstract class RemoteService extends Service { intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_SIGNATURE, packageSignature); intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), PRIVATE_REQUEST_CODE_REGISTER, intent, 0); + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_REGISTER, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -97,10 +98,12 @@ public abstract class RemoteService extends Service { Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, getString(R.string.api_error_wrong_signature)); + intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, + getString(R.string.api_error_wrong_signature)); intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), PRIVATE_REQUEST_CODE_ERROR, intent, 0); + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_ERROR, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -137,8 +140,9 @@ public abstract class RemoteService extends Service { AppSettings settings = ProviderHelper.getApiAppSettings(this, uri); - if (settings != null) + if (settings != null) { return settings; + } } return null; @@ -212,7 +216,7 @@ public abstract class RemoteService extends Service { return true; } else { throw new WrongPackageSignatureException( - "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); + "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java index 88661c050..e20114853 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java @@ -87,7 +87,8 @@ public class RemoteServiceActivity extends ActionBarActivity { final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); // Inflate a "Done"/"Cancel" custom action bar view - ActionBarHelper.setTwoButtonView(getSupportActionBar(), R.string.api_register_allow, R.drawable.ic_action_done, + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.api_register_allow, R.drawable.ic_action_done, new View.OnClickListener() { @Override public void onClick(View v) { @@ -107,13 +108,14 @@ public class RemoteServiceActivity extends ActionBarActivity { RemoteServiceActivity.this.finish(); } } - }, R.string.api_register_disallow, R.drawable.ic_action_cancel, new View.OnClickListener() { - @Override - public void onClick(View v) { - // Disallow - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - RemoteServiceActivity.this.finish(); - } + }, R.string.api_register_disallow, R.drawable.ic_action_cancel, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Disallow + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } } ); @@ -160,7 +162,8 @@ public class RemoteServiceActivity extends ActionBarActivity { } // Inflate a "Done"/"Cancel" custom action bar view - ActionBarHelper.setTwoButtonView(getSupportActionBar(), R.string.btn_okay, R.drawable.ic_action_done, + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.btn_okay, R.drawable.ic_action_done, new View.OnClickListener() { @Override public void onClick(View v) { @@ -213,7 +216,8 @@ public class RemoteServiceActivity extends ActionBarActivity { String text = "" + errorMessage + ""; // Inflate a "Done" custom action bar view - ActionBarHelper.setOneButtonView(getSupportActionBar(), R.string.btn_okay, R.drawable.ic_action_done, + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.btn_okay, R.drawable.ic_action_done, new View.OnClickListener() { @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java index cc08548e8..0b642086a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2013 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.service.remote; public class WrongPackageSignatureException extends Exception { @@ -7,4 +24,4 @@ public class WrongPackageSignatureException extends Exception { public WrongPackageSignatureException(String message) { super(message); } -} \ No newline at end of file +} -- cgit v1.2.3 From f26ba217e567aa35a6bcee2665c12c612440cbda Mon Sep 17 00:00:00 2001 From: uberspot Date: Thu, 13 Mar 2014 19:59:27 +0200 Subject: Fix code style in /helper --- .../keychain/helper/ActionBarHelper.java | 23 +++++----- .../keychain/helper/ExportHelper.java | 50 +++++++++++----------- .../keychain/helper/FileHelper.java | 37 +++++++--------- .../keychain/helper/OtherHelper.java | 16 +++---- .../keychain/helper/Preferences.java | 9 ++-- 5 files changed, 64 insertions(+), 71 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 24e8ff4c7..91e50637e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -17,24 +17,23 @@ package org.sufficientlysecure.keychain.helper; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.widget.TextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class ActionBarHelper { /** * Set actionbar without home button if called from another app - * + * * @param activity */ public static void setBackButton(ActionBarActivity activity) { @@ -54,7 +53,7 @@ public class ActionBarHelper { /** * Sets custom view on ActionBar for Done/Cancel activities - * + * * @param actionBar * @param firstText * @param firstDrawableId @@ -63,9 +62,9 @@ public class ActionBarHelper { * @param secondDrawableId * @param secondOnClickListener */ - public static void setTwoButtonView(ActionBar actionBar, int firstText, int firstDrawableId, - OnClickListener firstOnClickListener, int secondText, int secondDrawableId, - OnClickListener secondOnClickListener) { + public static void setTwoButtonView(ActionBar actionBar, + int firstText, int firstDrawableId, OnClickListener firstOnClickListener, + int secondText, int secondDrawableId, OnClickListener secondOnClickListener) { // Inflate the custom action bar view final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() @@ -94,13 +93,13 @@ public class ActionBarHelper { /** * Sets custom view on ActionBar for Done activities - * + * * @param actionBar * @param firstText * @param firstOnClickListener */ public static void setOneButtonView(ActionBar actionBar, int firstText, int firstDrawableId, - OnClickListener firstOnClickListener) { + OnClickListener firstOnClickListener) { // Inflate a "Done" custom action bar view to serve as the "Up" affordance. final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext() .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 245c5fda1..557d75dbf 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -26,7 +26,6 @@ import android.os.Message; import android.os.Messenger; import android.support.v7.app.ActionBarActivity; import android.widget.Toast; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -41,11 +40,11 @@ public class ExportHelper { protected FileDialogFragment mFileDialog; protected String mExportFilename; - ActionBarActivity activity; + ActionBarActivity mActivity; public ExportHelper(ActionBarActivity activity) { super(); - this.activity = activity; + this.mActivity = activity; } public void deleteKey(Uri dataUri, final int keyType, Handler deleteHandler) { @@ -55,16 +54,16 @@ public class ExportHelper { Messenger messenger = new Messenger(deleteHandler); DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, - new long[] { keyRingRowId }, keyType); + new long[]{keyRingRowId}, keyType); - deleteKeyDialog.show(activity.getSupportFragmentManager(), "deleteKeyDialog"); + deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog"); } /** * Show dialog where to export keys */ public void showExportKeysDialog(final long[] rowIds, final int keyType, - final String exportFilename) { + final String exportFilename) { mExportFilename = exportFilename; // Message is received after file is selected @@ -88,23 +87,23 @@ public class ExportHelper { String title = null; if (rowIds == null) { // export all keys - title = activity.getString(R.string.title_export_keys); + title = mActivity.getString(R.string.title_export_keys); } else { // export only key specified at data uri - title = activity.getString(R.string.title_export_key); + title = mActivity.getString(R.string.title_export_key); } String message = null; if (keyType == Id.type.public_key) { - message = activity.getString(R.string.specify_file_to_export_to); + message = mActivity.getString(R.string.specify_file_to_export_to); } else { - message = activity.getString(R.string.specify_file_to_export_secret_keys_to); + message = mActivity.getString(R.string.specify_file_to_export_secret_keys_to); } mFileDialog = FileDialogFragment.newInstance(messenger, title, message, exportFilename, null); - mFileDialog.show(activity.getSupportFragmentManager(), "fileDialog"); + mFileDialog.show(mActivity.getSupportFragmentManager(), "fileDialog"); } }); } @@ -116,7 +115,7 @@ public class ExportHelper { Log.d(Constants.TAG, "exportKeys started"); // Send all information needed to service to export key in other thread - final Intent intent = new Intent(activity, KeychainIntentService.class); + final Intent intent = new Intent(mActivity, KeychainIntentService.class); intent.setAction(KeychainIntentService.ACTION_EXPORT_KEYRING); @@ -135,12 +134,15 @@ public class ExportHelper { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after exporting is done in ApgService - KeychainIntentServiceHandler exportHandler = new KeychainIntentServiceHandler(activity, - activity.getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL, true, new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialogInterface) { - activity.stopService(intent); - } + KeychainIntentServiceHandler exportHandler = new KeychainIntentServiceHandler(mActivity, + mActivity.getString(R.string.progress_exporting), + ProgressDialog.STYLE_HORIZONTAL, + true, + new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + mActivity.stopService(intent); + } }) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first @@ -153,13 +155,13 @@ public class ExportHelper { int exported = returnData.getInt(KeychainIntentService.RESULT_EXPORT); String toastMessage; if (exported == 1) { - toastMessage = activity.getString(R.string.key_exported); + toastMessage = mActivity.getString(R.string.key_exported); } else if (exported > 0) { - toastMessage = activity.getString(R.string.keys_exported, exported); + toastMessage = mActivity.getString(R.string.keys_exported, exported); } else { - toastMessage = activity.getString(R.string.no_keys_exported); + toastMessage = mActivity.getString(R.string.no_keys_exported); } - Toast.makeText(activity, toastMessage, Toast.LENGTH_SHORT).show(); + Toast.makeText(mActivity, toastMessage, Toast.LENGTH_SHORT).show(); } } @@ -170,10 +172,10 @@ public class ExportHelper { intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog - exportHandler.showProgressDialog(activity); + exportHandler.showProgressDialog(mActivity); // start service with intent - activity.startService(intent); + mActivity.startService(intent); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java index ec56fe912..d24aeca52 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.helper; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; @@ -30,12 +26,15 @@ import android.net.Uri; import android.os.Environment; import android.support.v4.app.Fragment; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class FileHelper { /** * Checks if external storage is mounted if file is located on external storage - * + * * @param file * @return true if storage is mounted */ @@ -52,15 +51,12 @@ public class FileHelper { /** * Opens the preferred installed file manager on Android and shows a toast if no manager is * installed. - * + * * @param activity - * @param filename - * default selected file, not supported by all file managers - * @param mimeType - * can be text/plain for example - * @param requestCode - * requestCode used to identify the result coming back from file manager to - * onActivityResult() in your activity + * @param filename default selected file, not supported by all file managers + * @param mimeType can be text/plain for example + * @param requestCode requestCode used to identify the result coming back from file manager to + * onActivityResult() in your activity */ public static void openFile(Activity activity, String filename, String mimeType, int requestCode) { Intent intent = buildFileIntent(filename, mimeType); @@ -97,14 +93,13 @@ public class FileHelper { /** * Get a file path from a Uri. - * + *

* from https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/ * afilechooser/utils/FileUtils.java - * + * * @param context * @param uri * @return - * * @author paulburke */ public static String getPath(Context context, Uri uri) { @@ -115,21 +110,19 @@ public class FileHelper { + uri.getPathSegments().toString()); if ("content".equalsIgnoreCase(uri.getScheme())) { - String[] projection = { "_data" }; + String[] projection = {"_data"}; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projection, null, null, null); - int column_index = cursor.getColumnIndexOrThrow("_data"); + int columnIndex = cursor.getColumnIndexOrThrow("_data"); if (cursor.moveToFirst()) { - return cursor.getString(column_index); + return cursor.getString(columnIndex); } } catch (Exception e) { // Eat it } - } - - else if ("file".equalsIgnoreCase(uri.getScheme())) { + } else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java index 292b5bf3d..eb46a52e5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java @@ -17,22 +17,21 @@ package org.sufficientlysecure.keychain.helper; +import android.os.Bundle; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.util.Log; + import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Set; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.util.Log; - -import android.os.Bundle; - public class OtherHelper { /** * Logs bundle content to debug for inspecting the content - * + * * @param bundle * @param bundleName */ @@ -63,6 +62,7 @@ public class OtherHelper { /** * Converts the given bytes to a unique RGB color using SHA1 algorithm + * * @param bytes * @return an integer array containing 3 numeric color representations (Red, Green, Black) * @throws NoSuchAlgorithmException @@ -75,8 +75,8 @@ public class OtherHelper { byte[] digest = md.digest(); int[] result = {((int) digest[0] + 256) % 256, - ((int) digest[1] + 256) % 256, - ((int) digest[2] + 256) % 256}; + ((int) digest[1] + 256) % 256, + ((int) digest[2] + 256) % 256}; return result; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index f18a290b3..82e181664 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -17,14 +17,13 @@ package org.sufficientlysecure.keychain.helper; +import android.content.Context; +import android.content.SharedPreferences; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; -import android.content.Context; -import android.content.SharedPreferences; - import java.util.Vector; /** @@ -38,8 +37,8 @@ public class Preferences { return getPreferences(context, false); } - public static synchronized Preferences getPreferences(Context context, boolean force_new) { - if (mPreferences == null || force_new) { + public static synchronized Preferences getPreferences(Context context, boolean forceNew) { + if (mPreferences == null || forceNew) { mPreferences = new Preferences(context); } return mPreferences; -- cgit v1.2.3 From ad1e047aa926cc8aee68edd00917d06b297157b8 Mon Sep 17 00:00:00 2001 From: uberspot Date: Thu, 13 Mar 2014 20:25:01 +0200 Subject: First code style changes in ui --- .../keychain/ui/CertifyKeyActivity.java | 38 ++++---- .../keychain/ui/DecryptActivity.java | 50 ++++------ .../keychain/ui/DrawerActivity.java | 55 +++++------ .../keychain/ui/EditKeyActivity.java | 103 ++++++++++----------- .../keychain/ui/EncryptActivity.java | 46 ++++----- .../keychain/ui/HelpAboutFragment.java | 13 ++- .../keychain/ui/HelpActivity.java | 5 +- .../keychain/ui/HelpHtmlFragment.java | 13 ++- .../keychain/ui/ImportKeysActivity.java | 2 - .../keychain/ui/ImportKeysClipboardFragment.java | 6 +- .../keychain/ui/ImportKeysFileFragment.java | 10 +- .../keychain/ui/ImportKeysListFragment.java | 52 +++++------ .../keychain/ui/ImportKeysNFCFragment.java | 4 +- .../keychain/ui/ImportKeysQrCodeFragment.java | 84 ++++++++--------- .../keychain/ui/ImportKeysServerFragment.java | 10 +- .../keychain/ui/KeyListActivity.java | 9 +- .../keychain/ui/KeyListFragment.java | 79 +++++++--------- .../keychain/ui/PreferencesActivity.java | 68 +++++++------- .../keychain/ui/PreferencesKeyServerActivity.java | 18 ++-- .../keychain/ui/SelectPublicKeyActivity.java | 10 +- .../keychain/ui/SelectPublicKeyFragment.java | 32 +++---- .../keychain/ui/SelectSecretKeyActivity.java | 7 +- .../keychain/ui/SelectSecretKeyFragment.java | 29 +++--- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 17 ++-- .../keychain/ui/UploadKeyActivity.java | 16 ++-- .../keychain/ui/ViewKeyActivity.java | 3 +- .../keychain/ui/ViewKeyActivityJB.java | 17 ++-- .../keychain/ui/ViewKeyCertsFragment.java | 2 - .../keychain/ui/ViewKeyMainFragment.java | 15 +-- .../ui/adapter/AsyncTaskResultWrapper.java | 5 +- .../ui/adapter/HighlightQueryCursorAdapter.java | 1 - .../keychain/ui/adapter/ImportKeysAdapter.java | 22 ++--- .../keychain/ui/adapter/ImportKeysListEntry.java | 11 +-- .../keychain/ui/adapter/ImportKeysListLoader.java | 19 ++-- .../ui/adapter/ImportKeysListServerLoader.java | 1 - .../ui/adapter/KeyValueSpinnerAdapter.java | 8 +- .../ui/adapter/SelectKeyCursorAdapter.java | 16 ++-- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 9 +- .../keychain/ui/adapter/ViewKeyUserIdsAdapter.java | 7 +- .../ui/dialog/BadImportKeyDialogFragment.java | 1 - .../ui/dialog/CreateKeyDialogFragment.java | 2 - .../ui/dialog/DeleteFileDialogFragment.java | 7 +- .../ui/dialog/DeleteKeyDialogFragment.java | 3 +- .../keychain/ui/dialog/FileDialogFragment.java | 49 +++++----- .../ui/dialog/PassphraseDialogFragment.java | 50 +++++----- .../keychain/ui/dialog/ProgressDialogFragment.java | 1 - .../ui/dialog/SetPassphraseDialogFragment.java | 24 ++--- .../keychain/ui/dialog/ShareNfcDialogFragment.java | 5 +- .../ui/dialog/ShareQrCodeDialogFragment.java | 1 - .../keychain/ui/widget/FixedListView.java | 2 +- .../keychain/ui/widget/IntegerListPreference.java | 2 +- .../keychain/ui/widget/KeyEditor.java | 39 +++----- .../keychain/ui/widget/KeyServerEditor.java | 4 +- .../keychain/ui/widget/SectionView.java | 2 - .../keychain/ui/widget/UnderlineTextView.java | 2 +- .../keychain/ui/widget/UserIdEditor.java | 14 ++- 56 files changed, 486 insertions(+), 634 deletions(-) (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 029dda1a0..9a9911c94 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -17,8 +17,20 @@ package org.sufficientlysecure.keychain.ui; -import java.util.Iterator; - +import android.app.ProgressDialog; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.*; +import android.widget.CompoundButton.OnCheckedChangeListener; +import com.beardedhen.androidbootstrap.BootstrapButton; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSignature; import org.sufficientlysecure.keychain.Constants; @@ -33,25 +45,7 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; -import android.app.ProgressDialog; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarActivity; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.Spinner; -import android.widget.Toast; - -import com.beardedhen.androidbootstrap.BootstrapButton; +import java.util.Iterator; /** * Signs the specified public key with the specified secret master key @@ -87,7 +81,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements mSelectKeyserverSpinner = (Spinner) findViewById(R.id.sign_key_keyserver); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Preferences.getPreferences(this) - .getKeyServers()); + .getKeyServers()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSelectKeyserverSpinner.setAdapter(adapter); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 38d763ce4..42b20788f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -17,14 +17,20 @@ package org.sufficientlysecure.keychain.ui; -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.regex.Matcher; - +import android.annotation.SuppressLint; +import android.app.ProgressDialog; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.animation.AnimationUtils; +import android.widget.*; +import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; import org.openintents.openpgp.OpenPgpSignatureResult; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.sufficientlysecure.keychain.Constants; @@ -33,10 +39,10 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.FileHelper; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.exception.NoAsymmetricEncryptionException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -48,27 +54,8 @@ import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; -import android.annotation.SuppressLint; -import android.app.ProgressDialog; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.animation.AnimationUtils; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; -import android.widget.ViewFlipper; - -import com.beardedhen.androidbootstrap.BootstrapButton; -import com.devspark.appmsg.AppMsg; +import java.io.*; +import java.util.regex.Matcher; @SuppressLint("NewApi") public class DecryptActivity extends DrawerActivity { @@ -533,7 +520,8 @@ public class DecryptActivity extends DrawerActivity { } finally { try { if (inStream != null) inStream.close(); - } catch (Exception e){ } + } catch (Exception e) { + } } } else { inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes()); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index ebb520197..be22c8753 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -30,17 +26,14 @@ import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; 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.ViewGroup; +import android.view.*; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; - import com.beardedhen.androidbootstrap.FontAwesomeText; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; public class DrawerActivity extends ActionBarActivity { private DrawerLayout mDrawerLayout; @@ -50,9 +43,9 @@ public class DrawerActivity extends ActionBarActivity { private CharSequence mDrawerTitle; private CharSequence mTitle; - private static Class[] mItemsClass = new Class[] { KeyListActivity.class, + private static Class[] mItemsClass = new Class[]{KeyListActivity.class, EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class, - RegisteredAppsListActivity.class }; + RegisteredAppsListActivity.class}; private Class mSelectedItem; private static final int MENU_ID_PREFERENCE = 222; @@ -67,12 +60,12 @@ public class DrawerActivity extends ActionBarActivity { // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); - NavItem mItemIconTexts[] = new NavItem[] { + NavItem mItemIconTexts[] = new NavItem[]{ new NavItem("fa-user", getString(R.string.nav_contacts)), new NavItem("fa-lock", getString(R.string.nav_encrypt)), new NavItem("fa-unlock", getString(R.string.nav_decrypt)), new NavItem("fa-download", getString(R.string.nav_import)), - new NavItem("fa-android", getString(R.string.nav_apps)) }; + new NavItem("fa-android", getString(R.string.nav_apps))}; mDrawerList.setAdapter(new NavigationDrawerAdapter(this, R.layout.drawer_list_item, mItemIconTexts)); @@ -86,10 +79,10 @@ public class DrawerActivity extends ActionBarActivity { // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ - mDrawerLayout, /* DrawerLayout object */ - R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ - R.string.drawer_open, /* "open drawer" description for accessibility */ - R.string.drawer_close /* "close drawer" description for accessibility */ + mDrawerLayout, /* DrawerLayout object */ + R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ + R.string.drawer_open, /* "open drawer" description for accessibility */ + R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); @@ -97,7 +90,7 @@ public class DrawerActivity extends ActionBarActivity { supportInvalidateOptionsMenu(); // call intent activity if selected - if(mSelectedItem != null) { + if (mSelectedItem != null) { finish(); overridePendingTransition(0, 0); @@ -149,18 +142,18 @@ public class DrawerActivity extends ActionBarActivity { } switch (item.getItemId()) { - case MENU_ID_PREFERENCE: { - Intent intent = new Intent(this, PreferencesActivity.class); - startActivity(intent); - return true; - } - case MENU_ID_HELP: { - Intent intent = new Intent(this, HelpActivity.class); - startActivity(intent); - return true; - } - default: - return super.onOptionsItemSelected(item); + case MENU_ID_PREFERENCE: { + Intent intent = new Intent(this, PreferencesActivity.class); + startActivity(intent); + return true; + } + case MENU_ID_HELP: { + Intent intent = new Intent(this, HelpActivity.class); + startActivity(intent); + return true; + } + default: + return super.onOptionsItemSelected(item); } // Handle action buttons 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 0c35bb2b1..1dde4601b 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 @@ -17,10 +17,25 @@ package org.sufficientlysecure.keychain.ui; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.Vector; - +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v7.app.ActionBarActivity; +import android.view.*; +import android.view.View.OnClickListener; +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 org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; @@ -44,30 +59,9 @@ import org.sufficientlysecure.keychain.ui.widget.UserIdEditor; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; -import android.app.Activity; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -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; -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 java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.Vector; public class EditKeyActivity extends ActionBarActivity { @@ -130,7 +124,7 @@ public class EditKeyActivity extends ActionBarActivity { /** * Handle intent action to create new key - * + * * @param intent */ private void handleActionCreateKey(Intent intent) { @@ -146,7 +140,8 @@ public class EditKeyActivity extends ActionBarActivity { public void onClick(View v) { cancelClicked(); } - }); + } + ); Bundle extras = intent.getExtras(); @@ -245,7 +240,7 @@ public class EditKeyActivity extends ActionBarActivity { /** * Handle intent action to edit existing key - * + * * @param intent */ private void handleActionEditKey(Intent intent) { @@ -323,28 +318,28 @@ public class EditKeyActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_key_edit_cancel: - cancelClicked(); - return true; - case R.id.menu_key_edit_export_file: - long[] ids = new long[]{Long.valueOf(mDataUri.getLastPathSegment())}; - mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC); - return true; - case R.id.menu_key_edit_delete: { - // 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(); + case R.id.menu_key_edit_cancel: + cancelClicked(); + return true; + case R.id.menu_key_edit_export_file: + long[] ids = new long[]{Long.valueOf(mDataUri.getLastPathSegment())}; + mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC); + return true; + case R.id.menu_key_edit_delete: { + // 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(mDataUri, Id.type.secret_key, returnHandler); - return true; - } + mExportHelper.deleteKey(mDataUri, Id.type.secret_key, returnHandler); + return true; + } } return super.onOptionsItemSelected(item); } @@ -584,7 +579,7 @@ public class EditKeyActivity extends ActionBarActivity { /** * Returns user ids from the SectionView - * + * * @param userIdsView * @return */ @@ -633,7 +628,7 @@ public class EditKeyActivity extends ActionBarActivity { /** * Returns keys from the SectionView - * + * * @param keysView * @return */ @@ -656,7 +651,7 @@ public class EditKeyActivity extends ActionBarActivity { /** * Returns usage selections of keys from the SectionView - * + * * @param keysView * @return */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 8f8952763..d2d662e40 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -17,9 +17,22 @@ package org.sufficientlysecure.keychain.ui; -import java.io.File; -import java.util.Vector; - +import android.app.ProgressDialog; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.*; +import com.beardedhen.androidbootstrap.BootstrapButton; +import com.beardedhen.androidbootstrap.FontAwesomeText; +import com.devspark.appmsg.AppMsg; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSecretKey; @@ -43,31 +56,8 @@ import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Choice; import org.sufficientlysecure.keychain.util.Log; -import android.app.ProgressDialog; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.widget.ArrayAdapter; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.Spinner; -import android.widget.TextView; -import android.widget.Toast; -import android.widget.ViewFlipper; - -import com.beardedhen.androidbootstrap.BootstrapButton; -import com.beardedhen.androidbootstrap.FontAwesomeText; -import com.devspark.appmsg.AppMsg; +import java.io.File; +import java.util.Vector; public class EncryptActivity extends DrawerActivity { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java index 12d689274..a484b57de 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpAboutFragment.java @@ -17,11 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -31,6 +26,10 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import org.sufficientlysecure.htmltextview.HtmlTextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class HelpAboutFragment extends Fragment { @@ -55,7 +54,7 @@ public class HelpAboutFragment extends Fragment { /** * Get the current package version. - * + * * @return The current version. */ private String getVersion() { @@ -73,4 +72,4 @@ public class HelpAboutFragment extends Fragment { return result; } -} \ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java index 48068a6c4..436d9291d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpActivity.java @@ -17,14 +17,13 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter; - import android.content.Intent; import android.os.Bundle; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter; public class HelpActivity extends ActionBarActivity { public static final String EXTRA_SELECTED_TAB = "selected_tab"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java index 3afb5bbe0..6b3c51b08 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/HelpHtmlFragment.java @@ -17,8 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.htmltextview.HtmlTextView; - import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -27,11 +25,12 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ScrollView; +import org.sufficientlysecure.htmltextview.HtmlTextView; public class HelpHtmlFragment extends Fragment { private Activity mActivity; - private int htmlFile; + private int mHtmlFile; public static final String ARG_HTML_FILE = "htmlFile"; @@ -52,8 +51,8 @@ public class HelpHtmlFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mActivity = getActivity(); - - htmlFile = getArguments().getInt(ARG_HTML_FILE); + + mHtmlFile = getArguments().getInt(ARG_HTML_FILE); ScrollView scroller = new ScrollView(mActivity); HtmlTextView text = new HtmlTextView(mActivity); @@ -66,11 +65,11 @@ public class HelpHtmlFragment extends Fragment { scroller.addView(text); // load html from raw resource (Parsing handled by HtmlTextView library) - text.setHtmlFromRawResource(getActivity(), htmlFile); + text.setHtmlFromRawResource(getActivity(), mHtmlFile); // no flickering when clicking textview for Android < 4 text.setTextColor(getResources().getColor(android.R.color.black)); return scroller; } -} \ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index f04a0e227..aa0c127cf 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -34,10 +34,8 @@ import android.support.v7.app.ActionBar; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; - import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java index 211fc1f44..c21271220 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java @@ -17,17 +17,15 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; - import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; public class ImportKeysClipboardFragment extends Fragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java index 60b33c8a2..cdfba894a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysFileFragment.java @@ -17,11 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.FileHelper; - import android.app.Activity; import android.content.Intent; import android.os.Bundle; @@ -29,8 +24,11 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.FileHelper; public class ImportKeysFileFragment extends Fragment { private ImportKeysActivity mImportActivity; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java index a6917d6f4..346c009fb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java @@ -17,25 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.ui.adapter.AsyncTaskResultWrapper; -import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter; -import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader; -import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListServerLoader; -import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.KeyServer; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.net.Uri; import android.os.Bundle; @@ -44,8 +25,21 @@ import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; import android.view.View; import android.widget.ListView; - import com.devspark.appmsg.AppMsg; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.Preferences; +import org.sufficientlysecure.keychain.ui.adapter.*; +import org.sufficientlysecure.keychain.util.InputData; +import org.sufficientlysecure.keychain.util.KeyServer; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.ByteArrayInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; public class ImportKeysListFragment extends ListFragment implements LoaderManager.LoaderCallbacks>> { @@ -225,16 +219,16 @@ public class ImportKeysListFragment extends ListFragment implements switch (loader.getId()) { case LOADER_ID_BYTES: - if(error == null){ + if (error == null) { // No error - } else if(error instanceof ImportKeysListLoader.FileHasNoContent) { + } else if (error instanceof ImportKeysListLoader.FileHasNoContent) { AppMsg.makeText(getActivity(), R.string.error_import_file_no_content, AppMsg.STYLE_ALERT).show(); - } else if(error instanceof ImportKeysListLoader.NonPgpPart) { + } else if (error instanceof ImportKeysListLoader.NonPgpPart) { AppMsg.makeText(getActivity(), ((ImportKeysListLoader.NonPgpPart) error).getCount() + " " + getResources(). - getQuantityString(R.plurals.error_import_non_pgp_part, - ((ImportKeysListLoader.NonPgpPart) error).getCount()), + getQuantityString(R.plurals.error_import_non_pgp_part, + ((ImportKeysListLoader.NonPgpPart) error).getCount()), new AppMsg.Style(AppMsg.LENGTH_LONG, R.color.confirm)).show(); } else { AppMsg.makeText(getActivity(), R.string.error_generic_report_bug, @@ -244,19 +238,19 @@ public class ImportKeysListFragment extends ListFragment implements case LOADER_ID_SERVER_QUERY: - if(error == null) { + if (error == null) { AppMsg.makeText( getActivity(), getResources().getQuantityString(R.plurals.keys_found, mAdapter.getCount(), mAdapter.getCount()), AppMsg.STYLE_INFO ).show(); - } else if(error instanceof KeyServer.InsufficientQuery) { + } else if (error instanceof KeyServer.InsufficientQuery) { AppMsg.makeText(getActivity(), R.string.error_keyserver_insufficient_query, AppMsg.STYLE_ALERT).show(); - } else if(error instanceof KeyServer.QueryException) { + } else if (error instanceof KeyServer.QueryException) { AppMsg.makeText(getActivity(), R.string.error_keyserver_query, AppMsg.STYLE_ALERT).show(); - } else if(error instanceof KeyServer.TooManyResponses) { + } else if (error instanceof KeyServer.TooManyResponses) { AppMsg.makeText(getActivity(), R.string.error_keyserver_too_many_responses, AppMsg.STYLE_ALERT).show(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java index 83af8cf48..44b5848d8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java @@ -17,8 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.R; - import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -26,8 +24,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.R; public class ImportKeysNFCFragment extends Fragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java index ee91b2434..10c0752b1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java @@ -17,14 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.ArrayList; -import java.util.Locale; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4; -import org.sufficientlysecure.keychain.util.Log; - import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -36,9 +28,15 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; - import com.beardedhen.androidbootstrap.BootstrapButton; import com.google.zxing.integration.android.IntentResult; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.ArrayList; +import java.util.Locale; public class ImportKeysQrCodeFragment extends Fragment { @@ -94,45 +92,45 @@ public class ImportKeysQrCodeFragment extends Fragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode & 0xFFFF) { - case IntentIntegratorSupportV4.REQUEST_CODE: { - IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode, - resultCode, data); - if (scanResult != null && scanResult.getFormatName() != null) { - String scannedContent = scanResult.getContents(); - - Log.d(Constants.TAG, "scannedContent: " + scannedContent); - - // look if it's fingerprint only - if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { - importFingerprint(Uri.parse(scanResult.getContents())); - return; + case IntentIntegratorSupportV4.REQUEST_CODE: { + IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode, + resultCode, data); + if (scanResult != null && scanResult.getFormatName() != null) { + String scannedContent = scanResult.getContents(); + + Log.d(Constants.TAG, "scannedContent: " + scannedContent); + + // look if it's fingerprint only + if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { + importFingerprint(Uri.parse(scanResult.getContents())); + return; + } + + // look if it is the whole key + String[] parts = scannedContent.split(","); + if (parts.length == 3) { + importParts(parts); + return; + } + + // is this a full key encoded as qr code? + if (scannedContent.startsWith("-----BEGIN PGP")) { + mImportActivity.loadCallback(scannedContent.getBytes(), null, null, null); + return; + } + + // fail... + Toast.makeText(getActivity(), R.string.import_qr_code_wrong, Toast.LENGTH_LONG) + .show(); } - // look if it is the whole key - String[] parts = scannedContent.split(","); - if (parts.length == 3) { - importParts(parts); - return; - } - - // is this a full key encoded as qr code? - if (scannedContent.startsWith("-----BEGIN PGP")) { - mImportActivity.loadCallback(scannedContent.getBytes(), null, null, null); - return; - } - - // fail... - Toast.makeText(getActivity(), R.string.import_qr_code_wrong, Toast.LENGTH_LONG) - .show(); + break; } - break; - } - - default: - super.onActivityResult(requestCode, resultCode, data); + default: + super.onActivityResult(requestCode, resultCode, data); - break; + break; } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java index d77015aa7..f2449fae1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java @@ -17,11 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.util.Log; - import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -36,8 +31,11 @@ import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.Preferences; +import org.sufficientlysecure.keychain.util.Log; public class ImportKeysServerFragment extends Fragment { public static final String ARG_QUERY = "query"; 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 684ee6959..a70688cdf 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 @@ -17,15 +17,14 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ExportHelper; - import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ExportHelper; public class KeyListActivity extends DrawerActivity { 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 70ffe968d..6230abbed 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 @@ -17,27 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.HashMap; -import java.util.ArrayList; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.helper.ExportHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; -import org.sufficientlysecure.keychain.provider.KeychainDatabase; -import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter; -import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; -import org.sufficientlysecure.keychain.util.Log; - -import se.emilsjolander.stickylistheaders.ApiLevelTooLowException; -import se.emilsjolander.stickylistheaders.StickyListHeadersListView; -import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; - import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; @@ -45,11 +24,7 @@ import android.content.Intent; import android.database.Cursor; import android.graphics.Color; import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; +import android.os.*; import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; @@ -58,23 +33,31 @@ import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.text.TextUtils; -import android.view.ActionMode; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; +import android.view.*; import android.view.View.OnClickListener; -import android.view.ViewGroup; import android.view.animation.AnimationUtils; import android.widget.AbsListView.MultiChoiceModeListener; -import android.widget.AdapterView; -import android.widget.Button; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - +import android.widget.*; import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ExportHelper; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; +import org.sufficientlysecure.keychain.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter; +import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; +import org.sufficientlysecure.keychain.util.Log; +import se.emilsjolander.stickylistheaders.ApiLevelTooLowException; +import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; +import se.emilsjolander.stickylistheaders.StickyListHeadersListView; + +import java.util.ArrayList; +import java.util.HashMap; /** * Public key list with sticky list headers. It does _not_ extend ListFragment because it uses @@ -566,8 +549,8 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL if (convertView == null) { holder = new HeaderViewHolder(); convertView = mInflater.inflate(R.layout.key_list_header, parent, false); - holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text); - holder.count = (TextView) convertView.findViewById(R.id.contacts_num); + holder.mText = (TextView) convertView.findViewById(R.id.stickylist_header_text); + holder.mCount = (TextView) convertView.findViewById(R.id.contacts_num); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); @@ -587,11 +570,11 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL { // set contact count int num = mCursor.getCount(); String contactsTotal = getResources().getQuantityString(R.plurals.n_contacts, num, num); - holder.count.setText(contactsTotal); - holder.count.setVisibility(View.VISIBLE); + holder.mCount.setText(contactsTotal); + holder.mCount.setVisibility(View.VISIBLE); } - holder.text.setText(convertView.getResources().getString(R.string.my_keys)); + holder.mText.setText(convertView.getResources().getString(R.string.my_keys)); return convertView; } @@ -601,8 +584,8 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL if (userId != null && userId.length() > 0) { headerText = "" + mCursor.getString(KeyListFragment.INDEX_USER_ID).subSequence(0, 1).charAt(0); } - holder.text.setText(headerText); - holder.count.setVisibility(View.GONE); + holder.mText.setText(headerText); + holder.mCount.setVisibility(View.GONE); return convertView; } @@ -635,8 +618,8 @@ public class KeyListFragment extends Fragment implements SearchView.OnQueryTextL } class HeaderViewHolder { - TextView text; - TextView count; + TextView mText; + TextView mCount; } /** diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 2e8f25890..5660850b2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -16,6 +16,11 @@ package org.sufficientlysecure.keychain.ui; +import android.annotation.SuppressLint; +import android.content.Intent; +import android.os.Build; +import android.os.Bundle; +import android.preference.*; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; import org.sufficientlysecure.keychain.Constants; @@ -24,17 +29,6 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.ui.widget.IntegerListPreference; -import android.annotation.SuppressLint; -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.preference.CheckBoxPreference; -import android.preference.Preference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceFragment; -import android.preference.PreferenceScreen; -import android.support.v7.app.ActionBarActivity; - import java.util.List; @SuppressLint("NewApi") @@ -86,13 +80,13 @@ public class PreferencesActivity extends PreferenceActivity { initializeEncryptionAlgorithm( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM)); - int[] valueIds = new int[] { Id.choice.compression.none, Id.choice.compression.zip, - Id.choice.compression.zlib, Id.choice.compression.bzip2, }; - String[] entries = new String[] { + int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip, + Id.choice.compression.zlib, Id.choice.compression.bzip2,}; + String[] entries = new String[]{ getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")", "ZIP (" + getString(R.string.compression_fast) + ")", "ZLIB (" + getString(R.string.compression_fast) + ")", - "BZIP2 (" + getString(R.string.compression_very_slow) + ")", }; + "BZIP2 (" + getString(R.string.compression_very_slow) + ")",}; String[] values = new String[valueIds.length]; for (int i = 0; i < values.length; ++i) { values[i] = "" + valueIds[i]; @@ -100,15 +94,15 @@ public class PreferencesActivity extends PreferenceActivity { initializeHashAlgorithm( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_HASH_ALGORITHM), - valueIds, entries, values); + valueIds, entries, values); initializeMessageCompression( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_MESSAGE_COMPRESSION), - valueIds, entries, values); + valueIds, entries, values); initializeFileCompression( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION), - entries, values); + entries, values); initializeAsciiArmour((CheckBoxPreference) findPreference(Constants.pref.DEFAULT_ASCII_ARMOUR)); @@ -149,7 +143,9 @@ public class PreferencesActivity extends PreferenceActivity { loadHeadersFromResource(R.xml.preference_headers, target); } - /** This fragment shows the general preferences in android 3.0+ */ + /** + * This fragment shows the general preferences in android 3.0+ + */ public static class GeneralPrefsFragment extends PreferenceFragment { private PreferenceScreen mKeyServerPreference = null; @@ -204,7 +200,9 @@ public class PreferencesActivity extends PreferenceActivity { } } - /** This fragment shows the advanced preferences in android 3.0+ */ + /** + * This fragment shows the advanced preferences in android 3.0+ + */ public static class AdvancedPrefsFragment extends PreferenceFragment { @Override @@ -217,13 +215,13 @@ public class PreferencesActivity extends PreferenceActivity { initializeEncryptionAlgorithm( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_ENCRYPTION_ALGORITHM)); - int[] valueIds = new int[] { Id.choice.compression.none, Id.choice.compression.zip, - Id.choice.compression.zlib, Id.choice.compression.bzip2, }; - String[] entries = new String[] { + int[] valueIds = new int[]{Id.choice.compression.none, Id.choice.compression.zip, + Id.choice.compression.zlib, Id.choice.compression.bzip2,}; + String[] entries = new String[]{ getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")", "ZIP (" + getString(R.string.compression_fast) + ")", "ZLIB (" + getString(R.string.compression_fast) + ")", - "BZIP2 (" + getString(R.string.compression_very_slow) + ")", }; + "BZIP2 (" + getString(R.string.compression_very_slow) + ")",}; String[] values = new String[valueIds.length]; for (int i = 0; i < values.length; ++i) { values[i] = "" + valueIds[i]; @@ -231,11 +229,11 @@ public class PreferencesActivity extends PreferenceActivity { initializeHashAlgorithm( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_HASH_ALGORITHM), - valueIds, entries, values); + valueIds, entries, values); initializeMessageCompression( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_MESSAGE_COMPRESSION), - valueIds, entries, values); + valueIds, entries, values); initializeFileCompression( (IntegerListPreference) findPreference(Constants.pref.DEFAULT_FILE_COMPRESSION), @@ -247,7 +245,7 @@ public class PreferencesActivity extends PreferenceActivity { } } - protected boolean isValidFragment (String fragmentName) { + protected boolean isValidFragment(String fragmentName) { return AdvancedPrefsFragment.class.getName().equals(fragmentName) || GeneralPrefsFragment.class.getName().equals(fragmentName) || super.isValidFragment(fragmentName); @@ -268,12 +266,12 @@ public class PreferencesActivity extends PreferenceActivity { } private static void initializeEncryptionAlgorithm(final IntegerListPreference mEncryptionAlgorithm) { - int valueIds[] = { PGPEncryptedData.AES_128, PGPEncryptedData.AES_192, + int valueIds[] = {PGPEncryptedData.AES_128, PGPEncryptedData.AES_192, PGPEncryptedData.AES_256, PGPEncryptedData.BLOWFISH, PGPEncryptedData.TWOFISH, PGPEncryptedData.CAST5, PGPEncryptedData.DES, PGPEncryptedData.TRIPLE_DES, - PGPEncryptedData.IDEA, }; - String entries[] = { "AES-128", "AES-192", "AES-256", "Blowfish", "Twofish", "CAST5", - "DES", "Triple DES", "IDEA", }; + PGPEncryptedData.IDEA,}; + String entries[] = {"AES-128", "AES-192", "AES-256", "Blowfish", "Twofish", "CAST5", + "DES", "Triple DES", "IDEA",}; String values[] = new String[valueIds.length]; for (int i = 0; i < values.length; ++i) { values[i] = "" + valueIds[i]; @@ -296,11 +294,11 @@ public class PreferencesActivity extends PreferenceActivity { private static void initializeHashAlgorithm (final IntegerListPreference mHashAlgorithm, int[] valueIds, String[] entries, String[] values) { - valueIds = new int[] { HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160, + valueIds = new int[]{HashAlgorithmTags.MD5, HashAlgorithmTags.RIPEMD160, HashAlgorithmTags.SHA1, HashAlgorithmTags.SHA224, HashAlgorithmTags.SHA256, - HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512, }; - entries = new String[] { "MD5", "RIPEMD-160", "SHA-1", "SHA-224", "SHA-256", "SHA-384", - "SHA-512", }; + HashAlgorithmTags.SHA384, HashAlgorithmTags.SHA512,}; + entries = new String[]{"MD5", "RIPEMD-160", "SHA-1", "SHA-224", "SHA-256", "SHA-384", + "SHA-512",}; values = new String[valueIds.length]; for (int i = 0; i < values.length; ++i) { values[i] = "" + valueIds[i]; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java index 50fec1ffc..d890f35cb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java @@ -16,14 +16,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.Vector; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; -import org.sufficientlysecure.keychain.ui.widget.Editor; -import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; -import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor; - import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -33,6 +25,13 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.ui.widget.Editor; +import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; +import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor; + +import java.util.Vector; public class PreferencesKeyServerActivity extends ActionBarActivity implements OnClickListener, EditorListener { @@ -63,7 +62,8 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O // cancel cancelClicked(); } - }); + } + ); setContentView(R.layout.key_server_preference); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java index 3c63628f7..7efb43cce 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyActivity.java @@ -17,14 +17,13 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; - import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; public class SelectPublicKeyActivity extends ActionBarActivity { @@ -59,7 +58,8 @@ public class SelectPublicKeyActivity extends ActionBarActivity { // cancel cancelClicked(); } - }); + } + ); setContentView(R.layout.select_public_key_activity); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java index d320af451..7a30b11d2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -17,19 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.Date; -import java.util.Vector; - -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround; -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.provider.KeychainDatabase; -import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; -import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter; - import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; @@ -45,12 +32,19 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ProgressBar; -import android.widget.TextView; +import android.widget.*; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround; +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.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; +import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter; + +import java.util.Date; +import java.util.Vector; public class SelectPublicKeyFragment extends ListFragmentWorkaround implements TextWatcher, LoaderManager.LoaderCallbacks { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java index cd3b2cf78..1509bc88c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java @@ -17,14 +17,13 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; - import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.Menu; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; public class SelectSecretKeyActivity extends ActionBarActivity { @@ -90,7 +89,7 @@ public class SelectSecretKeyActivity extends ActionBarActivity { /** * This is executed by SelectSecretKeyFragment after clicking on an item - * + * * @param masterKeyId * @param userId */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 8ee2d381e..9b3541c81 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -17,17 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import java.util.Date; - -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -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.provider.KeychainDatabase; -import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; -import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter; - import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -39,6 +28,16 @@ import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +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.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; +import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter; + +import java.util.Date; public class SelectSecretKeyFragment extends ListFragment implements LoaderManager.LoaderCallbacks { @@ -46,9 +45,9 @@ public class SelectSecretKeyFragment extends ListFragment implements private SelectSecretKeyActivity mActivity; private SelectKeyCursorAdapter mAdapter; private ListView mListView; - + private boolean mFilterCertify; - + private static final String ARG_FILTER_CERTIFY = "filter_certify"; /** @@ -122,7 +121,7 @@ public class SelectSecretKeyFragment extends ListFragment implements // These are the rows that we will retrieve. long now = new Date().getTime() / 1000; - String[] projection = new String[] { + String[] projection = new String[]{ KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID, @@ -142,7 +141,7 @@ public class SelectSecretKeyFragment extends ListFragment implements + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY - + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,}; String orderBy = UserIds.USER_ID + " ASC"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index c9129285e..b1de85973 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -17,27 +17,22 @@ package org.sufficientlysecure.keychain.ui; -import org.spongycastle.openpgp.PGPSecretKey; -import org.spongycastle.openpgp.PGPSecretKeyRing; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper; - -import android.Manifest; import android.app.Activity; -import android.app.ActivityOptions; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper; public class SelectSecretKeyLayoutFragment extends Fragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java index 6f0aaa0f0..2c8f66488 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java @@ -17,13 +17,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.util.Log; - import android.app.ProgressDialog; import android.content.Intent; import android.net.Uri; @@ -36,8 +29,13 @@ import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.Preferences; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.util.Log; /** * Sends the selected public key to a keyserver @@ -59,7 +57,7 @@ public class UploadKeyActivity extends ActionBarActivity { ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Preferences.getPreferences(this) - .getKeyServers()); + .getKeyServers()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mKeyServerSpinner.setAdapter(adapter); if (adapter.getCount() > 0) { 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 581d14a22..2d47c7a92 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 @@ -29,7 +29,6 @@ import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -89,7 +88,7 @@ public class ViewKeyActivity extends ActionBarActivity { // given valid /public/ query long rowId = ProviderHelper.getRowId(this, getIntent().getData()); // TODO: handle (rowId == 0) with something else than a crash - mDataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)) ; + mDataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)); } Bundle mainBundle = new Bundle(); 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 59037d9ff..997ff9c7a 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 @@ -18,10 +18,6 @@ package org.sufficientlysecure.keychain.ui; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.ProviderHelper; - import android.annotation.TargetApi; import android.net.Uri; import android.nfc.NdefMessage; @@ -35,6 +31,9 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.ProviderHelper; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMessageCallback, @@ -66,7 +65,7 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess // get public keyring as byte array long masterKeyId = ProviderHelper.getMasterKeyId(this, dataUri); mSharedKeyringBytes = ProviderHelper.getKeyRingsAsByteArray(this, dataUri, - new long[] { masterKeyId }); + new long[]{masterKeyId}); // Register callback to set NDEF message mNfcAdapter.setNdefPushMessageCallback(this, this); @@ -109,10 +108,10 @@ public class ViewKeyActivityJB extends ViewKeyActivity implements CreateNdefMess @Override public void handleMessage(Message msg) { switch (msg.what) { - case NFC_SENT: - Toast.makeText(getApplicationContext(), R.string.nfc_successfull, Toast.LENGTH_LONG) - .show(); - break; + case NFC_SENT: + Toast.makeText(getApplicationContext(), R.string.nfc_successfull, Toast.LENGTH_LONG) + .show(); + break; } } }; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java index 36d3e6ace..a08492aa5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyCertsFragment.java @@ -24,9 +24,7 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; - import com.beardedhen.androidbootstrap.BootstrapButton; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.Log; 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 0e73ad983..a4a811bbc 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 @@ -29,16 +29,13 @@ import android.support.v4.content.Loader; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.format.DateFormat; -import android.text.style.BackgroundColorSpan; import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.OtherHelper; @@ -49,13 +46,11 @@ import org.sufficientlysecure.keychain.ui.adapter.ViewKeyKeysAdapter; import org.sufficientlysecure.keychain.ui.adapter.ViewKeyUserIdsAdapter; import org.sufficientlysecure.keychain.util.Log; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.Date; -public class ViewKeyMainFragment extends Fragment implements - LoaderManager.LoaderCallbacks{ +public class ViewKeyMainFragment extends Fragment implements + LoaderManager.LoaderCallbacks { public static final String ARG_DATA_URI = "uri"; @@ -130,7 +125,7 @@ public class ViewKeyMainFragment extends Fragment implements { // label whether secret key is available, and edit button if it is final long masterKeyId = ProviderHelper.getMasterKeyId(getActivity(), mDataUri); - if(ProviderHelper.hasSecretKeyByMasterKeyId(getActivity(), masterKeyId)) { + if (ProviderHelper.hasSecretKeyByMasterKeyId(getActivity(), masterKeyId)) { // set this attribute. this is a LITTLE unclean, but we have the info available // right here, so why not. mSecretKey.setTextColor(getResources().getColor(R.color.emphasis)); @@ -341,7 +336,7 @@ public class ViewKeyMainFragment extends Fragment implements g = Math.min(255, (int) (g * factor)); b = Math.min(255, (int) (b * factor)); - // If it is too light, then darken it to a respective maximal brightness. + // If it is too light, then darken it to a respective maximal brightness. } else if (brightness > 180) { double factor = 180.0 / brightness; r = (int) (r * factor); @@ -352,7 +347,7 @@ public class ViewKeyMainFragment extends Fragment implements // Create a foreground color with the 3 digest integers as RGB // and then converting that int to hex to use as a color sb.setSpan(new ForegroundColorSpan(Color.rgb(r, g, b)), - i, spanEnd, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + i, spanEnd, Spannable.SPAN_INCLUSIVE_INCLUSIVE); } } catch (Exception e) { Log.e(Constants.TAG, "Colorization failed", e); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/AsyncTaskResultWrapper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/AsyncTaskResultWrapper.java index 2ac19c1d9..0285deb2e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/AsyncTaskResultWrapper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/AsyncTaskResultWrapper.java @@ -22,14 +22,15 @@ package org.sufficientlysecure.keychain.ui.adapter; * You can pass the result and an exception in it if an error occurred. * Concept found at: * https://stackoverflow.com/questions/19593577/how-to-handle-errors-in-custom-asynctaskloader + * * @param - Typ of the result which is wrapped */ -public class AsyncTaskResultWrapper { +public class AsyncTaskResultWrapper { private final T result; private final Exception error; - public AsyncTaskResultWrapper(T result, Exception error){ + public AsyncTaskResultWrapper(T result, Exception error) { this.result = result; this.error = error; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java index fd7a2dc30..a3ed08a4c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/HighlightQueryCursorAdapter.java @@ -22,7 +22,6 @@ import android.database.Cursor; import android.support.v4.widget.CursorAdapter; import android.text.Spannable; import android.text.style.ForegroundColorSpan; - import org.sufficientlysecure.keychain.R; import java.util.regex.Matcher; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 4f7623bce..c0b6027cc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -17,12 +17,6 @@ package org.sufficientlysecure.keychain.ui.adapter; -import java.util.ArrayList; -import java.util.List; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; - import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; @@ -36,13 +30,19 @@ import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; + +import java.util.ArrayList; +import java.util.List; public class ImportKeysAdapter extends ArrayAdapter { protected LayoutInflater mInflater; protected Activity mActivity; protected List data; - static class ViewHolder{ + + static class ViewHolder { private TextView mainUserId; private TextView mainUserIdRest; private TextView keyId; @@ -51,6 +51,7 @@ public class ImportKeysAdapter extends ArrayAdapter { private TextView status; } + public ImportKeysAdapter(Activity activity) { super(activity, -1); mActivity = activity; @@ -95,7 +96,7 @@ public class ImportKeysAdapter extends ArrayAdapter { public View getView(int position, View convertView, ViewGroup parent) { ImportKeysListEntry entry = data.get(position); ViewHolder holder; - if(convertView == null) { + if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.import_keys_list_entry, null); holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId); @@ -105,9 +106,8 @@ public class ImportKeysAdapter extends ArrayAdapter { holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm); holder.status = (TextView) convertView.findViewById(R.id.status); convertView.setTag(holder); - } - else{ - holder = (ViewHolder)convertView.getTag(); + } else { + holder = (ViewHolder) convertView.getTag(); } // main user id String userId = entry.userIds.get(0); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index a52e9b447..fbfaa29fb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -19,12 +19,6 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.os.Parcel; import android.os.Parcelable; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; - import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKeyRing; @@ -33,6 +27,11 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; +import java.io.IOException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; + public class ImportKeysListEntry implements Serializable, Parcelable { private static final long serialVersionUID = -7797972103284992662L; public ArrayList userIds; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java index 3eca99f15..d7544d1bb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListLoader.java @@ -17,10 +17,8 @@ package org.sufficientlysecure.keychain.ui.adapter; -import java.io.BufferedInputStream; -import java.io.InputStream; -import java.util.ArrayList; - +import android.content.Context; +import android.support.v4.content.AsyncTaskLoader; import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPObjectFactory; import org.spongycastle.openpgp.PGPUtil; @@ -29,8 +27,9 @@ import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.PositionAwareInputStream; -import android.content.Context; -import android.support.v4.content.AsyncTaskLoader; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.util.ArrayList; public class ImportKeysListLoader extends AsyncTaskLoader>> { @@ -40,9 +39,11 @@ public class ImportKeysListLoader extends AsyncTaskLoader> (data, new FileHasNoContent()); } - if(nonPgpCounter > 0) { + if (nonPgpCounter > 0) { entryListWrapper = new AsyncTaskResultWrapper> (data, new NonPgpPart(nonPgpCounter)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java index 3a3b6e58b..0e1b83c81 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java @@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.support.v4.content.AsyncTaskLoader; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.KeyServer; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java index 78f7b1f7e..0a1dca751 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java @@ -17,15 +17,11 @@ package org.sufficientlysecure.keychain.ui.adapter; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; - import android.content.Context; import android.widget.ArrayAdapter; +import java.util.*; + public class KeyValueSpinnerAdapter extends ArrayAdapter { private final HashMap mData; private final int[] mKeys; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java index 6d67a0e65..eaaa54376 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java @@ -17,12 +17,6 @@ package org.sufficientlysecure.keychain.ui.adapter; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; - import android.content.Context; import android.database.Cursor; import android.view.LayoutInflater; @@ -31,7 +25,11 @@ import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; - +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter { @@ -50,7 +48,7 @@ public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter { public final static String PROJECTION_ROW_VALID = "valid"; public SelectKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView, - int keyType) { + int keyType) { super(context, c, flags); mInflater = LayoutInflater.from(context); @@ -69,7 +67,7 @@ public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter { /** * Get column indexes for performance reasons just once in constructor and swapCursor. For a * performance comparison see http://stackoverflow.com/a/17999582 - * + * * @param cursor */ private void initIndex(Cursor cursor) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 046a98883..153a3f266 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.ui.adapter; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; - import android.content.Context; import android.database.Cursor; import android.support.v4.widget.CursorAdapter; @@ -29,6 +25,9 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; public class ViewKeyKeysAdapter extends CursorAdapter { private LayoutInflater mInflater; @@ -59,7 +58,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { /** * Get column indexes for performance reasons just once in constructor and swapCursor. For a * performance comparison see http://stackoverflow.com/a/17999582 - * + * * @param cursor */ private void initIndex(Cursor cursor) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java index cf8699417..3ba291c3d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java @@ -17,9 +17,6 @@ package org.sufficientlysecure.keychain.ui.adapter; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; - import android.content.Context; import android.database.Cursor; import android.support.v4.widget.CursorAdapter; @@ -27,6 +24,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; public class ViewKeyUserIdsAdapter extends CursorAdapter { private LayoutInflater mInflater; @@ -51,7 +50,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { /** * Get column indexes for performance reasons just once in constructor and swapCursor. For a * performance comparison see http://stackoverflow.com/a/17999582 - * + * * @param cursor */ private void initIndex(Cursor cursor) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java index 2b8cba857..20b70658c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/BadImportKeyDialogFragment.java @@ -23,7 +23,6 @@ import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; - import org.sufficientlysecure.keychain.R; public class BadImportKeyDialogFragment extends DialogFragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java index a47601c9b..140a33641 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java @@ -27,13 +27,11 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Spinner; - import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.Choice; import java.util.ArrayList; -import java.util.Vector; public class CreateKeyDialogFragment extends DialogFragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index 162bf32fd..7f0c295ad 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; - import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; @@ -32,6 +28,9 @@ import android.os.Messenger; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.widget.Toast; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; public class DeleteFileDialogFragment extends DialogFragment { private static final String ARG_DELETE_FILE = "delete_file"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index dc40bab2a..c6751ec58 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -28,7 +28,6 @@ import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -118,7 +117,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { String selectionIDs = ""; for (int i = 0; i < keyRingRowIds.length; i++) { selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; - if (i+1 < keyRingRowIds.length) + if (i + 1 < keyRingRowIds.length) selectionIDs += ","; } selection += selectionIDs + ")"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java index 2a3a7508d..a4285c8e9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FileDialogFragment.java @@ -17,11 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.FileHelper; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -38,8 +33,11 @@ import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.FileHelper; +import org.sufficientlysecure.keychain.util.Log; public class FileDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; @@ -66,7 +64,7 @@ public class FileDialogFragment extends DialogFragment { * Creates new instance of this file dialog fragment */ public static FileDialogFragment newInstance(Messenger messenger, String title, String message, - String defaultFile, String checkboxText) { + String defaultFile, String checkboxText) { FileDialogFragment frag = new FileDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_MESSENGER, messenger); @@ -176,34 +174,33 @@ public class FileDialogFragment extends DialogFragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode & 0xFFFF) { - case REQUEST_CODE: { - if (resultCode == Activity.RESULT_OK && data != null) { - try { - String path = data.getData().getPath(); - Log.d(Constants.TAG, "path=" + path); - - // set filename used in export/import dialogs - setFilename(path); - } catch (NullPointerException e) { - Log.e(Constants.TAG, "Nullpointer while retrieving path!", e); + case REQUEST_CODE: { + if (resultCode == Activity.RESULT_OK && data != null) { + try { + String path = data.getData().getPath(); + Log.d(Constants.TAG, "path=" + path); + + // set filename used in export/import dialogs + setFilename(path); + } catch (NullPointerException e) { + Log.e(Constants.TAG, "Nullpointer while retrieving path!", e); + } } - } - break; - } + break; + } - default: - super.onActivityResult(requestCode, resultCode, data); + default: + super.onActivityResult(requestCode, resultCode, data); - break; + break; } } /** * Send message back to handler which is initialized in a activity - * - * @param what - * Message integer you want to send + * + * @param what Message integer you want to send */ private void sendMessageToHandler(Integer what, Bundle data) { Message msg = Message.obtain(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java index afa05cc91..fa74cbdc6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java @@ -17,20 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import org.spongycastle.openpgp.PGPException; -import org.spongycastle.openpgp.PGPPrivateKey; -import org.spongycastle.openpgp.PGPSecretKey; -import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; -import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -52,6 +38,19 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPPrivateKey; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; +import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.util.Log; public class PassphraseDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -66,16 +65,14 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor /** * Creates new instance of this dialog fragment - * - * @param secretKeyId - * secret key id you want to use - * @param messenger - * to communicate back after caching the passphrase + * + * @param secretKeyId secret key id you want to use + * @param messenger to communicate back after caching the passphrase * @return * @throws PgpGeneralException */ public static PassphraseDialogFragment newInstance(Context context, Messenger messenger, - long secretKeyId) throws PgpGeneralException { + long secretKeyId) throws PgpGeneralException { // check if secret key has a passphrase if (!(secretKeyId == Id.key.symmetric || secretKeyId == Id.key.none)) { if (!PassphraseCacheService.hasPassphrase(context, secretKeyId)) { @@ -171,7 +168,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor Toast.makeText(activity, R.string.error_could_not_extract_private_key, Toast.LENGTH_SHORT).show(); - + sendMessageToHandler(MESSAGE_CANCEL); return; } else { @@ -187,14 +184,14 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor } catch (PGPException e) { Toast.makeText(activity, R.string.wrong_passphrase, Toast.LENGTH_SHORT).show(); - + sendMessageToHandler(MESSAGE_CANCEL); return; } } else { Toast.makeText(activity, R.string.error_could_not_extract_private_key, Toast.LENGTH_SHORT).show(); - + sendMessageToHandler(MESSAGE_CANCEL); return; // ran out of keys to try } @@ -207,7 +204,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor // cache the new passphrase Log.d(Constants.TAG, "Everything okay! Caching entered passphrase"); PassphraseCacheService.addCachedPassphrase(activity, keyId, passphrase); - if ( !keyOK && clickSecretKey.getKeyID() != keyId) { + if (!keyOK && clickSecretKey.getKeyID() != keyId) { PassphraseCacheService.addCachedPassphrase(activity, clickSecretKey.getKeyID(), passphrase); } @@ -265,9 +262,8 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor /** * Send message back to handler which is initialized in a activity - * - * @param what - * Message integer you want to send + * + * @param what Message integer you want to send */ private void sendMessageToHandler(Integer what) { Message msg = Message.obtain(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java index b7a1882ef..062eca3e5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java @@ -26,7 +26,6 @@ import android.content.DialogInterface.OnKeyListener; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.KeyEvent; - import org.sufficientlysecure.keychain.R; public class ProgressDialogFragment extends DialogFragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java index e406547b3..69723b804 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/SetPassphraseDialogFragment.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -40,6 +36,9 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class SetPassphraseDialogFragment extends DialogFragment implements OnEditorActionListener { private static final String ARG_MESSENGER = "messenger"; @@ -55,11 +54,9 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi /** * Creates new instance of this dialog fragment - * - * @param title - * title of dialog - * @param messenger - * to communicate back after setting the passphrase + * + * @param title title of dialog + * @param messenger to communicate back after setting the passphrase * @return */ public static SetPassphraseDialogFragment newInstance(Messenger messenger, int title) { @@ -96,7 +93,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi mPassphraseAgainEditText = (EditText) view.findViewById(R.id.passphrase_passphrase_again); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - + @Override public void onClick(DialogInterface dialog, int id) { dismiss(); @@ -130,7 +127,7 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - + @Override public void onClick(DialogInterface dialog, int id) { dismiss(); @@ -168,9 +165,8 @@ public class SetPassphraseDialogFragment extends DialogFragment implements OnEdi /** * Send message back to handler which is initialized in a activity - * - * @param what - * Message integer you want to send + * + * @param what Message integer you want to send */ private void sendMessageToHandler(Integer what, Bundle data) { Message msg = Message.obtain(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java index b850638a6..6b4de0334 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareNfcDialogFragment.java @@ -17,9 +17,6 @@ package org.sufficientlysecure.keychain.ui.dialog; -import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.keychain.R; - import android.annotation.TargetApi; import android.app.AlertDialog; import android.app.Dialog; @@ -31,6 +28,8 @@ import android.os.Bundle; import android.provider.Settings; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; +import org.sufficientlysecure.htmltextview.HtmlTextView; +import org.sufficientlysecure.keychain.R; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public class ShareNfcDialogFragment extends DialogFragment { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java index f26cd35c0..b501ba230 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java @@ -28,7 +28,6 @@ import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; - import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java index b9dcd0d25..6245fd95c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FixedListView.java @@ -24,7 +24,7 @@ import android.widget.ListView; /** * Automatically calculate height of ListView based on contained items. This enables to put this * ListView into a ScrollView without messing up. - * + *

* from * http://stackoverflow.com/questions/2419246/how-do-i-create-a-listview-thats-not-in-a-scrollview- * or-has-the-scrollview-dis diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/IntegerListPreference.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/IntegerListPreference.java index bc60b2adf..6e1e4c678 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/IntegerListPreference.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/IntegerListPreference.java @@ -25,7 +25,7 @@ import android.util.AttributeSet; * values should use {@link android.content.SharedPreferences#getInt}. When using XML-declared * arrays for entry values, the arrays should be regular string arrays containing valid integer * values. - * + * * @author Rodrigo Damazio */ public class IntegerListPreference extends ListPreference { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 9f25fac42..0d15de982 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -16,20 +16,6 @@ package org.sufficientlysecure.keychain.ui.widget; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; -import java.util.Vector; - -import org.spongycastle.openpgp.PGPPublicKey; -import org.spongycastle.openpgp.PGPSecretKey; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.util.Choice; - import android.annotation.TargetApi; import android.app.DatePickerDialog; import android.app.Dialog; @@ -40,13 +26,17 @@ import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.DatePicker; -import android.widget.LinearLayout; -import android.widget.Spinner; -import android.widget.TextView; - +import android.widget.*; import com.beardedhen.androidbootstrap.BootstrapButton; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPSecretKey; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.util.Choice; + +import java.text.DateFormat; +import java.util.*; public class KeyEditor extends LinearLayout implements Editor, OnClickListener { private PGPSecretKey mKey; @@ -99,7 +89,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { new Choice(Id.choice.usage.encrypt_only, getResources().getString( R.string.choice_encrypt_only)), new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( - R.string.choice_sign_and_encrypt)), }; + R.string.choice_sign_and_encrypt)),}; ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); @@ -144,11 +134,11 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { dialog.getDatePicker().setCalendarViewShown(false); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - if ( dialog != null && mCreatedDate != null ) { - dialog.getDatePicker().setMinDate(mCreatedDate.getTime().getTime()+ DateUtils.DAY_IN_MILLIS); + if (dialog != null && mCreatedDate != null) { + dialog.getDatePicker().setMinDate(mCreatedDate.getTime().getTime() + DateUtils.DAY_IN_MILLIS); } else { //When created date isn't available - dialog.getDatePicker().setMinDate(date.getTime().getTime()+ DateUtils.DAY_IN_MILLIS); + dialog.getDatePicker().setMinDate(date.getTime().getTime() + DateUtils.DAY_IN_MILLIS); } } @@ -290,6 +280,7 @@ class ExpiryDatePickerDialog extends DatePickerDialog { public ExpiryDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) { super(context, callBack, year, monthOfYear, dayOfMonth); } + //Set permanent title. public void setTitle(CharSequence title) { super.setTitle(getContext().getString(R.string.expiry_date_dialog_title)); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java index 01259ccd1..f92c7532a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java @@ -16,8 +16,6 @@ package org.sufficientlysecure.keychain.ui.widget; -import org.sufficientlysecure.keychain.R; - import android.content.Context; import android.util.AttributeSet; import android.view.View; @@ -25,8 +23,8 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.R; public class KeyServerEditor extends LinearLayout implements Editor, OnClickListener { private EditorListener mEditorListener = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 0acfe13bc..d6e44ee4e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -31,9 +31,7 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; - import com.beardedhen.androidbootstrap.BootstrapButton; - import org.spongycastle.openpgp.PGPSecretKey; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UnderlineTextView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UnderlineTextView.java index 752d44f89..937a48e48 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UnderlineTextView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UnderlineTextView.java @@ -26,7 +26,7 @@ import android.widget.TextView; /** * Copied from StickyListHeaders lib example - * + * * @author Eric Frohnhoefer */ public class UnderlineTextView extends TextView { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 71cd89ae8..039e87446 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -16,21 +16,19 @@ package org.sufficientlysecure.keychain.ui.widget; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import android.widget.*; -import org.sufficientlysecure.keychain.R; - import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; - +import android.widget.*; import com.beardedhen.androidbootstrap.BootstrapButton; +import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ContactHelper; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + public class UserIdEditor extends LinearLayout implements Editor, OnClickListener { private EditorListener mEditorListener = null; @@ -109,7 +107,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mEmail.setAdapter( new ArrayAdapter (this.getContext(), android.R.layout.simple_dropdown_item_1line, - ContactHelper.getMailAccounts(getContext()) + ContactHelper.getMailAccounts(getContext()) )); super.onFinishInflate(); -- cgit v1.2.3 From ba9a4bec3a12332634772baaba9d68c5a68772f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 13 Mar 2014 20:11:21 +0100 Subject: Improve list item view, borderless button for API < 11 --- .../res/drawable/selector_transparent_button.xml | 7 ++ .../src/main/res/layout/key_list_item.xml | 121 ++++++++++++--------- .../layout/select_secret_key_layout_fragment.xml | 2 +- OpenPGP-Keychain/src/main/res/values/colors.xml | 3 +- 4 files changed, 78 insertions(+), 55 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/drawable/selector_transparent_button.xml (limited to 'OpenPGP-Keychain/src') diff --git a/OpenPGP-Keychain/src/main/res/drawable/selector_transparent_button.xml b/OpenPGP-Keychain/src/main/res/drawable/selector_transparent_button.xml new file mode 100644 index 000000000..6675a5c70 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/drawable/selector_transparent_button.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml index f52693138..3f1b25cc0 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml @@ -1,63 +1,78 @@ - - - - - -