From 3efaac2175d5b971e83bf4322d221bcde80157dc Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 17 Feb 2015 18:08:45 +0100 Subject: determine correct filesize during decryption from LiteralData packet --- .../keychain/operations/results/OperationResult.java | 1 + .../sufficientlysecure/keychain/pgp/PgpDecryptVerify.java | 12 +++++------- OpenKeychain/src/main/res/values/strings.xml | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java index 078eb7354..ec26d4bbe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java @@ -555,6 +555,7 @@ public abstract class OperationResult implements Parcelable { MSG_DC_CLEAR_META_FILE (LogLevel.DEBUG, R.string.msg_dc_clear_meta_file), MSG_DC_CLEAR_META_MIME (LogLevel.DEBUG, R.string.msg_dc_clear_meta_mime), MSG_DC_CLEAR_META_SIZE (LogLevel.DEBUG, R.string.msg_dc_clear_meta_size), + MSG_DC_CLEAR_META_SIZE_UNKNOWN (LogLevel.DEBUG, R.string.msg_dc_clear_meta_size_unknown), MSG_DC_CLEAR_META_TIME (LogLevel.DEBUG, R.string.msg_dc_clear_meta_time), MSG_DC_CLEAR (LogLevel.DEBUG, R.string.msg_dc_clear), MSG_DC_CLEAR_SIGNATURE_BAD (LogLevel.WARN, R.string.msg_dc_clear_signature_bad), diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index ad9b1900e..e7ab05261 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -540,12 +540,8 @@ public class PgpDecryptVerify extends BaseOperation { PGPLiteralData literalData = (PGPLiteralData) dataChunk; - // TODO: how to get the real original size? // this is the encrypted size so if we enable compression this value is wrong! - long originalSize = mData.getSize() - mData.getStreamPosition(); - if (originalSize < 0) { - originalSize = 0; - } + Long originalSize = literalData.getDataLengthIfAvailable(); String originalFilename = literalData.getFileName(); String mimeType = null; @@ -573,7 +569,7 @@ public class PgpDecryptVerify extends BaseOperation { originalFilename, mimeType, literalData.getModificationTime().getTime(), - originalSize); + originalSize == null ? 0 : originalSize); if (!originalFilename.equals("")) { log.add(LogType.MSG_DC_CLEAR_META_FILE, indent + 1, originalFilename); @@ -582,9 +578,11 @@ public class PgpDecryptVerify extends BaseOperation { mimeType); log.add(LogType.MSG_DC_CLEAR_META_TIME, indent + 1, new Date(literalData.getModificationTime().getTime()).toString()); - if (originalSize != 0) { + if (originalSize != null) { log.add(LogType.MSG_DC_CLEAR_META_SIZE, indent + 1, Long.toString(originalSize)); + } else { + log.add(LogType.MSG_DC_CLEAR_META_SIZE_UNKNOWN, indent + 1); } // return here if we want to decrypt the metadata only diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index e01f1c049..c2a44f0f9 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -935,6 +935,7 @@ "Filename: %s" "MIME type: %s" "Filesize: %s" + "Filesize is unknown" "Modification time: %s" "Signature check NOT OK!" "Verifying signature data" -- cgit v1.2.3 From bb30cb540123577e87c313f71b460482be3e287c Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Tue, 17 Feb 2015 18:43:43 +0100 Subject: fix comments and some warnings in PgpDecryptVerify --- .../sufficientlysecure/keychain/pgp/PgpDecryptVerify.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index e7ab05261..2ee923e42 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -160,9 +160,6 @@ public class PgpDecryptVerify extends BaseOperation { /** * If detachedSignature != null, it will be used exclusively to verify the signature - * - * @param detachedSignature - * @return */ public Builder setDetachedSignature(byte[] detachedSignature) { mDetachedSignature = detachedSignature; @@ -540,7 +537,7 @@ public class PgpDecryptVerify extends BaseOperation { PGPLiteralData literalData = (PGPLiteralData) dataChunk; - // this is the encrypted size so if we enable compression this value is wrong! + // reported size may be null if partial packets are involved (highly unlikely though) Long originalSize = literalData.getDataLengthIfAvailable(); String originalFilename = literalData.getFileName(); @@ -571,7 +568,7 @@ public class PgpDecryptVerify extends BaseOperation { literalData.getModificationTime().getTime(), originalSize == null ? 0 : originalSize); - if (!originalFilename.equals("")) { + if (!"".equals(originalFilename)) { log.add(LogType.MSG_DC_CLEAR_META_FILE, indent + 1, originalFilename); } log.add(LogType.MSG_DC_CLEAR_META_MIME, indent + 1, @@ -631,9 +628,8 @@ public class PgpDecryptVerify extends BaseOperation { progress = 100; } progressScaler.setProgress((int) progress, 100); - } else { - // TODO: slow annealing to fake a progress? } + // TODO: slow annealing to fake a progress? } if (signature != null) { @@ -849,9 +845,8 @@ public class PgpDecryptVerify extends BaseOperation { progress = 100; } progressScaler.setProgress((int) progress, 100); - } else { - // TODO: slow annealing to fake a progress? } + // TODO: slow annealing to fake a progress? } updateProgress(R.string.progress_verifying_signature, 90, 100); -- cgit v1.2.3 From 9d7e05c06ea485725389768c83eade445f5ecbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 20 Feb 2015 11:04:07 +0100 Subject: Screenshot for GSoC --- .../java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java | 2 +- OpenKeychain/src/main/res/menu/key_list.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java index d82e1c246..1bb8a9fb4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java @@ -39,7 +39,7 @@ public abstract class NavDrawerActivity extends MaterialNavigationDrawer { setDrawerHeaderImage(R.drawable.drawer_header); // create sections - addSection(newSection(getString(R.string.title_keys), R.drawable.ic_vpn_key_black_24dp, new KeyListFragment())); + addSection(newSection(getString(R.string.app_name), R.drawable.ic_vpn_key_black_24dp, new KeyListFragment())); addSection(newSection(getString(R.string.nav_encrypt_decrypt), R.drawable.ic_lock_black_24dp, new EncryptDecryptOverviewFragment())); addSection(newSection(getString(R.string.title_api_registered_apps), R.drawable.ic_apps_black_24dp, new AppsListFragment())); diff --git a/OpenKeychain/src/main/res/menu/key_list.xml b/OpenKeychain/src/main/res/menu/key_list.xml index 8a682badc..fef449463 100644 --- a/OpenKeychain/src/main/res/menu/key_list.xml +++ b/OpenKeychain/src/main/res/menu/key_list.xml @@ -13,12 +13,12 @@ android:id="@+id/menu_key_list_search_cloud" android:icon="@drawable/ic_cloud_search_24px" android:title="@string/menu_search_cloud" - app:showAsAction="ifRoom|withText" /> + app:showAsAction="never" /> + app:showAsAction="never" /> Date: Sat, 21 Feb 2015 20:01:19 +0100 Subject: Status bar height fix --- OpenKeychain/src/main/res/layout/api_app_settings_activity.xml | 2 +- OpenKeychain/src/main/res/layout/first_time_activity.xml | 2 +- OpenKeychain/src/main/res/layout/toolbar_standalone.xml | 6 +++++- OpenKeychain/src/main/res/values-v21/dimens.xml | 8 ++++++-- OpenKeychain/src/main/res/values/dimens.xml | 3 ++- OpenKeychain/src/main/res/values/themes.xml | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml index c7b8c9b3a..253836080 100644 --- a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml +++ b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml @@ -18,7 +18,7 @@ + android:layout_height="@dimen/statusbar_height" /> + - 21dp - + + 24dp + 141dp \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/dimens.xml b/OpenKeychain/src/main/res/values/dimens.xml index 21ef110ea..7e361a358 100644 --- a/OpenKeychain/src/main/res/values/dimens.xml +++ b/OpenKeychain/src/main/res/values/dimens.xml @@ -1,5 +1,6 @@ - 0dp + + 0dp 120dp \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/themes.xml b/OpenKeychain/src/main/res/values/themes.xml index f1d1ea490..885d5e682 100644 --- a/OpenKeychain/src/main/res/values/themes.xml +++ b/OpenKeychain/src/main/res/values/themes.xml @@ -4,7 +4,7 @@ diff --git a/OpenKeychain/src/main/res/values/themes.xml b/OpenKeychain/src/main/res/values/themes.xml index 147bd8d4c..da616492c 100644 --- a/OpenKeychain/src/main/res/values/themes.xml +++ b/OpenKeychain/src/main/res/values/themes.xml @@ -12,12 +12,14 @@ true false + + true @style/MySearchViewStyle @integer/DRAWERTYPE_IMAGE - @style/ThemeOverlay.AppCompat.Dark.ActionBar + @style/ThemeOverlay.AppCompat.Dark @style/ThemeOverlay.AppCompat.Light #fafafa -- cgit v1.2.3 From d984f50cb77db4fe8d1eae17c669673a3380bb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 22 Feb 2015 23:55:23 +0100 Subject: Disable default yubikey PIN by default --- .../src/main/java/org/sufficientlysecure/keychain/util/Preferences.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java index 8d4af58d7..a36af5c87 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java @@ -172,7 +172,7 @@ public class Preferences { } public boolean useDefaultYubikeyPin() { - return mSharedPreferences.getBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, true); + return mSharedPreferences.getBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, false); } public void setUseDefaultYubikeyPin(boolean useDefaultYubikeyPin) { -- cgit v1.2.3 From 4e8c4af262ebe838cdbe848c40588f4bcc4a4d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 00:11:06 +0100 Subject: Update tab lib and fix colors of tabs --- OpenKeychain/src/main/res/layout/help_activity.xml | 5 +++-- OpenKeychain/src/main/res/layout/view_key_activity.xml | 5 +++-- OpenKeychain/src/main/res/values/colors.xml | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/res/layout/help_activity.xml b/OpenKeychain/src/main/res/layout/help_activity.xml index 6a78aa273..1722f03ea 100644 --- a/OpenKeychain/src/main/res/layout/help_activity.xml +++ b/OpenKeychain/src/main/res/layout/help_activity.xml @@ -20,8 +20,9 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" - android:textColor="#FFFFFF" - app:pstsIndicatorColor="#FFFFFF" /> + android:textColor="@color/tab_text" + app:pstsTextColorSelected="@color/tab_text_selected" + app:pstsIndicatorColor="@color/tab_indicator" /> + android:textColor="@color/tab_text" + app:pstsTextColorSelected="@color/tab_text_selected" + app:pstsIndicatorColor="@color/tab_indicator" /> #33999999 #33CCCCCC + + #70FFFFFF + #FFFFFF + #FFFFFF + #B2000000 -- cgit v1.2.3 From 6b57afc350996484256d85b862c284788b9f3f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 00:17:27 +0100 Subject: Removed submodule android-lockpattern --- .../android/lockpattern/LockPatternFragment.java | 55 -- .../lockpattern/LockPatternFragmentOld.java | 926 --------------------- 2 files changed, 981 deletions(-) delete mode 100644 OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragment.java delete mode 100644 OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragmentOld.java (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragment.java b/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragment.java deleted file mode 100644 index 318a7c2e5..000000000 --- a/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragment.java +++ /dev/null @@ -1,55 +0,0 @@ - - -package com.haibison.android.lockpattern; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import com.haibison.android.lockpattern.widget.LockPatternUtils; -import com.haibison.android.lockpattern.widget.LockPatternView; - - -public class LockPatternFragment extends Fragment { - public static final String NUMBER_OF_MEASUREMENTS = "number_of_measurements"; - public static final String PATTERN_STRING = "pattern_string"; - - private String mPatternString; - private LockPatternView.OnPatternListener mEvents; - - public static LockPatternFragment newInstance(String pattern) { - LockPatternFragment fragment = new LockPatternFragment(); - Bundle args = new Bundle(); - args.putString(PATTERN_STRING, pattern); - fragment.setArguments(args); - return fragment; - } - - public LockPatternFragment() { - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - - mEvents = (LockPatternView.OnPatternListener) activity; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Get the number of measurements from the bundle, or load the default: - mPatternString = getArguments().getString(PATTERN_STRING); - - View rootView = inflater.inflate(R.layout.alp_42447968_lock_pattern_activity, container, false); - - final LockPatternView lpv = (LockPatternView) rootView.findViewById(R.id.alp_42447968_view_lock_pattern); - lpv.setPattern(LockPatternView.DisplayMode.Correct, LockPatternUtils.stringToPattern(mPatternString)); - - lpv.setOnPatternListener(mEvents); - - return rootView; - } -} diff --git a/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragmentOld.java b/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragmentOld.java deleted file mode 100644 index 439cf3562..000000000 --- a/OpenKeychain/src/main/java/com/haibison/android/lockpattern/LockPatternFragmentOld.java +++ /dev/null @@ -1,926 +0,0 @@ -/* - * Copyright 2012 Hai Bison - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use getActivity() file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.haibison.android.lockpattern; - -import android.app.Activity; -import android.app.PendingIntent; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.ResultReceiver; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.text.TextUtils; -import android.text.format.DateUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.widget.Button; -import android.widget.TextView; -import android.widget.Toast; - -import com.haibison.android.lockpattern.util.IEncrypter; -import com.haibison.android.lockpattern.util.InvalidEncrypterException; -import com.haibison.android.lockpattern.util.LoadingDialog; -import com.haibison.android.lockpattern.util.Settings; -import com.haibison.android.lockpattern.util.UI; -import com.haibison.android.lockpattern.widget.LockPatternUtils; -import com.haibison.android.lockpattern.widget.LockPatternView; -import com.haibison.android.lockpattern.widget.LockPatternView.Cell; -import com.haibison.android.lockpattern.widget.LockPatternView.DisplayMode; - -import org.sufficientlysecure.keychain.ui.PassphraseWizardActivity; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static com.haibison.android.lockpattern.util.Settings.Display.METADATA_CAPTCHA_WIRED_DOTS; -import static com.haibison.android.lockpattern.util.Settings.Display.METADATA_MAX_RETRIES; -import static com.haibison.android.lockpattern.util.Settings.Display.METADATA_MIN_WIRED_DOTS; -import static com.haibison.android.lockpattern.util.Settings.Display.METADATA_STEALTH_MODE; -import static com.haibison.android.lockpattern.util.Settings.Security.METADATA_AUTO_SAVE_PATTERN; -import static com.haibison.android.lockpattern.util.Settings.Security.METADATA_ENCRYPTER_CLASS; - -/** - * Main activity for getActivity() library. - *

- * You can deliver result to {@link android.app.PendingIntent}'s and/ or - * {@link android.os.ResultReceiver} too. See {@link #EXTRA_PENDING_INTENT_OK}, - * {@link #EXTRA_PENDING_INTENT_CANCELLED} and {@link #EXTRA_RESULT_RECEIVER} - * for more details. - *

- * - *

NOTES

- *
    - *
  • - * You must use one of built-in actions when calling getActivity() activity. They start - * with {@code ACTION_*}. Otherwise the library might behave strangely (we don't - * cover those cases).
  • - *
  • You must use one of the themes that getActivity() library supports. They start - * with {@code R.style.Alp_42447968_Theme_*}. The reason is the themes contain - * resources that the library needs.
  • - *
  • With {@link #ACTION_COMPARE_PATTERN}, there are 4 possible result - * codes: {@link android.app.Activity#RESULT_OK}, {@link android.app.Activity#RESULT_CANCELED}, - * {@link #RESULT_FAILED} and {@link #RESULT_FORGOT_PATTERN}.
  • - *
  • With {@link #ACTION_VERIFY_CAPTCHA}, there are 3 possible result - * codes: {@link android.app.Activity#RESULT_OK}, {@link android.app.Activity#RESULT_CANCELED}, - * and {@link #RESULT_FAILED}.
  • - *
- * - * @author Hai Bison - * @since v1.0 - */ -public class LockPatternFragmentOld extends Fragment { - - private static final String CLASSNAME = LockPatternFragmentOld.class.getName(); - - public static final String ACTION_CREATE_PATTERN = "create"; - - /** - * Use getSelectedMethod() to compare pattern. You provide the pattern to be - * compared with {@link #EXTRA_PATTERN}. - *

- * If you enabled feature auto-save pattern before (with - * {@link com.haibison.android.lockpattern.util.Settings.Security#setAutoSavePattern(android.content.Context, boolean)} ), - * then you don't need {@link #EXTRA_PATTERN} at getActivity() time. - *

- * You can use {@link #EXTRA_PENDING_INTENT_FORGOT_PATTERN} to help your - * users in case they forgot the patterns. - *

- * If the user passes, {@link android.app.Activity#RESULT_OK} returns. If not, - * {@link #RESULT_FAILED} returns. - *

- * If the user cancels the task, {@link android.app.Activity#RESULT_CANCELED} returns. - *

- * In any case, there will have extra {@link #EXTRA_RETRY_COUNT} available - * in the intent result. - * - * @see #EXTRA_PATTERN - * @see #EXTRA_PENDING_INTENT_OK - * @see #EXTRA_PENDING_INTENT_CANCELLED - * @see #RESULT_FAILED - * @see #EXTRA_RETRY_COUNT - * @since v2.4 beta - */ - public static final String ACTION_COMPARE_PATTERN = "authenticate";//CLASSNAME + ".compare_pattern"; - - /** - * Use getActivity() action to let the activity generate a random pattern and ask the - * user to re-draw it to verify. - *

- * The default length of the auto-generated pattern is {@code 4}. You can - * change it with - * {@link com.haibison.android.lockpattern.util.Settings.Display#setCaptchaWiredDots(android.content.Context, int)}. - * - * @since v2.7 beta - */ - public static final String ACTION_VERIFY_CAPTCHA = CLASSNAME + ".verify_captcha"; - - /** - * If you use {@link #ACTION_COMPARE_PATTERN} and the user fails to "login" - * after a number of tries, getActivity() activity will finish with getActivity() result code. - * - * @see #ACTION_COMPARE_PATTERN - * @see #EXTRA_RETRY_COUNT - */ - public final int RESULT_FAILED = Activity.RESULT_FIRST_USER + 1; - - /** - * If you use {@link #ACTION_COMPARE_PATTERN} and the user forgot his/ her - * pattern and decided to ask for your help with recovering the pattern ( - * {@link #EXTRA_PENDING_INTENT_FORGOT_PATTERN}), getActivity() activity will finish - * with getActivity() result code. - * - * @see #ACTION_COMPARE_PATTERN - * @see #EXTRA_RETRY_COUNT - * @see #EXTRA_PENDING_INTENT_FORGOT_PATTERN - * @since v2.8 beta - */ - public static final int RESULT_FORGOT_PATTERN = Activity.RESULT_FIRST_USER + 2; - - /** - * For actions {@link #ACTION_COMPARE_PATTERN} and - * {@link #ACTION_VERIFY_CAPTCHA}, getActivity() key holds the number of tries that - * the user attempted to verify the input pattern. - */ - public static final String EXTRA_RETRY_COUNT = CLASSNAME + ".retry_count"; - - /** - * Sets value of getActivity() key to a theme in {@code R.style.Alp_42447968_Theme_*} - * . Default is the one you set in your {@code AndroidManifest.xml}. Note - * that theme {@link R.style#Alp_42447968_Theme_Light_DarkActionBar} is - * available in API 4+, but it only works in API 14+. - * - * @since v1.5.3 beta - */ - public static final String EXTRA_THEME = CLASSNAME + ".theme"; - - /** - * Key to hold the pattern. It must be a {@code char[]} array. - *

- *

    - *
  • If you use encrypter, it should be an encrypted array.
  • - *
  • If you don't use encrypter, it should be the SHA-1 value of the - * actual pattern. You can generate the value by - * {@link com.haibison.android.lockpattern.widget.LockPatternUtils#patternToSha1(java.util.List)}.
  • - *
- * - * @since v2 beta - */ - public static final String EXTRA_PATTERN = CLASSNAME + ".pattern"; - - /** - * You can provide an {@link android.os.ResultReceiver} with getActivity() key. The activity - * will notify your receiver the same result code and intent data as you - * will receive them in {@link #onActivityResult(int, int, android.content.Intent)}. - * - * @since v2.4 beta - */ - public static final String EXTRA_RESULT_RECEIVER = CLASSNAME - + ".result_receiver"; - - /** - * Put a {@link android.app.PendingIntent} into getActivity() key. It will be sent before - * {@link android.app.Activity#RESULT_OK} will be returning. If you were calling getActivity() - * activity with {@link #ACTION_CREATE_PATTERN}, key {@link #EXTRA_PATTERN} - * will be attached to the original intent which the pending intent holds. - * - *

Notes

- *
    - *
  • If you're going to use an activity, you don't need - * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} for the intent, since the library - * will call it inside {@link LockPatternFragmentOld} .
  • - *
- */ - public static final String EXTRA_PENDING_INTENT_OK = CLASSNAME - + ".pending_intent_ok"; - - /** - * Put a {@link android.app.PendingIntent} into getActivity() key. It will be sent before - * {@link android.app.Activity#RESULT_CANCELED} will be returning. - * - *

Notes

- *
    - *
  • If you're going to use an activity, you don't need - * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} for the intent, since the library - * will call it inside {@link LockPatternFragmentOld} .
  • - *
- */ - public static final String EXTRA_PENDING_INTENT_CANCELLED = CLASSNAME - + ".pending_intent_cancelled"; - - /** - * You put a {@link android.app.PendingIntent} into getActivity() extra. The library will show a - * button "Forgot pattern?" and call your intent later when the user - * taps it. - *

- *

Notes

- *
    - *
  • If you use an activity, you don't need - * {@link android.content.Intent#FLAG_ACTIVITY_NEW_TASK} for the intent, since the library - * will call it inside {@link LockPatternFragmentOld} .
  • - *
  • {@link LockPatternFragmentOld} will finish with - * {@link #RESULT_FORGOT_PATTERN} after making a call to start - * your pending intent.
  • - *
  • It is your responsibility to make sure the Intent is good. The - * library doesn't cover any errors when calling your intent.
  • - *
- * - * @see #ACTION_COMPARE_PATTERN - * @since v2.8 beta - */ - public static final String EXTRA_PENDING_INTENT_FORGOT_PATTERN = CLASSNAME - + ".pending_intent_forgot_pattern"; - - /** - * Helper enum for button OK commands. (Because we use only one "OK" button - * for different commands). - * - * @author Hai Bison - */ - private static enum ButtonOkCommand { - CONTINUE,DONE - }// ButtonOkCommand - - /** - * Delay time to reload the lock pattern view after a wrong pattern. - */ - private static final long DELAY_TIME_TO_RELOAD_LOCK_PATTERN_VIEW = DateUtils.SECOND_IN_MILLIS; - - /* - * FIELDS - */ - private int mMaxRetries, mMinWiredDots, mRetryCount = 0, mCaptchaWiredDots; - private boolean mAutoSave, mStealthMode; - private IEncrypter mEncrypter; - private ButtonOkCommand mBtnOkCmd; - private Intent mIntentResult; - - /* - * CONTROLS - */ - private TextView mTextInfo; - private LockPatternView mLockPatternView; - private Button mBtnConfirm; - - /* - * FRAGMENTS - */ - private FragmentActivity fa; - - /** - * Called when the activity is first created. - */ - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - - fa = getActivity(); - - /* - * EXTRA_THEME - */ - if (fa.getIntent().hasExtra(EXTRA_THEME)) - fa.setTheme(fa.getIntent().getIntExtra(EXTRA_THEME, - R.style.Alp_42447968_Theme_Dark)); - View view = inflater.inflate(R.layout.alp_42447968_lock_pattern_activity, container, false); - loadSettings(); - - mIntentResult = new Intent(); - fa.setResult(Activity.RESULT_CANCELED, mIntentResult); - initContentView(view); - return view; - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - - /** - * Loads settings, either from manifest or {@link com.haibison.android.lockpattern.util.Settings}. - */ - private void loadSettings() { - Bundle metaData = null; - try { - metaData = fa.getPackageManager().getActivityInfo(fa.getComponentName(), - PackageManager.GET_META_DATA).metaData; - } catch (NameNotFoundException e) { - /* - * Never catch getActivity(). - */ - e.printStackTrace(); - } - - if (metaData != null && metaData.containsKey(METADATA_MIN_WIRED_DOTS)) - mMinWiredDots = Settings.Display.validateMinWiredDots(getActivity(), - metaData.getInt(METADATA_MIN_WIRED_DOTS)); - else - mMinWiredDots = Settings.Display.getMinWiredDots(getActivity()); - - if (metaData != null && metaData.containsKey(METADATA_MAX_RETRIES)) - mMaxRetries = Settings.Display.validateMaxRetries(getActivity(), - metaData.getInt(METADATA_MAX_RETRIES)); - else - mMaxRetries = Settings.Display.getMaxRetries(getActivity()); - - if (metaData != null - && metaData.containsKey(METADATA_AUTO_SAVE_PATTERN)) - mAutoSave = metaData.getBoolean(METADATA_AUTO_SAVE_PATTERN); - else - mAutoSave = Settings.Security.isAutoSavePattern(getActivity()); - - if (metaData != null - && metaData.containsKey(METADATA_CAPTCHA_WIRED_DOTS)) - mCaptchaWiredDots = Settings.Display.validateCaptchaWiredDots(getActivity(), - metaData.getInt(METADATA_CAPTCHA_WIRED_DOTS)); - else - mCaptchaWiredDots = Settings.Display.getCaptchaWiredDots(getActivity()); - - if (metaData != null && metaData.containsKey(METADATA_STEALTH_MODE)) - mStealthMode = metaData.getBoolean(METADATA_STEALTH_MODE); - else - mStealthMode = Settings.Display.isStealthMode(getActivity()); - - /* - * Encrypter. - */ - char[] encrypterClass; - if (metaData != null && metaData.containsKey(METADATA_ENCRYPTER_CLASS)) - encrypterClass = metaData.getString(METADATA_ENCRYPTER_CLASS) - .toCharArray(); - else - encrypterClass = Settings.Security.getEncrypterClass(getActivity()); - - if (encrypterClass != null) { - try { - mEncrypter = (IEncrypter) Class.forName( - new String(encrypterClass), false, fa.getClassLoader()) - .newInstance(); - } catch (Throwable t) { - throw new InvalidEncrypterException(); - } - } - } - - /** - * Initializes UI... - */ - private void initContentView(View view) { - - /* - * Save all controls' state to restore later. - */ - CharSequence infoText = mTextInfo != null ? mTextInfo.getText() : null; - Boolean btnOkEnabled = mBtnConfirm != null ? mBtnConfirm.isEnabled() - : null; - DisplayMode lastDisplayMode = mLockPatternView != null ? mLockPatternView - .getDisplayMode() : null; - List lastPattern = mLockPatternView != null ? mLockPatternView - .getPattern() : null; - - UI.adjustDialogSizeForLargeScreens(fa.getWindow()); - - View mFooter; - Button mBtnCancel; - - mTextInfo = (TextView) view.findViewById(R.id.alp_42447968_textview_info); - mLockPatternView = (LockPatternView) view.findViewById(R.id.alp_42447968_view_lock_pattern); - - mFooter = view.findViewById(R.id.alp_42447968_viewgroup_footer); - mBtnCancel = (Button) view.findViewById(R.id.alp_42447968_button_cancel); - mBtnConfirm = (Button) view.findViewById(R.id.alp_42447968_button_confirm); - - /* - * LOCK PATTERN VIEW - */ - - switch (getResources().getConfiguration().screenLayout - & Configuration.SCREENLAYOUT_SIZE_MASK) { - case Configuration.SCREENLAYOUT_SIZE_LARGE: - case Configuration.SCREENLAYOUT_SIZE_XLARGE: { - final int size = getResources().getDimensionPixelSize( - R.dimen.alp_42447968_lockpatternview_size); - LayoutParams lp = mLockPatternView.getLayoutParams(); - lp.width = size; - lp.height = size; - mLockPatternView.setLayoutParams(lp); - - break; - } - } - - /* - * Haptic feedback. - */ - boolean hapticFeedbackEnabled = false; - try { - hapticFeedbackEnabled = android.provider.Settings.System - .getInt(fa.getContentResolver(), - android.provider.Settings.System.HAPTIC_FEEDBACK_ENABLED, - 0) != 0; - } catch (Throwable t) { - /* - * Ignore it. - */ - } - mLockPatternView.setTactileFeedbackEnabled(hapticFeedbackEnabled); - - mLockPatternView.setInStealthMode(mStealthMode - && !ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())); - mLockPatternView.setOnPatternListener(mLockPatternViewListener); - if (lastPattern != null && lastDisplayMode != null - && !ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())) - mLockPatternView.setPattern(lastDisplayMode, lastPattern); - /* - * COMMAND BUTTONS - */ - - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) { - mBtnCancel.setOnClickListener(mBtnCancelOnClickListener); - mBtnConfirm.setOnClickListener(mBtnConfirmOnClickListener); - - mBtnCancel.setVisibility(View.VISIBLE); - mFooter.setVisibility(View.VISIBLE); - mTextInfo.setVisibility(View.VISIBLE); - if (infoText != null) - mTextInfo.setText(infoText); - else - mTextInfo //TODO nfc text glaube ich hier oder so - .setText(R.string.alp_42447968_msg_draw_an_unlock_pattern); - - /* - * BUTTON OK - */ - if (mBtnOkCmd == null) - mBtnOkCmd = ButtonOkCommand.CONTINUE; - switch (mBtnOkCmd) { - case CONTINUE: - mBtnConfirm.setText(R.string.alp_42447968_cmd_continue); - break; - case DONE: - mBtnConfirm.setText(R.string.alp_42447968_cmd_confirm); - break; - default: - break; - } - if (btnOkEnabled != null) - mBtnConfirm.setEnabled(btnOkEnabled); - } - else if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - if (TextUtils.isEmpty(infoText)) - mTextInfo - .setText(R.string.alp_42447968_msg_draw_pattern_to_unlock); - else - mTextInfo.setText(infoText); - if (fa.getIntent().hasExtra(EXTRA_PENDING_INTENT_FORGOT_PATTERN)) { - mBtnConfirm.setOnClickListener(mBtnConfirmOnClickListener); - mBtnConfirm.setText(R.string.alp_42447968_cmd_forgot_pattern); - mBtnConfirm.setEnabled(true); - mFooter.setVisibility(View.VISIBLE); - } - } - else if (ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())) { - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - - /* - * NOTE: EXTRA_PATTERN should hold a char[] array. In getActivity() case we - * use it as a temporary variable to hold a list of Cell. - */ - - final ArrayList pattern; - if (fa.getIntent().hasExtra(EXTRA_PATTERN)) - pattern = fa.getIntent() - .getParcelableArrayListExtra(EXTRA_PATTERN); - else - fa.getIntent().putParcelableArrayListExtra( - EXTRA_PATTERN, - pattern = LockPatternUtils - .genCaptchaPattern(mCaptchaWiredDots)); - - mLockPatternView.setPattern(DisplayMode.Animate, pattern); - } - } - - /** - * Compares {@code pattern} to the given pattern ( - * {@link #ACTION_COMPARE_PATTERN}) or to the generated "CAPTCHA" pattern ( - * {@link #ACTION_VERIFY_CAPTCHA}). Then finishes the activity if they - * match. - * - * @param pattern - * the pattern to be compared. - */ - private void doComparePattern(final List pattern) { - if (pattern == null) - return; - - /* - * Use a LoadingDialog because decrypting pattern might take time... - */ - new LoadingDialog(getActivity(), false) { - - @Override - protected Boolean doInBackground(Void... params) { - if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - char[] currentPattern = PassphraseWizardActivity.pattern; - if (currentPattern == null) - currentPattern = Settings.Security - .getPattern(getActivity()); - if (currentPattern != null) { - if (mEncrypter != null) { - return pattern.equals(mEncrypter.decrypt( - getActivity(), currentPattern)); - } else - return Arrays.equals(currentPattern, - LockPatternUtils.patternToSha1(pattern) - .toCharArray()); - } - } - else if (ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())) { - return pattern.equals(fa.getIntent() - .getParcelableArrayListExtra(EXTRA_PATTERN)); - } - return false; - } - - @Override - protected void onPostExecute(Boolean result) { - super.onPostExecute(result); - if (result) { - Toast.makeText(getActivity(), "unlocked", Toast.LENGTH_SHORT).show(); - finishWithResultOk(null); - }else { - mRetryCount++; - mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount); - - if (mRetryCount >= mMaxRetries) - finishWithNegativeResult(RESULT_FAILED); - else { - mLockPatternView.setDisplayMode(DisplayMode.Wrong); - mTextInfo.setText(R.string.alp_42447968_msg_try_again); - mLockPatternView.postDelayed(mLockPatternViewReloader, - DELAY_TIME_TO_RELOAD_LOCK_PATTERN_VIEW); - } - } - } - - }.execute(); - } - - /** - * Checks and creates the pattern. - * - * @param pattern - * the current pattern of lock pattern view. - */ - private void doCheckAndCreatePattern(final List pattern) { - if (pattern.size() < mMinWiredDots) { - mLockPatternView.setDisplayMode(DisplayMode.Wrong); - mTextInfo.setText(getResources().getQuantityString( - R.plurals.alp_42447968_pmsg_connect_x_dots, mMinWiredDots, - mMinWiredDots)); - mLockPatternView.postDelayed(mLockPatternViewReloader, - DELAY_TIME_TO_RELOAD_LOCK_PATTERN_VIEW); - return; - } - - if (fa.getIntent().hasExtra(EXTRA_PATTERN)) { - /* - * Use a LoadingDialog because decrypting pattern might take time... - */ - new LoadingDialog(getActivity(), false) { - - @Override - protected Boolean doInBackground(Void... params) { - if (mEncrypter != null) - return pattern.equals(mEncrypter.decrypt( - getActivity(), fa.getIntent() - .getCharArrayExtra(EXTRA_PATTERN))); - else - return Arrays.equals( - fa.getIntent().getCharArrayExtra(EXTRA_PATTERN), - LockPatternUtils.patternToSha1(pattern) - .toCharArray()); - } - - @Override - protected void onPostExecute(Boolean result) { - super.onPostExecute(result); - - if (result) { - mTextInfo - .setText(R.string.alp_42447968_msg_your_new_unlock_pattern); - mBtnConfirm.setEnabled(true); - PassphraseWizardActivity.pattern = fa.getIntent() - .getCharArrayExtra(EXTRA_PATTERN); - } else { - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - mBtnConfirm.setEnabled(false); - mLockPatternView.setDisplayMode(DisplayMode.Wrong); - mLockPatternView.postDelayed(mLockPatternViewReloader, - DELAY_TIME_TO_RELOAD_LOCK_PATTERN_VIEW); - } - } - }.execute(); - } else { - /* - * Use a LoadingDialog because encrypting pattern might take time... - */ - new LoadingDialog(getActivity(), false) { - - @Override - protected char[] doInBackground(Void... params) { - return mEncrypter != null ? mEncrypter.encrypt( - getActivity(), pattern) - : LockPatternUtils.patternToSha1(pattern) - .toCharArray(); - } - - @Override - protected void onPostExecute(char[] result) { - super.onPostExecute(result); - - fa.getIntent().putExtra(EXTRA_PATTERN, result); - mTextInfo - .setText(R.string.alp_42447968_msg_pattern_recorded); - mBtnConfirm.setEnabled(true); - } - - }.execute(); - } - } - - /** - * Finishes activity with {@link android.app.Activity#RESULT_OK}. - * - * @param pattern - * the pattern, if getActivity() is in mode creating pattern. In any - * cases, it can be set to {@code null}. - */ - private void finishWithResultOk(char[] pattern) { - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) - mIntentResult.putExtra(EXTRA_PATTERN, pattern); - else { - /* - * If the user was "logging in", minimum try count can not be zero. - */ - mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount + 1); - } - - fa.setResult(fa.RESULT_OK, mIntentResult); - - /* - * ResultReceiver - */ - ResultReceiver receiver = fa.getIntent().getParcelableExtra( - EXTRA_RESULT_RECEIVER); - if (receiver != null) { - Bundle bundle = new Bundle(); - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) - bundle.putCharArray(EXTRA_PATTERN, pattern); - else { - /* - * If the user was "logging in", minimum try count can not be - * zero. - */ - bundle.putInt(EXTRA_RETRY_COUNT, mRetryCount + 1); - } - receiver.send(fa.RESULT_OK, bundle); - } - - /* - * PendingIntent - */ - PendingIntent pi = fa.getIntent().getParcelableExtra( - EXTRA_PENDING_INTENT_OK); - if (pi != null) { - try { - pi.send(getActivity(), fa.RESULT_OK, mIntentResult); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - fa.finish(); - } - - /** - * Finishes the activity with negative result ( - * {@link android.app.Activity#RESULT_CANCELED}, {@link #RESULT_FAILED} or - * {@link #RESULT_FORGOT_PATTERN}). - */ - private void finishWithNegativeResult(int resultCode) { - if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) - mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount); - - fa.setResult(resultCode, mIntentResult); - - /* - * ResultReceiver - */ - ResultReceiver receiver = fa.getIntent().getParcelableExtra( - EXTRA_RESULT_RECEIVER); - if (receiver != null) { - Bundle resultBundle = null; - if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - resultBundle = new Bundle(); - resultBundle.putInt(EXTRA_RETRY_COUNT, mRetryCount); - } - receiver.send(resultCode, resultBundle); - } - - /* - * PendingIntent - */ - PendingIntent pi = fa.getIntent().getParcelableExtra( - EXTRA_PENDING_INTENT_CANCELLED); - if (pi != null) { - try { - pi.send(getActivity(), resultCode, mIntentResult); - } catch (Throwable t) { - t.printStackTrace(); - } - } - - fa.finish(); - } - - /* - * LISTENERS - */ - - private final LockPatternView.OnPatternListener mLockPatternViewListener = new LockPatternView.OnPatternListener() { - - @Override - public void onPatternStart() { - mLockPatternView.removeCallbacks(mLockPatternViewReloader); - mLockPatternView.setDisplayMode(DisplayMode.Correct); - - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) { - mTextInfo - .setText(R.string.alp_42447968_msg_release_finger_when_done); - mBtnConfirm.setEnabled(false); - if (mBtnOkCmd == ButtonOkCommand.CONTINUE) - fa.getIntent().removeExtra(EXTRA_PATTERN); - } - else if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - mTextInfo - .setText(R.string.alp_42447968_msg_draw_pattern_to_unlock); - } - else if (ACTION_VERIFY_CAPTCHA.equals(getSelectedMethod())) { - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - } - } - - @Override - public void onPatternDetected(List pattern) { - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) { - doCheckAndCreatePattern(pattern); - } - else if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - doComparePattern(pattern); - } - else if (ACTION_VERIFY_CAPTCHA.equals(getSelectedMethod())) { - if (!DisplayMode.Animate.equals(mLockPatternView - .getDisplayMode())) - doComparePattern(pattern); - } - } - - @Override - public void onPatternCleared() { - mLockPatternView.removeCallbacks(mLockPatternViewReloader); - - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) { - mLockPatternView.setDisplayMode(DisplayMode.Correct); - mBtnConfirm.setEnabled(false); - if (mBtnOkCmd == ButtonOkCommand.CONTINUE) { - fa.getIntent().removeExtra(EXTRA_PATTERN); - mTextInfo - .setText(R.string.alp_42447968_msg_draw_an_unlock_pattern); - } else - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - } - else if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - mLockPatternView.setDisplayMode(DisplayMode.Correct); - mTextInfo - .setText(R.string.alp_42447968_msg_draw_pattern_to_unlock); - } - else if (ACTION_VERIFY_CAPTCHA.equals(fa.getIntent().getAction())) { - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - List pattern = fa.getIntent().getParcelableArrayListExtra( - EXTRA_PATTERN); - mLockPatternView.setPattern(DisplayMode.Animate, pattern); - } - } - - @Override - public void onPatternCellAdded(List pattern) { - } - }; - - private final View.OnClickListener mBtnCancelOnClickListener = new View.OnClickListener() { - - @Override - public void onClick(View v) { - finishWithNegativeResult(fa.RESULT_CANCELED); - } - }; - - private final View.OnClickListener mBtnConfirmOnClickListener = new View.OnClickListener() { - - @Override - public void onClick(View v) { - if (ACTION_CREATE_PATTERN.equals(getSelectedMethod())) { - if (mBtnOkCmd == ButtonOkCommand.CONTINUE) { - mBtnOkCmd = ButtonOkCommand.DONE; - mLockPatternView.clearPattern(); - mTextInfo - .setText(R.string.alp_42447968_msg_redraw_pattern_to_confirm); - mBtnConfirm.setText(R.string.alp_42447968_cmd_confirm); - mBtnConfirm.setEnabled(false); - } else { - final char[] pattern = fa.getIntent().getCharArrayExtra( - EXTRA_PATTERN); - if (mAutoSave) - Settings.Security.setPattern(getActivity(), - pattern); - finishWithResultOk(pattern); - } - } - else if (ACTION_COMPARE_PATTERN.equals(getSelectedMethod())) { - /* - * We don't need to verify the extra. First, getActivity() button is only - * visible if there is getActivity() extra in the intent. Second, it is - * the responsibility of the caller to make sure the extra is - * good. - */ - PendingIntent pi; - try { - pi = fa.getIntent().getParcelableExtra( - EXTRA_PENDING_INTENT_FORGOT_PATTERN); - pi.send(); - } catch (Throwable t) { - t.printStackTrace(); - } - finishWithNegativeResult(RESULT_FORGOT_PATTERN); - } - } - }; - - /** - * getActivity() reloads the {@link #mLockPatternView} after a wrong pattern. - */ - private final Runnable mLockPatternViewReloader = new Runnable() { - - @Override - public void run() { - mLockPatternView.clearPattern(); - mLockPatternViewListener.onPatternCleared(); - } - }; - - /** - * Fragment constructor allowing to add a bundle with all necessary information to the fragment - * @param method contains information about which method to choose (set - * @return LockPatternFragment with bundle - */ - public static LockPatternFragmentOld newInstance(String method){ - LockPatternFragmentOld fragment = new LockPatternFragmentOld(); - Bundle args = new Bundle(); - args.putString("ACTION", method); - fragment.setArguments(args); - return fragment; - } - - /** - * Getter for the method string saved in fragment arguments - * @return String telling which method was selected - */ - public String getSelectedMethod () { - return getArguments().getString("ACTION"); - } -} -- cgit v1.2.3 From 7bddd5be1d76360f1112e780091ee6636591caae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 00:28:26 +0100 Subject: Remove old pattern lib, add new pattern lib --- OpenKeychain/src/main/AndroidManifest.xml | 8 +-- .../keychain/ui/PassphraseDialogActivity.java | 24 ++++---- .../keychain/ui/PassphraseWizardActivity.java | 45 ++++----------- .../layout/alp_42447968_lock_pattern_fragment.xml | 15 ----- .../passphrase_wizard_fragment_passphrase.xml | 64 ++++++++++++---------- 5 files changed, 60 insertions(+), 96 deletions(-) delete mode 100644 OpenKeychain/src/main/res/layout/alp_42447968_lock_pattern_fragment.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index c8f190151..8cbb3bd41 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -67,8 +67,10 @@ + - + + + + + + + + + + + + + + + + + + + + +
+ Date: Mon, 23 Feb 2015 00:30:02 +0100 Subject: Remove unused FixedDrawerLayout --- .../support/v4/widget/FixedDrawerLayout.java | 49 ---------------------- 1 file changed, 49 deletions(-) delete mode 100644 OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java b/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java deleted file mode 100644 index 6924e0b06..000000000 --- a/OpenKeychain/src/main/java/android/support/v4/widget/FixedDrawerLayout.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.support.v4.widget; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.Gravity; -import android.view.View; - -/** - * Fix for NullPointerException at android.support.v4.widget.DrawerLayout.isContentView(DrawerLayout.java:840) - *

- * http://stackoverflow.com/a/18107942 - */ -public class FixedDrawerLayout extends DrawerLayout { - public FixedDrawerLayout(Context context) { - super(context); - } - - public FixedDrawerLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public FixedDrawerLayout(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - boolean isContentView(View child) { - if (child == null) { - return false; - } - return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY; - } -} -- cgit v1.2.3 From dd3af50956ec80502f9f14e91cffbd271cc232fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 10:36:39 +0100 Subject: Uncluttering App Settings: Move advanced info in dialog --- .../keychain/remote/ui/AppSettingsActivity.java | 48 +++++++++------ .../dialog/AdvancedAppSettingsDialogFragment.java | 72 ++++++++++++++++++++++ .../main/res/layout/api_app_settings_activity.xml | 41 ------------ .../src/main/res/menu/api_app_settings.xml | 5 ++ 4 files changed, 107 insertions(+), 59 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AdvancedAppSettingsDialogFragment.java (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index c6b8b186c..407480c98 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -40,7 +40,10 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.BaseActivity; +import org.sufficientlysecure.keychain.ui.dialog.AddSubkeyDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.AdvancedAppSettingsDialogFragment; import org.sufficientlysecure.keychain.util.Log; import java.security.MessageDigest; @@ -130,16 +133,40 @@ public class AppSettingsActivity extends BaseActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_api_settings_revoke: + case R.id.menu_api_save: { + save(); + return true; + } + case R.id.menu_api_settings_revoke: { revokeAccess(); return true; - case R.id.menu_api_save: - save(); + } + case R.id.menu_api_settings_advanced: { + showAdvancedInfo(); return true; + } } return super.onOptionsItemSelected(item); } + private void showAdvancedInfo() { + String signature = null; + // advanced info: package signature SHA-256 + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(mAppSettings.getPackageSignature()); + byte[] digest = md.digest(); + signature = new String(Hex.encode(digest)); + } catch (NoSuchAlgorithmException e) { + Log.e(Constants.TAG, "Should not happen!", e); + } + + AdvancedAppSettingsDialogFragment dialogFragment = + AdvancedAppSettingsDialogFragment.newInstance(mAppSettings.getPackageName(), signature); + + dialogFragment.show(getSupportFragmentManager(), "advancedDialog"); + } + private void startApp() { Intent i; PackageManager manager = getPackageManager(); @@ -175,21 +202,6 @@ public class AppSettingsActivity extends BaseActivity { mAppNameView.setText(appName); mAppIconView.setImageDrawable(appIcon); - // advanced info: package name - mPackageName.setText(mAppSettings.getPackageName()); - - // advanced info: package signature SHA-256 - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(mAppSettings.getPackageSignature()); - byte[] digest = md.digest(); - String signature = new String(Hex.encode(digest)); - - mPackageSignature.setText(signature); - } catch (NoSuchAlgorithmException e) { - Log.e(Constants.TAG, "Should not happen!", e); - } - Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); Log.d(Constants.TAG, "accountsUri: " + accountsUri); Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AdvancedAppSettingsDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AdvancedAppSettingsDialogFragment.java new file mode 100644 index 000000000..d2fa37cf7 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/AdvancedAppSettingsDialogFragment.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui.dialog; + +import android.app.Dialog; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentActivity; + +import org.sufficientlysecure.keychain.R; + +public class AdvancedAppSettingsDialogFragment extends DialogFragment { + private static final String ARG_PACKAGE_NAME = "package_name"; + private static final String ARG_SIGNATURE = "signature"; + + /** + * Creates new instance of this fragment + */ + public static AdvancedAppSettingsDialogFragment newInstance(String packageName, String digest) { + AdvancedAppSettingsDialogFragment frag = new AdvancedAppSettingsDialogFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PACKAGE_NAME, packageName); + args.putString(ARG_SIGNATURE, digest); + + frag.setArguments(args); + return frag; + } + + /** + * Creates dialog + */ + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + final FragmentActivity activity = getActivity(); + + CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity); + + alert.setTitle(R.string.api_settings_advanced); + alert.setCancelable(true); + + alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dismiss(); + } + }); + + String packageName = getArguments().getString(ARG_PACKAGE_NAME); + String signature = getArguments().getString(ARG_SIGNATURE); + + alert.setMessage(getString(R.string.api_settings_package_name) + ": " + packageName + "\n\n" + + getString(R.string.api_settings_package_signature) + ": " + signature); + + return alert.show(); + } +} diff --git a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml index 253836080..6df5c84f5 100644 --- a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml +++ b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml @@ -103,47 +103,6 @@ android:layout_height="match_parent" android:orientation="vertical" /> - - - - - - - - - - - - - - diff --git a/OpenKeychain/src/main/res/menu/api_app_settings.xml b/OpenKeychain/src/main/res/menu/api_app_settings.xml index 4b4fc39e8..5ac340550 100644 --- a/OpenKeychain/src/main/res/menu/api_app_settings.xml +++ b/OpenKeychain/src/main/res/menu/api_app_settings.xml @@ -12,4 +12,9 @@ android:title="@string/api_settings_revoke" app:showAsAction="never" /> + + \ No newline at end of file -- cgit v1.2.3 From 2064d81aef27492e5f9f13a14375fc505bf105ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 21:52:04 +0100 Subject: Refactor AppsListFragment --- .../keychain/remote/ui/AppsListFragment.java | 278 +++++++++++---------- OpenKeychain/src/main/res/values/strings.xml | 1 - 2 files changed, 142 insertions(+), 137 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java index 976ce20d6..506b2da7f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2014 Dominik Schürmann + * Copyright (C) 2013-2015 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 @@ -50,8 +50,7 @@ import org.sufficientlysecure.keychain.util.Log; public class AppsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { - // This is the Adapter being used to display the list's data. - RegisteredAppsAdapter mAdapter; + AppsAdapter mAdapter; @Override public void onActivityCreated(Bundle savedInstanceState) { @@ -66,7 +65,7 @@ public class AppsListFragment extends ListFragment implements if (installed) { if (registered) { - // edit app settings + // Edit app settings Intent intent = new Intent(getActivity(), AppSettingsActivity.class); intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(selectedPackageName)); startActivity(intent); @@ -75,9 +74,10 @@ public class AppsListFragment extends ListFragment implements PackageManager manager = getActivity().getPackageManager(); try { i = manager.getLaunchIntentForPackage(selectedPackageName); - if (i == null) + if (i == null) { throw new PackageManager.NameNotFoundException(); - // start like the Android launcher would do + } + // Start like the Android launcher would do i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); @@ -91,30 +91,32 @@ public class AppsListFragment extends ListFragment implements Uri.parse("market://details?id=" + selectedPackageName))); } catch (ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse("http://play.google.com/store/apps/details?id=" + selectedPackageName))); + Uri.parse("https://play.google.com/store/apps/details?id=" + selectedPackageName))); } } } }); - // Give some text to display if there is no data. In a real - // application this would come from a resource. - setEmptyText(getString(R.string.api_no_apps)); + // NOTE: No setEmptyText(), we always have the default entries // We have a menu item to show in action bar. setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. - mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); + mAdapter = new AppsAdapter(getActivity(), null, 0); setListAdapter(mAdapter); - // Loader is started in onResume! + // NOTE: Loader is started in onResume! } @Override public void onResume() { super.onResume(); - // after coming back from Google Play -> reload + + // Start out with a progress indicator. + setListShown(false); + + // After coming back from Google Play -> reload getLoaderManager().restartLoader(0, null, this); } @@ -123,7 +125,6 @@ public class AppsListFragment extends ListFragment implements private static final String TEMP_COLUMN_REGISTERED = "REGISTERED"; private static final String TEMP_COLUMN_ICON_RES_ID = "ICON_RES_ID"; - // These are the Contacts rows that we will retrieve. static final String[] PROJECTION = new String[]{ ApiApps._ID, // 0 ApiApps.PACKAGE_NAME, // 1 @@ -149,106 +150,17 @@ public class AppsListFragment extends ListFragment implements // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, + return new AppsLoader(getActivity(), baseUri, PROJECTION, null, null, ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC"); } public void onLoadFinished(Loader loader, Cursor data) { - MatrixCursor availableAppsCursor = new MatrixCursor(new String[]{ - ApiApps._ID, - ApiApps.PACKAGE_NAME, - TEMP_COLUMN_NAME, - TEMP_COLUMN_INSTALLED, - TEMP_COLUMN_REGISTERED, - TEMP_COLUMN_ICON_RES_ID - }); - // NOTE: SORT ascending by package name, this is REQUIRED for CursorJoiner! - // Drawables taken from projects res/drawables-xxhdpi/ic_launcher.png - availableAppsCursor.addRow(new Object[]{1, "com.fsck.k9", "K-9 Mail", 0, 0, R.drawable.apps_k9}); - availableAppsCursor.addRow(new Object[]{1, "com.zeapo.pwdstore", "Password Store", 0, 0, R.drawable.apps_password_store}); - availableAppsCursor.addRow(new Object[]{1, "eu.siacs.conversations", "Conversations (Instant Messaging)", 0, 0, R.drawable.apps_conversations}); - - MatrixCursor mergedCursor = new MatrixCursor(new String[]{ - ApiApps._ID, - ApiApps.PACKAGE_NAME, - TEMP_COLUMN_NAME, - TEMP_COLUMN_INSTALLED, - TEMP_COLUMN_REGISTERED, - TEMP_COLUMN_ICON_RES_ID - }); - - CursorJoiner joiner = new CursorJoiner( - availableAppsCursor, - new String[]{ApiApps.PACKAGE_NAME}, - data, - new String[]{ApiApps.PACKAGE_NAME}); - for (CursorJoiner.Result joinerResult : joiner) { - switch (joinerResult) { - case LEFT: { - // handle case where a row in availableAppsCursor is unique - String packageName = availableAppsCursor.getString(INDEX_PACKAGE_NAME); - - mergedCursor.addRow(new Object[]{ - 1, // no need for unique _ID - packageName, - availableAppsCursor.getString(INDEX_NAME), - isInstalled(packageName), - 0, - availableAppsCursor.getInt(INDEX_ICON_RES_ID) - }); - break; - } - case RIGHT: { - // handle case where a row in data is unique - String packageName = data.getString(INDEX_PACKAGE_NAME); - - mergedCursor.addRow(new Object[]{ - 1, // no need for unique _ID - packageName, - null, - isInstalled(packageName), - 1, // registered! - R.drawable.ic_launcher // icon is retrieved later - }); - break; - } - case BOTH: { - // handle case where a row with the same key is in both cursors - String packageName = data.getString(INDEX_PACKAGE_NAME); - - String name; - if (isInstalled(packageName) == 1) { - name = data.getString(INDEX_NAME); - } else { - // if not installed take name from available apps list - name = availableAppsCursor.getString(INDEX_NAME); - } - - mergedCursor.addRow(new Object[]{ - 1, // no need for unique _ID - packageName, - name, - isInstalled(packageName), - 1, // registered! - R.drawable.ic_launcher // icon is retrieved later - }); - break; - } - } - } - // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) - mAdapter.swapCursor(mergedCursor); - } + mAdapter.swapCursor(data); - private int isInstalled(String packageName) { - try { - getActivity().getPackageManager().getApplicationInfo(packageName, 0); - return 1; - } catch (final PackageManager.NameNotFoundException e) { - return 0; - } + // The list should now be shown. + setListShown(true); } public void onLoaderReset(Loader loader) { @@ -258,12 +170,127 @@ public class AppsListFragment extends ListFragment implements mAdapter.swapCursor(null); } - private class RegisteredAppsAdapter extends CursorAdapter { + /** + * Besides the queried cursor with all registered apps, this loader also returns non-installed + * proposed apps using a MatrixCursor. + */ + private static class AppsLoader extends CursorLoader { + + public AppsLoader(Context context) { + super(context); + } + + public AppsLoader(Context context, Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { + super(context, uri, projection, selection, selectionArgs, sortOrder); + } + + @Override + public Cursor loadInBackground() { + // Load registered apps from content provider + Cursor data = super.loadInBackground(); + + MatrixCursor availableAppsCursor = new MatrixCursor(new String[]{ + ApiApps._ID, + ApiApps.PACKAGE_NAME, + TEMP_COLUMN_NAME, + TEMP_COLUMN_INSTALLED, + TEMP_COLUMN_REGISTERED, + TEMP_COLUMN_ICON_RES_ID + }); + // NOTE: SORT ascending by package name, this is REQUIRED for CursorJoiner! + // Drawables taken from projects res/drawables-xxhdpi/ic_launcher.png + availableAppsCursor.addRow(new Object[]{1, "com.fsck.k9", "K-9 Mail", 0, 0, R.drawable.apps_k9}); + availableAppsCursor.addRow(new Object[]{1, "com.zeapo.pwdstore", "Password Store", 0, 0, R.drawable.apps_password_store}); + availableAppsCursor.addRow(new Object[]{1, "eu.siacs.conversations", "Conversations (Instant Messaging)", 0, 0, R.drawable.apps_conversations}); + + MatrixCursor mergedCursor = new MatrixCursor(new String[]{ + ApiApps._ID, + ApiApps.PACKAGE_NAME, + TEMP_COLUMN_NAME, + TEMP_COLUMN_INSTALLED, + TEMP_COLUMN_REGISTERED, + TEMP_COLUMN_ICON_RES_ID + }); + + CursorJoiner joiner = new CursorJoiner( + availableAppsCursor, + new String[]{ApiApps.PACKAGE_NAME}, + data, + new String[]{ApiApps.PACKAGE_NAME}); + for (CursorJoiner.Result joinerResult : joiner) { + switch (joinerResult) { + case LEFT: { + // handle case where a row in availableAppsCursor is unique + String packageName = availableAppsCursor.getString(INDEX_PACKAGE_NAME); + + mergedCursor.addRow(new Object[]{ + 1, // no need for unique _ID + packageName, + availableAppsCursor.getString(INDEX_NAME), + isInstalled(packageName), + 0, + availableAppsCursor.getInt(INDEX_ICON_RES_ID) + }); + break; + } + case RIGHT: { + // handle case where a row in data is unique + String packageName = data.getString(INDEX_PACKAGE_NAME); + + mergedCursor.addRow(new Object[]{ + 1, // no need for unique _ID + packageName, + null, + isInstalled(packageName), + 1, // registered! + R.drawable.ic_launcher // icon is retrieved later + }); + break; + } + case BOTH: { + // handle case where a row with the same key is in both cursors + String packageName = data.getString(INDEX_PACKAGE_NAME); + + String name; + if (isInstalled(packageName) == 1) { + name = data.getString(INDEX_NAME); + } else { + // if not installed take name from available apps list + name = availableAppsCursor.getString(INDEX_NAME); + } + + mergedCursor.addRow(new Object[]{ + 1, // no need for unique _ID + packageName, + name, + isInstalled(packageName), + 1, // registered! + R.drawable.ic_launcher // icon is retrieved later + }); + break; + } + } + } + + return mergedCursor; + } + + private int isInstalled(String packageName) { + try { + getContext().getPackageManager().getApplicationInfo(packageName, 0); + return 1; + } catch (final PackageManager.NameNotFoundException e) { + return 0; + } + } + } + + private class AppsAdapter extends CursorAdapter { private LayoutInflater mInflater; private PackageManager mPM; - public RegisteredAppsAdapter(Context context, Cursor c, int flags) { + public AppsAdapter(Context context, Cursor c, int flags) { super(context, c, flags); mInflater = LayoutInflater.from(context); @@ -273,44 +300,23 @@ public class AppsListFragment extends ListFragment implements /** * Similar to CursorAdapter.getItemId(). * Required to build Uris for api apps, which are not based on row ids - * - * @param position - * @return */ public String getItemPackageName(int position) { - if (mDataValid && mCursor != null) { - if (mCursor.moveToPosition(position)) { - return mCursor.getString(INDEX_PACKAGE_NAME); - } else { - return null; - } + if (mDataValid && mCursor != null && mCursor.moveToPosition(position)) { + return mCursor.getString(INDEX_PACKAGE_NAME); } else { return null; } } public boolean getItemIsInstalled(int position) { - if (mDataValid && mCursor != null) { - if (mCursor.moveToPosition(position)) { - return (mCursor.getInt(INDEX_INSTALLED) == 1); - } else { - return false; - } - } else { - return false; - } + return mDataValid && mCursor != null + && mCursor.moveToPosition(position) && (mCursor.getInt(INDEX_INSTALLED) == 1); } public boolean getItemIsRegistered(int position) { - if (mDataValid && mCursor != null) { - if (mCursor.moveToPosition(position)) { - return (mCursor.getInt(INDEX_REGISTERED) == 1); - } else { - return false; - } - } else { - return false; - } + return mDataValid && mCursor != null + && mCursor.moveToPosition(position) && (mCursor.getInt(INDEX_REGISTERED) == 1); } @Override diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 97e6a9d71..4a56274d7 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -476,7 +476,6 @@ "Decrypt with OpenKeychain" - "No registered apps!\n\nA list of supported third-party applications can be found in 'Help'!" "Show advanced information" "Hide advanced information" "Show advanced settings" -- cgit v1.2.3 From 29628e54ec70c0867fea99172745f6c678b66ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 21:55:44 +0100 Subject: Refactor AppsListFragment --- .../keychain/remote/ui/AppsListFragment.java | 82 +++++++++++----------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java index 506b2da7f..2deb33a67 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -48,7 +48,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; import org.sufficientlysecure.keychain.util.Log; public class AppsListFragment extends ListFragment implements - LoaderManager.LoaderCallbacks { + LoaderManager.LoaderCallbacks, OnItemClickListener { AppsAdapter mAdapter; @@ -56,46 +56,7 @@ public class AppsListFragment extends ListFragment implements public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - getListView().setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long id) { - String selectedPackageName = mAdapter.getItemPackageName(position); - boolean installed = mAdapter.getItemIsInstalled(position); - boolean registered = mAdapter.getItemIsRegistered(position); - - if (installed) { - if (registered) { - // Edit app settings - Intent intent = new Intent(getActivity(), AppSettingsActivity.class); - intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(selectedPackageName)); - startActivity(intent); - } else { - Intent i; - PackageManager manager = getActivity().getPackageManager(); - try { - i = manager.getLaunchIntentForPackage(selectedPackageName); - if (i == null) { - throw new PackageManager.NameNotFoundException(); - } - // Start like the Android launcher would do - i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - i.addCategory(Intent.CATEGORY_LAUNCHER); - startActivity(i); - } catch (PackageManager.NameNotFoundException e) { - Log.e(Constants.TAG, "startApp", e); - } - } - } else { - try { - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse("market://details?id=" + selectedPackageName))); - } catch (ActivityNotFoundException anfe) { - startActivity(new Intent(Intent.ACTION_VIEW, - Uri.parse("https://play.google.com/store/apps/details?id=" + selectedPackageName))); - } - } - } - }); + getListView().setOnItemClickListener(this); // NOTE: No setEmptyText(), we always have the default entries @@ -120,6 +81,45 @@ public class AppsListFragment extends ListFragment implements getLoaderManager().restartLoader(0, null, this); } + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + String selectedPackageName = mAdapter.getItemPackageName(position); + boolean installed = mAdapter.getItemIsInstalled(position); + boolean registered = mAdapter.getItemIsRegistered(position); + + if (installed) { + if (registered) { + // Edit app settings + Intent intent = new Intent(getActivity(), AppSettingsActivity.class); + intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(selectedPackageName)); + startActivity(intent); + } else { + Intent i; + PackageManager manager = getActivity().getPackageManager(); + try { + i = manager.getLaunchIntentForPackage(selectedPackageName); + if (i == null) { + throw new PackageManager.NameNotFoundException(); + } + // Start like the Android launcher would do + i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); + i.addCategory(Intent.CATEGORY_LAUNCHER); + startActivity(i); + } catch (PackageManager.NameNotFoundException e) { + Log.e(Constants.TAG, "startApp", e); + } + } + } else { + try { + startActivity(new Intent(Intent.ACTION_VIEW, + Uri.parse("market://details?id=" + selectedPackageName))); + } catch (ActivityNotFoundException anfe) { + startActivity(new Intent(Intent.ACTION_VIEW, + Uri.parse("https://play.google.com/store/apps/details?id=" + selectedPackageName))); + } + } + } + private static final String TEMP_COLUMN_NAME = "NAME"; private static final String TEMP_COLUMN_INSTALLED = "INSTALLED"; private static final String TEMP_COLUMN_REGISTERED = "REGISTERED"; -- cgit v1.2.3 From 52bcfd71adc1935ad81be7c0a9b2aae02000357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 23 Feb 2015 23:03:45 +0100 Subject: New advanced key view --- OpenKeychain/src/main/AndroidManifest.xml | 4 +- .../keychain/ui/BaseActivity.java | 2 + .../keychain/ui/ViewKeyActivity.java | 10 +- .../keychain/ui/ViewKeyAdvActivity.java | 240 +++++++++++++ .../keychain/ui/ViewKeyAdvCertsFragment.java | 342 ++++++++++++++++++ .../keychain/ui/ViewKeyAdvKeysFragment.java | 125 +++++++ .../keychain/ui/ViewKeyAdvMainFragment.java | 350 +++++++++++++++++++ .../keychain/ui/ViewKeyAdvShareFragment.java | 387 +++++++++++++++++++++ .../keychain/ui/ViewKeyAdvancedActivity.java | 91 ----- .../keychain/ui/ViewKeyAdvancedFragment.java | 378 -------------------- .../keychain/ui/ViewKeyMainFragment.java | 350 ------------------- .../keychain/ui/ViewKeyShareFragment.java | 387 --------------------- .../src/main/res/layout/view_key_adv_activity.xml | 41 +++ .../res/layout/view_key_adv_certs_fragment.xml | 57 +++ .../res/layout/view_key_adv_share_fragment.xml | 212 +++++++++++ .../res/layout/view_key_adv_subkeys_fragment.xml | 34 ++ .../main/res/layout/view_key_advanced_activity.xml | 32 -- .../main/res/layout/view_key_advanced_fragment.xml | 87 ----- .../main/res/layout/view_key_share_fragment.xml | 212 ----------- 19 files changed, 1797 insertions(+), 1544 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedActivity.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedFragment.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_activity.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_certs_fragment.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_subkeys_fragment.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_advanced_activity.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_advanced_fragment.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_share_fragment.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 8cbb3bd41..6426a229c 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -413,9 +413,9 @@ android:value=".ui.ViewKeyActivity" /> + android:label="@string/title_advanced_key_info"/> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.support.v4.view.ViewPager; +import android.view.View; +import android.widget.Toast; + +import com.astuetz.PagerSlidingTabStrip; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.KeyRing; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.util.ContactHelper; +import org.sufficientlysecure.keychain.util.ExportHelper; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.Date; + +public class ViewKeyAdvActivity extends BaseActivity implements + LoaderManager.LoaderCallbacks { + + ExportHelper mExportHelper; + ProviderHelper mProviderHelper; + + protected Uri mDataUri; + + public static final String EXTRA_SELECTED_TAB = "selected_tab"; + public static final int TAB_MAIN = 0; + public static final int TAB_SHARE = 1; + + // view + private ViewPager mViewPager; + private PagerSlidingTabStrip mSlidingTabLayout; + private PagerTabStripAdapter mTabsAdapter; + + private static final int LOADER_ID_UNIFIED = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setFullScreenDialogClose(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + mExportHelper = new ExportHelper(this); + mProviderHelper = new ProviderHelper(this); + + mViewPager = (ViewPager) findViewById(R.id.view_key_pager); + mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.view_key_sliding_tab_layout); + + int switchToTab = TAB_MAIN; + Intent intent = getIntent(); + if (intent.getExtras() != null && intent.getExtras().containsKey(EXTRA_SELECTED_TAB)) { + switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB); + } + + mDataUri = getIntent().getData(); + if (mDataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be uri of key!"); + finish(); + return; + } + if (mDataUri.getHost().equals(ContactsContract.AUTHORITY)) { + mDataUri = ContactHelper.dataUriFromContactUri(this, mDataUri); + if (mDataUri == null) { + Log.e(Constants.TAG, "Contact Data missing. Should be uri of key!"); + Toast.makeText(this, R.string.error_contacts_key_id_missing, Toast.LENGTH_LONG).show(); + finish(); + return; + } + } + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + + initTabs(mDataUri); + + // switch to tab selected by extra + mViewPager.setCurrentItem(switchToTab); + } + + @Override + protected void initLayout() { + setContentView(R.layout.view_key_adv_activity); + } + + private void initTabs(Uri dataUri) { + mTabsAdapter = new PagerTabStripAdapter(this); + mViewPager.setAdapter(mTabsAdapter); + + Bundle mainBundle = new Bundle(); + mainBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvMainFragment.class, + mainBundle, getString(R.string.key_view_tab_main)); + + Bundle shareBundle = new Bundle(); + shareBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvShareFragment.class, + shareBundle, getString(R.string.key_view_tab_share)); + + Bundle keysBundle = new Bundle(); + keysBundle.putParcelable(ViewKeyAdvKeysFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvKeysFragment.class, + keysBundle, getString(R.string.key_view_tab_keys)); + + Bundle certsBundle = new Bundle(); + certsBundle.putParcelable(ViewKeyAdvCertsFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvCertsFragment.class, + certsBundle, getString(R.string.key_view_tab_certs)); + + // update layout after operations + mSlidingTabLayout.setViewPager(mViewPager); + } + + // These are the rows that we will retrieve. + static final String[] PROJECTION = new String[]{ + KeychainContract.KeyRings._ID, + KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.USER_ID, + KeychainContract.KeyRings.IS_REVOKED, + KeychainContract.KeyRings.EXPIRY, + KeychainContract.KeyRings.VERIFIED, + KeychainContract.KeyRings.HAS_ANY_SECRET + }; + + static final int INDEX_MASTER_KEY_ID = 1; + static final int INDEX_USER_ID = 2; + static final int INDEX_IS_REVOKED = 3; + static final int INDEX_EXPIRY = 4; + static final int INDEX_VERIFIED = 5; + static final int INDEX_HAS_ANY_SECRET = 6; + + @Override + public Loader onCreateLoader(int id, Bundle args) { + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(this, baseUri, PROJECTION, null, null, null); + } + + default: + return null; + } + } + + @Override + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + // get name, email, and comment from USER_ID + String[] mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID)); + if (mainUserId[0] != null) { + setTitle(mainUserId[0]); + } else { + setTitle(R.string.user_id_no_name); + } + + // get key id from MASTER_KEY_ID + long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID); + getSupportActionBar().setSubtitle(KeyFormattingUtils.beautifyKeyIdWithPrefix(this, masterKeyId)); + + boolean isSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; + boolean isExpired = !data.isNull(INDEX_EXPIRY) + && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); + boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; + + // Note: order is important + int color; + if (isRevoked || isExpired) { + color = getResources().getColor(R.color.android_red_light); + } else if (isSecret) { + color = getResources().getColor(R.color.primary); + } else { + if (isVerified) { + color = getResources().getColor(R.color.primary); + } else { + color = getResources().getColor(R.color.android_orange_light); + } + } + mToolbar.setBackgroundColor(color); + mStatusBar.setBackgroundColor(color); + mSlidingTabLayout.setBackgroundColor(color); + + break; + } + } + } + } + + @Override + public void onLoaderReset(Loader loader) { + + } +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java new file mode 100644 index 000000000..83daa541d --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2014-2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +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.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.KeyRing; +import org.sufficientlysecure.keychain.pgp.WrappedSignature; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.util.Log; + +import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; +import se.emilsjolander.stickylistheaders.StickyListHeadersListView; + + +public class ViewKeyAdvCertsFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks, AdapterView.OnItemClickListener { + + public static final String ARG_DATA_URI = "data_uri"; + + private StickyListHeadersListView mStickyList; + private CertListAdapter mCertsAdapter; + + private Uri mDataUriCerts; + + // These are the rows that we will retrieve. + static final String[] CERTS_PROJECTION = new String[]{ + KeychainContract.Certs._ID, + KeychainContract.Certs.MASTER_KEY_ID, + KeychainContract.Certs.VERIFIED, + KeychainContract.Certs.TYPE, + KeychainContract.Certs.RANK, + KeychainContract.Certs.KEY_ID_CERTIFIER, + KeychainContract.Certs.USER_ID, + KeychainContract.Certs.SIGNER_UID + }; + + // sort by our user id, + static final String CERTS_SORT_ORDER = + KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.RANK + " ASC, " + + KeychainContract.Certs.VERIFIED + " DESC, " + + KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.TYPE + " DESC, " + + KeychainContract.Certs.SIGNER_UID + " ASC"; + + /** + * Creates new instance of this fragment + */ + public static ViewKeyAdvCertsFragment newInstance(Uri dataUri) { + ViewKeyAdvCertsFragment frag = new ViewKeyAdvCertsFragment(); + + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); + + frag.setArguments(args); + return frag; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_adv_certs_fragment, getContainer()); + + mStickyList = (StickyListHeadersListView) view.findViewById(R.id.certs_list); + + return root; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUriCerts = KeychainContract.Certs.buildCertsUri(dataUri); + + mStickyList.setAreHeadersSticky(true); + mStickyList.setDrawingListUnderStickyHeader(false); + mStickyList.setOnItemClickListener(this); + + mStickyList.setEmptyView(getActivity().findViewById(R.id.empty)); + + // Create an empty adapter we will use to display the loaded data. + mCertsAdapter = new CertListAdapter(getActivity(), null); + mStickyList.setAdapter(mCertsAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(0, null, this); + } + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + + // Now create and return a CursorLoader that will take care of + // creating a Cursor for the data being displayed. + return new CursorLoader(getActivity(), mDataUriCerts, + CERTS_PROJECTION, null, null, CERTS_SORT_ORDER); + + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Avoid NullPointerExceptions, if we get an empty result set. + if (data.getCount() == 0) { + return; + } + + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mCertsAdapter.swapCursor(data); + mStickyList.setAdapter(mCertsAdapter); + + // TODO: maybe show not before both are loaded! + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + mCertsAdapter.swapCursor(null); + } + + /** + * On click on item, start key view activity + */ + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + if (view.getTag(R.id.tag_mki) != null) { + long masterKeyId = (Long) view.getTag(R.id.tag_mki); + long rank = (Long) view.getTag(R.id.tag_rank); + long certifierId = (Long) view.getTag(R.id.tag_certifierId); + + Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class); + viewIntent.setData(KeychainContract.Certs.buildCertsSpecificUri( + masterKeyId, rank, certifierId)); + startActivity(viewIntent); + } + } + + + /** + * Implements StickyListHeadersAdapter from library + */ + private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter { + private LayoutInflater mInflater; + private int mIndexMasterKeyId, mIndexUserId, mIndexRank; + private int mIndexSignerKeyId, mIndexSignerUserId; + private int mIndexVerified, mIndexType; + + public CertListAdapter(Context context, Cursor c) { + super(context, c, 0); + + 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) { + mIndexMasterKeyId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.MASTER_KEY_ID); + mIndexUserId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.USER_ID); + mIndexRank = cursor.getColumnIndexOrThrow(KeychainContract.Certs.RANK); + mIndexType = cursor.getColumnIndexOrThrow(KeychainContract.Certs.TYPE); + mIndexVerified = cursor.getColumnIndexOrThrow(KeychainContract.Certs.VERIFIED); + mIndexSignerKeyId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.KEY_ID_CERTIFIER); + mIndexSignerUserId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.SIGNER_UID); + } + } + + /** + * Bind cursor data to the item list view + *

+ * NOTE: CursorAdapter already implements the ViewHolder pattern in its getView() method. + * Thus no ViewHolder is required here. + */ + @Override + public void bindView(View view, Context context, Cursor cursor) { + + // set name and stuff, common to both key types + TextView wSignerKeyId = (TextView) view.findViewById(R.id.signerKeyId); + TextView wSignerName = (TextView) view.findViewById(R.id.signerName); + TextView wSignStatus = (TextView) view.findViewById(R.id.signStatus); + + String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(getActivity(), cursor.getLong(mIndexSignerKeyId)); + String[] userId = KeyRing.splitUserId(cursor.getString(mIndexSignerUserId)); + if (userId[0] != null) { + wSignerName.setText(userId[0]); + } else { + wSignerName.setText(R.string.user_id_no_name); + } + wSignerKeyId.setText(signerKeyId); + + switch (cursor.getInt(mIndexType)) { + case WrappedSignature.DEFAULT_CERTIFICATION: // 0x10 + wSignStatus.setText(R.string.cert_default); + break; + case WrappedSignature.NO_CERTIFICATION: // 0x11 + wSignStatus.setText(R.string.cert_none); + break; + case WrappedSignature.CASUAL_CERTIFICATION: // 0x12 + wSignStatus.setText(R.string.cert_casual); + break; + case WrappedSignature.POSITIVE_CERTIFICATION: // 0x13 + wSignStatus.setText(R.string.cert_positive); + break; + case WrappedSignature.CERTIFICATION_REVOCATION: // 0x30 + wSignStatus.setText(R.string.cert_revoke); + break; + } + + + view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId)); + view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank)); + view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId)); + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) { + return mInflater.inflate(R.layout.view_key_certs_item, parent, false); + } + + /** + * Creates a new header view and binds the section headers to it. It uses the ViewHolder + * pattern. Most functionality is similar to getView() from Android's CursorAdapter. + *

+ * NOTE: The variables mDataValid and mCursor are available due to the super class + * CursorAdapter. + */ + @Override + public View getHeaderView(int position, View convertView, ViewGroup parent) { + HeaderViewHolder holder; + if (convertView == null) { + holder = new HeaderViewHolder(); + convertView = mInflater.inflate(R.layout.view_key_certs_header, parent, false); + holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text); + holder.count = (TextView) convertView.findViewById(R.id.certs_num); + convertView.setTag(holder); + } else { + holder = (HeaderViewHolder) convertView.getTag(); + } + + if (!mDataValid) { + // no data available at this point + Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); + return convertView; + } + + if (!mCursor.moveToPosition(position)) { + throw new IllegalStateException("couldn't move cursor to position " + position); + } + + // set header text as first char in user id + String userId = mCursor.getString(mIndexUserId); + holder.text.setText(userId); + holder.count.setVisibility(View.GONE); + return convertView; + } + + /** + * Header IDs should be static, position=1 should always return the same Id that is. + */ + @Override + public long getHeaderId(int position) { + if (!mDataValid) { + // no data available at this point + Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); + return -1; + } + + if (!mCursor.moveToPosition(position)) { + throw new IllegalStateException("couldn't move cursor to position " + position); + } + + // otherwise, return the first character of the name as ID + return mCursor.getInt(mIndexRank); + + // sort by the first four characters (should be enough I guess?) + // return ByteBuffer.wrap(userId.getBytes()).asLongBuffer().get(0); + } + + class HeaderViewHolder { + TextView text; + TextView count; + } + + } +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java new file mode 100644 index 000000000..548e249b6 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2014-2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; +import org.sufficientlysecure.keychain.util.Log; + +public class ViewKeyAdvKeysFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "data_uri"; + + private ListView mSubkeysList; + private SubkeysAdapter mSubkeysAdapter; + + private Uri mDataUriSubkeys; + + /** + * Creates new instance of this fragment + */ + public static ViewKeyAdvKeysFragment newInstance(Uri dataUri) { + ViewKeyAdvKeysFragment frag = new ViewKeyAdvKeysFragment(); + + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); + + frag.setArguments(args); + return frag; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_adv_subkeys_fragment, getContainer()); + + mSubkeysList = (ListView) view.findViewById(R.id.keys); + + return root; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUriSubkeys = KeychainContract.Keys.buildKeysUri(dataUri); + + // Create an empty adapter we will use to display the loaded data. + mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0); + mSubkeysList.setAdapter(mSubkeysAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(0, null, this); + } + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + return new CursorLoader(getActivity(), mDataUriSubkeys, + SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null); + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Avoid NullPointerExceptions, if we get an empty result set. + if (data.getCount() == 0) { + return; + } + + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mSubkeysAdapter.swapCursor(data); + + // TODO: maybe show not before both are loaded! + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + mSubkeysAdapter.swapCursor(null); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java new file mode 100644 index 000000000..8bab5e3bf --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java @@ -0,0 +1,350 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * Copyright (C) 2014 Vincent Breitmoser + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.content.Intent; +import android.database.Cursor; +import android.graphics.PorterDuff; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.ListView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; +import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.Date; + +public class ViewKeyAdvMainFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "uri"; + + private View mActionEdit; + private View mActionEditDivider; + private View mActionEncryptFiles; + private View mActionEncryptText; + private View mActionEncryptTextText; + private View mActionCertify; + private View mActionCertifyText; + private ImageView mActionCertifyImage; + private View mActionUpdate; + + private ListView mUserIds; + + private static final int LOADER_ID_UNIFIED = 0; + private static final int LOADER_ID_USER_IDS = 1; + + // conservative attitude + private boolean mHasEncrypt = true; + + private UserIdsAdapter mUserIdsAdapter; + + private Uri mDataUri; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer()); + + mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); + mActionEdit = view.findViewById(R.id.view_key_action_edit); + mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); + mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text); + mActionEncryptTextText = view.findViewById(R.id.view_key_action_encrypt_text_text); + mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files); + mActionCertify = view.findViewById(R.id.view_key_action_certify); + mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text); + mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image); + // make certify image gray, like action icons + mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), + PorterDuff.Mode.SRC_IN); + mActionUpdate = view.findViewById(R.id.view_key_action_update); + + mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + showUserIdInfo(position); + } + }); + + return root; + } + + private void showUserIdInfo(final int position) { + final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); + final int isVerified = mUserIdsAdapter.getIsVerified(position); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + UserIdInfoDialogFragment dialogFragment = + UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); + } + }); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUri = dataUri; + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + mActionEncryptFiles.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, false); + } + }); + mActionEncryptText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, true); + } + }); + mActionCertify.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + certify(mDataUri); + } + }); + mActionEdit.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + editKey(mDataUri); + } + }); + mActionUpdate.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + try { + updateFromKeyserver(mDataUri, new ProviderHelper(getActivity())); + } catch (NotFoundException e) { + Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); + } + } + }); + + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); + mUserIds.setAdapter(mUserIdsAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); + } + + static final String[] UNIFIED_PROJECTION = new String[]{ + KeyRings._ID, KeyRings.MASTER_KEY_ID, + KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, KeyRings.EXPIRY, KeyRings.HAS_ENCRYPT + }; + static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; + static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; + static final int INDEX_UNIFIED_IS_REVOKED = 3; + static final int INDEX_UNIFIED_EXPIRY = 4; + static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + case LOADER_ID_USER_IDS: { + Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + } + + default: + return null; + } + } + + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) { + // edit button + mActionEdit.setVisibility(View.VISIBLE); + mActionEditDivider.setVisibility(View.VISIBLE); + } else { + // edit button + mActionEdit.setVisibility(View.GONE); + mActionEditDivider.setVisibility(View.GONE); + } + + // If this key is revoked, it cannot be used for anything! + if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { + mActionEdit.setEnabled(false); + mActionCertify.setEnabled(false); + mActionCertifyText.setEnabled(false); + mActionEncryptText.setEnabled(false); + mActionEncryptTextText.setEnabled(false); + mActionEncryptFiles.setEnabled(false); + } else { + mActionEdit.setEnabled(true); + + Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); + if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { + mActionCertify.setEnabled(false); + mActionCertifyText.setEnabled(false); + mActionEncryptText.setEnabled(false); + mActionEncryptTextText.setEnabled(false); + mActionEncryptFiles.setEnabled(false); + } else { + mActionCertify.setEnabled(true); + mActionCertifyText.setEnabled(true); + mActionEncryptText.setEnabled(true); + mActionEncryptTextText.setEnabled(true); + mActionEncryptFiles.setEnabled(true); + } + } + + mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0; + + break; + } + } + + case LOADER_ID_USER_IDS: + mUserIdsAdapter.swapCursor(data); + break; + + } + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + switch (loader.getId()) { + case LOADER_ID_USER_IDS: + mUserIdsAdapter.swapCursor(null); + break; + } + } + + private void encrypt(Uri dataUri, boolean text) { + // If there is no encryption key, don't bother. + if (!mHasEncrypt) { + Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR); + return; + } + try { + long keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + long[] encryptionKeyIds = new long[]{keyId}; + Intent intent; + if (text) { + intent = new Intent(getActivity(), EncryptTextActivity.class); + intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT); + intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } else { + intent = new Intent(getActivity(), EncryptFilesActivity.class); + intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA); + intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } + // used instead of startActivity set actionbar based on callingPackage + startActivityForResult(intent, 0); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + } + + private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) + throws ProviderHelper.NotFoundException { + byte[] blob = (byte[]) providerHelper.getGenericData( + KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); + + Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class); + queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); + queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + + startActivityForResult(queryIntent, 0); + } + + private void certify(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); + certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); + startActivityForResult(certifyIntent, 0); + } + + private void editKey(Uri dataUri) { + Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); + editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); + startActivityForResult(editIntent, 0); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java new file mode 100644 index 000000000..6208cff4e --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvShareFragment.java @@ -0,0 +1,387 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.annotation.TargetApi; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.PorterDuff; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.IOException; + + +public class ViewKeyAdvShareFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "uri"; + + private TextView mFingerprint; + private ImageView mFingerprintQrCode; + private View mFingerprintShareButton; + private View mFingerprintClipboardButton; + private View mKeyShareButton; + private View mKeyClipboardButton; + private ImageButton mKeySafeSlingerButton; + private View mNfcHelpButton; + private View mNfcPrefsButton; + private View mKeyUploadButton; + + ProviderHelper mProviderHelper; + + private static final int LOADER_ID_UNIFIED = 0; + + private Uri mDataUri; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_adv_share_fragment, getContainer()); + + mProviderHelper = new ProviderHelper(ViewKeyAdvShareFragment.this.getActivity()); + + mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint); + mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image); + mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share); + mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard); + mKeyShareButton = view.findViewById(R.id.view_key_action_key_share); + mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); + mKeySafeSlingerButton = (ImageButton) view.findViewById(R.id.view_key_action_key_safeslinger); + mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); + mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); + mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); + + mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light), + PorterDuff.Mode.SRC_IN); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mNfcPrefsButton.setVisibility(View.VISIBLE); + } else { + mNfcPrefsButton.setVisibility(View.GONE); + } + + mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showQrCodeDialog(); + } + }); + + mFingerprintShareButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, true, false); + } + }); + mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, true, true); + } + }); + mKeyShareButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, false, false); + } + }); + mKeyClipboardButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, false, true); + } + }); + mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startSafeSlinger(mDataUri); + } + }); + mNfcHelpButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showNfcHelpDialog(); + } + }); + mNfcPrefsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showNfcPrefs(); + } + }); + mKeyUploadButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + uploadToKeyserver(); + } + }); + + return root; + } + + private void startSafeSlinger(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class); + safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); + startActivityForResult(safeSlingerIntent, 0); + } + + private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, + boolean toClipboard) { + try { + String content; + if (fingerprintOnly) { + byte[] data = (byte[]) providerHelper.getGenericData( + KeyRings.buildUnifiedKeyRingUri(dataUri), + Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data); + if (!toClipboard) { + content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + } else { + content = fingerprint; + } + } else { + Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(dataUri); + // get public keyring as ascii armored string + content = providerHelper.getKeyRingAsArmoredString(uri); + } + + if (toClipboard) { + ClipboardReflection.copyToClipboard(getActivity(), content); + String message; + if (fingerprintOnly) { + message = getResources().getString(R.string.fingerprint_copied_to_clipboard); + } else { + message = getResources().getString(R.string.key_copied_to_clipboard); + } + Notify.showNotify(getActivity(), message, Notify.Style.OK); + } else { + // Android will fail with android.os.TransactionTooLargeException if key is too big + // see http://www.lonestarprod.com/?p=34 + if (content.length() >= 86389) { + Notify.showNotify(getActivity(), R.string.key_too_big_for_sharing, + Notify.Style.ERROR); + return; + } + + // let user choose application + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, content); + sendIntent.setType("text/plain"); + String title; + if (fingerprintOnly) { + title = getResources().getString(R.string.title_share_fingerprint_with); + } else { + title = getResources().getString(R.string.title_share_key); + } + startActivity(Intent.createChooser(sendIntent, title)); + } + } catch (PgpGeneralException | IOException e) { + Log.e(Constants.TAG, "error processing key!", e); + Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR); + } catch (ProviderHelper.NotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); + } + } + + private void showQrCodeDialog() { + Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class); + qrCodeIntent.setData(mDataUri); + startActivity(qrCodeIntent); + } + + private void showNfcHelpDialog() { + ShareNfcDialogFragment dialog = ShareNfcDialogFragment.newInstance(); + dialog.show(getActivity().getSupportFragmentManager(), "shareNfcDialog"); + } + + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) + private void showNfcPrefs() { + Intent intentSettings = new Intent( + Settings.ACTION_NFCSHARING_SETTINGS); + startActivity(intentSettings); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUri = dataUri; + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + } + + static final String[] UNIFIED_PROJECTION = new String[]{ + KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET, + KeyRings.USER_ID, KeyRings.FINGERPRINT, + KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY, + + }; + static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; + static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; + static final int INDEX_UNIFIED_USER_ID = 3; + static final int INDEX_UNIFIED_FINGERPRINT = 4; + static final int INDEX_UNIFIED_ALGORITHM = 5; + static final int INDEX_UNIFIED_KEY_SIZE = 6; + static final int INDEX_UNIFIED_CREATION = 7; + static final int INDEX_UNIFIED_EXPIRY = 8; + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + + default: + return null; + } + } + + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + + byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); + mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); + + loadQrCode(fingerprint); + + break; + } + } + + } + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + } + + /** + * Load QR Code asynchronously and with a fade in animation + * + * @param fingerprint + */ + private void loadQrCode(final String fingerprint) { + AsyncTask loadTask = + new AsyncTask() { + protected Bitmap doInBackground(Void... unused) { + String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + // render with minimal size + return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); + } + + protected void onPostExecute(Bitmap qrCode) { + // only change view, if fragment is attached to activity + if (ViewKeyAdvShareFragment.this.isAdded()) { + + // scale the image up to our actual size. we do this in code rather + // than let the ImageView do this because we don't require filtering. + Bitmap scaled = Bitmap.createScaledBitmap(qrCode, + mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(), + false); + mFingerprintQrCode.setImageBitmap(scaled); + + // simple fade-in animation + AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); + anim.setDuration(200); + mFingerprintQrCode.startAnimation(anim); + } + } + }; + + loadTask.execute(); + } + + private void uploadToKeyserver() { + Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); + uploadIntent.setData(mDataUri); + startActivityForResult(uploadIntent, 0); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedActivity.java deleted file mode 100644 index 471f55c47..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedActivity.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2013-2014 Dominik Schürmann - * Copyright (C) 2013 Bahtiar 'kalkin' Gadimov - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.net.Uri; -import android.os.Bundle; -import android.view.View; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.ExportHelper; -import org.sufficientlysecure.keychain.util.Log; - -public class ViewKeyAdvancedActivity extends BaseActivity { - - ExportHelper mExportHelper; - ProviderHelper mProviderHelper; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mExportHelper = new ExportHelper(this); - mProviderHelper = new ProviderHelper(this); - - // Inflate a "Done" custom action bar - setFullScreenDialogClose( - new View.OnClickListener() { - @Override - public void onClick(View v) { - // "Done" - finish(); - } - } - ); - - Uri dataUri = getIntent().getData(); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be uri of key!"); - finish(); - return; - } - - Log.i(Constants.TAG, "mDataUri: " + dataUri.toString()); - - startFragment(savedInstanceState, dataUri); - } - - @Override - protected void initLayout() { - setContentView(R.layout.view_key_advanced_activity); - } - - private void startFragment(Bundle savedInstanceState, Uri dataUri) { - // However, if we're being restored from a previous state, - // then we don't need to do anything and should return or else - // we could end up with overlapping fragments. - if (savedInstanceState != null) { - return; - } - - // Create an instance of the fragment - ViewKeyAdvancedFragment frag = ViewKeyAdvancedFragment.newInstance(dataUri); - - // Add the fragment to the 'fragment_container' FrameLayout - // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! - getSupportFragmentManager().beginTransaction() - .replace(R.id.view_key_advanced_fragment, frag) - .commitAllowingStateLoss(); - // do it immediately! - getSupportFragmentManager().executePendingTransactions(); - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedFragment.java deleted file mode 100644 index 61bd126ce..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvancedFragment.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.content.Context; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -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.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.TextView; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.KeyRing; -import org.sufficientlysecure.keychain.pgp.WrappedSignature; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainDatabase; -import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; -import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.util.Log; - -import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter; -import se.emilsjolander.stickylistheaders.StickyListHeadersListView; - - -public class ViewKeyAdvancedFragment extends LoaderFragment implements - LoaderManager.LoaderCallbacks, AdapterView.OnItemClickListener { - - public static final String ARG_DATA_URI = "data_uri"; - - private ListView mSubkeysList; - private SubkeysAdapter mSubkeysAdapter; - - private StickyListHeadersListView mStickyList; - private CertListAdapter mCertsAdapter; - - private Uri mDataUriSubkeys; - private Uri mDataUriCerts; - - private static final int LOADER_SUBKEYS = 1; - private static final int LOADER_CERTS = 2; - - // These are the rows that we will retrieve. - static final String[] CERTS_PROJECTION = new String[]{ - KeychainContract.Certs._ID, - KeychainContract.Certs.MASTER_KEY_ID, - KeychainContract.Certs.VERIFIED, - KeychainContract.Certs.TYPE, - KeychainContract.Certs.RANK, - KeychainContract.Certs.KEY_ID_CERTIFIER, - KeychainContract.Certs.USER_ID, - KeychainContract.Certs.SIGNER_UID - }; - - // sort by our user id, - static final String CERTS_SORT_ORDER = - KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.RANK + " ASC, " - + KeychainContract.Certs.VERIFIED + " DESC, " - + KeychainDatabase.Tables.CERTS + "." + KeychainContract.Certs.TYPE + " DESC, " - + KeychainContract.Certs.SIGNER_UID + " ASC"; - - /** - * Creates new instance of this fragment - */ - public static ViewKeyAdvancedFragment newInstance(Uri dataUri) { - ViewKeyAdvancedFragment frag = new ViewKeyAdvancedFragment(); - - Bundle args = new Bundle(); - args.putParcelable(ARG_DATA_URI, dataUri); - - frag.setArguments(args); - return frag; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_advanced_fragment, getContainer()); - - mSubkeysList = (ListView) view.findViewById(R.id.keys); - mStickyList = (StickyListHeadersListView) view.findViewById(R.id.certs_list); - - return root; - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); - getActivity().finish(); - return; - } - - loadData(dataUri); - } - - private void loadData(Uri dataUri) { - mDataUriSubkeys = KeychainContract.Keys.buildKeysUri(dataUri); - mDataUriCerts = KeychainContract.Certs.buildCertsUri(dataUri); - - mStickyList.setAreHeadersSticky(true); - mStickyList.setDrawingListUnderStickyHeader(false); - mStickyList.setOnItemClickListener(this); - - mStickyList.setEmptyView(getActivity().findViewById(R.id.empty)); - - // Create an empty adapter we will use to display the loaded data. - mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0); - mSubkeysList.setAdapter(mSubkeysAdapter); - - mCertsAdapter = new CertListAdapter(getActivity(), null); - mStickyList.setAdapter(mCertsAdapter); - - // Prepare the loaders. Either re-connect with an existing ones, - // or start new ones. - getLoaderManager().initLoader(LOADER_SUBKEYS, null, this); - getLoaderManager().initLoader(LOADER_CERTS, null, this); - } - - public Loader onCreateLoader(int id, Bundle args) { - setContentShown(false); - switch (id) { - case LOADER_SUBKEYS: - return new CursorLoader(getActivity(), mDataUriSubkeys, - SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null); - - case LOADER_CERTS: - // Now create and return a CursorLoader that will take care of - // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), mDataUriCerts, - CERTS_PROJECTION, null, null, CERTS_SORT_ORDER); - - default: - return null; - } - } - - public void onLoadFinished(Loader loader, Cursor data) { - // Avoid NullPointerExceptions, if we get an empty result set. - if (data.getCount() == 0) { - return; - } - - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - switch (loader.getId()) { - case LOADER_SUBKEYS: - mSubkeysAdapter.swapCursor(data); - break; - case LOADER_CERTS: - mCertsAdapter.swapCursor(data); - mStickyList.setAdapter(mCertsAdapter); - break; - } - - // TODO: maybe show not before both are loaded! - setContentShown(true); - } - - /** - * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. - * We need to make sure we are no longer using it. - */ - public void onLoaderReset(Loader loader) { - switch (loader.getId()) { - case LOADER_SUBKEYS: - mSubkeysAdapter.swapCursor(null); - break; - case LOADER_CERTS: - mCertsAdapter.swapCursor(null); - break; - } - } - - /** - * On click on item, start key view activity - */ - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long id) { - if (view.getTag(R.id.tag_mki) != null) { - long masterKeyId = (Long) view.getTag(R.id.tag_mki); - long rank = (Long) view.getTag(R.id.tag_rank); - long certifierId = (Long) view.getTag(R.id.tag_certifierId); - - Intent viewIntent = new Intent(getActivity(), ViewCertActivity.class); - viewIntent.setData(KeychainContract.Certs.buildCertsSpecificUri( - masterKeyId, rank, certifierId)); - startActivity(viewIntent); - } - } - - - /** - * Implements StickyListHeadersAdapter from library - */ - private class CertListAdapter extends CursorAdapter implements StickyListHeadersAdapter { - private LayoutInflater mInflater; - private int mIndexMasterKeyId, mIndexUserId, mIndexRank; - private int mIndexSignerKeyId, mIndexSignerUserId; - private int mIndexVerified, mIndexType; - - public CertListAdapter(Context context, Cursor c) { - super(context, c, 0); - - 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) { - mIndexMasterKeyId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.MASTER_KEY_ID); - mIndexUserId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.USER_ID); - mIndexRank = cursor.getColumnIndexOrThrow(KeychainContract.Certs.RANK); - mIndexType = cursor.getColumnIndexOrThrow(KeychainContract.Certs.TYPE); - mIndexVerified = cursor.getColumnIndexOrThrow(KeychainContract.Certs.VERIFIED); - mIndexSignerKeyId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.KEY_ID_CERTIFIER); - mIndexSignerUserId = cursor.getColumnIndexOrThrow(KeychainContract.Certs.SIGNER_UID); - } - } - - /** - * Bind cursor data to the item list view - *

- * NOTE: CursorAdapter already implements the ViewHolder pattern in its getView() method. - * Thus no ViewHolder is required here. - */ - @Override - public void bindView(View view, Context context, Cursor cursor) { - - // set name and stuff, common to both key types - TextView wSignerKeyId = (TextView) view.findViewById(R.id.signerKeyId); - TextView wSignerName = (TextView) view.findViewById(R.id.signerName); - TextView wSignStatus = (TextView) view.findViewById(R.id.signStatus); - - String signerKeyId = KeyFormattingUtils.beautifyKeyIdWithPrefix(getActivity(), cursor.getLong(mIndexSignerKeyId)); - String[] userId = KeyRing.splitUserId(cursor.getString(mIndexSignerUserId)); - if (userId[0] != null) { - wSignerName.setText(userId[0]); - } else { - wSignerName.setText(R.string.user_id_no_name); - } - wSignerKeyId.setText(signerKeyId); - - switch (cursor.getInt(mIndexType)) { - case WrappedSignature.DEFAULT_CERTIFICATION: // 0x10 - wSignStatus.setText(R.string.cert_default); - break; - case WrappedSignature.NO_CERTIFICATION: // 0x11 - wSignStatus.setText(R.string.cert_none); - break; - case WrappedSignature.CASUAL_CERTIFICATION: // 0x12 - wSignStatus.setText(R.string.cert_casual); - break; - case WrappedSignature.POSITIVE_CERTIFICATION: // 0x13 - wSignStatus.setText(R.string.cert_positive); - break; - case WrappedSignature.CERTIFICATION_REVOCATION: // 0x30 - wSignStatus.setText(R.string.cert_revoke); - break; - } - - - view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId)); - view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank)); - view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId)); - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - return mInflater.inflate(R.layout.view_key_certs_item, parent, false); - } - - /** - * Creates a new header view and binds the section headers to it. It uses the ViewHolder - * pattern. Most functionality is similar to getView() from Android's CursorAdapter. - *

- * NOTE: The variables mDataValid and mCursor are available due to the super class - * CursorAdapter. - */ - @Override - public View getHeaderView(int position, View convertView, ViewGroup parent) { - HeaderViewHolder holder; - if (convertView == null) { - holder = new HeaderViewHolder(); - convertView = mInflater.inflate(R.layout.view_key_certs_header, parent, false); - holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text); - holder.count = (TextView) convertView.findViewById(R.id.certs_num); - convertView.setTag(holder); - } else { - holder = (HeaderViewHolder) convertView.getTag(); - } - - if (!mDataValid) { - // no data available at this point - Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); - return convertView; - } - - if (!mCursor.moveToPosition(position)) { - throw new IllegalStateException("couldn't move cursor to position " + position); - } - - // set header text as first char in user id - String userId = mCursor.getString(mIndexUserId); - holder.text.setText(userId); - holder.count.setVisibility(View.GONE); - return convertView; - } - - /** - * Header IDs should be static, position=1 should always return the same Id that is. - */ - @Override - public long getHeaderId(int position) { - if (!mDataValid) { - // no data available at this point - Log.d(Constants.TAG, "getHeaderView: No data available at this point!"); - return -1; - } - - if (!mCursor.moveToPosition(position)) { - throw new IllegalStateException("couldn't move cursor to position " + position); - } - - // otherwise, return the first character of the name as ID - return mCursor.getInt(mIndexRank); - - // sort by the first four characters (should be enough I guess?) - // return ByteBuffer.wrap(userId.getBytes()).asLongBuffer().get(0); - } - - class HeaderViewHolder { - TextView text; - TextView count; - } - - } -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java deleted file mode 100644 index 8e957a36f..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * Copyright (C) 2014 Vincent Breitmoser - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.content.Intent; -import android.database.Cursor; -import android.graphics.PorterDuff; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ImageView; -import android.widget.ListView; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; -import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; -import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; -import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.util.Log; - -import java.util.Date; - -public class ViewKeyMainFragment extends LoaderFragment implements - LoaderManager.LoaderCallbacks { - - public static final String ARG_DATA_URI = "uri"; - - private View mActionEdit; - private View mActionEditDivider; - private View mActionEncryptFiles; - private View mActionEncryptText; - private View mActionEncryptTextText; - private View mActionCertify; - private View mActionCertifyText; - private ImageView mActionCertifyImage; - private View mActionUpdate; - - private ListView mUserIds; - - private static final int LOADER_ID_UNIFIED = 0; - private static final int LOADER_ID_USER_IDS = 1; - - // conservative attitude - private boolean mHasEncrypt = true; - - private UserIdsAdapter mUserIdsAdapter; - - private Uri mDataUri; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer()); - - mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); - mActionEdit = view.findViewById(R.id.view_key_action_edit); - mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); - mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text); - mActionEncryptTextText = view.findViewById(R.id.view_key_action_encrypt_text_text); - mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files); - mActionCertify = view.findViewById(R.id.view_key_action_certify); - mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text); - mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image); - // make certify image gray, like action icons - mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), - PorterDuff.Mode.SRC_IN); - mActionUpdate = view.findViewById(R.id.view_key_action_update); - - mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - showUserIdInfo(position); - } - }); - - return root; - } - - private void showUserIdInfo(final int position) { - final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); - final int isVerified = mUserIdsAdapter.getIsVerified(position); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - UserIdInfoDialogFragment dialogFragment = - UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); - } - }); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); - getActivity().finish(); - return; - } - - loadData(dataUri); - } - - private void loadData(Uri dataUri) { - mDataUri = dataUri; - - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - - mActionEncryptFiles.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - encrypt(mDataUri, false); - } - }); - mActionEncryptText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - encrypt(mDataUri, true); - } - }); - mActionCertify.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - certify(mDataUri); - } - }); - mActionEdit.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - editKey(mDataUri); - } - }); - mActionUpdate.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - try { - updateFromKeyserver(mDataUri, new ProviderHelper(getActivity())); - } catch (NotFoundException e) { - Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); - } - } - }); - - mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); - mUserIds.setAdapter(mUserIdsAdapter); - - // Prepare the loaders. Either re-connect with an existing ones, - // or start new ones. - getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); - getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); - } - - static final String[] UNIFIED_PROJECTION = new String[]{ - KeyRings._ID, KeyRings.MASTER_KEY_ID, - KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, KeyRings.EXPIRY, KeyRings.HAS_ENCRYPT - }; - static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; - static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; - static final int INDEX_UNIFIED_IS_REVOKED = 3; - static final int INDEX_UNIFIED_EXPIRY = 4; - static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; - - public Loader onCreateLoader(int id, Bundle args) { - setContentShown(false); - - switch (id) { - case LOADER_ID_UNIFIED: { - Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); - } - case LOADER_ID_USER_IDS: { - Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); - } - - default: - return null; - } - } - - public void onLoadFinished(Loader loader, Cursor data) { - /* TODO better error handling? May cause problems when a key is deleted, - * because the notification triggers faster than the activity closes. - */ - // Avoid NullPointerExceptions... - if (data.getCount() == 0) { - return; - } - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - switch (loader.getId()) { - case LOADER_ID_UNIFIED: { - if (data.moveToFirst()) { - if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) { - // edit button - mActionEdit.setVisibility(View.VISIBLE); - mActionEditDivider.setVisibility(View.VISIBLE); - } else { - // edit button - mActionEdit.setVisibility(View.GONE); - mActionEditDivider.setVisibility(View.GONE); - } - - // If this key is revoked, it cannot be used for anything! - if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { - mActionEdit.setEnabled(false); - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - mActionEncryptText.setEnabled(false); - mActionEncryptTextText.setEnabled(false); - mActionEncryptFiles.setEnabled(false); - } else { - mActionEdit.setEnabled(true); - - Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); - if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - mActionEncryptText.setEnabled(false); - mActionEncryptTextText.setEnabled(false); - mActionEncryptFiles.setEnabled(false); - } else { - mActionCertify.setEnabled(true); - mActionCertifyText.setEnabled(true); - mActionEncryptText.setEnabled(true); - mActionEncryptTextText.setEnabled(true); - mActionEncryptFiles.setEnabled(true); - } - } - - mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0; - - break; - } - } - - case LOADER_ID_USER_IDS: - mUserIdsAdapter.swapCursor(data); - break; - - } - setContentShown(true); - } - - /** - * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. - * We need to make sure we are no longer using it. - */ - public void onLoaderReset(Loader loader) { - switch (loader.getId()) { - case LOADER_ID_USER_IDS: - mUserIdsAdapter.swapCursor(null); - break; - } - } - - private void encrypt(Uri dataUri, boolean text) { - // If there is no encryption key, don't bother. - if (!mHasEncrypt) { - Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR); - return; - } - try { - long keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - long[] encryptionKeyIds = new long[]{keyId}; - Intent intent; - if (text) { - intent = new Intent(getActivity(), EncryptTextActivity.class); - intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT); - intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); - } else { - intent = new Intent(getActivity(), EncryptFilesActivity.class); - intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA); - intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); - } - // used instead of startActivity set actionbar based on callingPackage - startActivityForResult(intent, 0); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - } - - private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) - throws ProviderHelper.NotFoundException { - byte[] blob = (byte[]) providerHelper.getGenericData( - KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), - KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); - - Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class); - queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); - queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); - - startActivityForResult(queryIntent, 0); - } - - private void certify(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); - certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); - startActivityForResult(certifyIntent, 0); - } - - private void editKey(Uri dataUri) { - Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); - editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); - startActivityForResult(editIntent, 0); - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java deleted file mode 100644 index 7c47cbd0d..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.annotation.TargetApi; -import android.content.Intent; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.PorterDuff; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Build; -import android.os.Bundle; -import android.provider.Settings; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.AlphaAnimation; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; -import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; -import org.sufficientlysecure.keychain.util.Log; - -import java.io.IOException; - - -public class ViewKeyShareFragment extends LoaderFragment implements - LoaderManager.LoaderCallbacks { - - public static final String ARG_DATA_URI = "uri"; - - private TextView mFingerprint; - private ImageView mFingerprintQrCode; - private View mFingerprintShareButton; - private View mFingerprintClipboardButton; - private View mKeyShareButton; - private View mKeyClipboardButton; - private ImageButton mKeySafeSlingerButton; - private View mNfcHelpButton; - private View mNfcPrefsButton; - private View mKeyUploadButton; - - ProviderHelper mProviderHelper; - - private static final int LOADER_ID_UNIFIED = 0; - - private Uri mDataUri; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_share_fragment, getContainer()); - - mProviderHelper = new ProviderHelper(ViewKeyShareFragment.this.getActivity()); - - mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint); - mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image); - mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share); - mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard); - mKeyShareButton = view.findViewById(R.id.view_key_action_key_share); - mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); - mKeySafeSlingerButton = (ImageButton) view.findViewById(R.id.view_key_action_key_safeslinger); - mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); - mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); - mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); - - mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light), - PorterDuff.Mode.SRC_IN); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - mNfcPrefsButton.setVisibility(View.VISIBLE); - } else { - mNfcPrefsButton.setVisibility(View.GONE); - } - - mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showQrCodeDialog(); - } - }); - - mFingerprintShareButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, true, false); - } - }); - mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, true, true); - } - }); - mKeyShareButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, false, false); - } - }); - mKeyClipboardButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, false, true); - } - }); - mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startSafeSlinger(mDataUri); - } - }); - mNfcHelpButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showNfcHelpDialog(); - } - }); - mNfcPrefsButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showNfcPrefs(); - } - }); - mKeyUploadButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - uploadToKeyserver(); - } - }); - - return root; - } - - private void startSafeSlinger(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class); - safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); - startActivityForResult(safeSlingerIntent, 0); - } - - private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, - boolean toClipboard) { - try { - String content; - if (fingerprintOnly) { - byte[] data = (byte[]) providerHelper.getGenericData( - KeyRings.buildUnifiedKeyRingUri(dataUri), - Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data); - if (!toClipboard) { - content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; - } else { - content = fingerprint; - } - } else { - Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(dataUri); - // get public keyring as ascii armored string - content = providerHelper.getKeyRingAsArmoredString(uri); - } - - if (toClipboard) { - ClipboardReflection.copyToClipboard(getActivity(), content); - String message; - if (fingerprintOnly) { - message = getResources().getString(R.string.fingerprint_copied_to_clipboard); - } else { - message = getResources().getString(R.string.key_copied_to_clipboard); - } - Notify.showNotify(getActivity(), message, Notify.Style.OK); - } else { - // Android will fail with android.os.TransactionTooLargeException if key is too big - // see http://www.lonestarprod.com/?p=34 - if (content.length() >= 86389) { - Notify.showNotify(getActivity(), R.string.key_too_big_for_sharing, - Notify.Style.ERROR); - return; - } - - // let user choose application - Intent sendIntent = new Intent(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_TEXT, content); - sendIntent.setType("text/plain"); - String title; - if (fingerprintOnly) { - title = getResources().getString(R.string.title_share_fingerprint_with); - } else { - title = getResources().getString(R.string.title_share_key); - } - startActivity(Intent.createChooser(sendIntent, title)); - } - } catch (PgpGeneralException | IOException e) { - Log.e(Constants.TAG, "error processing key!", e); - Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR); - } catch (ProviderHelper.NotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); - } - } - - private void showQrCodeDialog() { - Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class); - qrCodeIntent.setData(mDataUri); - startActivity(qrCodeIntent); - } - - private void showNfcHelpDialog() { - ShareNfcDialogFragment dialog = ShareNfcDialogFragment.newInstance(); - dialog.show(getActivity().getSupportFragmentManager(), "shareNfcDialog"); - } - - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - private void showNfcPrefs() { - Intent intentSettings = new Intent( - Settings.ACTION_NFCSHARING_SETTINGS); - startActivity(intentSettings); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); - getActivity().finish(); - return; - } - - loadData(dataUri); - } - - private void loadData(Uri dataUri) { - mDataUri = dataUri; - - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - - // Prepare the loaders. Either re-connect with an existing ones, - // or start new ones. - getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); - } - - static final String[] UNIFIED_PROJECTION = new String[]{ - KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET, - KeyRings.USER_ID, KeyRings.FINGERPRINT, - KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY, - - }; - static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; - static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; - static final int INDEX_UNIFIED_USER_ID = 3; - static final int INDEX_UNIFIED_FINGERPRINT = 4; - static final int INDEX_UNIFIED_ALGORITHM = 5; - static final int INDEX_UNIFIED_KEY_SIZE = 6; - static final int INDEX_UNIFIED_CREATION = 7; - static final int INDEX_UNIFIED_EXPIRY = 8; - - public Loader onCreateLoader(int id, Bundle args) { - setContentShown(false); - switch (id) { - case LOADER_ID_UNIFIED: { - Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); - } - - default: - return null; - } - } - - public void onLoadFinished(Loader loader, Cursor data) { - /* TODO better error handling? May cause problems when a key is deleted, - * because the notification triggers faster than the activity closes. - */ - // Avoid NullPointerExceptions... - if (data.getCount() == 0) { - return; - } - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - switch (loader.getId()) { - case LOADER_ID_UNIFIED: { - if (data.moveToFirst()) { - - byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); - mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); - - loadQrCode(fingerprint); - - break; - } - } - - } - setContentShown(true); - } - - /** - * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. - * We need to make sure we are no longer using it. - */ - public void onLoaderReset(Loader loader) { - } - - /** - * Load QR Code asynchronously and with a fade in animation - * - * @param fingerprint - */ - private void loadQrCode(final String fingerprint) { - AsyncTask loadTask = - new AsyncTask() { - protected Bitmap doInBackground(Void... unused) { - String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; - // render with minimal size - return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); - } - - protected void onPostExecute(Bitmap qrCode) { - // only change view, if fragment is attached to activity - if (ViewKeyShareFragment.this.isAdded()) { - - // scale the image up to our actual size. we do this in code rather - // than let the ImageView do this because we don't require filtering. - Bitmap scaled = Bitmap.createScaledBitmap(qrCode, - mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(), - false); - mFingerprintQrCode.setImageBitmap(scaled); - - // simple fade-in animation - AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); - anim.setDuration(200); - mFingerprintQrCode.startAnimation(anim); - } - } - }; - - loadTask.execute(); - } - - private void uploadToKeyserver() { - Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); - uploadIntent.setData(mDataUri); - startActivityForResult(uploadIntent, 0); - } - -} diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_activity.xml b/OpenKeychain/src/main/res/layout/view_key_adv_activity.xml new file mode 100644 index 000000000..59888c25a --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_activity.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_certs_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_certs_fragment.xml new file mode 100644 index 000000000..2232ea9f2 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_certs_fragment.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml new file mode 100644 index 000000000..9971032ce --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_subkeys_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_subkeys_fragment.xml new file mode 100644 index 000000000..62fd113f9 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_subkeys_fragment.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_advanced_activity.xml b/OpenKeychain/src/main/res/layout/view_key_advanced_activity.xml deleted file mode 100644 index c7f0f50d9..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_advanced_activity.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_advanced_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_advanced_fragment.xml deleted file mode 100644 index 9a2190f7e..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_advanced_fragment.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml deleted file mode 100644 index 9971032ce..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From 17a6003eddff3fd52b4b2ac5ee553e3f70315d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 24 Feb 2015 11:25:19 +0100 Subject: Remove tabs in view key --- .../keychain/ui/ViewKeyActivity.java | 50 +- .../keychain/ui/ViewKeyAdvActivity.java | 4 +- .../keychain/ui/ViewKeyAdvCertsFragment.java | 4 +- .../keychain/ui/ViewKeyAdvKeysFragment.java | 125 ----- .../keychain/ui/ViewKeyAdvMainFragment.java | 2 +- .../keychain/ui/ViewKeyAdvSubkeysFragment.java | 125 +++++ .../keychain/ui/ViewKeyFragment.java | 615 +++++++++++++++++++++ .../keychain/ui/adapter/SubkeysAdapter.java | 2 +- .../keychain/ui/adapter/SubkeysAddedAdapter.java | 2 +- .../keychain/ui/adapter/UserIdsAdapter.java | 2 +- .../keychain/ui/adapter/UserIdsAddedAdapter.java | 2 +- .../src/main/res/layout/view_key_activity.xml | 23 +- .../main/res/layout/view_key_adv_certs_header.xml | 27 + .../main/res/layout/view_key_adv_certs_item.xml | 46 ++ .../main/res/layout/view_key_adv_main_fragment.xml | 164 ++++++ .../main/res/layout/view_key_adv_subkey_item.xml | 130 +++++ .../main/res/layout/view_key_adv_user_id_item.xml | 83 +++ .../src/main/res/layout/view_key_certs_header.xml | 27 - .../src/main/res/layout/view_key_certs_item.xml | 46 -- .../src/main/res/layout/view_key_fragment.xml | 360 ++++++++++++ .../src/main/res/layout/view_key_main_fragment.xml | 164 ------ .../src/main/res/layout/view_key_subkey_item.xml | 130 ----- .../src/main/res/layout/view_key_user_id_item.xml | 83 --- 23 files changed, 1586 insertions(+), 630 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_certs_header.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_certs_item.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_adv_user_id_item.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_certs_header.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_certs_item.xml create mode 100644 OpenKeychain/src/main/res/layout/view_key_fragment.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_main_fragment.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_subkey_item.xml delete mode 100644 OpenKeychain/src/main/res/layout/view_key_user_id_item.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index f45a29a96..18a63f5ad 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -72,15 +72,6 @@ public class ViewKeyActivity extends BaseActivity implements protected Uri mDataUri; - public static final String EXTRA_SELECTED_TAB = "selected_tab"; - public static final int TAB_MAIN = 0; - public static final int TAB_SHARE = 1; - - // view - private ViewPager mViewPager; - private PagerSlidingTabStrip mSlidingTabLayout; - private PagerTabStripAdapter mTabsAdapter; - private LinearLayout mStatusLayout; private TextView mStatusText; private ImageView mStatusImage; @@ -113,14 +104,8 @@ public class ViewKeyActivity extends BaseActivity implements mStatusImage = (ImageView) findViewById(R.id.view_key_status_image); mStatusDivider = findViewById(R.id.view_key_status_divider); - mViewPager = (ViewPager) findViewById(R.id.view_key_pager); - mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.view_key_sliding_tab_layout); - int switchToTab = TAB_MAIN; Intent intent = getIntent(); - if (intent.getExtras() != null && intent.getExtras().containsKey(EXTRA_SELECTED_TAB)) { - switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB); - } mDataUri = getIntent().getData(); if (mDataUri == null) { @@ -146,10 +131,7 @@ public class ViewKeyActivity extends BaseActivity implements initNfc(mDataUri); - initTabs(mDataUri); - - // switch to tab selected by extra - mViewPager.setCurrentItem(switchToTab); + startFragment(savedInstanceState, mDataUri); } @Override @@ -157,22 +139,24 @@ public class ViewKeyActivity extends BaseActivity implements setContentView(R.layout.view_key_activity); } - private void initTabs(Uri dataUri) { - mTabsAdapter = new PagerTabStripAdapter(this); - mViewPager.setAdapter(mTabsAdapter); - - Bundle mainBundle = new Bundle(); - mainBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); - mTabsAdapter.addTab(ViewKeyAdvMainFragment.class, - mainBundle, getString(R.string.key_view_tab_main)); + private void startFragment(Bundle savedInstanceState, Uri dataUri) { + // However, if we're being restored from a previous state, + // then we don't need to do anything and should return or else + // we could end up with overlapping fragments. + if (savedInstanceState != null) { + return; + } - Bundle shareBundle = new Bundle(); - shareBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); - mTabsAdapter.addTab(ViewKeyAdvShareFragment.class, - shareBundle, getString(R.string.key_view_tab_share)); + // Create an instance of the fragment + ViewKeyFragment frag = ViewKeyFragment.newInstance(dataUri); - // update layout after operations - mSlidingTabLayout.setViewPager(mViewPager); + // Add the fragment to the 'fragment_container' FrameLayout + // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! + getSupportFragmentManager().beginTransaction() + .replace(R.id.view_key_fragment, frag) + .commitAllowingStateLoss(); + // do it immediately! + getSupportFragmentManager().executePendingTransactions(); } @Override diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index 6a43845d6..840dea471 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -134,8 +134,8 @@ public class ViewKeyAdvActivity extends BaseActivity implements shareBundle, getString(R.string.key_view_tab_share)); Bundle keysBundle = new Bundle(); - keysBundle.putParcelable(ViewKeyAdvKeysFragment.ARG_DATA_URI, dataUri); - mTabsAdapter.addTab(ViewKeyAdvKeysFragment.class, + keysBundle.putParcelable(ViewKeyAdvSubkeysFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvSubkeysFragment.class, keysBundle, getString(R.string.key_view_tab_keys)); Bundle certsBundle = new Bundle(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java index 83daa541d..90d7a400f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvCertsFragment.java @@ -271,7 +271,7 @@ public class ViewKeyAdvCertsFragment extends LoaderFragment implements @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { - return mInflater.inflate(R.layout.view_key_certs_item, parent, false); + return mInflater.inflate(R.layout.view_key_adv_certs_item, parent, false); } /** @@ -286,7 +286,7 @@ public class ViewKeyAdvCertsFragment extends LoaderFragment implements HeaderViewHolder holder; if (convertView == null) { holder = new HeaderViewHolder(); - convertView = mInflater.inflate(R.layout.view_key_certs_header, parent, false); + convertView = mInflater.inflate(R.layout.view_key_adv_certs_header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text); holder.count = (TextView) convertView.findViewById(R.id.certs_num); convertView.setTag(holder); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java deleted file mode 100644 index 548e249b6..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvKeysFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2014-2015 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ListView; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; -import org.sufficientlysecure.keychain.util.Log; - -public class ViewKeyAdvKeysFragment extends LoaderFragment implements - LoaderManager.LoaderCallbacks { - - public static final String ARG_DATA_URI = "data_uri"; - - private ListView mSubkeysList; - private SubkeysAdapter mSubkeysAdapter; - - private Uri mDataUriSubkeys; - - /** - * Creates new instance of this fragment - */ - public static ViewKeyAdvKeysFragment newInstance(Uri dataUri) { - ViewKeyAdvKeysFragment frag = new ViewKeyAdvKeysFragment(); - - Bundle args = new Bundle(); - args.putParcelable(ARG_DATA_URI, dataUri); - - frag.setArguments(args); - return frag; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_adv_subkeys_fragment, getContainer()); - - mSubkeysList = (ListView) view.findViewById(R.id.keys); - - return root; - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); - getActivity().finish(); - return; - } - - loadData(dataUri); - } - - private void loadData(Uri dataUri) { - mDataUriSubkeys = KeychainContract.Keys.buildKeysUri(dataUri); - - // Create an empty adapter we will use to display the loaded data. - mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0); - mSubkeysList.setAdapter(mSubkeysAdapter); - - // Prepare the loaders. Either re-connect with an existing ones, - // or start new ones. - getLoaderManager().initLoader(0, null, this); - } - - public Loader onCreateLoader(int id, Bundle args) { - setContentShown(false); - - return new CursorLoader(getActivity(), mDataUriSubkeys, - SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null); - } - - public void onLoadFinished(Loader loader, Cursor data) { - // Avoid NullPointerExceptions, if we get an empty result set. - if (data.getCount() == 0) { - return; - } - - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - mSubkeysAdapter.swapCursor(data); - - // TODO: maybe show not before both are loaded! - setContentShown(true); - } - - /** - * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. - * We need to make sure we are no longer using it. - */ - public void onLoaderReset(Loader loader) { - mSubkeysAdapter.swapCursor(null); - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java index 8bab5e3bf..abed59aa9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java @@ -80,7 +80,7 @@ public class ViewKeyAdvMainFragment extends LoaderFragment implements @Override public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer()); + View view = inflater.inflate(R.layout.view_key_adv_main_fragment, getContainer()); mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); mActionEdit = view.findViewById(R.id.view_key_action_edit); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java new file mode 100644 index 000000000..bd00c6780 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvSubkeysFragment.java @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2014-2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter; +import org.sufficientlysecure.keychain.util.Log; + +public class ViewKeyAdvSubkeysFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "data_uri"; + + private ListView mSubkeysList; + private SubkeysAdapter mSubkeysAdapter; + + private Uri mDataUriSubkeys; + + /** + * Creates new instance of this fragment + */ + public static ViewKeyAdvSubkeysFragment newInstance(Uri dataUri) { + ViewKeyAdvSubkeysFragment frag = new ViewKeyAdvSubkeysFragment(); + + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); + + frag.setArguments(args); + return frag; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_adv_subkeys_fragment, getContainer()); + + mSubkeysList = (ListView) view.findViewById(R.id.keys); + + return root; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUriSubkeys = KeychainContract.Keys.buildKeysUri(dataUri); + + // Create an empty adapter we will use to display the loaded data. + mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0); + mSubkeysList.setAdapter(mSubkeysAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(0, null, this); + } + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + return new CursorLoader(getActivity(), mDataUriSubkeys, + SubkeysAdapter.SUBKEYS_PROJECTION, null, null, null); + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Avoid NullPointerExceptions, if we get an empty result set. + if (data.getCount() == 0) { + return; + } + + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mSubkeysAdapter.swapCursor(data); + + // TODO: maybe show not before both are loaded! + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + mSubkeysAdapter.swapCursor(null); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java new file mode 100644 index 000000000..9ae656b2d --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -0,0 +1,615 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * Copyright (C) 2014 Vincent Breitmoser + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.annotation.TargetApi; +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.PorterDuff; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; +import android.widget.AdapterView; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; +import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; +import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.IOException; +import java.util.Date; + +public class ViewKeyFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "uri"; + + private View mActionEdit; + private View mActionEditDivider; + private View mActionEncryptFiles; + private View mActionEncryptText; + private View mActionEncryptTextText; + private View mActionCertify; + private View mActionCertifyText; + private ImageView mActionCertifyImage; + private View mActionUpdate; + + private TextView mFingerprint; + private ImageView mFingerprintQrCode; + private View mFingerprintShareButton; + private View mFingerprintClipboardButton; + private View mKeyShareButton; + private View mKeyClipboardButton; + private ImageButton mKeySafeSlingerButton; + private View mNfcHelpButton; + private View mNfcPrefsButton; + private View mKeyUploadButton; + private ListView mUserIds; + + private static final int LOADER_ID_UNIFIED = 0; + private static final int LOADER_ID_USER_IDS = 1; + + // conservative attitude + private boolean mHasEncrypt = true; + + private UserIdsAdapter mUserIdsAdapter; + + private Uri mDataUri; + + ProviderHelper mProviderHelper; + + /** + * Creates new instance of this fragment + */ + public static ViewKeyFragment newInstance(Uri dataUri) { + ViewKeyFragment frag = new ViewKeyFragment(); + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); + + frag.setArguments(args); + + return frag; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_fragment, getContainer()); + + mProviderHelper = new ProviderHelper(getActivity()); + + mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); + mActionEdit = view.findViewById(R.id.view_key_action_edit); + mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); + mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text); + mActionEncryptTextText = view.findViewById(R.id.view_key_action_encrypt_text_text); + mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files); + mActionCertify = view.findViewById(R.id.view_key_action_certify); + mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text); + mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image); + // make certify image gray, like action icons + mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), + PorterDuff.Mode.SRC_IN); + mActionUpdate = view.findViewById(R.id.view_key_action_update); + + mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + showUserIdInfo(position); + } + }); + + mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint); + mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image); + mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share); + mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard); + mKeyShareButton = view.findViewById(R.id.view_key_action_key_share); + mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); + mKeySafeSlingerButton = (ImageButton) view.findViewById(R.id.view_key_action_key_safeslinger); + mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); + mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); + mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); + + mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light), + PorterDuff.Mode.SRC_IN); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mNfcPrefsButton.setVisibility(View.VISIBLE); + } else { + mNfcPrefsButton.setVisibility(View.GONE); + } + + mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showQrCodeDialog(); + } + }); + + mFingerprintShareButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, true, false); + } + }); + mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, true, true); + } + }); + mKeyShareButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, false, false); + } + }); + mKeyClipboardButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, false, true); + } + }); + mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startSafeSlinger(mDataUri); + } + }); + mNfcHelpButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showNfcHelpDialog(); + } + }); + mNfcPrefsButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showNfcPrefs(); + } + }); + mKeyUploadButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + uploadToKeyserver(); + } + }); + + + return root; + } + + private void startSafeSlinger(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class); + safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); + startActivityForResult(safeSlingerIntent, 0); + } + + private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, + boolean toClipboard) { + try { + String content; + if (fingerprintOnly) { + byte[] data = (byte[]) providerHelper.getGenericData( + KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data); + if (!toClipboard) { + content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + } else { + content = fingerprint; + } + } else { + Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(dataUri); + // get public keyring as ascii armored string + content = providerHelper.getKeyRingAsArmoredString(uri); + } + + if (toClipboard) { + ClipboardReflection.copyToClipboard(getActivity(), content); + String message; + if (fingerprintOnly) { + message = getResources().getString(R.string.fingerprint_copied_to_clipboard); + } else { + message = getResources().getString(R.string.key_copied_to_clipboard); + } + Notify.showNotify(getActivity(), message, Notify.Style.OK); + } else { + // Android will fail with android.os.TransactionTooLargeException if key is too big + // see http://www.lonestarprod.com/?p=34 + if (content.length() >= 86389) { + Notify.showNotify(getActivity(), R.string.key_too_big_for_sharing, + Notify.Style.ERROR); + return; + } + + // let user choose application + Intent sendIntent = new Intent(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, content); + sendIntent.setType("text/plain"); + String title; + if (fingerprintOnly) { + title = getResources().getString(R.string.title_share_fingerprint_with); + } else { + title = getResources().getString(R.string.title_share_key); + } + startActivity(Intent.createChooser(sendIntent, title)); + } + } catch (PgpGeneralException | IOException e) { + Log.e(Constants.TAG, "error processing key!", e); + Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR); + } catch (ProviderHelper.NotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); + } + } + + private void showQrCodeDialog() { + Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class); + qrCodeIntent.setData(mDataUri); + startActivity(qrCodeIntent); + } + + private void showNfcHelpDialog() { + ShareNfcDialogFragment dialog = ShareNfcDialogFragment.newInstance(); + dialog.show(getActivity().getSupportFragmentManager(), "shareNfcDialog"); + } + + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) + private void showNfcPrefs() { + Intent intentSettings = new Intent( + Settings.ACTION_NFCSHARING_SETTINGS); + startActivity(intentSettings); + } + + private void showUserIdInfo(final int position) { + final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); + final int isVerified = mUserIdsAdapter.getIsVerified(position); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + UserIdInfoDialogFragment dialogFragment = + UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); + } + }); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUri = dataUri; + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + mActionEncryptFiles.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, false); + } + }); + mActionEncryptText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, true); + } + }); + mActionCertify.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + certify(mDataUri); + } + }); + mActionEdit.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + editKey(mDataUri); + } + }); + mActionUpdate.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + try { + updateFromKeyserver(mDataUri, new ProviderHelper(getActivity())); + } catch (NotFoundException e) { + Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); + } + } + }); + + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); + mUserIds.setAdapter(mUserIdsAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); + } + + static final String[] UNIFIED_PROJECTION = new String[]{ + KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET, + KeyRings.USER_ID, KeyRings.FINGERPRINT, + KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY, + KeyRings.IS_REVOKED, KeyRings.HAS_ENCRYPT, + + }; + static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; + static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; + static final int INDEX_UNIFIED_USER_ID = 3; + static final int INDEX_UNIFIED_FINGERPRINT = 4; + static final int INDEX_UNIFIED_ALGORITHM = 5; + static final int INDEX_UNIFIED_KEY_SIZE = 6; + static final int INDEX_UNIFIED_CREATION = 7; + static final int INDEX_UNIFIED_EXPIRY = 8; + static final int INDEX_UNIFIED_IS_REVOKED = 9; + static final int INDEX_UNIFIED_HAS_ENCRYPT = 10; + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + case LOADER_ID_USER_IDS: { + Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + } + + default: + return null; + } + } + + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); + mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); + + loadQrCode(fingerprint); + + if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) { + // edit button + mActionEdit.setVisibility(View.VISIBLE); + mActionEditDivider.setVisibility(View.VISIBLE); + } else { + // edit button + mActionEdit.setVisibility(View.GONE); + mActionEditDivider.setVisibility(View.GONE); + } + + // If this key is revoked, it cannot be used for anything! + if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { + mActionEdit.setEnabled(false); + mActionCertify.setEnabled(false); + mActionCertifyText.setEnabled(false); + mActionEncryptText.setEnabled(false); + mActionEncryptTextText.setEnabled(false); + mActionEncryptFiles.setEnabled(false); + } else { + mActionEdit.setEnabled(true); + + Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); + if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { + mActionCertify.setEnabled(false); + mActionCertifyText.setEnabled(false); + mActionEncryptText.setEnabled(false); + mActionEncryptTextText.setEnabled(false); + mActionEncryptFiles.setEnabled(false); + } else { + mActionCertify.setEnabled(true); + mActionCertifyText.setEnabled(true); + mActionEncryptText.setEnabled(true); + mActionEncryptTextText.setEnabled(true); + mActionEncryptFiles.setEnabled(true); + } + } + + mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0; + + break; + } + } + + case LOADER_ID_USER_IDS: + mUserIdsAdapter.swapCursor(data); + break; + + } + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + switch (loader.getId()) { + case LOADER_ID_USER_IDS: + mUserIdsAdapter.swapCursor(null); + break; + } + } + + + /** + * Load QR Code asynchronously and with a fade in animation + * + * @param fingerprint + */ + private void loadQrCode(final String fingerprint) { + AsyncTask loadTask = + new AsyncTask() { + protected Bitmap doInBackground(Void... unused) { + String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + // render with minimal size + return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); + } + + protected void onPostExecute(Bitmap qrCode) { + // only change view, if fragment is attached to activity + if (ViewKeyFragment.this.isAdded()) { + + // scale the image up to our actual size. we do this in code rather + // than let the ImageView do this because we don't require filtering. + Bitmap scaled = Bitmap.createScaledBitmap(qrCode, + mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(), + false); + mFingerprintQrCode.setImageBitmap(scaled); + + // simple fade-in animation + AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); + anim.setDuration(200); + mFingerprintQrCode.startAnimation(anim); + } + } + }; + + loadTask.execute(); + } + + private void uploadToKeyserver() { + Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); + uploadIntent.setData(mDataUri); + startActivityForResult(uploadIntent, 0); + } + + private void encrypt(Uri dataUri, boolean text) { + // If there is no encryption key, don't bother. + if (!mHasEncrypt) { + Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR); + return; + } + try { + long keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + long[] encryptionKeyIds = new long[]{keyId}; + Intent intent; + if (text) { + intent = new Intent(getActivity(), EncryptTextActivity.class); + intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT); + intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } else { + intent = new Intent(getActivity(), EncryptFilesActivity.class); + intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA); + intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } + // used instead of startActivity set actionbar based on callingPackage + startActivityForResult(intent, 0); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + } + + private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) + throws NotFoundException { + byte[] blob = (byte[]) providerHelper.getGenericData( + KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); + + Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class); + queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); + queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + + startActivityForResult(queryIntent, 0); + } + + private void certify(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); + certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); + startActivityForResult(certifyIntent, 0); + } + + private void editKey(Uri dataUri) { + Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); + editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); + startActivityForResult(editIntent, 0); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java index c286218ed..a3bd4d470 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java @@ -301,7 +301,7 @@ public class SubkeysAdapter extends CursorAdapter { @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { - View view = mInflater.inflate(R.layout.view_key_subkey_item, null); + View view = mInflater.inflate(R.layout.view_key_adv_subkey_item, null); if (mDefaultTextColor == null) { TextView keyId = (TextView) view.findViewById(R.id.subkey_item_key_id); mDefaultTextColor = keyId.getTextColors(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java index abc1d8816..d2359a387 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAddedAdapter.java @@ -68,7 +68,7 @@ public class SubkeysAddedAdapter extends ArrayAdapter { public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { // Not recycled, inflate a new view - convertView = mInflater.inflate(R.layout.view_key_user_id_item, null); + convertView = mInflater.inflate(R.layout.view_key_adv_user_id_item, null); final ViewHolder holder = new ViewHolder(); holder.vAddress = (TextView) convertView.findViewById(R.id.user_id_item_address); holder.vName = (TextView) convertView.findViewById(R.id.user_id_item_name); diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index f9a329acd..25115eb2f 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -47,21 +47,18 @@ android:visibility="gone" android:id="@+id/view_key_status_divider" /> - + android:layout_height="match_parent"> - + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_certs_header.xml b/OpenKeychain/src/main/res/layout/view_key_adv_certs_header.xml new file mode 100644 index 000000000..f99c012c9 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_certs_header.xml @@ -0,0 +1,27 @@ + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_certs_item.xml b/OpenKeychain/src/main/res/layout/view_key_adv_certs_item.xml new file mode 100644 index 000000000..e84a98cdb --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_certs_item.xml @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml new file mode 100644 index 000000000..691ee357d --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml b/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml new file mode 100644 index 000000000..b2875b9e6 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_user_id_item.xml b/OpenKeychain/src/main/res/layout/view_key_adv_user_id_item.xml new file mode 100644 index 000000000..24e8e1a10 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_adv_user_id_item.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_certs_header.xml b/OpenKeychain/src/main/res/layout/view_key_certs_header.xml deleted file mode 100644 index f99c012c9..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_certs_header.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_certs_item.xml b/OpenKeychain/src/main/res/layout/view_key_certs_item.xml deleted file mode 100644 index e84a98cdb..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_certs_item.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - diff --git a/OpenKeychain/src/main/res/layout/view_key_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_fragment.xml new file mode 100644 index 000000000..fadad0e56 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/view_key_fragment.xml @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml deleted file mode 100644 index 691ee357d..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenKeychain/src/main/res/layout/view_key_subkey_item.xml b/OpenKeychain/src/main/res/layout/view_key_subkey_item.xml deleted file mode 100644 index b2875b9e6..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_subkey_item.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenKeychain/src/main/res/layout/view_key_user_id_item.xml b/OpenKeychain/src/main/res/layout/view_key_user_id_item.xml deleted file mode 100644 index 24e8e1a10..000000000 --- a/OpenKeychain/src/main/res/layout/view_key_user_id_item.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From 2b609b8144c093b1034c2845a8110ac84eecc414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 24 Feb 2015 13:43:24 +0100 Subject: Fix QR Code, design experiments for key view --- .../res/drawable-hdpi/ic_qrcode_white_24dp.png | Bin 0 -> 427 bytes .../res/drawable-mdpi/ic_qrcode_white_24dp.png | Bin 0 -> 231 bytes .../res/drawable-xhdpi/ic_qrcode_white_24dp.png | Bin 0 -> 284 bytes .../res/drawable-xxhdpi/ic_qrcode_white_24dp.png | Bin 0 -> 352 bytes .../res/drawable-xxxhdpi/ic_qrcode_white_24dp.png | Bin 0 -> 414 bytes OpenKeychain/src/main/res/drawable/qrcode.xml | 8 -- .../src/main/res/layout/key_list_fragment.xml | 2 +- .../src/main/res/layout/view_key_activity.xml | 105 ++++++++++++++++----- OpenKeychain/src/main/res/menu/key_view.xml | 7 +- 9 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_qrcode_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_qrcode_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_qrcode_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_qrcode_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_qrcode_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable/qrcode.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_qrcode_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_qrcode_white_24dp.png new file mode 100644 index 000000000..261f4a5ab Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_qrcode_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_qrcode_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_qrcode_white_24dp.png new file mode 100644 index 000000000..5cf552b13 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_qrcode_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_qrcode_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_qrcode_white_24dp.png new file mode 100644 index 000000000..a2c6ade61 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_qrcode_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_qrcode_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_qrcode_white_24dp.png new file mode 100644 index 000000000..c4f2f57c9 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_qrcode_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_qrcode_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_qrcode_white_24dp.png new file mode 100644 index 000000000..e795f80a5 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_qrcode_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable/qrcode.xml b/OpenKeychain/src/main/res/drawable/qrcode.xml deleted file mode 100644 index 87eb7d485..000000000 --- a/OpenKeychain/src/main/res/drawable/qrcode.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/key_list_fragment.xml b/OpenKeychain/src/main/res/layout/key_list_fragment.xml index c918ace37..3c46b4f9c 100644 --- a/OpenKeychain/src/main/res/layout/key_list_fragment.xml +++ b/OpenKeychain/src/main/res/layout/key_list_fragment.xml @@ -66,7 +66,7 @@ android:id="@+id/fab_add_qr_code" android:layout_width="wrap_content" android:layout_height="wrap_content" - fab:fab_icon="@drawable/qrcode" + fab:fab_icon="@drawable/ic_qrcode_white_24dp" fab:fab_colorNormal="@color/primary" fab:fab_colorPressed="@color/primary_dark" fab:fab_title="Scan QR Code" diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 25115eb2f..f9c23f065 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -1,44 +1,88 @@ - - - + android:layout_height="@dimen/big_toolbar" + android:elevation="4dp" + android:background="?attr/colorPrimary" + android:orientation="horizontal"> - + - + android:minHeight="?attr/actionBarSize" + android:background="?attr/colorPrimary" + android:overScrollMode="always" + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" + app:popupTheme="@style/ThemeOverlay.AppCompat.Light" + tools:ignore="UnusedAttribute" + android:transitionGroup="false" + android:touchscreenBlocksFocus="false" /> - + + + android:layout_height="wrap_content" + android:layout_gravity="center" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:orientation="horizontal"> + + + + + + - + android:paddingLeft="8dp" + android:layout_gravity="center_vertical" /> + + + - + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/menu/key_view.xml b/OpenKeychain/src/main/res/menu/key_view.xml index 049c7013a..d2ca90942 100644 --- a/OpenKeychain/src/main/res/menu/key_view.xml +++ b/OpenKeychain/src/main/res/menu/key_view.xml @@ -2,9 +2,14 @@

+ + -- cgit v1.2.3 From 56d38dd68b7248dff54d56affce0af14e8e2e161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 02:35:09 +0100 Subject: First work on new key view toolbar --- .../keychain/ui/KeyListFragment.java | 4 +- .../keychain/ui/ViewKeyActivity.java | 151 +++++++++++++++------ .../keychain/ui/adapter/ImportKeysAdapter.java | 4 +- .../ui/adapter/SelectKeyCursorAdapter.java | 4 +- .../keychain/ui/adapter/UserIdsAdapter.java | 8 +- .../keychain/ui/util/KeyFormattingUtils.java | 48 ++++--- .../keychain/ui/widget/AspectRatioImageView.java | 138 +++++++++++++++++++ .../keychain/ui/widget/CertifyKeySpinner.java | 7 +- .../keychain/ui/widget/SignKeySpinner.java | 7 +- .../res/drawable-hdpi/ic_action_encrypt_file.png | Bin 0 -> 623 bytes .../res/drawable-hdpi/ic_action_encrypt_text.png | Bin 0 -> 787 bytes .../drawable-hdpi/ic_action_verified_cutout.png | Bin 0 -> 1080 bytes .../res/drawable-mdpi/ic_action_encrypt_file.png | Bin 0 -> 480 bytes .../res/drawable-mdpi/ic_action_encrypt_text.png | Bin 0 -> 572 bytes .../drawable-mdpi/ic_action_verified_cutout.png | Bin 0 -> 751 bytes .../res/drawable-xhdpi/ic_action_encrypt_file.png | Bin 0 -> 836 bytes .../res/drawable-xhdpi/ic_action_encrypt_text.png | Bin 0 -> 976 bytes .../drawable-xhdpi/ic_action_verified_cutout.png | Bin 0 -> 1455 bytes .../res/drawable-xxhdpi/ic_action_encrypt_file.png | Bin 0 -> 1095 bytes .../res/drawable-xxhdpi/ic_action_encrypt_text.png | Bin 0 -> 1331 bytes .../drawable-xxhdpi/ic_action_verified_cutout.png | Bin 0 -> 2168 bytes .../src/main/res/layout/view_key_activity.xml | 106 +++++++++++---- OpenKeychain/src/main/res/menu/key_view2.xml | 11 ++ OpenKeychain/src/main/res/values-v21/dimens.xml | 1 + OpenKeychain/src/main/res/values/attr.xml | 9 ++ OpenKeychain/src/main/res/values/dimens.xml | 1 + OpenKeychain/src/main/res/values/strings.xml | 7 +- 27 files changed, 403 insertions(+), 103 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AspectRatioImageView.java create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_file.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_text.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_file.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_text.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_file.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_text.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_file.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_text.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/menu/key_view2.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 55efd9bb0..f60ddcef6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -778,13 +778,13 @@ public class KeyListFragment extends LoaderFragment // Note: order is important! if (isRevoked) { - KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); h.mStatus.setVisibility(View.VISIBLE); h.mSlinger.setVisibility(View.GONE); h.mMainUserId.setTextColor(context.getResources().getColor(R.color.bg_gray)); h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.bg_gray)); } else if (isExpired) { - KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_EXPIRED, true); + KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_EXPIRED, R.color.bg_gray); h.mStatus.setVisibility(View.VISIBLE); h.mSlinger.setVisibility(View.GONE); h.mMainUserId.setTextColor(context.getResources().getColor(R.color.bg_gray)); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 18a63f5ad..8ef5d01aa 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.ui; import android.annotation.TargetApi; import android.content.Intent; import android.database.Cursor; +import android.graphics.Bitmap; import android.net.Uri; import android.nfc.NdefMessage; import android.nfc.NdefRecord; @@ -35,17 +36,20 @@ import android.provider.ContactsContract; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; -import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; +import android.support.v7.widget.Toolbar; +import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; import android.widget.ImageView; -import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; -import com.astuetz.PagerSlidingTabStrip; +import com.getbase.floatingactionbutton.FloatingActionButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -54,9 +58,9 @@ import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.widget.AspectRatioImageView; import org.sufficientlysecure.keychain.util.ContactHelper; import org.sufficientlysecure.keychain.util.ExportHelper; import org.sufficientlysecure.keychain.util.Log; @@ -72,10 +76,16 @@ public class ViewKeyActivity extends BaseActivity implements protected Uri mDataUri; - private LinearLayout mStatusLayout; + private TextView mName; private TextView mStatusText; private ImageView mStatusImage; - private View mStatusDivider; + private RelativeLayout mBigToolbar; + + private ImageButton mActionEncryptFile; + private ImageButton mActionEncryptText; + private ImageButton mActionVerify; + private FloatingActionButton mFab; + private AspectRatioImageView mPhoto; // NFC private NfcAdapter mNfcAdapter; @@ -93,19 +103,18 @@ public class ViewKeyActivity extends BaseActivity implements mExportHelper = new ExportHelper(this); mProviderHelper = new ProviderHelper(this); - // let the actionbar look like Android's contact app - ActionBar actionBar = getSupportActionBar(); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setIcon(android.R.color.transparent); - actionBar.setHomeButtonEnabled(true); + setTitle(null); - mStatusLayout = (LinearLayout) findViewById(R.id.view_key_status_layout); - mStatusText = (TextView) findViewById(R.id.view_key_status_text); + mName = (TextView) findViewById(R.id.view_key_name); + mStatusText = (TextView) findViewById(R.id.view_key_status); mStatusImage = (ImageView) findViewById(R.id.view_key_status_image); - mStatusDivider = findViewById(R.id.view_key_status_divider); - + mBigToolbar = (RelativeLayout) findViewById(R.id.toolbar_big); - Intent intent = getIntent(); + mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files); + mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); + mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); + mFab = (FloatingActionButton) findViewById(R.id.fab); + mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mDataUri = getIntent().getData(); if (mDataUri == null) { @@ -329,25 +338,32 @@ public class ViewKeyActivity extends BaseActivity implements } }; - static final String[] UNIFIED_PROJECTION = new String[]{ + // These are the rows that we will retrieve. + static final String[] PROJECTION = new String[]{ KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID, KeychainContract.KeyRings.USER_ID, KeychainContract.KeyRings.IS_REVOKED, KeychainContract.KeyRings.EXPIRY, - + KeychainContract.KeyRings.VERIFIED, + KeychainContract.KeyRings.HAS_ANY_SECRET, + KeychainContract.KeyRings.FINGERPRINT }; - static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; - static final int INDEX_UNIFIED_USER_ID = 2; - static final int INDEX_UNIFIED_IS_REVOKED = 3; - static final int INDEX_UNIFIED_EXPIRY = 4; + + static final int INDEX_MASTER_KEY_ID = 1; + static final int INDEX_USER_ID = 2; + static final int INDEX_IS_REVOKED = 3; + static final int INDEX_EXPIRY = 4; + static final int INDEX_VERIFIED = 5; + static final int INDEX_HAS_ANY_SECRET = 6; + static final int INDEX_FINGERPRINT = 7; @Override public Loader onCreateLoader(int id, Bundle args) { switch (id) { case LOADER_ID_UNIFIED: { Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); - return new CursorLoader(this, baseUri, UNIFIED_PROJECTION, null, null, null); + return new CursorLoader(this, baseUri, PROJECTION, null, null, null); } default: @@ -370,36 +386,91 @@ public class ViewKeyActivity extends BaseActivity implements case LOADER_ID_UNIFIED: { if (data.moveToFirst()) { // get name, email, and comment from USER_ID - String[] mainUserId = KeyRing.splitUserId(data.getString(INDEX_UNIFIED_USER_ID)); + String[] mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID)); if (mainUserId[0] != null) { - setTitle(mainUserId[0]); + mName.setText(mainUserId[0]); } else { - setTitle(R.string.user_id_no_name); + mName.setText(R.string.user_id_no_name); } - // get key id from MASTER_KEY_ID - long masterKeyId = data.getLong(INDEX_UNIFIED_MASTER_KEY_ID); - getSupportActionBar().setSubtitle(KeyFormattingUtils.beautifyKeyIdWithPrefix(this, masterKeyId)); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT)); - boolean isRevoked = data.getInt(INDEX_UNIFIED_IS_REVOKED) > 0; - boolean isExpired = !data.isNull(INDEX_UNIFIED_EXPIRY) - && new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000).before(new Date()); + boolean isSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; + boolean isExpired = !data.isNull(INDEX_EXPIRY) + && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); + boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; // Note: order is important + int color; if (isRevoked) { mStatusText.setText(R.string.view_key_revoked); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED); - mStatusDivider.setVisibility(View.VISIBLE); - mStatusLayout.setVisibility(View.VISIBLE); + mStatusImage.setVisibility(View.VISIBLE); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons); + color = getResources().getColor(R.color.android_red_light); + + mActionEncryptFile.setVisibility(View.INVISIBLE); + mActionEncryptText.setVisibility(View.INVISIBLE); + mActionVerify.setVisibility(View.INVISIBLE); + mFab.setVisibility(View.INVISIBLE); } else if (isExpired) { mStatusText.setText(R.string.view_key_expired); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED); - mStatusDivider.setVisibility(View.VISIBLE); - mStatusLayout.setVisibility(View.VISIBLE); + mStatusImage.setVisibility(View.VISIBLE); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons); + color = getResources().getColor(R.color.android_red_light); + + mActionEncryptFile.setVisibility(View.INVISIBLE); + mActionEncryptText.setVisibility(View.INVISIBLE); + mActionVerify.setVisibility(View.INVISIBLE); + mFab.setVisibility(View.INVISIBLE); + } else if (isSecret) { + mStatusText.setText(R.string.view_key_my_key); + mStatusImage.setVisibility(View.INVISIBLE); + color = getResources().getColor(R.color.primary); + + mActionEncryptFile.setVisibility(View.VISIBLE); + mActionEncryptText.setVisibility(View.VISIBLE); + mActionVerify.setVisibility(View.INVISIBLE); + mFab.setVisibility(View.INVISIBLE); // TODO } else { - mStatusDivider.setVisibility(View.GONE); - mStatusLayout.setVisibility(View.GONE); + mActionEncryptFile.setVisibility(View.VISIBLE); + mActionEncryptText.setVisibility(View.VISIBLE); + + if (isVerified) { + mStatusText.setText(R.string.view_key_verified); + mStatusImage.setVisibility(View.VISIBLE); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons); + color = getResources().getColor(R.color.primary); + + AsyncTask photoTask = + new AsyncTask() { + protected Bitmap doInBackground(String... fingerprint) { + return ContactHelper.photoFromFingerprint(getContentResolver(), fingerprint[0]); + } + + protected void onPostExecute(Bitmap photo) { + mPhoto.setImageBitmap(photo); + mPhoto.setVisibility(View.VISIBLE); + } + }; + + photoTask.execute(fingerprint); + + mActionVerify.setVisibility(View.INVISIBLE); + mFab.setVisibility(View.INVISIBLE); + } else { + mStatusText.setText(R.string.view_key_unverified); + mStatusImage.setVisibility(View.VISIBLE); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_UNVERIFIED, R.color.icons); + color = getResources().getColor(R.color.android_orange_light); + + mActionVerify.setVisibility(View.VISIBLE); + mFab.setVisibility(View.VISIBLE); + } } + mToolbar.setBackgroundColor(color); + mStatusBar.setBackgroundColor(color); + mBigToolbar.setBackgroundColor(color); break; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 8e82dd7d0..598793233 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -175,9 +175,9 @@ public class ImportKeysAdapter extends ArrayAdapter { } if (entry.isRevoked()) { - KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); } else if (entry.isExpired()) { - KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, KeyFormattingUtils.STATE_EXPIRED, true); + KeyFormattingUtils.setStatusImage(getContext(), holder.status, null, KeyFormattingUtils.STATE_EXPIRED, R.color.bg_gray); } if (entry.isRevoked() || entry.isExpired()) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java index e90b57c1c..a836b35df 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java @@ -133,11 +133,11 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter { boolean enabled; if (cursor.getInt(mIndexIsRevoked) != 0) { h.statusIcon.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); enabled = false; } else if (cursor.getInt(mIndexIsExpiry) != 0) { h.statusIcon.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, null, KeyFormattingUtils.STATE_EXPIRED, true); + KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, null, KeyFormattingUtils.STATE_EXPIRED, R.color.bg_gray); enabled = false; } else { h.statusIcon.setVisibility(View.GONE); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 6281bb8b3..8e86efebe 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -162,7 +162,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC if (isRevoked) { // set revocation icon (can this even be primary?) - KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); // disable revoked user ids vName.setEnabled(false); @@ -184,13 +184,13 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC int isVerified = cursor.getInt(INDEX_VERIFIED); switch (isVerified) { case Certs.VERIFIED_SECRET: - KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_VERIFIED, false); + KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_VERIFIED, KeyFormattingUtils.DEFAULT_COLOR); break; case Certs.VERIFIED_SELF: - KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_UNVERIFIED, false); + KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_UNVERIFIED, KeyFormattingUtils.DEFAULT_COLOR); break; default: - KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_INVALID, false); + KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_INVALID, KeyFormattingUtils.DEFAULT_COLOR); break; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java index bff7d6b27..1c3dec629 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java @@ -377,6 +377,8 @@ public class KeyFormattingUtils { ((int) digest[2] + 256) % 256}; } + public static final int DEFAULT_COLOR = -1; + public static final int STATE_REVOKED = 1; public static final int STATE_EXPIRED = 2; public static final int STATE_VERIFIED = 3; @@ -393,20 +395,22 @@ public class KeyFormattingUtils { } public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, int state) { - setStatusImage(context, statusIcon, statusText, state, false); + setStatusImage(context, statusIcon, statusText, state, KeyFormattingUtils.DEFAULT_COLOR); } /** * Sets status image based on constant */ public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, - int state, boolean unobtrusive) { + int state, int color) { switch (state) { /** GREEN: everything is good **/ case STATE_VERIFIED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_verified_cutout)); - int color = R.color.android_green_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_green_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -417,7 +421,9 @@ public class KeyFormattingUtils { case STATE_ENCRYPTED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_lock_closed)); - int color = R.color.android_green_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_green_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -429,7 +435,9 @@ public class KeyFormattingUtils { case STATE_UNVERIFIED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout)); - int color = R.color.android_orange_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_orange_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -440,7 +448,9 @@ public class KeyFormattingUtils { case STATE_UNKNOWN_KEY: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); - int color = R.color.android_orange_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_orange_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -452,9 +462,8 @@ public class KeyFormattingUtils { case STATE_REVOKED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout)); - int color = R.color.android_red_light; - if (unobtrusive) { - color = R.color.bg_gray; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_red_light; } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); @@ -466,9 +475,8 @@ public class KeyFormattingUtils { case STATE_EXPIRED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_expired_cutout)); - int color = R.color.android_red_light; - if (unobtrusive) { - color = R.color.bg_gray; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_red_light; } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); @@ -480,7 +488,9 @@ public class KeyFormattingUtils { case STATE_NOT_ENCRYPTED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_lock_open)); - int color = R.color.android_red_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_red_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -491,7 +501,9 @@ public class KeyFormattingUtils { case STATE_NOT_SIGNED: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); - int color = R.color.android_red_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_red_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -502,7 +514,9 @@ public class KeyFormattingUtils { case STATE_INVALID: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); - int color = R.color.android_red_light; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.android_red_light; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { @@ -514,7 +528,9 @@ public class KeyFormattingUtils { case STATE_UNAVAILABLE: { statusIcon.setImageDrawable( context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); - int color = R.color.bg_gray; + if (color == KeyFormattingUtils.DEFAULT_COLOR) { + color = R.color.bg_gray; + } statusIcon.setColorFilter(context.getResources().getColor(color), PorterDuff.Mode.SRC_IN); if (statusText != null) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AspectRatioImageView.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AspectRatioImageView.java new file mode 100644 index 000000000..0df5ba5e8 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/AspectRatioImageView.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.widget.ImageView; + +import org.sufficientlysecure.keychain.R; + +/** + * Maintains an aspect ratio based on either width or height. Disabled by default. + * + * from https://gist.github.com/JakeWharton/2856179 + */ +public class AspectRatioImageView extends ImageView { + // NOTE: These must be kept in sync with the AspectRatioImageView attributes in attrs.xml. + public static final int MEASUREMENT_WIDTH = 0; + public static final int MEASUREMENT_HEIGHT = 1; + + private static final float DEFAULT_ASPECT_RATIO = 1f; + private static final boolean DEFAULT_ASPECT_RATIO_ENABLED = false; + private static final int DEFAULT_DOMINANT_MEASUREMENT = MEASUREMENT_WIDTH; + + private float aspectRatio; + private boolean aspectRatioEnabled; + private int dominantMeasurement; + + public AspectRatioImageView(Context context) { + this(context, null); + } + + public AspectRatioImageView(Context context, AttributeSet attrs) { + super(context, attrs); + + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AspectRatioImageView); + aspectRatio = a.getFloat(R.styleable.AspectRatioImageView_aspectRatio, DEFAULT_ASPECT_RATIO); + aspectRatioEnabled = a.getBoolean(R.styleable.AspectRatioImageView_aspectRatioEnabled, + DEFAULT_ASPECT_RATIO_ENABLED); + dominantMeasurement = a.getInt(R.styleable.AspectRatioImageView_dominantMeasurement, + DEFAULT_DOMINANT_MEASUREMENT); + a.recycle(); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (!aspectRatioEnabled) return; + + int newWidth; + int newHeight; + switch (dominantMeasurement) { + case MEASUREMENT_WIDTH: + newWidth = getMeasuredWidth(); + newHeight = (int) (newWidth * aspectRatio); + break; + + case MEASUREMENT_HEIGHT: + newHeight = getMeasuredHeight(); + newWidth = (int) (newHeight * aspectRatio); + break; + + default: + throw new IllegalStateException("Unknown measurement with ID " + dominantMeasurement); + } + + setMeasuredDimension(newWidth, newHeight); + } + + /** + * Get the aspect ratio for this image view. + */ + public float getAspectRatio() { + return aspectRatio; + } + + /** + * Set the aspect ratio for this image view. This will update the view instantly. + */ + public void setAspectRatio(float aspectRatio) { + this.aspectRatio = aspectRatio; + if (aspectRatioEnabled) { + requestLayout(); + } + } + + /** + * Get whether or not forcing the aspect ratio is enabled. + */ + public boolean getAspectRatioEnabled() { + return aspectRatioEnabled; + } + + /** + * set whether or not forcing the aspect ratio is enabled. This will re-layout the view. + */ + public void setAspectRatioEnabled(boolean aspectRatioEnabled) { + this.aspectRatioEnabled = aspectRatioEnabled; + requestLayout(); + } + + /** + * Get the dominant measurement for the aspect ratio. + */ + public int getDominantMeasurement() { + return dominantMeasurement; + } + + /** + * Set the dominant measurement for the aspect ratio. + * + * @see #MEASUREMENT_WIDTH + * @see #MEASUREMENT_HEIGHT + */ + public void setDominantMeasurement(int dominantMeasurement) { + if (dominantMeasurement != MEASUREMENT_HEIGHT && dominantMeasurement != MEASUREMENT_WIDTH) { + throw new IllegalArgumentException("Invalid measurement type."); + } + this.dominantMeasurement = dominantMeasurement; + requestLayout(); + } +} \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java index 904cde47e..25033658d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java @@ -27,6 +27,7 @@ import android.util.AttributeSet; import android.widget.ImageView; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -101,16 +102,16 @@ public class CertifyKeySpinner extends KeySpinner { @Override boolean setStatus(Context context, Cursor cursor, ImageView statusView) { if (cursor.getInt(mIndexIsRevoked) != 0) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); return false; } if (cursor.getInt(mIndexIsExpired) != 0) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, R.color.bg_gray); return false; } // don't invalidate the "None" entry, which is also null! if (cursor.getPosition() != 0 && cursor.isNull(mIndexHasCertify)) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, R.color.bg_gray); return false; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SignKeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SignKeySpinner.java index 9c8e4aedb..fe91e306e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SignKeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SignKeySpinner.java @@ -26,6 +26,7 @@ import android.support.v4.content.Loader; import android.util.AttributeSet; import android.widget.ImageView; +import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -83,15 +84,15 @@ public class SignKeySpinner extends KeySpinner { @Override boolean setStatus(Context context, Cursor cursor, ImageView statusView) { if (cursor.getInt(mIndexIsRevoked) != 0) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_REVOKED, R.color.bg_gray); return false; } if (cursor.getInt(mIndexIsExpired) != 0) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_EXPIRED, R.color.bg_gray); return false; } if (cursor.getInt(mIndexHasSign) == 0) { - KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, true); + KeyFormattingUtils.setStatusImage(getContext(), statusView, null, KeyFormattingUtils.STATE_UNAVAILABLE, R.color.bg_gray); return false; } diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_file.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_file.png new file mode 100644 index 000000000..1e397ebed Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_file.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_text.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_text.png new file mode 100644 index 000000000..1cbd993a7 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_encrypt_text.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_verified_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_verified_cutout.png new file mode 100644 index 000000000..896aca575 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_verified_cutout.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_file.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_file.png new file mode 100644 index 000000000..06a054160 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_file.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_text.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_text.png new file mode 100644 index 000000000..97cb03def Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_encrypt_text.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_verified_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_verified_cutout.png new file mode 100644 index 000000000..0329b488f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_verified_cutout.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_file.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_file.png new file mode 100644 index 000000000..5f528864d Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_file.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_text.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_text.png new file mode 100644 index 000000000..f8867e922 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_encrypt_text.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_verified_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_verified_cutout.png new file mode 100644 index 000000000..116adf28d Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_verified_cutout.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_file.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_file.png new file mode 100644 index 000000000..c77329563 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_file.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_text.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_text.png new file mode 100644 index 000000000..15650500d Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_encrypt_text.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_verified_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_verified_cutout.png new file mode 100644 index 000000000..49b13017c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_verified_cutout.png differ diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index f9c23f065..ad46a8d62 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -9,11 +9,22 @@ + + - + android:layout_gravity="center_vertical" + android:layout_marginLeft="2dp" /> - + + android:text="" + android:textColor="@color/icons" + android:textAppearance="?android:attr/textAppearanceLarge" /> + - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values-v21/dimens.xml b/OpenKeychain/src/main/res/values-v21/dimens.xml index 3a85cca93..eee21b52e 100644 --- a/OpenKeychain/src/main/res/values-v21/dimens.xml +++ b/OpenKeychain/src/main/res/values-v21/dimens.xml @@ -7,4 +7,5 @@ 24dp 141dp + 233dp \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/attr.xml b/OpenKeychain/src/main/res/values/attr.xml index 5dfa03987..98ce1c364 100644 --- a/OpenKeychain/src/main/res/values/attr.xml +++ b/OpenKeychain/src/main/res/values/attr.xml @@ -6,4 +6,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/dimens.xml b/OpenKeychain/src/main/res/values/dimens.xml index 7e361a358..08b072202 100644 --- a/OpenKeychain/src/main/res/values/dimens.xml +++ b/OpenKeychain/src/main/res/values/dimens.xml @@ -3,4 +3,5 @@ 0dp 120dp + 212dp \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 4a56274d7..730746787 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -582,8 +582,11 @@ "Change key configuration" - "This key has been revoked!" - "This key is expired!" + "Revoked: Key must not be used anymore!" + "Expired: The contact needs to extend the keys validity!" + "My Key" + "Verified Key" + "Unverified: Scan QR Code to verify key!" "Keys" -- cgit v1.2.3 From 430ba2f7778e70c6c8a8c46e51de46543e074f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 11:29:46 +0100 Subject: Bigger status icon in key view --- .../keychain/ui/ViewKeyActivity.java | 10 ++-- .../keychain/ui/adapter/SubkeysAdapter.java | 4 +- .../keychain/ui/util/KeyFormattingUtils.java | 57 +++++++++++++++------ .../res/drawable-hdpi/key_flag_authenticate.png | Bin 1302 -> 0 bytes .../drawable-hdpi/key_flag_authenticate_24px.png | Bin 0 -> 1302 bytes .../main/res/drawable-hdpi/key_flag_certify.png | Bin 2289 -> 0 bytes .../res/drawable-hdpi/key_flag_certify_24px.png | Bin 0 -> 2289 bytes .../main/res/drawable-hdpi/key_flag_encrypt.png | Bin 1530 -> 0 bytes .../res/drawable-hdpi/key_flag_encrypt_24px.png | Bin 0 -> 1530 bytes .../src/main/res/drawable-hdpi/key_flag_sign.png | Bin 1751 -> 0 bytes .../main/res/drawable-hdpi/key_flag_sign_24px.png | Bin 0 -> 1751 bytes .../main/res/drawable-hdpi/status_lock_closed.png | Bin 675 -> 0 bytes .../res/drawable-hdpi/status_lock_closed_24px.png | Bin 0 -> 675 bytes .../main/res/drawable-hdpi/status_lock_error.png | Bin 748 -> 0 bytes .../res/drawable-hdpi/status_lock_error_24px.png | Bin 0 -> 748 bytes .../main/res/drawable-hdpi/status_lock_open.png | Bin 675 -> 0 bytes .../res/drawable-hdpi/status_lock_open_24px.png | Bin 0 -> 675 bytes .../res/drawable-hdpi/status_signature_expired.png | Bin 723 -> 0 bytes .../status_signature_expired_cutout.png | Bin 789 -> 0 bytes .../status_signature_expired_cutout_24px.png | Bin 0 -> 789 bytes .../status_signature_expired_cutout_96px.png | Bin 0 -> 3241 bytes .../res/drawable-hdpi/status_signature_invalid.png | Bin 528 -> 0 bytes .../status_signature_invalid_cutout.png | Bin 444 -> 0 bytes .../status_signature_invalid_cutout_24px.png | Bin 0 -> 444 bytes .../status_signature_invalid_cutout_96px.png | Bin 0 -> 1656 bytes .../res/drawable-hdpi/status_signature_revoked.png | Bin 714 -> 0 bytes .../status_signature_revoked_cutout.png | Bin 861 -> 0 bytes .../status_signature_revoked_cutout_24px.png | Bin 0 -> 861 bytes .../status_signature_revoked_cutout_96px.png | Bin 0 -> 3638 bytes .../res/drawable-hdpi/status_signature_unknown.png | Bin 640 -> 0 bytes .../status_signature_unknown_cutout.png | Bin 740 -> 0 bytes .../status_signature_unknown_cutout_24px.png | Bin 0 -> 740 bytes .../status_signature_unknown_cutout_96px.png | Bin 0 -> 2878 bytes .../drawable-hdpi/status_signature_unverified.png | Bin 536 -> 0 bytes .../status_signature_unverified_cutout.png | Bin 813 -> 0 bytes .../status_signature_unverified_cutout_24px.png | Bin 0 -> 813 bytes .../status_signature_unverified_cutout_96px.png | Bin 0 -> 3257 bytes .../drawable-hdpi/status_signature_verified.png | Bin 541 -> 0 bytes .../status_signature_verified_cutout.png | Bin 695 -> 0 bytes .../status_signature_verified_cutout_24px.png | Bin 0 -> 695 bytes .../status_signature_verified_cutout_96px.png | Bin 0 -> 3277 bytes .../res/drawable-mdpi/key_flag_authenticate.png | Bin 897 -> 0 bytes .../drawable-mdpi/key_flag_authenticate_24px.png | Bin 0 -> 897 bytes .../main/res/drawable-mdpi/key_flag_certify.png | Bin 1746 -> 0 bytes .../res/drawable-mdpi/key_flag_certify_24px.png | Bin 0 -> 1746 bytes .../main/res/drawable-mdpi/key_flag_encrypt.png | Bin 1153 -> 0 bytes .../res/drawable-mdpi/key_flag_encrypt_24px.png | Bin 0 -> 1153 bytes .../src/main/res/drawable-mdpi/key_flag_sign.png | Bin 1353 -> 0 bytes .../main/res/drawable-mdpi/key_flag_sign_24px.png | Bin 0 -> 1353 bytes .../main/res/drawable-mdpi/status_lock_closed.png | Bin 528 -> 0 bytes .../res/drawable-mdpi/status_lock_closed_24px.png | Bin 0 -> 528 bytes .../main/res/drawable-mdpi/status_lock_error.png | Bin 622 -> 0 bytes .../res/drawable-mdpi/status_lock_error_24px.png | Bin 0 -> 622 bytes .../main/res/drawable-mdpi/status_lock_open.png | Bin 522 -> 0 bytes .../res/drawable-mdpi/status_lock_open_24px.png | Bin 0 -> 522 bytes .../res/drawable-mdpi/status_signature_expired.png | Bin 601 -> 0 bytes .../status_signature_expired_cutout.png | Bin 643 -> 0 bytes .../status_signature_expired_cutout_24px.png | Bin 0 -> 643 bytes .../status_signature_expired_cutout_96px.png | Bin 0 -> 2411 bytes .../res/drawable-mdpi/status_signature_invalid.png | Bin 463 -> 0 bytes .../status_signature_invalid_cutout.png | Bin 410 -> 0 bytes .../status_signature_invalid_cutout_24px.png | Bin 0 -> 410 bytes .../status_signature_invalid_cutout_96px.png | Bin 0 -> 958 bytes .../res/drawable-mdpi/status_signature_revoked.png | Bin 613 -> 0 bytes .../status_signature_revoked_cutout.png | Bin 685 -> 0 bytes .../status_signature_revoked_cutout_24px.png | Bin 0 -> 685 bytes .../status_signature_revoked_cutout_96px.png | Bin 0 -> 2475 bytes .../res/drawable-mdpi/status_signature_unknown.png | Bin 517 -> 0 bytes .../status_signature_unknown_cutout.png | Bin 589 -> 0 bytes .../status_signature_unknown_cutout_24px.png | Bin 0 -> 589 bytes .../status_signature_unknown_cutout_96px.png | Bin 0 -> 2105 bytes .../drawable-mdpi/status_signature_unverified.png | Bin 469 -> 0 bytes .../status_signature_unverified_cutout.png | Bin 667 -> 0 bytes .../status_signature_unverified_cutout_24px.png | Bin 0 -> 667 bytes .../status_signature_unverified_cutout_96px.png | Bin 0 -> 2314 bytes .../drawable-mdpi/status_signature_verified.png | Bin 476 -> 0 bytes .../status_signature_verified_cutout.png | Bin 557 -> 0 bytes .../status_signature_verified_cutout_24px.png | Bin 0 -> 557 bytes .../status_signature_verified_cutout_96px.png | Bin 0 -> 2148 bytes .../res/drawable-xhdpi/key_flag_authenticate.png | Bin 2161 -> 0 bytes .../drawable-xhdpi/key_flag_authenticate_24px.png | Bin 0 -> 2161 bytes .../main/res/drawable-xhdpi/key_flag_certify.png | Bin 3713 -> 0 bytes .../res/drawable-xhdpi/key_flag_certify_24px.png | Bin 0 -> 3713 bytes .../main/res/drawable-xhdpi/key_flag_encrypt.png | Bin 2310 -> 0 bytes .../res/drawable-xhdpi/key_flag_encrypt_24px.png | Bin 0 -> 2310 bytes .../src/main/res/drawable-xhdpi/key_flag_sign.png | Bin 2705 -> 0 bytes .../main/res/drawable-xhdpi/key_flag_sign_24px.png | Bin 0 -> 2705 bytes .../main/res/drawable-xhdpi/status_lock_closed.png | Bin 911 -> 0 bytes .../res/drawable-xhdpi/status_lock_closed_24px.png | Bin 0 -> 911 bytes .../main/res/drawable-xhdpi/status_lock_error.png | Bin 1008 -> 0 bytes .../res/drawable-xhdpi/status_lock_error_24px.png | Bin 0 -> 1008 bytes .../main/res/drawable-xhdpi/status_lock_open.png | Bin 911 -> 0 bytes .../res/drawable-xhdpi/status_lock_open_24px.png | Bin 0 -> 911 bytes .../drawable-xhdpi/status_signature_expired.png | Bin 1049 -> 0 bytes .../status_signature_expired_cutout.png | Bin 1179 -> 0 bytes .../status_signature_expired_cutout_24px.png | Bin 0 -> 1179 bytes .../status_signature_expired_cutout_96px.png | Bin 0 -> 4973 bytes .../drawable-xhdpi/status_signature_invalid.png | Bin 736 -> 0 bytes .../status_signature_invalid_cutout.png | Bin 676 -> 0 bytes .../status_signature_invalid_cutout_24px.png | Bin 0 -> 676 bytes .../status_signature_invalid_cutout_96px.png | Bin 0 -> 2306 bytes .../drawable-xhdpi/status_signature_revoked.png | Bin 1033 -> 0 bytes .../status_signature_revoked_cutout.png | Bin 1218 -> 0 bytes .../status_signature_revoked_cutout_24px.png | Bin 0 -> 1218 bytes .../status_signature_revoked_cutout_96px.png | Bin 0 -> 5757 bytes .../drawable-xhdpi/status_signature_unknown.png | Bin 906 -> 0 bytes .../status_signature_unknown_cutout.png | Bin 1043 -> 0 bytes .../status_signature_unknown_cutout_24px.png | Bin 0 -> 1043 bytes .../status_signature_unknown_cutout_96px.png | Bin 0 -> 4395 bytes .../drawable-xhdpi/status_signature_unverified.png | Bin 706 -> 0 bytes .../status_signature_unverified_cutout.png | Bin 1166 -> 0 bytes .../status_signature_unverified_cutout_24px.png | Bin 0 -> 1166 bytes .../status_signature_unverified_cutout_96px.png | Bin 0 -> 4908 bytes .../drawable-xhdpi/status_signature_verified.png | Bin 784 -> 0 bytes .../status_signature_verified_cutout.png | Bin 1017 -> 0 bytes .../status_signature_verified_cutout_24px.png | Bin 0 -> 1017 bytes .../status_signature_verified_cutout_96px.png | Bin 0 -> 5309 bytes .../res/drawable-xxhdpi/key_flag_authenticate.png | Bin 3073 -> 0 bytes .../drawable-xxhdpi/key_flag_authenticate_24px.png | Bin 0 -> 3073 bytes .../main/res/drawable-xxhdpi/key_flag_certify.png | Bin 5303 -> 0 bytes .../res/drawable-xxhdpi/key_flag_certify_24px.png | Bin 0 -> 5303 bytes .../main/res/drawable-xxhdpi/key_flag_encrypt.png | Bin 3158 -> 0 bytes .../res/drawable-xxhdpi/key_flag_encrypt_24px.png | Bin 0 -> 3158 bytes .../src/main/res/drawable-xxhdpi/key_flag_sign.png | Bin 3765 -> 0 bytes .../res/drawable-xxhdpi/key_flag_sign_24px.png | Bin 0 -> 3765 bytes .../res/drawable-xxhdpi/status_lock_closed.png | Bin 1160 -> 0 bytes .../drawable-xxhdpi/status_lock_closed_24px.png | Bin 0 -> 1160 bytes .../main/res/drawable-xxhdpi/status_lock_error.png | Bin 1316 -> 0 bytes .../res/drawable-xxhdpi/status_lock_error_24px.png | Bin 0 -> 1316 bytes .../main/res/drawable-xxhdpi/status_lock_open.png | Bin 1165 -> 0 bytes .../res/drawable-xxhdpi/status_lock_open_24px.png | Bin 0 -> 1165 bytes .../drawable-xxhdpi/status_signature_expired.png | Bin 1429 -> 0 bytes .../status_signature_expired_cutout.png | Bin 1590 -> 0 bytes .../status_signature_expired_cutout_24px.png | Bin 0 -> 1590 bytes .../status_signature_expired_cutout_96px.png | Bin 0 -> 6986 bytes .../drawable-xxhdpi/status_signature_invalid.png | Bin 840 -> 0 bytes .../status_signature_invalid_cutout.png | Bin 694 -> 0 bytes .../status_signature_invalid_cutout_24px.png | Bin 0 -> 694 bytes .../status_signature_invalid_cutout_96px.png | Bin 0 -> 3701 bytes .../drawable-xxhdpi/status_signature_revoked.png | Bin 1353 -> 0 bytes .../status_signature_revoked_cutout.png | Bin 1660 -> 0 bytes .../status_signature_revoked_cutout_24px.png | Bin 0 -> 1660 bytes .../status_signature_revoked_cutout_96px.png | Bin 0 -> 7922 bytes .../drawable-xxhdpi/status_signature_unknown.png | Bin 1231 -> 0 bytes .../status_signature_unknown_cutout.png | Bin 1377 -> 0 bytes .../status_signature_unknown_cutout_24px.png | Bin 0 -> 1377 bytes .../status_signature_unknown_cutout_96px.png | Bin 0 -> 5952 bytes .../status_signature_unverified.png | Bin 946 -> 0 bytes .../status_signature_unverified_cutout.png | Bin 1555 -> 0 bytes .../status_signature_unverified_cutout_24px.png | Bin 0 -> 1555 bytes .../status_signature_unverified_cutout_96px.png | Bin 0 -> 6544 bytes .../drawable-xxhdpi/status_signature_verified.png | Bin 1012 -> 0 bytes .../status_signature_verified_cutout.png | Bin 1319 -> 0 bytes .../status_signature_verified_cutout_24px.png | Bin 0 -> 1319 bytes .../status_signature_verified_cutout_96px.png | Bin 0 -> 7353 bytes .../src/main/res/layout/certify_key_fragment.xml | 2 +- .../src/main/res/layout/decrypt_result_include.xml | 4 +- .../src/main/res/layout/import_keys_list_item.xml | 2 +- OpenKeychain/src/main/res/layout/key_list_item.xml | 2 +- .../src/main/res/layout/keyspinner_item.xml | 2 +- .../src/main/res/layout/select_key_item.xml | 2 +- .../src/main/res/layout/view_key_activity.xml | 32 +++++++----- .../main/res/layout/view_key_adv_main_fragment.xml | 2 +- .../main/res/layout/view_key_adv_subkey_item.xml | 10 ++-- .../src/main/res/layout/view_key_fragment.xml | 2 +- 165 files changed, 83 insertions(+), 48 deletions(-) delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_error.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_error_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_open.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_lock_open_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_error.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_error_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_open.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_lock_open_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open_24px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_96px.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_24px.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_96px.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 8ef5d01aa..ac1988d08 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -406,7 +406,7 @@ public class ViewKeyActivity extends BaseActivity implements if (isRevoked) { mStatusText.setText(R.string.view_key_revoked); mStatusImage.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); mActionEncryptFile.setVisibility(View.INVISIBLE); @@ -416,7 +416,7 @@ public class ViewKeyActivity extends BaseActivity implements } else if (isExpired) { mStatusText.setText(R.string.view_key_expired); mStatusImage.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); mActionEncryptFile.setVisibility(View.INVISIBLE); @@ -439,7 +439,7 @@ public class ViewKeyActivity extends BaseActivity implements if (isVerified) { mStatusText.setText(R.string.view_key_verified); mStatusImage.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons, true); color = getResources().getColor(R.color.primary); AsyncTask photoTask = @@ -461,7 +461,7 @@ public class ViewKeyActivity extends BaseActivity implements } else { mStatusText.setText(R.string.view_key_unverified); mStatusImage.setVisibility(View.VISIBLE); - KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_UNVERIFIED, R.color.icons); + KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_UNVERIFIED, R.color.icons, true); color = getResources().getColor(R.color.android_orange_light); mActionVerify.setVisibility(View.VISIBLE); @@ -472,6 +472,8 @@ public class ViewKeyActivity extends BaseActivity implements mStatusBar.setBackgroundColor(color); mBigToolbar.setBackgroundColor(color); + mStatusImage.setAlpha(80); + break; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java index a3bd4d470..ff5fbb49a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SubkeysAdapter.java @@ -272,12 +272,12 @@ public class SubkeysAdapter extends CursorAdapter { PorterDuff.Mode.SRC_IN); if (isRevoked) { - vStatus.setImageResource(R.drawable.status_signature_revoked_cutout); + vStatus.setImageResource(R.drawable.status_signature_revoked_cutout_24px); vStatus.setColorFilter( mContext.getResources().getColor(R.color.bg_gray), PorterDuff.Mode.SRC_IN); } else if (isExpired) { - vStatus.setImageResource(R.drawable.status_signature_expired_cutout); + vStatus.setImageResource(R.drawable.status_signature_expired_cutout_24px); vStatus.setColorFilter( mContext.getResources().getColor(R.color.bg_gray), PorterDuff.Mode.SRC_IN); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java index 1c3dec629..38ed88b9c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/KeyFormattingUtils.java @@ -395,19 +395,29 @@ public class KeyFormattingUtils { } public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, int state) { - setStatusImage(context, statusIcon, statusText, state, KeyFormattingUtils.DEFAULT_COLOR); + setStatusImage(context, statusIcon, statusText, state, KeyFormattingUtils.DEFAULT_COLOR, false); + } + + public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, + int state, int color) { + setStatusImage(context, statusIcon, statusText, state, color, false); } /** * Sets status image based on constant */ public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, - int state, int color) { + int state, int color, boolean big) { switch (state) { /** GREEN: everything is good **/ case STATE_VERIFIED: { - statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_verified_cutout)); + if (big) { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_verified_cutout_96px)); + } else { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_verified_cutout_24px)); + } if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_green_light; } @@ -420,7 +430,7 @@ public class KeyFormattingUtils { } case STATE_ENCRYPTED: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_lock_closed)); + context.getResources().getDrawable(R.drawable.status_lock_closed_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_green_light; } @@ -433,8 +443,13 @@ public class KeyFormattingUtils { } /** ORANGE: mostly bad... **/ case STATE_UNVERIFIED: { - statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout)); + if (big) { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout_96px)); + } else { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout_24px)); + } if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_orange_light; } @@ -447,7 +462,7 @@ public class KeyFormattingUtils { } case STATE_UNKNOWN_KEY: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); + context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_orange_light; } @@ -460,8 +475,13 @@ public class KeyFormattingUtils { } /** RED: really bad... **/ case STATE_REVOKED: { - statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout)); + if (big) { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout_96px)); + } else { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout_24px)); + } if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_red_light; } @@ -473,8 +493,13 @@ public class KeyFormattingUtils { break; } case STATE_EXPIRED: { - statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_expired_cutout)); + if (big) { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_expired_cutout_96px)); + } else { + statusIcon.setImageDrawable( + context.getResources().getDrawable(R.drawable.status_signature_expired_cutout_24px)); + } if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_red_light; } @@ -487,7 +512,7 @@ public class KeyFormattingUtils { } case STATE_NOT_ENCRYPTED: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_lock_open)); + context.getResources().getDrawable(R.drawable.status_lock_open_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_red_light; } @@ -500,7 +525,7 @@ public class KeyFormattingUtils { } case STATE_NOT_SIGNED: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); + context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_red_light; } @@ -513,7 +538,7 @@ public class KeyFormattingUtils { } case STATE_INVALID: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); + context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.android_red_light; } @@ -527,7 +552,7 @@ public class KeyFormattingUtils { /** special **/ case STATE_UNAVAILABLE: { statusIcon.setImageDrawable( - context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); + context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout_24px)); if (color == KeyFormattingUtils.DEFAULT_COLOR) { color = R.color.bg_gray; } diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate.png deleted file mode 100644 index 9d4ed6e84..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate_24px.png new file mode 100644 index 000000000..9d4ed6e84 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_authenticate_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify.png deleted file mode 100644 index e76393659..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify_24px.png new file mode 100644 index 000000000..e76393659 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_certify_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt.png deleted file mode 100644 index 3c2f8c09c..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt_24px.png new file mode 100644 index 000000000..3c2f8c09c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_encrypt_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign.png deleted file mode 100644 index 046424643..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign_24px.png new file mode 100644 index 000000000..046424643 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/key_flag_sign_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed.png deleted file mode 100644 index a1b090630..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed_24px.png new file mode 100644 index 000000000..a1b090630 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_closed_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error.png deleted file mode 100644 index e567055aa..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error_24px.png new file mode 100644 index 000000000..e567055aa Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_error_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open.png deleted file mode 100644 index 98e32eadc..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open_24px.png new file mode 100644 index 000000000..98e32eadc Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_lock_open_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired.png deleted file mode 100644 index 21e8b536a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout.png deleted file mode 100644 index 84ac9bec2..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_24px.png new file mode 100644 index 000000000..84ac9bec2 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_96px.png new file mode 100644 index 000000000..63546068f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_expired_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid.png deleted file mode 100644 index 9ae2a09ab..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png deleted file mode 100644 index 967e00e80..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_24px.png new file mode 100644 index 000000000..967e00e80 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_96px.png new file mode 100644 index 000000000..9957db288 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_invalid_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked.png deleted file mode 100644 index 16e1d7181..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png deleted file mode 100644 index 244dd0708..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_24px.png new file mode 100644 index 000000000..244dd0708 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_96px.png new file mode 100644 index 000000000..1c3a15c07 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_revoked_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown.png deleted file mode 100644 index 5c3ba866d..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png deleted file mode 100644 index 82cc25a4b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_24px.png new file mode 100644 index 000000000..82cc25a4b Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_96px.png new file mode 100644 index 000000000..ce46c6317 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unknown_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified.png deleted file mode 100644 index b8b472a5a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png deleted file mode 100644 index e752eaeab..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_24px.png new file mode 100644 index 000000000..e752eaeab Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_96px.png new file mode 100644 index 000000000..19ee3c241 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_unverified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified.png deleted file mode 100644 index d8141b47b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout.png deleted file mode 100644 index 08a9f464c..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_24px.png new file mode 100644 index 000000000..08a9f464c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_96px.png new file mode 100644 index 000000000..ed3db0aca Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/status_signature_verified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate.png deleted file mode 100644 index ed1ba24d2..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate_24px.png new file mode 100644 index 000000000..ed1ba24d2 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_authenticate_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify.png deleted file mode 100644 index d54d461fa..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify_24px.png new file mode 100644 index 000000000..d54d461fa Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_certify_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt.png deleted file mode 100644 index 81c1b3dfa..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt_24px.png new file mode 100644 index 000000000..81c1b3dfa Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_encrypt_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign.png deleted file mode 100644 index 9afc43901..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign_24px.png new file mode 100644 index 000000000..9afc43901 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/key_flag_sign_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed.png deleted file mode 100644 index cfc39f0e7..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed_24px.png new file mode 100644 index 000000000..cfc39f0e7 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_closed_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error.png deleted file mode 100644 index 824dc2672..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error_24px.png new file mode 100644 index 000000000..824dc2672 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_error_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open.png deleted file mode 100644 index 9bca59ae3..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open_24px.png new file mode 100644 index 000000000..9bca59ae3 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_lock_open_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired.png deleted file mode 100644 index 81a900147..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout.png deleted file mode 100644 index bc91094b5..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_24px.png new file mode 100644 index 000000000..bc91094b5 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_96px.png new file mode 100644 index 000000000..df385bb1b Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_expired_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid.png deleted file mode 100644 index baa78f795..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png deleted file mode 100644 index bc2f56e2a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_24px.png new file mode 100644 index 000000000..bc2f56e2a Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_96px.png new file mode 100644 index 000000000..aeb899599 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_invalid_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked.png deleted file mode 100644 index 7cf985274..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png deleted file mode 100644 index 2d2593194..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_24px.png new file mode 100644 index 000000000..2d2593194 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_96px.png new file mode 100644 index 000000000..d77c5e1c1 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_revoked_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown.png deleted file mode 100644 index 3d4665320..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png deleted file mode 100644 index 0fc74d07e..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_24px.png new file mode 100644 index 000000000..0fc74d07e Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_96px.png new file mode 100644 index 000000000..ee0661234 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unknown_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified.png deleted file mode 100644 index 8348b32b3..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png deleted file mode 100644 index 96a2d1413..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_24px.png new file mode 100644 index 000000000..96a2d1413 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_96px.png new file mode 100644 index 000000000..1602747f1 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_unverified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified.png deleted file mode 100644 index 02e53ac8a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout.png deleted file mode 100644 index 9f7cf837c..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_24px.png new file mode 100644 index 000000000..9f7cf837c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_96px.png new file mode 100644 index 000000000..61c23f749 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/status_signature_verified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate.png deleted file mode 100644 index 8d36d7202..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate_24px.png new file mode 100644 index 000000000..8d36d7202 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_authenticate_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify.png deleted file mode 100644 index 01a74bcc0..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify_24px.png new file mode 100644 index 000000000..01a74bcc0 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_certify_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt.png deleted file mode 100644 index ff07bd0a4..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt_24px.png new file mode 100644 index 000000000..ff07bd0a4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_encrypt_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign.png deleted file mode 100644 index b8002162a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign_24px.png new file mode 100644 index 000000000..b8002162a Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/key_flag_sign_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed.png deleted file mode 100644 index 7c6bb2d18..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed_24px.png new file mode 100644 index 000000000..7c6bb2d18 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_closed_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error.png deleted file mode 100644 index da4a5d89a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error_24px.png new file mode 100644 index 000000000..da4a5d89a Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_error_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open.png deleted file mode 100644 index cd02fc1e4..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open_24px.png new file mode 100644 index 000000000..cd02fc1e4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_lock_open_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired.png deleted file mode 100644 index f5105c1ae..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png deleted file mode 100644 index 83f6fde35..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_24px.png new file mode 100644 index 000000000..83f6fde35 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96px.png new file mode 100644 index 000000000..568b48c43 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_expired_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid.png deleted file mode 100644 index 67880d6db..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png deleted file mode 100644 index 29830f5ba..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_24px.png new file mode 100644 index 000000000..29830f5ba Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_96px.png new file mode 100644 index 000000000..89f899212 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_invalid_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked.png deleted file mode 100644 index 2ed67419b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png deleted file mode 100644 index 2f7695043..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_24px.png new file mode 100644 index 000000000..2f7695043 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_96px.png new file mode 100644 index 000000000..3db663e2e Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_revoked_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown.png deleted file mode 100644 index a6f1f2792..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png deleted file mode 100644 index 2ce28c7ca..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_24px.png new file mode 100644 index 000000000..2ce28c7ca Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_96px.png new file mode 100644 index 000000000..4e0e04375 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unknown_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified.png deleted file mode 100644 index c25a84b4d..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png deleted file mode 100644 index 442c55eee..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_24px.png new file mode 100644 index 000000000..442c55eee Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_96px.png new file mode 100644 index 000000000..0b2ccc9f7 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_unverified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified.png deleted file mode 100644 index 6f435a85e..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png deleted file mode 100644 index 160ec7cbe..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_24px.png new file mode 100644 index 000000000..160ec7cbe Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_96px.png new file mode 100644 index 000000000..471e5e513 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/status_signature_verified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate.png deleted file mode 100644 index d786dc72f..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate_24px.png new file mode 100644 index 000000000..d786dc72f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_authenticate_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify.png deleted file mode 100644 index 4bb97f992..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify_24px.png new file mode 100644 index 000000000..4bb97f992 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_certify_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt.png deleted file mode 100644 index fe0c8e41b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt_24px.png new file mode 100644 index 000000000..fe0c8e41b Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_encrypt_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign.png deleted file mode 100644 index 51ab367a9..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign_24px.png new file mode 100644 index 000000000..51ab367a9 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/key_flag_sign_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed.png deleted file mode 100644 index 5a9664d59..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed_24px.png new file mode 100644 index 000000000..5a9664d59 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_closed_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error.png deleted file mode 100644 index 608f065af..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error_24px.png new file mode 100644 index 000000000..608f065af Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_error_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open.png deleted file mode 100644 index ee34dd396..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open_24px.png new file mode 100644 index 000000000..ee34dd396 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_lock_open_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired.png deleted file mode 100644 index f475c9d84..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png deleted file mode 100644 index 33a3efed1..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_24px.png new file mode 100644 index 000000000..33a3efed1 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_96px.png new file mode 100644 index 000000000..ba7e8c2f4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_expired_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid.png deleted file mode 100644 index f21c2cf52..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png deleted file mode 100644 index bc39d3496..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_24px.png new file mode 100644 index 000000000..bc39d3496 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_96px.png new file mode 100644 index 000000000..1fbf5ceb2 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_invalid_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked.png deleted file mode 100644 index be1a1d9dc..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png deleted file mode 100644 index 58929661f..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_24px.png new file mode 100644 index 000000000..58929661f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_96px.png new file mode 100644 index 000000000..338c696ac Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_revoked_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown.png deleted file mode 100644 index 841cfa958..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png deleted file mode 100644 index 3020357a4..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_24px.png new file mode 100644 index 000000000..3020357a4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_96px.png new file mode 100644 index 000000000..2690310a6 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unknown_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified.png deleted file mode 100644 index 525d1cf6b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png deleted file mode 100644 index 3829bb3a0..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_24px.png new file mode 100644 index 000000000..3829bb3a0 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_96px.png new file mode 100644 index 000000000..e559faf9d Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_unverified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified.png deleted file mode 100644 index 54eee5ba0..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png deleted file mode 100644 index 3548ee2b6..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_24px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_24px.png new file mode 100644 index 000000000..3548ee2b6 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_24px.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_96px.png b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_96px.png new file mode 100644 index 000000000..79e4ec4a9 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/status_signature_verified_cutout_96px.png differ diff --git a/OpenKeychain/src/main/res/layout/certify_key_fragment.xml b/OpenKeychain/src/main/res/layout/certify_key_fragment.xml index a55a8ea0c..2df3755a4 100644 --- a/OpenKeychain/src/main/res/layout/certify_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/certify_key_fragment.xml @@ -95,7 +95,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/status_signature_verified_cutout" + android:src="@drawable/status_signature_verified_cutout_24px" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/decrypt_result_include.xml b/OpenKeychain/src/main/res/layout/decrypt_result_include.xml index 9140ad07b..659d1c207 100644 --- a/OpenKeychain/src/main/res/layout/decrypt_result_include.xml +++ b/OpenKeychain/src/main/res/layout/decrypt_result_include.xml @@ -24,7 +24,7 @@ android:id="@+id/result_encryption_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/status_lock_open" + android:src="@drawable/status_lock_open_24px" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/keyspinner_item.xml b/OpenKeychain/src/main/res/layout/keyspinner_item.xml index b75bb808e..757dae5be 100644 --- a/OpenKeychain/src/main/res/layout/keyspinner_item.xml +++ b/OpenKeychain/src/main/res/layout/keyspinner_item.xml @@ -50,7 +50,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:src="@drawable/status_signature_revoked_cutout" + android:src="@drawable/status_signature_revoked_cutout_24px" android:paddingLeft="16dp" android:paddingRight="16dp" /> diff --git a/OpenKeychain/src/main/res/layout/select_key_item.xml b/OpenKeychain/src/main/res/layout/select_key_item.xml index c7fa882cb..13f63d2ee 100644 --- a/OpenKeychain/src/main/res/layout/select_key_item.xml +++ b/OpenKeychain/src/main/res/layout/select_key_item.xml @@ -50,7 +50,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" - android:src="@drawable/status_signature_revoked_cutout" + android:src="@drawable/status_signature_revoked_cutout_24px" android:paddingLeft="16dp" android:paddingRight="16dp" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index ad46a8d62..9b055d322 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -53,19 +53,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - @@ -98,12 +89,15 @@ android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" - android:layout_marginLeft="32dp"> + android:layout_marginLeft="32dp" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true"> @@ -111,6 +105,7 @@ android:id="@+id/view_key_action_encrypt_text" android:layout_width="64dp" android:layout_height="64dp" + android:visibility="invisible" style="?android:attr/borderlessButtonStyle" android:src="@drawable/ic_action_encrypt_text" /> @@ -123,6 +118,18 @@ android:src="@drawable/ic_action_verified_cutout" /> + + diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml b/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml index b2875b9e6..f41109d84 100644 --- a/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml +++ b/OpenKeychain/src/main/res/layout/view_key_adv_subkey_item.xml @@ -11,7 +11,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:src="@drawable/status_signature_revoked_cutout" + android:src="@drawable/status_signature_revoked_cutout_24px" android:paddingLeft="8dp" android:layout_centerVertical="true" android:layout_alignParentStart="true" /> @@ -71,7 +71,7 @@ android:id="@+id/subkey_item_ic_certify" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/key_flag_certify" + android:src="@drawable/key_flag_certify_24px" android:layout_marginLeft="8dp" android:layout_gravity="center_vertical" /> @@ -79,7 +79,7 @@ android:id="@+id/subkey_item_ic_sign" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/key_flag_sign" + android:src="@drawable/key_flag_sign_24px" android:layout_marginLeft="8dp" android:layout_gravity="center_vertical" /> @@ -87,7 +87,7 @@ android:id="@+id/subkey_item_ic_encrypt" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/key_flag_encrypt" + android:src="@drawable/key_flag_encrypt_24px" android:layout_marginLeft="8dp" android:layout_gravity="center_vertical" /> @@ -95,7 +95,7 @@ android:id="@+id/subkey_item_ic_authenticate" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/key_flag_authenticate" + android:src="@drawable/key_flag_authenticate_24px" android:layout_marginLeft="8dp" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_fragment.xml index fadad0e56..790d4143e 100644 --- a/OpenKeychain/src/main/res/layout/view_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_fragment.xml @@ -60,7 +60,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/status_signature_verified_cutout" + android:src="@drawable/status_signature_verified_cutout_24px" android:layout_gravity="center_vertical" /> -- cgit v1.2.3 From fa92ceeae3ba89d11cce1282e7c2f824969acf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 13:49:21 +0100 Subject: Toolbar: qr code in header, cleanup of fragment --- .../keychain/ui/ViewKeyActivity.java | 254 ++++++++++-- .../keychain/ui/ViewKeyFragment.java | 456 +-------------------- .../res/drawable-hdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 351 bytes .../ic_swap_vert_circle_white_24dp.png | Bin 0 -> 483 bytes .../res/drawable-hdpi/ic_swap_vert_white_24dp.png | Bin 0 -> 300 bytes .../res/drawable-mdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 272 bytes .../ic_swap_vert_circle_white_24dp.png | Bin 0 -> 341 bytes .../res/drawable-mdpi/ic_swap_vert_white_24dp.png | Bin 0 -> 226 bytes .../res/drawable-xhdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 378 bytes .../ic_swap_vert_circle_white_24dp.png | Bin 0 -> 569 bytes .../res/drawable-xhdpi/ic_swap_vert_white_24dp.png | Bin 0 -> 330 bytes .../drawable-xxhdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 490 bytes .../ic_swap_vert_circle_white_24dp.png | Bin 0 -> 863 bytes .../drawable-xxhdpi/ic_swap_vert_white_24dp.png | Bin 0 -> 414 bytes .../drawable-xxxhdpi/ic_mode_edit_white_24dp.png | Bin 0 -> 632 bytes .../ic_swap_vert_circle_white_24dp.png | Bin 0 -> 1048 bytes .../drawable-xxxhdpi/ic_swap_vert_white_24dp.png | Bin 0 -> 502 bytes .../src/main/res/layout/view_key_activity.xml | 82 ++-- .../src/main/res/layout/view_key_fragment.xml | 368 ++--------------- 19 files changed, 301 insertions(+), 859 deletions(-) create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index ac1988d08..5454e4f3e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -36,13 +36,10 @@ import android.provider.ContactsContract; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; -import android.support.v7.app.ActionBar; -import android.support.v7.widget.Toolbar; -import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup; +import android.view.animation.AlphaAnimation; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -55,11 +52,13 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.KeyRing; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; import org.sufficientlysecure.keychain.ui.widget.AspectRatioImageView; import org.sufficientlysecure.keychain.util.ContactHelper; import org.sufficientlysecure.keychain.util.ExportHelper; @@ -84,8 +83,10 @@ public class ViewKeyActivity extends BaseActivity implements private ImageButton mActionEncryptFile; private ImageButton mActionEncryptText; private ImageButton mActionVerify; + private ImageButton mActionEdit; private FloatingActionButton mFab; private AspectRatioImageView mPhoto; + private ImageButton mQrCode; // NFC private NfcAdapter mNfcAdapter; @@ -96,6 +97,9 @@ public class ViewKeyActivity extends BaseActivity implements private static final int LOADER_ID_UNIFIED = 0; + private boolean mIsSecret; + private boolean mHasEncrypt; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -113,8 +117,10 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files); mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); + mActionEdit = (ImageButton) findViewById(R.id.view_key_action_edit); mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); + mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); mDataUri = getIntent().getData(); if (mDataUri == null) { @@ -134,6 +140,48 @@ public class ViewKeyActivity extends BaseActivity implements Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + mActionEncryptFile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, false); + } + }); + mActionEncryptText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encrypt(mDataUri, true); + } + }); + mActionVerify.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + certify(mDataUri); + } + }); + mActionEdit.setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + editKey(mDataUri); + } + }); + + mFab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mIsSecret) { + startSafeSlinger(mDataUri); + } else { + certify(mDataUri); + } + } + }); + + mQrCode.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showQrCodeDialog(); + } + }); + + // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. getSupportLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); @@ -199,6 +247,13 @@ public class ViewKeyActivity extends BaseActivity implements advancedIntent.setData(mDataUri); startActivity(advancedIntent); } + case R.id.menu_key_view_refresh: { + try { + updateFromKeyserver(mDataUri, mProviderHelper); + } catch (ProviderHelper.NotFoundException e) { + Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); + } + } } } catch (ProviderHelper.NotFoundException e) { Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); @@ -207,6 +262,12 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + private void showQrCodeDialog() { + Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); + qrCodeIntent.setData(mDataUri); + startActivity(qrCodeIntent); + } + private void exportToFile(Uri dataUri, ExportHelper exportHelper, ProviderHelper providerHelper) throws ProviderHelper.NotFoundException { Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri); @@ -248,6 +309,119 @@ public class ViewKeyActivity extends BaseActivity implements } } + private void encrypt(Uri dataUri, boolean text) { + // If there is no encryption key, don't bother. + if (!mHasEncrypt) { + Notify.showNotify(this, R.string.error_no_encrypt_subkey, Notify.Style.ERROR); + return; + } + try { + long keyId = new ProviderHelper(this) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + long[] encryptionKeyIds = new long[]{keyId}; + Intent intent; + if (text) { + intent = new Intent(this, EncryptTextActivity.class); + intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT); + intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } else { + intent = new Intent(this, EncryptFilesActivity.class); + intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA); + intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + } + // used instead of startActivity set actionbar based on callingPackage + startActivityForResult(intent, 0); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + } + + private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) + throws ProviderHelper.NotFoundException { + byte[] blob = (byte[]) providerHelper.getGenericData( + KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), + KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); + + Intent queryIntent = new Intent(this, ImportKeysActivity.class); + queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); + queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + + startActivityForResult(queryIntent, 0); + } + + private void certify(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(this) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent certifyIntent = new Intent(this, CertifyKeyActivity.class); + certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); + startActivityForResult(certifyIntent, 0); + } + + private void editKey(Uri dataUri) { + Intent editIntent = new Intent(this, EditKeyActivity.class); + editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); + startActivityForResult(editIntent, 0); + } + + private void startSafeSlinger(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(this) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent safeSlingerIntent = new Intent(this, SafeSlingerActivity.class); + safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); + startActivityForResult(safeSlingerIntent, 0); + } + + + /** + * Load QR Code asynchronously and with a fade in animation + * + * @param fingerprint + */ + private void loadQrCode(final String fingerprint) { + AsyncTask loadTask = + new AsyncTask() { + protected Bitmap doInBackground(Void... unused) { + String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; + // render with minimal size + return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); + } + + protected void onPostExecute(Bitmap qrCode) { + // only change view, if fragment is attached to activity +// if (ViewKeyFragment.this.isAdded()) { + + // scale the image up to our actual size. we do this in code rather + // than let the ImageView do this because we don't require filtering. + Bitmap scaled = Bitmap.createScaledBitmap(qrCode, + mQrCode.getHeight(), mQrCode.getHeight(), + false); + mQrCode.setImageBitmap(scaled); + + // simple fade-in animation + AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); + anim.setDuration(200); + mQrCode.startAnimation(anim); + } +// } + }; + + loadTask.execute(); + } + /** * NFC: Initialize NFC sharing if OS and device supports it */ @@ -347,7 +521,8 @@ public class ViewKeyActivity extends BaseActivity implements KeychainContract.KeyRings.EXPIRY, KeychainContract.KeyRings.VERIFIED, KeychainContract.KeyRings.HAS_ANY_SECRET, - KeychainContract.KeyRings.FINGERPRINT + KeychainContract.KeyRings.FINGERPRINT, + KeychainContract.KeyRings.HAS_ENCRYPT }; static final int INDEX_MASTER_KEY_ID = 1; @@ -357,6 +532,7 @@ public class ViewKeyActivity extends BaseActivity implements static final int INDEX_VERIFIED = 5; static final int INDEX_HAS_ANY_SECRET = 6; static final int INDEX_FINGERPRINT = 7; + static final int INDEX_HAS_ENCRYPT = 8; @Override public Loader onCreateLoader(int id, Bundle args) { @@ -395,12 +571,26 @@ public class ViewKeyActivity extends BaseActivity implements String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data.getBlob(INDEX_FINGERPRINT)); - boolean isSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + mHasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0; boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; boolean isExpired = !data.isNull(INDEX_EXPIRY) && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; + + AsyncTask photoTask = + new AsyncTask() { + protected Bitmap doInBackground(String... fingerprint) { + return ContactHelper.photoFromFingerprint(getContentResolver(), fingerprint[0]); + } + + protected void onPostExecute(Bitmap photo) { + mPhoto.setImageBitmap(photo); + mPhoto.setVisibility(View.VISIBLE); + } + }; + // Note: order is important int color; if (isRevoked) { @@ -409,55 +599,53 @@ public class ViewKeyActivity extends BaseActivity implements KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); - mActionEncryptFile.setVisibility(View.INVISIBLE); - mActionEncryptText.setVisibility(View.INVISIBLE); - mActionVerify.setVisibility(View.INVISIBLE); - mFab.setVisibility(View.INVISIBLE); + mActionEncryptFile.setVisibility(View.GONE); + mActionEncryptText.setVisibility(View.GONE); + mActionVerify.setVisibility(View.GONE); + mActionEdit.setVisibility(View.GONE); + mFab.setVisibility(View.GONE); + mQrCode.setVisibility(View.GONE); } else if (isExpired) { mStatusText.setText(R.string.view_key_expired); mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); - mActionEncryptFile.setVisibility(View.INVISIBLE); - mActionEncryptText.setVisibility(View.INVISIBLE); - mActionVerify.setVisibility(View.INVISIBLE); - mFab.setVisibility(View.INVISIBLE); - } else if (isSecret) { + mActionEncryptFile.setVisibility(View.GONE); + mActionEncryptText.setVisibility(View.GONE); + mActionVerify.setVisibility(View.GONE); + mActionEdit.setVisibility(View.GONE); + mFab.setVisibility(View.GONE); + mQrCode.setVisibility(View.GONE); + } else if (mIsSecret) { mStatusText.setText(R.string.view_key_my_key); - mStatusImage.setVisibility(View.INVISIBLE); + mStatusImage.setVisibility(View.GONE); color = getResources().getColor(R.color.primary); + photoTask.execute(fingerprint); + loadQrCode(fingerprint); + mQrCode.setVisibility(View.VISIBLE); mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); - mActionVerify.setVisibility(View.INVISIBLE); - mFab.setVisibility(View.INVISIBLE); // TODO + mActionVerify.setVisibility(View.GONE); + mActionEdit.setVisibility(View.VISIBLE); + mFab.setVisibility(View.VISIBLE); + mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_swap_vert_white_24dp)); } else { mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); + mActionEdit.setVisibility(View.GONE); + mQrCode.setVisibility(View.GONE); if (isVerified) { mStatusText.setText(R.string.view_key_verified); mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_VERIFIED, R.color.icons, true); color = getResources().getColor(R.color.primary); - - AsyncTask photoTask = - new AsyncTask() { - protected Bitmap doInBackground(String... fingerprint) { - return ContactHelper.photoFromFingerprint(getContentResolver(), fingerprint[0]); - } - - protected void onPostExecute(Bitmap photo) { - mPhoto.setImageBitmap(photo); - mPhoto.setVisibility(View.VISIBLE); - } - }; - photoTask.execute(fingerprint); - mActionVerify.setVisibility(View.INVISIBLE); - mFab.setVisibility(View.INVISIBLE); + mActionVerify.setVisibility(View.GONE); + mFab.setVisibility(View.GONE); } else { mStatusText.setText(R.string.view_key_unverified); mStatusImage.setVisibility(View.VISIBLE); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index 9ae656b2d..571c86b82 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -18,84 +18,36 @@ package org.sufficientlysecure.keychain.ui; -import android.annotation.TargetApi; -import android.content.Intent; import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.PorterDuff; import android.net.Uri; -import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; -import android.provider.Settings; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.animation.AlphaAnimation; import android.widget.AdapterView; -import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.ListView; -import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; -import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; -import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; -import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.ui.util.QrCodeUtils; import org.sufficientlysecure.keychain.util.Log; -import java.io.IOException; -import java.util.Date; - public class ViewKeyFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { public static final String ARG_DATA_URI = "uri"; - private View mActionEdit; - private View mActionEditDivider; - private View mActionEncryptFiles; - private View mActionEncryptText; - private View mActionEncryptTextText; - private View mActionCertify; - private View mActionCertifyText; - private ImageView mActionCertifyImage; - private View mActionUpdate; - - private TextView mFingerprint; - private ImageView mFingerprintQrCode; - private View mFingerprintShareButton; - private View mFingerprintClipboardButton; - private View mKeyShareButton; - private View mKeyClipboardButton; - private ImageButton mKeySafeSlingerButton; - private View mNfcHelpButton; - private View mNfcPrefsButton; - private View mKeyUploadButton; private ListView mUserIds; - private static final int LOADER_ID_UNIFIED = 0; private static final int LOADER_ID_USER_IDS = 1; - // conservative attitude - private boolean mHasEncrypt = true; - private UserIdsAdapter mUserIdsAdapter; private Uri mDataUri; @@ -123,18 +75,7 @@ public class ViewKeyFragment extends LoaderFragment implements mProviderHelper = new ProviderHelper(getActivity()); mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); - mActionEdit = view.findViewById(R.id.view_key_action_edit); - mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); - mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text); - mActionEncryptTextText = view.findViewById(R.id.view_key_action_encrypt_text_text); - mActionEncryptFiles = view.findViewById(R.id.view_key_action_encrypt_files); - mActionCertify = view.findViewById(R.id.view_key_action_certify); - mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text); - mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image); - // make certify image gray, like action icons - mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), - PorterDuff.Mode.SRC_IN); - mActionUpdate = view.findViewById(R.id.view_key_action_update); + mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -143,176 +84,10 @@ public class ViewKeyFragment extends LoaderFragment implements } }); - mFingerprint = (TextView) view.findViewById(R.id.view_key_fingerprint); - mFingerprintQrCode = (ImageView) view.findViewById(R.id.view_key_fingerprint_qr_code_image); - mFingerprintShareButton = view.findViewById(R.id.view_key_action_fingerprint_share); - mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard); - mKeyShareButton = view.findViewById(R.id.view_key_action_key_share); - mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); - mKeySafeSlingerButton = (ImageButton) view.findViewById(R.id.view_key_action_key_safeslinger); - mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); - mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); - mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); - - mKeySafeSlingerButton.setColorFilter(getResources().getColor(R.color.tertiary_text_light), - PorterDuff.Mode.SRC_IN); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - mNfcPrefsButton.setVisibility(View.VISIBLE); - } else { - mNfcPrefsButton.setVisibility(View.GONE); - } - - mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showQrCodeDialog(); - } - }); - - mFingerprintShareButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, true, false); - } - }); - mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, true, true); - } - }); - mKeyShareButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, false, false); - } - }); - mKeyClipboardButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - share(mDataUri, mProviderHelper, false, true); - } - }); - mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startSafeSlinger(mDataUri); - } - }); - mNfcHelpButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showNfcHelpDialog(); - } - }); - mNfcPrefsButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showNfcPrefs(); - } - }); - mKeyUploadButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - uploadToKeyserver(); - } - }); - return root; } - private void startSafeSlinger(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class); - safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, keyId); - startActivityForResult(safeSlingerIntent, 0); - } - - private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, - boolean toClipboard) { - try { - String content; - if (fingerprintOnly) { - byte[] data = (byte[]) providerHelper.getGenericData( - KeyRings.buildUnifiedKeyRingUri(dataUri), - KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(data); - if (!toClipboard) { - content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; - } else { - content = fingerprint; - } - } else { - Uri uri = KeychainContract.KeyRingData.buildPublicKeyRingUri(dataUri); - // get public keyring as ascii armored string - content = providerHelper.getKeyRingAsArmoredString(uri); - } - - if (toClipboard) { - ClipboardReflection.copyToClipboard(getActivity(), content); - String message; - if (fingerprintOnly) { - message = getResources().getString(R.string.fingerprint_copied_to_clipboard); - } else { - message = getResources().getString(R.string.key_copied_to_clipboard); - } - Notify.showNotify(getActivity(), message, Notify.Style.OK); - } else { - // Android will fail with android.os.TransactionTooLargeException if key is too big - // see http://www.lonestarprod.com/?p=34 - if (content.length() >= 86389) { - Notify.showNotify(getActivity(), R.string.key_too_big_for_sharing, - Notify.Style.ERROR); - return; - } - - // let user choose application - Intent sendIntent = new Intent(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_TEXT, content); - sendIntent.setType("text/plain"); - String title; - if (fingerprintOnly) { - title = getResources().getString(R.string.title_share_fingerprint_with); - } else { - title = getResources().getString(R.string.title_share_key); - } - startActivity(Intent.createChooser(sendIntent, title)); - } - } catch (PgpGeneralException | IOException e) { - Log.e(Constants.TAG, "error processing key!", e); - Notify.showNotify(getActivity(), R.string.error_key_processing, Notify.Style.ERROR); - } catch (ProviderHelper.NotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); - } - } - - private void showQrCodeDialog() { - Intent qrCodeIntent = new Intent(getActivity(), QrCodeViewActivity.class); - qrCodeIntent.setData(mDataUri); - startActivity(qrCodeIntent); - } - - private void showNfcHelpDialog() { - ShareNfcDialogFragment dialog = ShareNfcDialogFragment.newInstance(); - dialog.show(getActivity().getSupportFragmentManager(), "shareNfcDialog"); - } - - @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) - private void showNfcPrefs() { - Intent intentSettings = new Intent( - Settings.ACTION_NFCSHARING_SETTINGS); - startActivity(intentSettings); - } private void showUserIdInfo(final int position) { final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); @@ -347,82 +122,21 @@ public class ViewKeyFragment extends LoaderFragment implements Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - mActionEncryptFiles.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - encrypt(mDataUri, false); - } - }); - mActionEncryptText.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - encrypt(mDataUri, true); - } - }); - mActionCertify.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - certify(mDataUri); - } - }); - mActionEdit.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - editKey(mDataUri); - } - }); - mActionUpdate.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - try { - updateFromKeyserver(mDataUri, new ProviderHelper(getActivity())); - } catch (NotFoundException e) { - Notify.showNotify(getActivity(), R.string.error_key_not_found, Notify.Style.ERROR); - } - } - }); - mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); mUserIds.setAdapter(mUserIdsAdapter); // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. - getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); } - static final String[] UNIFIED_PROJECTION = new String[]{ - KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET, - KeyRings.USER_ID, KeyRings.FINGERPRINT, - KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY, - KeyRings.IS_REVOKED, KeyRings.HAS_ENCRYPT, - - }; - static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; - static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; - static final int INDEX_UNIFIED_USER_ID = 3; - static final int INDEX_UNIFIED_FINGERPRINT = 4; - static final int INDEX_UNIFIED_ALGORITHM = 5; - static final int INDEX_UNIFIED_KEY_SIZE = 6; - static final int INDEX_UNIFIED_CREATION = 7; - static final int INDEX_UNIFIED_EXPIRY = 8; - static final int INDEX_UNIFIED_IS_REVOKED = 9; - static final int INDEX_UNIFIED_HAS_ENCRYPT = 10; public Loader onCreateLoader(int id, Bundle args) { setContentShown(false); - switch (id) { - case LOADER_ID_UNIFIED: { - Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); - } - case LOADER_ID_USER_IDS: { - Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); - } - - default: - return null; - } + Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); } public void onLoadFinished(Loader loader, Cursor data) { @@ -435,63 +149,8 @@ public class ViewKeyFragment extends LoaderFragment implements } // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) - switch (loader.getId()) { - case LOADER_ID_UNIFIED: { - if (data.moveToFirst()) { - byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); - mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); - - loadQrCode(fingerprint); - - if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) { - // edit button - mActionEdit.setVisibility(View.VISIBLE); - mActionEditDivider.setVisibility(View.VISIBLE); - } else { - // edit button - mActionEdit.setVisibility(View.GONE); - mActionEditDivider.setVisibility(View.GONE); - } - - // If this key is revoked, it cannot be used for anything! - if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { - mActionEdit.setEnabled(false); - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - mActionEncryptText.setEnabled(false); - mActionEncryptTextText.setEnabled(false); - mActionEncryptFiles.setEnabled(false); - } else { - mActionEdit.setEnabled(true); - - Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); - if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - mActionEncryptText.setEnabled(false); - mActionEncryptTextText.setEnabled(false); - mActionEncryptFiles.setEnabled(false); - } else { - mActionCertify.setEnabled(true); - mActionCertifyText.setEnabled(true); - mActionEncryptText.setEnabled(true); - mActionEncryptTextText.setEnabled(true); - mActionEncryptFiles.setEnabled(true); - } - } - - mHasEncrypt = data.getInt(INDEX_UNIFIED_HAS_ENCRYPT) != 0; - - break; - } - } - - case LOADER_ID_USER_IDS: - mUserIdsAdapter.swapCursor(data); - break; - } + mUserIdsAdapter.swapCursor(data); setContentShown(true); } @@ -507,109 +166,4 @@ public class ViewKeyFragment extends LoaderFragment implements } } - - /** - * Load QR Code asynchronously and with a fade in animation - * - * @param fingerprint - */ - private void loadQrCode(final String fingerprint) { - AsyncTask loadTask = - new AsyncTask() { - protected Bitmap doInBackground(Void... unused) { - String qrCodeContent = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; - // render with minimal size - return QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); - } - - protected void onPostExecute(Bitmap qrCode) { - // only change view, if fragment is attached to activity - if (ViewKeyFragment.this.isAdded()) { - - // scale the image up to our actual size. we do this in code rather - // than let the ImageView do this because we don't require filtering. - Bitmap scaled = Bitmap.createScaledBitmap(qrCode, - mFingerprintQrCode.getHeight(), mFingerprintQrCode.getHeight(), - false); - mFingerprintQrCode.setImageBitmap(scaled); - - // simple fade-in animation - AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); - anim.setDuration(200); - mFingerprintQrCode.startAnimation(anim); - } - } - }; - - loadTask.execute(); - } - - private void uploadToKeyserver() { - Intent uploadIntent = new Intent(getActivity(), UploadKeyActivity.class); - uploadIntent.setData(mDataUri); - startActivityForResult(uploadIntent, 0); - } - - private void encrypt(Uri dataUri, boolean text) { - // If there is no encryption key, don't bother. - if (!mHasEncrypt) { - Notify.showNotify(getActivity(), R.string.error_no_encrypt_subkey, Notify.Style.ERROR); - return; - } - try { - long keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - long[] encryptionKeyIds = new long[]{keyId}; - Intent intent; - if (text) { - intent = new Intent(getActivity(), EncryptTextActivity.class); - intent.setAction(EncryptTextActivity.ACTION_ENCRYPT_TEXT); - intent.putExtra(EncryptTextActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); - } else { - intent = new Intent(getActivity(), EncryptFilesActivity.class); - intent.setAction(EncryptFilesActivity.ACTION_ENCRYPT_DATA); - intent.putExtra(EncryptFilesActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); - } - // used instead of startActivity set actionbar based on callingPackage - startActivityForResult(intent, 0); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - } - - private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) - throws NotFoundException { - byte[] blob = (byte[]) providerHelper.getGenericData( - KeyRings.buildUnifiedKeyRingUri(dataUri), - KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); - String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); - - Intent queryIntent = new Intent(getActivity(), ImportKeysActivity.class); - queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); - queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); - - startActivityForResult(queryIntent, 0); - } - - private void certify(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); - certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); - startActivityForResult(certifyIntent, 0); - } - - private void editKey(Uri dataUri) { - Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); - editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); - startActivityForResult(editIntent, 0); - } - } diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 000000000..3ee3e1720 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_mode_edit_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png new file mode 100644 index 000000000..ddd8bb736 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png new file mode 100644 index 000000000..705a4cc70 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 000000000..85cff0b91 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_mode_edit_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png new file mode 100644 index 000000000..efa97b3af Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png new file mode 100644 index 000000000..5f6e11bc8 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 000000000..7f0ea51bf Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_mode_edit_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png new file mode 100644 index 000000000..677b7267c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png new file mode 100644 index 000000000..fb82f4208 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 000000000..34ec7092f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_mode_edit_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png new file mode 100644 index 000000000..74557d202 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png new file mode 100644 index 000000000..c34970372 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png new file mode 100644 index 000000000..9380370f4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_mode_edit_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png new file mode 100644 index 000000000..c43cc4325 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png new file mode 100644 index 000000000..06b27ea19 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 9b055d322..17303ee84 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -44,40 +44,35 @@ android:transitionGroup="false" android:touchscreenBlocksFocus="false" /> - - - - - - - - - - + android:layout_height="wrap_content" + android:layout_marginLeft="48dp" + android:layout_marginStart="48dp" + android:layout_marginRight="48dp" + android:layout_marginEnd="48dp" + android:layout_above="@+id/view_key_status" + android:text="" + android:textColor="@color/icons" + android:textAppearance="?android:attr/textAppearanceLarge" + android:layout_toLeftOf="@+id/view_key_qr_code" + android:layout_toStartOf="@+id/view_key_qr_code" /> + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + card_view:cardCornerRadius="4dp"> + + + + + + + + -- cgit v1.2.3 From 8ddca4f8fec566de898fa1ec296aa63ec0410c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 13:49:54 +0100 Subject: Fix menu --- .../main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 5454e4f3e..c16a52e9c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -246,6 +246,7 @@ public class ViewKeyActivity extends BaseActivity implements Intent advancedIntent = new Intent(this, ViewKeyAdvActivity.class); advancedIntent.setData(mDataUri); startActivity(advancedIntent); + return true; } case R.id.menu_key_view_refresh: { try { @@ -253,6 +254,7 @@ public class ViewKeyActivity extends BaseActivity implements } catch (ProviderHelper.NotFoundException e) { Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); } + return true; } } } catch (ProviderHelper.NotFoundException e) { -- cgit v1.2.3 From 4ea59f79ccbfac85129d09c52dfe5d5247713d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 15:18:00 +0100 Subject: Use material icon for safeslinger --- .../src/main/res/drawable-hdpi/ic_action_safeslinger.png | Bin 2616 -> 0 bytes .../main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png | Bin 0 -> 300 bytes .../src/main/res/drawable-mdpi/ic_action_safeslinger.png | Bin 1457 -> 0 bytes .../main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png | Bin 0 -> 230 bytes .../main/res/drawable-xhdpi/ic_action_safeslinger.png | Bin 4012 -> 0 bytes .../main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png | Bin 0 -> 332 bytes .../main/res/drawable-xxhdpi/ic_action_safeslinger.png | Bin 6626 -> 0 bytes .../main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png | Bin 0 -> 418 bytes .../main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png | Bin 0 -> 531 bytes OpenKeychain/src/main/res/layout/key_list_item.xml | 2 +- .../src/main/res/layout/safe_slinger_activity.xml | 2 +- .../src/main/res/layout/view_key_adv_share_fragment.xml | 2 +- 12 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_safeslinger.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_safeslinger.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_safeslinger.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_safeslinger.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_safeslinger.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_safeslinger.png deleted file mode 100644 index 6ff9bb7b4..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_safeslinger.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png new file mode 100644 index 000000000..961aedecc Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_safeslinger.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_safeslinger.png deleted file mode 100644 index bfea67f33..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_safeslinger.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png new file mode 100644 index 000000000..f7faa5cf4 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_safeslinger.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_safeslinger.png deleted file mode 100644 index 864a18d1a..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_safeslinger.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png new file mode 100644 index 000000000..22ff0c308 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_safeslinger.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_safeslinger.png deleted file mode 100644 index 02efa1d24..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_safeslinger.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png new file mode 100644 index 000000000..3edec452e Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png new file mode 100644 index 000000000..3dea0d014 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/layout/key_list_item.xml b/OpenKeychain/src/main/res/layout/key_list_item.xml index 5a3a97358..9f9cf4eca 100644 --- a/OpenKeychain/src/main/res/layout/key_list_item.xml +++ b/OpenKeychain/src/main/res/layout/key_list_item.xml @@ -58,7 +58,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" - android:src="@drawable/ic_action_safeslinger" + android:src="@drawable/ic_swap_vert_grey_24dp" android:padding="12dp" style="@style/SelectableItem" /> diff --git a/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml b/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml index 8dbe1d62e..ff5fa6d94 100644 --- a/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml +++ b/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml @@ -69,7 +69,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/ic_action_safeslinger" + android:src="@drawable/ic_swap_vert_grey_24dp" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml index 9971032ce..782091f16 100644 --- a/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml @@ -135,7 +135,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/ic_action_safeslinger" + android:src="@drawable/ic_swap_vert_grey_24dp" android:layout_gravity="center_vertical" style="@style/SelectableItem" /> -- cgit v1.2.3 From 27263edda5ffba4241e54e2f64f35eb1058663e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 18:37:31 +0100 Subject: CardView and more header design --- .../keychain/ui/ViewKeyActivity.java | 33 +++++++++++------ .../keychain/ui/ViewKeyAdvActivity.java | 12 ++++++ .../keychain/ui/ViewKeyFragment.java | 5 ++- .../keychain/ui/util/QrCodeUtils.java | 2 +- .../src/main/res/drawable/cardview_header.xml | 11 ++++++ .../src/main/res/layout/view_key_activity.xml | 43 +++++++++++++--------- .../src/main/res/layout/view_key_fragment.xml | 9 +++-- OpenKeychain/src/main/res/values/strings.xml | 1 + OpenKeychain/src/main/res/values/styles.xml | 10 +++++ 9 files changed, 90 insertions(+), 36 deletions(-) create mode 100644 OpenKeychain/src/main/res/drawable/cardview_header.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c16a52e9c..efa526e33 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -36,6 +36,7 @@ import android.provider.ContactsContract; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; +import android.support.v7.widget.CardView; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -87,6 +88,7 @@ public class ViewKeyActivity extends BaseActivity implements private FloatingActionButton mFab; private AspectRatioImageView mPhoto; private ImageButton mQrCode; + private CardView mQrCodeLayout; // NFC private NfcAdapter mNfcAdapter; @@ -121,6 +123,7 @@ public class ViewKeyActivity extends BaseActivity implements mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); + mQrCodeLayout = (CardView) findViewById(R.id.view_key_qr_code_layout); mDataUri = getIntent().getData(); if (mDataUri == null) { @@ -169,7 +172,7 @@ public class ViewKeyActivity extends BaseActivity implements if (mIsSecret) { startSafeSlinger(mDataUri); } else { - certify(mDataUri); + scanQrCode(); } } }); @@ -264,6 +267,12 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + private void scanQrCode() { + Intent scanQrCode = new Intent(this, QrCodeScanActivity.class); + scanQrCode.setAction(QrCodeScanActivity.ACTION_SCAN_WITH_RESULT); + startActivityForResult(scanQrCode, 0); + } + private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); qrCodeIntent.setData(mDataUri); @@ -403,9 +412,6 @@ public class ViewKeyActivity extends BaseActivity implements } protected void onPostExecute(Bitmap qrCode) { - // only change view, if fragment is attached to activity -// if (ViewKeyFragment.this.isAdded()) { - // scale the image up to our actual size. we do this in code rather // than let the ImageView do this because we don't require filtering. Bitmap scaled = Bitmap.createScaledBitmap(qrCode, @@ -418,7 +424,6 @@ public class ViewKeyActivity extends BaseActivity implements anim.setDuration(200); mQrCode.startAnimation(anim); } -// } }; loadTask.execute(); @@ -580,7 +585,6 @@ public class ViewKeyActivity extends BaseActivity implements && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; - AsyncTask photoTask = new AsyncTask() { protected Bitmap doInBackground(String... fingerprint) { @@ -606,9 +610,15 @@ public class ViewKeyActivity extends BaseActivity implements mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.GONE); mFab.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); } else if (isExpired) { - mStatusText.setText(R.string.view_key_expired); + if (mIsSecret) { + mStatusText.setText(R.string.view_key_expired_secret); + mActionEdit.setVisibility(View.VISIBLE); + } else { + mStatusText.setText(R.string.view_key_expired); + mActionEdit.setVisibility(View.GONE); + } mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED, R.color.icons, true); color = getResources().getColor(R.color.android_red_light); @@ -616,16 +626,15 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); - mActionEdit.setVisibility(View.GONE); mFab.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { mStatusText.setText(R.string.view_key_my_key); mStatusImage.setVisibility(View.GONE); color = getResources().getColor(R.color.primary); photoTask.execute(fingerprint); loadQrCode(fingerprint); - mQrCode.setVisibility(View.VISIBLE); + mQrCodeLayout.setVisibility(View.VISIBLE); mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); @@ -637,7 +646,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); mActionEdit.setVisibility(View.GONE); - mQrCode.setVisibility(View.GONE); + mQrCodeLayout.setVisibility(View.GONE); if (isVerified) { mStatusText.setText(R.string.view_key_verified); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index 840dea471..37f9113bb 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -33,6 +33,7 @@ import com.astuetz.PagerSlidingTabStrip; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; @@ -237,4 +238,15 @@ public class ViewKeyAdvActivity extends BaseActivity implements public void onLoaderReset(Loader loader) { } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // if a result has been returned, display a notify + if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { + OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); + result.createNotify(this).show(); + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index 571c86b82..f30ab2b33 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -88,7 +88,6 @@ public class ViewKeyFragment extends LoaderFragment implements return root; } - private void showUserIdInfo(final int position) { final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); final int isVerified = mUserIdsAdapter.getIsVerified(position); @@ -130,13 +129,15 @@ public class ViewKeyFragment extends LoaderFragment implements getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); } + // don't show revoked user ids here, irrelevant for average users + public static final String WHERE = UserPackets.IS_REVOKED + " = 0"; public Loader onCreateLoader(int id, Bundle args) { setContentShown(false); Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + UserIdsAdapter.USER_IDS_PROJECTION, WHERE, null, null); } public void onLoadFinished(Loader loader, Cursor data) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java index 0bb4100c5..b8d4ea7d2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/QrCodeUtils.java @@ -59,7 +59,7 @@ public class QrCodeUtils { for (int y = 0; y < height; y++) { final int offset = y * width; for (int x = 0; x < width; x++) { - pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.WHITE; + pixels[offset + x] = result.get(x, y) ? Color.BLACK : Color.TRANSPARENT; } } diff --git a/OpenKeychain/src/main/res/drawable/cardview_header.xml b/OpenKeychain/src/main/res/drawable/cardview_header.xml new file mode 100644 index 000000000..9bab96ea9 --- /dev/null +++ b/OpenKeychain/src/main/res/drawable/cardview_header.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 17303ee84..25b978e37 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:fab="http://schemas.android.com/apk/res-auto" + xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -52,12 +53,12 @@ android:layout_marginStart="48dp" android:layout_marginRight="48dp" android:layout_marginEnd="48dp" - android:layout_above="@+id/view_key_status" android:text="" android:textColor="@color/icons" android:textAppearance="?android:attr/textAppearanceLarge" - android:layout_toLeftOf="@+id/view_key_qr_code" - android:layout_toStartOf="@+id/view_key_qr_code" /> + android:layout_above="@+id/view_key_status" + android:layout_toLeftOf="@+id/view_key_qr_code_layout" + android:layout_toStartOf="@+id/view_key_qr_code_layout" /> - + android:layout_above="@+id/toolbar2" + android:layout_toLeftOf="@+id/view_key_qr_code_layout" + android:layout_toStartOf="@+id/view_key_qr_code_layout" /> - + android:layout_marginRight="20dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + card_view:cardBackgroundColor="@android:color/white" + card_view:cardUseCompatPadding="true" + card_view:cardCornerRadius="4dp"> + + + diff --git a/OpenKeychain/src/main/res/layout/view_key_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_fragment.xml index d37a41236..8e1bad3a8 100644 --- a/OpenKeychain/src/main/res/layout/view_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_fragment.xml @@ -8,6 +8,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingTop="16dp" + android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="16dp"> @@ -15,7 +16,10 @@ android:id="@+id/card_view" android:layout_gravity="center" android:layout_width="match_parent" - android:layout_height="200dp" + android:layout_height="wrap_content" + card_view:cardBackgroundColor="@android:color/white" + card_view:cardElevation="2sp" + card_view:cardUseCompatPadding="true" card_view:cardCornerRadius="4dp"> "Revoked: Key must not be used anymore!" "Expired: The contact needs to extend the keys validity!" + "Expired: You can extend the keys validity by editing it!" "My Key" "Verified Key" "Unverified: Scan QR Code to verify key!" diff --git a/OpenKeychain/src/main/res/values/styles.xml b/OpenKeychain/src/main/res/values/styles.xml index f05bdb0ff..8420e0c13 100644 --- a/OpenKeychain/src/main/res/values/styles.xml +++ b/OpenKeychain/src/main/res/values/styles.xml @@ -20,6 +20,16 @@ + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/dimens.xml b/OpenKeychain/src/main/res/values/dimens.xml index 08b072202..434a0a171 100644 --- a/OpenKeychain/src/main/res/values/dimens.xml +++ b/OpenKeychain/src/main/res/values/dimens.xml @@ -3,5 +3,5 @@ 0dp 120dp - 212dp + 222dp \ No newline at end of file -- cgit v1.2.3 From 0931c7742bdb238d222362fee3b865bfa33dfc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 20:20:39 +0100 Subject: Other icon for key exchange --- .../sufficientlysecure/keychain/ui/ViewKeyActivity.java | 2 +- .../src/main/res/drawable-hdpi/ic_repeat_grey_24dp.png | Bin 0 -> 297 bytes .../src/main/res/drawable-hdpi/ic_repeat_white_24dp.png | Bin 0 -> 296 bytes .../res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png | Bin 483 -> 0 bytes .../main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png | Bin 300 -> 0 bytes .../main/res/drawable-hdpi/ic_swap_vert_white_24dp.png | Bin 300 -> 0 bytes .../src/main/res/drawable-mdpi/ic_repeat_grey_24dp.png | Bin 0 -> 238 bytes .../src/main/res/drawable-mdpi/ic_repeat_white_24dp.png | Bin 0 -> 236 bytes .../res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png | Bin 341 -> 0 bytes .../main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png | Bin 230 -> 0 bytes .../main/res/drawable-mdpi/ic_swap_vert_white_24dp.png | Bin 226 -> 0 bytes .../src/main/res/drawable-xhdpi/ic_repeat_grey_24dp.png | Bin 0 -> 317 bytes .../src/main/res/drawable-xhdpi/ic_repeat_white_24dp.png | Bin 0 -> 314 bytes .../drawable-xhdpi/ic_swap_vert_circle_white_24dp.png | Bin 569 -> 0 bytes .../main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png | Bin 332 -> 0 bytes .../main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png | Bin 330 -> 0 bytes .../src/main/res/drawable-xxhdpi/ic_repeat_grey_24dp.png | Bin 0 -> 400 bytes .../main/res/drawable-xxhdpi/ic_repeat_white_24dp.png | Bin 0 -> 397 bytes .../drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png | Bin 863 -> 0 bytes .../main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png | Bin 418 -> 0 bytes .../main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png | Bin 414 -> 0 bytes .../main/res/drawable-xxxhdpi/ic_repeat_grey_24dp.png | Bin 0 -> 481 bytes .../main/res/drawable-xxxhdpi/ic_repeat_white_24dp.png | Bin 0 -> 478 bytes .../drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png | Bin 1048 -> 0 bytes .../main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png | Bin 531 -> 0 bytes .../res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png | Bin 502 -> 0 bytes OpenKeychain/src/main/res/layout/key_list_item.xml | 2 +- .../src/main/res/layout/safe_slinger_activity.xml | 2 +- .../src/main/res/layout/view_key_adv_share_fragment.xml | 2 +- 29 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_grey_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index df586c11c..4e8a14008 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -676,7 +676,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.VISIBLE); mFab.setVisibility(View.VISIBLE); - mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_swap_vert_white_24dp)); + mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp)); } else { mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_grey_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_grey_24dp.png new file mode 100644 index 000000000..48d6ce93a Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_white_24dp.png new file mode 100644 index 000000000..612e73458 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_repeat_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png deleted file mode 100644 index ddd8bb736..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_circle_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png deleted file mode 100644 index 961aedecc..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_grey_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png deleted file mode 100644 index 705a4cc70..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_swap_vert_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_grey_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_grey_24dp.png new file mode 100644 index 000000000..60aa53747 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_white_24dp.png new file mode 100644 index 000000000..8a2b641ca Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_repeat_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png deleted file mode 100644 index efa97b3af..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_circle_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png deleted file mode 100644 index f7faa5cf4..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_grey_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png deleted file mode 100644 index 5f6e11bc8..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_swap_vert_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_grey_24dp.png new file mode 100644 index 000000000..3d0e27547 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_white_24dp.png new file mode 100644 index 000000000..729220066 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_repeat_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png deleted file mode 100644 index 677b7267c..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_circle_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png deleted file mode 100644 index 22ff0c308..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_grey_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png deleted file mode 100644 index fb82f4208..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_swap_vert_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_grey_24dp.png new file mode 100644 index 000000000..6a8906126 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_white_24dp.png new file mode 100644 index 000000000..63f8de50f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_repeat_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png deleted file mode 100644 index 74557d202..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_circle_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png deleted file mode 100644 index 3edec452e..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_grey_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png deleted file mode 100644 index c34970372..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_swap_vert_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_grey_24dp.png new file mode 100644 index 000000000..bf33f287b Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_grey_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_white_24dp.png new file mode 100644 index 000000000..f3c284330 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_repeat_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png deleted file mode 100644 index c43cc4325..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_circle_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png deleted file mode 100644 index 3dea0d014..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_grey_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png deleted file mode 100644 index 06b27ea19..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_swap_vert_white_24dp.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/layout/key_list_item.xml b/OpenKeychain/src/main/res/layout/key_list_item.xml index 9f9cf4eca..27444a260 100644 --- a/OpenKeychain/src/main/res/layout/key_list_item.xml +++ b/OpenKeychain/src/main/res/layout/key_list_item.xml @@ -58,7 +58,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="center" - android:src="@drawable/ic_swap_vert_grey_24dp" + android:src="@drawable/ic_repeat_grey_24dp" android:padding="12dp" style="@style/SelectableItem" /> diff --git a/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml b/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml index ff5fa6d94..bafad173b 100644 --- a/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml +++ b/OpenKeychain/src/main/res/layout/safe_slinger_activity.xml @@ -69,7 +69,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/ic_swap_vert_grey_24dp" + android:src="@drawable/ic_repeat_grey_24dp" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml index 782091f16..cd8f96e6f 100644 --- a/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_adv_share_fragment.xml @@ -135,7 +135,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/ic_swap_vert_grey_24dp" + android:src="@drawable/ic_repeat_grey_24dp" android:layout_gravity="center_vertical" style="@style/SelectableItem" /> -- cgit v1.2.3 From b521162ef049d223987af4c424083a8355c9bfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 25 Feb 2015 20:50:34 +0100 Subject: Invoke NFC button --- .../keychain/ui/ViewKeyActivity.java | 28 +++++++++++++++++++++ .../src/main/res/drawable-hdpi/ic_action_nfc.png | Bin 1660 -> 0 bytes .../main/res/drawable-hdpi/ic_action_qr_code.png | Bin 2134 -> 0 bytes .../main/res/drawable-hdpi/ic_nfc_white_24dp.png | Bin 0 -> 740 bytes .../src/main/res/drawable-mdpi/ic_action_nfc.png | Bin 1147 -> 0 bytes .../main/res/drawable-mdpi/ic_action_qr_code.png | Bin 1314 -> 0 bytes .../main/res/drawable-mdpi/ic_nfc_white_24dp.png | Bin 0 -> 485 bytes .../src/main/res/drawable-xhdpi/ic_action_nfc.png | Bin 2297 -> 0 bytes .../main/res/drawable-xhdpi/ic_action_qr_code.png | Bin 2959 -> 0 bytes .../main/res/drawable-xhdpi/ic_nfc_white_24dp.png | Bin 0 -> 943 bytes .../src/main/res/drawable-xxhdpi/ic_action_nfc.png | Bin 2378 -> 0 bytes .../main/res/drawable-xxhdpi/ic_action_qr_code.png | Bin 4129 -> 0 bytes .../main/res/drawable-xxhdpi/ic_nfc_white_24dp.png | Bin 0 -> 1476 bytes .../res/drawable-xxxhdpi/ic_nfc_white_24dp.png | Bin 0 -> 1938 bytes .../res/layout/import_keys_qr_code_fragment.xml | 4 +-- .../src/main/res/layout/view_key_activity.xml | 8 ++++++ 16 files changed, 38 insertions(+), 2 deletions(-) delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_nfc.png delete mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png create mode 100644 OpenKeychain/src/main/res/drawable-hdpi/ic_nfc_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_nfc.png delete mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png create mode 100644 OpenKeychain/src/main/res/drawable-mdpi/ic_nfc_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_nfc.png delete mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png create mode 100644 OpenKeychain/src/main/res/drawable-xhdpi/ic_nfc_white_24dp.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_nfc.png delete mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png create mode 100644 OpenKeychain/src/main/res/drawable-xxhdpi/ic_nfc_white_24dp.png create mode 100644 OpenKeychain/src/main/res/drawable-xxxhdpi/ic_nfc_white_24dp.png (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 4e8a14008..3ddaccad3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -88,6 +88,7 @@ public class ViewKeyActivity extends BaseActivity implements private ImageButton mActionEncryptText; private ImageButton mActionVerify; private ImageButton mActionEdit; + private ImageButton mActionNfc; private FloatingActionButton mFab; private AspectRatioImageView mPhoto; private ImageButton mQrCode; @@ -123,6 +124,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); mActionEdit = (ImageButton) findViewById(R.id.view_key_action_edit); + mActionNfc = (ImageButton) findViewById(R.id.view_key_action_nfc); mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); @@ -187,6 +189,13 @@ public class ViewKeyActivity extends BaseActivity implements } }); + mActionNfc.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + invokeNfcBeam(); + } + }); + // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. @@ -270,6 +279,15 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + private void invokeNfcBeam() { + // Check for available NFC Adapter + mNfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (mNfcAdapter != null) { + mNfcAdapter.invokeBeam(this); + } + } + private void scanQrCode() { Intent scanQrCode = new Intent(this, QrCodeScanActivity.class); scanQrCode.setAction(QrCodeScanActivity.ACTION_SCAN_WITH_RESULT); @@ -623,6 +641,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (isExpired) { @@ -641,6 +660,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { @@ -675,6 +695,13 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.VISIBLE); mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.VISIBLE); + + // invokeBeam is available from API 21 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + mActionNfc.setVisibility(View.VISIBLE); + } else { + mActionNfc.setVisibility(View.GONE); + } mFab.setVisibility(View.VISIBLE); mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp)); } else { @@ -682,6 +709,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.VISIBLE); mActionEdit.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); if (isVerified) { mStatusText.setText(R.string.view_key_verified); diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_nfc.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_nfc.png deleted file mode 100644 index 635633709..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_nfc.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png deleted file mode 100644 index ceb3b1645..000000000 Binary files a/OpenKeychain/src/main/res/drawable-hdpi/ic_action_qr_code.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-hdpi/ic_nfc_white_24dp.png b/OpenKeychain/src/main/res/drawable-hdpi/ic_nfc_white_24dp.png new file mode 100644 index 000000000..1d87415c5 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-hdpi/ic_nfc_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_nfc.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_nfc.png deleted file mode 100644 index da5e267d0..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_nfc.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png deleted file mode 100644 index 21594e62f..000000000 Binary files a/OpenKeychain/src/main/res/drawable-mdpi/ic_action_qr_code.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-mdpi/ic_nfc_white_24dp.png b/OpenKeychain/src/main/res/drawable-mdpi/ic_nfc_white_24dp.png new file mode 100644 index 000000000..65ae04b7c Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-mdpi/ic_nfc_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_nfc.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_nfc.png deleted file mode 100644 index ff569927c..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_nfc.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png deleted file mode 100644 index 93bdac866..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xhdpi/ic_action_qr_code.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xhdpi/ic_nfc_white_24dp.png b/OpenKeychain/src/main/res/drawable-xhdpi/ic_nfc_white_24dp.png new file mode 100644 index 000000000..44b9006ab Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xhdpi/ic_nfc_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_nfc.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_nfc.png deleted file mode 100644 index 1f96ce37b..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_nfc.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png deleted file mode 100644 index 7ede90609..000000000 Binary files a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_action_qr_code.png and /dev/null differ diff --git a/OpenKeychain/src/main/res/drawable-xxhdpi/ic_nfc_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_nfc_white_24dp.png new file mode 100644 index 000000000..484856b3f Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxhdpi/ic_nfc_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_nfc_white_24dp.png b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_nfc_white_24dp.png new file mode 100644 index 000000000..c8f25bbf7 Binary files /dev/null and b/OpenKeychain/src/main/res/drawable-xxxhdpi/ic_nfc_white_24dp.png differ diff --git a/OpenKeychain/src/main/res/layout/import_keys_qr_code_fragment.xml b/OpenKeychain/src/main/res/layout/import_keys_qr_code_fragment.xml index 1cc414dab..9007d2149 100644 --- a/OpenKeychain/src/main/res/layout/import_keys_qr_code_fragment.xml +++ b/OpenKeychain/src/main/res/layout/import_keys_qr_code_fragment.xml @@ -21,7 +21,7 @@ android:layout_height="match_parent" android:text="@string/import_qr_code_button" android:layout_weight="1" - android:drawableRight="@drawable/ic_action_qr_code" + android:drawableRight="@drawable/ic_qrcode_white_24dp" android:drawablePadding="8dp" android:gravity="center_vertical" /> @@ -38,7 +38,7 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" - android:src="@drawable/ic_action_nfc" + android:src="@drawable/ic_nfc_white_24dp" android:layout_gravity="center_vertical" style="@style/SelectableItem" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index bc46ac85f..94f0932f4 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -116,6 +116,14 @@ style="?android:attr/borderlessButtonStyle" android:src="@drawable/ic_mode_edit_white_24dp" /> + + Date: Wed, 25 Feb 2015 21:53:46 +0100 Subject: Dont show verification icons in my key view, hide edit button for non-secret keys --- .../keychain/ui/ViewKeyActivity.java | 57 ++++++++--- .../keychain/ui/ViewKeyAdvMainFragment.java | 3 +- .../keychain/ui/ViewKeyFragment.java | 108 ++++++++++++++++----- .../keychain/ui/adapter/UserIdsAdapter.java | 22 ++++- .../src/main/res/layout/view_key_activity.xml | 8 -- OpenKeychain/src/main/res/menu/key_view.xml | 7 ++ OpenKeychain/src/main/res/values/strings.xml | 4 +- 7 files changed, 155 insertions(+), 54 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 3ddaccad3..c67fde8e1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -34,6 +34,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.provider.ContactsContract; +import android.provider.Settings; import android.support.v4.app.ActivityCompat; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; @@ -87,7 +88,6 @@ public class ViewKeyActivity extends BaseActivity implements private ImageButton mActionEncryptFile; private ImageButton mActionEncryptText; private ImageButton mActionVerify; - private ImageButton mActionEdit; private ImageButton mActionNfc; private FloatingActionButton mFab; private AspectRatioImageView mPhoto; @@ -103,8 +103,8 @@ public class ViewKeyActivity extends BaseActivity implements private static final int LOADER_ID_UNIFIED = 0; - private boolean mIsSecret; - private boolean mHasEncrypt; + private boolean mIsSecret = false; + private boolean mHasEncrypt = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -123,7 +123,6 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files); mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); - mActionEdit = (ImageButton) findViewById(R.id.view_key_action_edit); mActionNfc = (ImageButton) findViewById(R.id.view_key_action_nfc); mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); @@ -165,11 +164,6 @@ public class ViewKeyActivity extends BaseActivity implements certify(mDataUri); } }); - mActionEdit.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - editKey(mDataUri); - } - }); mFab.setOnClickListener(new View.OnClickListener() { @Override @@ -271,6 +265,10 @@ public class ViewKeyActivity extends BaseActivity implements } return true; } + case R.id.menu_key_view_edit: { + editKey(mDataUri); + return true; + } } } catch (ProviderHelper.NotFoundException e) { Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); @@ -279,13 +277,42 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + MenuItem register = menu.findItem(R.id.menu_key_view_edit); + register.setVisible(mIsSecret); + return true; + } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void invokeNfcBeam() { // Check for available NFC Adapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); - if (mNfcAdapter != null) { - mNfcAdapter.invokeBeam(this); + if (mNfcAdapter == null || !mNfcAdapter.isEnabled()) { + Notify.createNotify(this, R.string.error_nfc_needed, Notify.LENGTH_LONG, Notify.Style.ERROR, new Notify.ActionListener() { + @Override + public void onAction() { + Intent intentSettings = new Intent(Settings.ACTION_NFC_SETTINGS); + startActivity(intentSettings); + } + }, R.string.menu_nfc_preferences).show(); + + return; + } + + if (!mNfcAdapter.isNdefPushEnabled()) { + Notify.createNotify(this, R.string.error_beam_needed, Notify.LENGTH_LONG, Notify.Style.ERROR, new Notify.ActionListener() { + @Override + public void onAction() { + Intent intentSettings = new Intent(Settings.ACTION_NFCSHARING_SETTINGS); + startActivity(intentSettings); + } + }, R.string.menu_beam_preferences).show(); + + return; } + + mNfcAdapter.invokeBeam(this); } private void scanQrCode() { @@ -640,17 +667,14 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); - mActionEdit.setVisibility(View.GONE); mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (isExpired) { if (mIsSecret) { mStatusText.setText(R.string.view_key_expired_secret); - mActionEdit.setVisibility(View.VISIBLE); } else { mStatusText.setText(R.string.view_key_expired); - mActionEdit.setVisibility(View.GONE); } mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, @@ -664,6 +688,9 @@ public class ViewKeyActivity extends BaseActivity implements mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { + // re-create options menu to see edit button + supportInvalidateOptionsMenu(); + mStatusText.setText(R.string.view_key_my_key); mStatusImage.setVisibility(View.GONE); color = getResources().getColor(R.color.primary); @@ -694,7 +721,6 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); mActionVerify.setVisibility(View.GONE); - mActionEdit.setVisibility(View.VISIBLE); // invokeBeam is available from API 21 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -707,7 +733,6 @@ public class ViewKeyActivity extends BaseActivity implements } else { mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); - mActionEdit.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); mActionNfc.setVisibility(View.GONE); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java index abed59aa9..c9d20f9f4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java @@ -265,9 +265,10 @@ public class ViewKeyAdvMainFragment extends LoaderFragment implements } } - case LOADER_ID_USER_IDS: + case LOADER_ID_USER_IDS: { mUserIdsAdapter.swapCursor(data); break; + } } setContentShown(true); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index f30ab2b33..453bfd499 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -33,12 +33,15 @@ import android.widget.ListView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; import org.sufficientlysecure.keychain.util.Log; +import java.util.Date; + public class ViewKeyFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { @@ -46,6 +49,9 @@ public class ViewKeyFragment extends LoaderFragment implements private ListView mUserIds; + boolean mIsSecret = false; + + private static final int LOADER_ID_UNIFIED = 0; private static final int LOADER_ID_USER_IDS = 1; private UserIdsAdapter mUserIdsAdapter; @@ -76,7 +82,6 @@ public class ViewKeyFragment extends LoaderFragment implements mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); - mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { @@ -84,22 +89,23 @@ public class ViewKeyFragment extends LoaderFragment implements } }); - return root; } private void showUserIdInfo(final int position) { - final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); - final int isVerified = mUserIdsAdapter.getIsVerified(position); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - UserIdInfoDialogFragment dialogFragment = - UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); - } - }); + if (!mIsSecret) { + final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); + final int isVerified = mUserIdsAdapter.getIsVerified(position); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + UserIdInfoDialogFragment dialogFragment = + UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); + } + }); + } } @Override @@ -116,28 +122,59 @@ public class ViewKeyFragment extends LoaderFragment implements loadData(dataUri); } + + // These are the rows that we will retrieve. + static final String[] UNIFIED_PROJECTION = new String[]{ + KeychainContract.KeyRings._ID, + KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.USER_ID, + KeychainContract.KeyRings.IS_REVOKED, + KeychainContract.KeyRings.EXPIRY, + KeychainContract.KeyRings.VERIFIED, + KeychainContract.KeyRings.HAS_ANY_SECRET, + KeychainContract.KeyRings.FINGERPRINT, + KeychainContract.KeyRings.HAS_ENCRYPT + }; + + static final int INDEX_MASTER_KEY_ID = 1; + static final int INDEX_USER_ID = 2; + static final int INDEX_IS_REVOKED = 3; + static final int INDEX_EXPIRY = 4; + static final int INDEX_VERIFIED = 5; + static final int INDEX_HAS_ANY_SECRET = 6; + static final int INDEX_FINGERPRINT = 7; + static final int INDEX_HAS_ENCRYPT = 8; + private void loadData(Uri dataUri) { mDataUri = dataUri; Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); - mUserIds.setAdapter(mUserIdsAdapter); - // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. - getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); } // don't show revoked user ids here, irrelevant for average users - public static final String WHERE = UserPackets.IS_REVOKED + " = 0"; + public static final String USER_IDS_WHERE = UserPackets.IS_REVOKED + " = 0"; public Loader onCreateLoader(int id, Bundle args) { setContentShown(false); - Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, WHERE, null, null); + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + case LOADER_ID_USER_IDS: { + Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_WHERE, null, null); + } + + default: + return null; + } } public void onLoadFinished(Loader loader, Cursor data) { @@ -150,8 +187,32 @@ public class ViewKeyFragment extends LoaderFragment implements } // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + + mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0; + boolean hasEncrypt = data.getInt(INDEX_HAS_ENCRYPT) != 0; + boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; + boolean isExpired = !data.isNull(INDEX_EXPIRY) + && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); + boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; + + // load user ids after we know if it's a secret key + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0, false, !mIsSecret, null); + mUserIds.setAdapter(mUserIdsAdapter); + getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); + + break; + } + } - mUserIdsAdapter.swapCursor(data); + case LOADER_ID_USER_IDS: { + mUserIdsAdapter.swapCursor(data); + break; + } + + } setContentShown(true); } @@ -161,9 +222,10 @@ public class ViewKeyFragment extends LoaderFragment implements */ public void onLoaderReset(Loader loader) { switch (loader.getId()) { - case LOADER_ID_USER_IDS: + case LOADER_ID_USER_IDS: { mUserIdsAdapter.swapCursor(null); break; + } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 8e86efebe..ad7c9e430 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -43,6 +43,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC private LayoutInflater mInflater; private final ArrayList mCheckStates; private SaveKeyringParcel mSaveKeyringParcel; + private boolean mShowStatusImages; public static final String[] USER_IDS_PROJECTION = new String[]{ UserPackets._ID, @@ -60,24 +61,30 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC private static final int INDEX_IS_REVOKED = 5; public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes, - SaveKeyringParcel saveKeyringParcel) { + boolean showStatusImages, SaveKeyringParcel saveKeyringParcel) { super(context, c, flags); mInflater = LayoutInflater.from(context); mCheckStates = showCheckBoxes ? new ArrayList() : null; mSaveKeyringParcel = saveKeyringParcel; + mShowStatusImages = showStatusImages; + } + + public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes, + SaveKeyringParcel saveKeyringParcel) { + this(context, c, flags, showCheckBoxes, false, saveKeyringParcel); } public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { - this(context, c, flags, showCheckBoxes, null); + this(context, c, flags, showCheckBoxes, false, null); } public UserIdsAdapter(Context context, Cursor c, int flags, SaveKeyringParcel saveKeyringParcel) { - this(context, c, flags, false, saveKeyringParcel); + this(context, c, flags, false, false, saveKeyringParcel); } public UserIdsAdapter(Context context, Cursor c, int flags) { - this(context, c, flags, false, null); + this(context, c, flags, false, false, null); } @Override @@ -157,7 +164,12 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC vVerifiedLayout.setVisibility(View.GONE); } else { vEditImage.setVisibility(View.GONE); - vVerifiedLayout.setVisibility(View.VISIBLE); + + if (mShowStatusImages) { + vVerifiedLayout.setVisibility(View.VISIBLE); + } else { + vVerifiedLayout.setVisibility(View.GONE); + } } if (isRevoked) { diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 94f0932f4..7dd30c22c 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -108,14 +108,6 @@ style="?android:attr/borderlessButtonStyle" android:src="@drawable/ic_action_verified_cutout" /> - - + + "Create my key" "Import from file" "Search" + "NFC settings" "Beam settings" "Cancel" "Encrypt to…" @@ -272,7 +273,8 @@ "You need Android 4.1 to use Android's NFC Beam feature!" - "NFC is not available on your device!" + "NFC must be enabled!" + "Beam must be enabled!" "No keys found!" "Retrieving the key ID from contacts failed!" "A generic error occurred, please create a new bug report for OpenKeychain." -- cgit v1.2.3 From 72acaaa41f88c729b651575a2c014cff11ca0fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 26 Feb 2015 02:06:57 +0100 Subject: Fingerprint verification, design fixes for qr code card --- OpenKeychain/src/main/AndroidManifest.xml | 8 + .../keychain/ui/CertifyFingerprintActivity.java | 92 +++++++++++ .../keychain/ui/CertifyFingerprintFragment.java | 184 +++++++++++++++++++++ .../keychain/ui/QrCodeViewActivity.java | 15 +- .../keychain/ui/ViewKeyActivity.java | 60 +++---- .../res/layout/certify_fingerprint_activity.xml | 32 ++++ .../res/layout/certify_fingerprint_fragment.xml | 154 +++++++++++++++++ .../src/main/res/layout/create_key_activity.xml | 10 +- .../main/res/layout/create_key_final_fragment.xml | 4 +- .../main/res/layout/create_key_input_fragment.xml | 4 +- .../src/main/res/layout/qr_code_activity.xml | 12 +- .../src/main/res/layout/view_key_activity.xml | 15 +- OpenKeychain/src/main/res/menu/key_view.xml | 6 + OpenKeychain/src/main/res/values/strings.xml | 5 + 14 files changed, 531 insertions(+), 70 deletions(-) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java create mode 100644 OpenKeychain/src/main/res/layout/certify_fingerprint_activity.xml create mode 100644 OpenKeychain/src/main/res/layout/certify_fingerprint_fragment.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 6426a229c..29b748410 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -442,6 +442,14 @@ android:name="android.support.PARENT_ACTIVITY" android:value=".ui.MainActivity" /> + + + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.operations.results.OperationResult; +import org.sufficientlysecure.keychain.util.Log; + +public class CertifyFingerprintActivity extends BaseActivity { + + protected Uri mDataUri; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mDataUri = getIntent().getData(); + if (mDataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be uri of key!"); + finish(); + return; + } + + setFullScreenDialogClose(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + startFragment(savedInstanceState, mDataUri); + } + + @Override + protected void initLayout() { + setContentView(R.layout.certify_fingerprint_activity); + } + + private void startFragment(Bundle savedInstanceState, Uri dataUri) { + // However, if we're being restored from a previous state, + // then we don't need to do anything and should return or else + // we could end up with overlapping fragments. + if (savedInstanceState != null) { + return; + } + + // Create an instance of the fragment + CertifyFingerprintFragment frag = CertifyFingerprintFragment.newInstance(dataUri); + + // Add the fragment to the 'fragment_container' FrameLayout + // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! + getSupportFragmentManager().beginTransaction() + .replace(R.id.certify_fingerprint_fragment, frag) + .commitAllowingStateLoss(); + // do it immediately! + getSupportFragmentManager().executePendingTransactions(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // if a result has been returned, display a notify + if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { + OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); + result.createNotify(this).show(); + } else { + super.onActivityResult(requestCode, resultCode, data); + } + } +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java new file mode 100644 index 000000000..aef705ee9 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2015 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; +import org.sufficientlysecure.keychain.util.Log; + + +public class CertifyFingerprintFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "uri"; + + private TextView mFingerprint; + + private static final int LOADER_ID_UNIFIED = 0; + + private Uri mDataUri; + + private View mActionNo; + private View mActionYes; + + /** + * Creates new instance of this fragment + */ + public static CertifyFingerprintFragment newInstance(Uri dataUri) { + CertifyFingerprintFragment frag = new CertifyFingerprintFragment(); + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); + + frag.setArguments(args); + + return frag; + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.certify_fingerprint_fragment, getContainer()); + + mActionNo = view.findViewById(R.id.certify_fingerprint_button_no); + mActionYes = view.findViewById(R.id.certify_fingerprint_button_yes); + + mFingerprint = (TextView) view.findViewById(R.id.certify_fingerprint_fingerprint); + + mActionNo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getActivity().finish(); + } + }); + mActionYes.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + certify(mDataUri); + } + }); + + return root; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUri = dataUri; + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + } + + static final String[] UNIFIED_PROJECTION = new String[]{ + KeyRings._ID, KeyRings.FINGERPRINT, + + }; + static final int INDEX_UNIFIED_FINGERPRINT = 1; + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + + default: + return null; + } + } + + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + + byte[] fingerprintBlob = data.getBlob(INDEX_UNIFIED_FINGERPRINT); + String fingerprint = KeyFormattingUtils.convertFingerprintToHex(fingerprintBlob); + mFingerprint.setText(KeyFormattingUtils.colorizeFingerprint(fingerprint)); + + break; + } + } + + } + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + } + + private void certify(Uri dataUri) { + long keyId = 0; + try { + keyId = new ProviderHelper(getActivity()) + .getCachedPublicKeyRing(dataUri) + .extractOrGetMasterKeyId(); + } catch (PgpKeyNotFoundException e) { + Log.e(Constants.TAG, "key not found!", e); + } + Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); + certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); + startActivityForResult(certifyIntent, 0); + } + +} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java index b24ee84a4..d3c1d971a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/QrCodeViewActivity.java @@ -21,6 +21,7 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.ActivityCompat; +import android.support.v7.widget.CardView; import android.view.View; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.widget.ImageView; @@ -37,7 +38,8 @@ import org.sufficientlysecure.keychain.util.Log; public class QrCodeViewActivity extends BaseActivity { - private ImageView mFingerprintQrCode; + private ImageView mQrCode; + private CardView mQrCodeLayout; @Override public void onCreate(Bundle savedInstanceState) { @@ -61,9 +63,10 @@ public class QrCodeViewActivity extends BaseActivity { return; } - mFingerprintQrCode = (ImageView) findViewById(R.id.qr_code_image); + mQrCode = (ImageView) findViewById(R.id.qr_code_image); + mQrCodeLayout = (CardView) findViewById(R.id.qr_code_image_layout); - mFingerprintQrCode.setOnClickListener(new View.OnClickListener() { + mQrCodeLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityCompat.finishAfterTransition(QrCodeViewActivity.this); @@ -87,14 +90,14 @@ public class QrCodeViewActivity extends BaseActivity { // create a minimal size qr code, we can keep this in ram no problem final Bitmap qrCode = QrCodeUtils.getQRCodeBitmap(qrCodeContent, 0); - mFingerprintQrCode.getViewTreeObserver().addOnGlobalLayoutListener( + mQrCode.getViewTreeObserver().addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // create actual bitmap in display dimensions Bitmap scaled = Bitmap.createScaledBitmap(qrCode, - mFingerprintQrCode.getWidth(), mFingerprintQrCode.getWidth(), false); - mFingerprintQrCode.setImageBitmap(scaled); + mQrCode.getWidth(), mQrCode.getWidth(), false); + mQrCode.setImageBitmap(scaled); } }); } catch (ProviderHelper.NotFoundException e) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c67fde8e1..e1a8981c4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -87,11 +87,10 @@ public class ViewKeyActivity extends BaseActivity implements private ImageButton mActionEncryptFile; private ImageButton mActionEncryptText; - private ImageButton mActionVerify; private ImageButton mActionNfc; private FloatingActionButton mFab; private AspectRatioImageView mPhoto; - private ImageButton mQrCode; + private ImageView mQrCode; private CardView mQrCodeLayout; // NFC @@ -105,6 +104,7 @@ public class ViewKeyActivity extends BaseActivity implements private boolean mIsSecret = false; private boolean mHasEncrypt = false; + private boolean mIsVerified = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -122,11 +122,10 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile = (ImageButton) findViewById(R.id.view_key_action_encrypt_files); mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); - mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); mActionNfc = (ImageButton) findViewById(R.id.view_key_action_nfc); mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); - mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); + mQrCode = (ImageView) findViewById(R.id.view_key_qr_code); mQrCodeLayout = (CardView) findViewById(R.id.view_key_qr_code_layout); mDataUri = getIntent().getData(); @@ -159,11 +158,6 @@ public class ViewKeyActivity extends BaseActivity implements encrypt(mDataUri, true); } }); - mActionVerify.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - certify(mDataUri); - } - }); mFab.setOnClickListener(new View.OnClickListener() { @Override @@ -176,7 +170,7 @@ public class ViewKeyActivity extends BaseActivity implements } }); - mQrCode.setOnClickListener(new View.OnClickListener() { + mQrCodeLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showQrCodeDialog(); @@ -269,6 +263,10 @@ public class ViewKeyActivity extends BaseActivity implements editKey(mDataUri); return true; } + case R.id.menu_key_view_certify_fingerprint: { + certifyFingeprint(mDataUri); + return true; + } } } catch (ProviderHelper.NotFoundException e) { Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR); @@ -279,8 +277,11 @@ public class ViewKeyActivity extends BaseActivity implements @Override public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem register = menu.findItem(R.id.menu_key_view_edit); - register.setVisible(mIsSecret); + MenuItem editKey = menu.findItem(R.id.menu_key_view_edit); + editKey.setVisible(mIsSecret); + MenuItem certifyFingerprint = menu.findItem(R.id.menu_key_view_certify_fingerprint); + certifyFingerprint.setVisible(!mIsSecret && !mIsVerified); + return true; } @@ -321,6 +322,12 @@ public class ViewKeyActivity extends BaseActivity implements startActivityForResult(scanQrCode, 0); } + private void certifyFingeprint(Uri dataUri) { + Intent intent = new Intent(this, CertifyFingerprintActivity.class); + intent.setData(dataUri); + startActivityForResult(intent, 0); + } + private void showQrCodeDialog() { Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class); @@ -420,20 +427,6 @@ public class ViewKeyActivity extends BaseActivity implements startActivityForResult(queryIntent, 0); } - private void certify(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(this) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent certifyIntent = new Intent(this, CertifyKeyActivity.class); - certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); - startActivityForResult(certifyIntent, 0); - } - private void editKey(Uri dataUri) { Intent editIntent = new Intent(this, EditKeyActivity.class); editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri)); @@ -641,7 +634,10 @@ public class ViewKeyActivity extends BaseActivity implements boolean isRevoked = data.getInt(INDEX_IS_REVOKED) > 0; boolean isExpired = !data.isNull(INDEX_EXPIRY) && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); - boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; + mIsVerified = data.getInt(INDEX_VERIFIED) > 0; + + // re-create options menu based on mIsSecret, mIsVerified + supportInvalidateOptionsMenu(); AsyncTask photoTask = new AsyncTask() { @@ -666,7 +662,6 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); - mActionVerify.setVisibility(View.GONE); mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); @@ -683,14 +678,10 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); - mActionVerify.setVisibility(View.GONE); mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { - // re-create options menu to see edit button - supportInvalidateOptionsMenu(); - mStatusText.setText(R.string.view_key_my_key); mStatusImage.setVisibility(View.GONE); color = getResources().getColor(R.color.primary); @@ -720,7 +711,6 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.VISIBLE); mActionEncryptText.setVisibility(View.VISIBLE); - mActionVerify.setVisibility(View.GONE); // invokeBeam is available from API 21 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -736,7 +726,7 @@ public class ViewKeyActivity extends BaseActivity implements mQrCodeLayout.setVisibility(View.GONE); mActionNfc.setVisibility(View.GONE); - if (isVerified) { + if (mIsVerified) { mStatusText.setText(R.string.view_key_verified); mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, @@ -744,7 +734,6 @@ public class ViewKeyActivity extends BaseActivity implements color = getResources().getColor(R.color.primary); photoTask.execute(fingerprint); - mActionVerify.setVisibility(View.GONE); mFab.setVisibility(View.GONE); } else { mStatusText.setText(R.string.view_key_unverified); @@ -753,7 +742,6 @@ public class ViewKeyActivity extends BaseActivity implements KeyFormattingUtils.STATE_UNVERIFIED, R.color.icons, true); color = getResources().getColor(R.color.android_orange_light); - mActionVerify.setVisibility(View.VISIBLE); mFab.setVisibility(View.VISIBLE); } } diff --git a/OpenKeychain/src/main/res/layout/certify_fingerprint_activity.xml b/OpenKeychain/src/main/res/layout/certify_fingerprint_activity.xml new file mode 100644 index 000000000..ec91d1455 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/certify_fingerprint_activity.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/certify_fingerprint_fragment.xml b/OpenKeychain/src/main/res/layout/certify_fingerprint_fragment.xml new file mode 100644 index 000000000..9b6b35012 --- /dev/null +++ b/OpenKeychain/src/main/res/layout/certify_fingerprint_fragment.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/create_key_activity.xml b/OpenKeychain/src/main/res/layout/create_key_activity.xml index e8422fb37..c42fd4d4b 100644 --- a/OpenKeychain/src/main/res/layout/create_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/create_key_activity.xml @@ -7,19 +7,15 @@ android:id="@+id/toolbar_include" layout="@layout/toolbar_standalone" /> - - - + android:layout_height="match_parent" /> - + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml index 189579f91..97eba9cd1 100644 --- a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml @@ -159,7 +159,7 @@ android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:clickable="true" - style="@style/SelectableItem" + style="?android:attr/borderlessButtonStyle" android:layout_gravity="center_vertical" /> diff --git a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml index d92988111..026d98004 100644 --- a/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_key_input_fragment.xml @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/qr_code_activity.xml b/OpenKeychain/src/main/res/layout/qr_code_activity.xml index 126be4c3a..4ce097f40 100644 --- a/OpenKeychain/src/main/res/layout/qr_code_activity.xml +++ b/OpenKeychain/src/main/res/layout/qr_code_activity.xml @@ -1,6 +1,5 @@ @@ -21,16 +20,17 @@ android:layout_margin="32dp" android:layout_width="match_parent" android:layout_height="wrap_content" - card_view:cardBackgroundColor="@android:color/white" - card_view:cardUseCompatPadding="true" - card_view:cardCornerRadius="4dp"> + android:clickable="true" + android:foreground="?android:attr/selectableItemBackground" + app:cardBackgroundColor="@android:color/white" + app:cardUseCompatPadding="true" + app:cardCornerRadius="4dp"> + app:aspectRatioEnabled="true" /> diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index 7dd30c22c..e2d153e0d 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -100,14 +100,6 @@ style="?android:attr/borderlessButtonStyle" android:src="@drawable/ic_action_encrypt_text" /> - - - + android:layout_height="96dp" /> diff --git a/OpenKeychain/src/main/res/menu/key_view.xml b/OpenKeychain/src/main/res/menu/key_view.xml index 86f8ea6a2..c724c46a5 100644 --- a/OpenKeychain/src/main/res/menu/key_view.xml +++ b/OpenKeychain/src/main/res/menu/key_view.xml @@ -31,4 +31,10 @@ app:showAsAction="never" android:title="@string/menu_advanced" /> + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 067ce20ea..e4b7cdd20 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -78,6 +78,8 @@ "Upload To Keyserver" "Next" "Back" + "No" + "Fingerprints are matching" "Lookup key" "Encrypt and share message" "View certification key" @@ -107,6 +109,7 @@ "Search cloud" "Export all keys" "Show advanced info" + "Verify via fingerprint comparison" "Message" @@ -1124,6 +1127,8 @@ "Only validated self-certificates and validated certificates created with your keys are displayed here." "Identities for " "The keys you are importing contain “identities”: names and emails. Select exactly those for certification which match what you expected." + "Compare the displayed fingerprint, character by character, with the one displayed on your partners device." + "Do the displayed fingerprints match?" "Revocation Reason" "Verification Status" "Type" -- cgit v1.2.3 From ad8209bd9425c71e21d3c43c2520bd57957115d7 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 26 Feb 2015 10:48:17 +0100 Subject: pre-select certification key if only one is available --- .../sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java index 25033658d..6d0e6556f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/CertifyKeySpinner.java @@ -86,16 +86,17 @@ public class CertifyKeySpinner extends KeySpinner { super.onLoadFinished(loader, data); if (loader.getId() == LOADER_ID) { + mIndexHasCertify = data.getColumnIndex(KeychainContract.KeyRings.HAS_CERTIFY); + mIndexIsRevoked = data.getColumnIndex(KeychainContract.KeyRings.IS_REVOKED); + mIndexIsExpired = data.getColumnIndex(KeychainContract.KeyRings.IS_EXPIRED); + // If there is only one choice, pick it by default if (mAdapter.getCount() == 2) { // preselect if key can certify - if (data.moveToPosition(1) && !data.isNull(mIndexHasCertify)) { + if (data.moveToPosition(0) && !data.isNull(mIndexHasCertify)) { setSelection(1); } } - mIndexHasCertify = data.getColumnIndex(KeychainContract.KeyRings.HAS_CERTIFY); - mIndexIsRevoked = data.getColumnIndex(KeychainContract.KeyRings.IS_REVOKED); - mIndexIsExpired = data.getColumnIndex(KeychainContract.KeyRings.IS_EXPIRED); } } -- cgit v1.2.3 From 4c4782bd5eb54b1f67a66b9065ce48a585ed2d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 26 Feb 2015 17:32:08 +0100 Subject: Hopefully fixes drop down icon for spinners on Android lower 5 --- .../keychain/ui/widget/KeySpinner.java | 8 ++++++-- OpenKeychain/src/main/res/values/styles.xml | 19 ------------------- 2 files changed, 6 insertions(+), 21 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java index 17bfbef57..c8eceea50 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java @@ -24,13 +24,13 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.app.LoaderManager; import android.support.v4.content.Loader; import android.support.v4.widget.CursorAdapter; +import android.support.v7.internal.widget.TintSpinner; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ImageView; -import android.widget.Spinner; import android.widget.SpinnerAdapter; import android.widget.TextView; @@ -41,7 +41,11 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.util.Log; -public abstract class KeySpinner extends Spinner implements LoaderManager.LoaderCallbacks { +/** + * Use TintSpinner from AppCompat lib instead of Spinner. Fixes white dropdown icon. + * Related: http://stackoverflow.com/a/27713090 + */ +public abstract class KeySpinner extends TintSpinner implements LoaderManager.LoaderCallbacks { public interface OnKeyChangedListener { public void onKeyChanged(long masterKeyId); } diff --git a/OpenKeychain/src/main/res/values/styles.xml b/OpenKeychain/src/main/res/values/styles.xml index 8420e0c13..8d8797bf0 100644 --- a/OpenKeychain/src/main/res/values/styles.xml +++ b/OpenKeychain/src/main/res/values/styles.xml @@ -1,24 +1,5 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenKeychain/src/main/res/values/themes.xml b/OpenKeychain/src/main/res/values/themes.xml index da616492c..c87895c01 100644 --- a/OpenKeychain/src/main/res/values/themes.xml +++ b/OpenKeychain/src/main/res/values/themes.xml @@ -3,7 +3,6 @@ - - \ No newline at end of file -- cgit v1.2.3