From a14c5de22ea6f4fcd1ff83107c8372389e6bae6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 2 Feb 2014 17:34:43 +0100 Subject: [PATCH] Use buttons for encrypt decrypt instead of actionbar --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 6 +- .../keychain/ui/DecryptActivity.java | 78 ++---------- .../keychain/ui/EncryptActivity.java | 120 ++++++------------ .../src/main/res/layout/decrypt_activity.xml | 49 +++++-- .../src/main/res/layout/encrypt_activity.xml | 80 +++++++++--- .../src/main/res/values/strings.xml | 11 +- 6 files changed, 157 insertions(+), 187 deletions(-) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index 414361a47..083288640 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -120,8 +120,7 @@ android:name=".ui.SelectPublicKeyActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_select_recipients" - android:launchMode="singleTop" - android:uiOptions="splitActionBarWhenNarrow"> + android:launchMode="singleTop"> @@ -151,7 +150,6 @@ android:name=".ui.EncryptActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_encrypt" - android:uiOptions="splitActionBarWhenNarrow" android:windowSoftInputMode="stateHidden"> @@ -175,7 +173,6 @@ android:name=".ui.DecryptActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_decrypt" - android:uiOptions="splitActionBarWhenNarrow" android:windowSoftInputMode="stateHidden"> @@ -250,7 +247,6 @@ android:name=".ui.PreferencesKeyServerActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:label="@string/title_key_server_preference" - android:uiOptions="splitActionBarWhenNarrow" android:windowSoftInputMode="stateHidden" /> + * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,7 +43,6 @@ import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Choice; import org.sufficientlysecure.keychain.util.Log; -import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.Intent; import android.net.Uri; @@ -51,9 +50,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; -import android.support.v4.view.MenuItemCompat; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.animation.AnimationUtils; @@ -88,11 +84,6 @@ public class EncryptActivity extends DrawerActivity { private EditText mMessage = null; private BootstrapButton mSelectKeysButton = null; - private boolean mEncryptEnabled = false; - private String mEncryptString = ""; - private boolean mEncryptToClipboardEnabled = false; - private String mEncryptToClipboardString = ""; - private CheckBox mSign = null; private TextView mMainUserId = null; private TextView mMainUserIdRest = null; @@ -130,42 +121,9 @@ public class EncryptActivity extends DrawerActivity { private FileDialogFragment mFileDialog; - /** - * ActionBar menu is created based on class variables to change it at runtime - */ - @Override - public boolean onCreateOptionsMenu(Menu menu) { - if (mEncryptToClipboardEnabled) { - MenuItem item = menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mEncryptToClipboardString); - MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - } - if (mEncryptEnabled) { - MenuItem item = menu.add(1, Id.menu.option.encrypt, 1, mEncryptString); - MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); - } - - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - - case Id.menu.option.encrypt_to_clipboard: - encryptToClipboardClicked(); - - return true; - - case Id.menu.option.encrypt: - encryptClicked(); - - return true; - - default: - return super.onOptionsItemSelected(item); - - } - } + private BootstrapButton mEncryptShare; + private BootstrapButton mEncryptClipboard; + private BootstrapButton mEncryptFile; @Override public void onCreate(Bundle savedInstanceState) { @@ -366,58 +324,40 @@ public class EncryptActivity extends DrawerActivity { updateActionBarButtons(); } - /** - * Set ActionBar buttons based on parameters - * - * @param encryptEnabled - * @param encryptStringRes - * @param encryptToClipboardEnabled - * @param encryptToClipboardStringRes - */ - @SuppressLint("NewApi") - private void setActionbarButtons(boolean encryptEnabled, int encryptStringRes, - boolean encryptToClipboardEnabled, int encryptToClipboardStringRes) { - mEncryptEnabled = encryptEnabled; - if (encryptEnabled) { - mEncryptString = getString(encryptStringRes); - } - mEncryptToClipboardEnabled = encryptToClipboardEnabled; - if (encryptToClipboardEnabled) { - mEncryptToClipboardString = getString(encryptToClipboardStringRes); - } - - // build new action bar based on these class variables - supportInvalidateOptionsMenu(); - } - /** * Update ActionBar buttons based on current selection in view */ private void updateActionBarButtons() { switch (mSource.getCurrentView().getId()) { case R.id.sourceFile: { - setActionbarButtons(true, R.string.btn_encrypt_file, false, 0); - + mEncryptShare.setVisibility(View.GONE); + mEncryptClipboard.setVisibility(View.GONE); + mEncryptFile.setVisibility(View.VISIBLE); break; } case R.id.sourceMessage: { mSourceLabel.setText(R.string.label_message); + mEncryptShare.setVisibility(View.VISIBLE); + mEncryptClipboard.setVisibility(View.VISIBLE); + mEncryptFile.setVisibility(View.GONE); + if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { - setActionbarButtons(true, R.string.btn_encrypt_and_send, true, - R.string.btn_encrypt_to_clipboard); + mEncryptShare.setEnabled(true); + mEncryptClipboard.setEnabled(true); } else { if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { if (mSecretKeyId == 0) { - setActionbarButtons(false, 0, false, 0); + mEncryptShare.setEnabled(false); + mEncryptClipboard.setEnabled(false); } else { - setActionbarButtons(true, R.string.btn_sign_and_send, true, - R.string.btn_sign_to_clipboard); + mEncryptShare.setEnabled(true); + mEncryptClipboard.setEnabled(true); } } else { - setActionbarButtons(true, R.string.btn_encrypt_and_send, true, - R.string.btn_encrypt_to_clipboard); + mEncryptShare.setEnabled(true); + mEncryptClipboard.setEnabled(true); } } break; @@ -889,6 +829,28 @@ public class EncryptActivity extends DrawerActivity { } } }); + + mEncryptClipboard = (BootstrapButton) findViewById(R.id.action_encrypt_clipboard); + mEncryptClipboard.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + encryptToClipboardClicked(); + } + }); + mEncryptShare = (BootstrapButton) findViewById(R.id.action_encrypt_share); + mEncryptShare.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(); + } + }); + mEncryptFile = (BootstrapButton) findViewById(R.id.action_encrypt_file); + mEncryptFile.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(); + } + }); } private void updateView() { diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml index 9d9e1a1e8..c6834d745 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml @@ -3,25 +3,25 @@ xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent"> + android:orientation="vertical"> + android:fillViewport="true"> + android:paddingRight="10dp"> + android:paddingRight="10dp"> + android:layout_height="wrap_content"> + android:paddingLeft="5dip"> + android:orientation="horizontal"> + android:layout_weight="1"> + android:padding="4dp"> + android:padding="4dp"> + android:orientation="horizontal"> + android:orientation="horizontal"> + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml index eea484df2..678f2bd4e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_activity.xml @@ -3,25 +3,25 @@ xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" - android:layout_height="match_parent" > + android:layout_height="match_parent"> + android:fillViewport="true"> + android:paddingRight="10dp"> + android:padding="4dp"> + android:layout_height="wrap_content"> + android:padding="4dp"> + android:orientation="horizontal"> + android:paddingLeft="16dp"> + android:paddingBottom="3dip"> + android:stretchColumns="1"> @@ -174,7 +174,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:padding="4dp" > + android:padding="4dp"> + android:layout_weight="1"> + android:padding="4dp"> + android:padding="4dp"> + android:orientation="horizontal"> + android:orientation="horizontal"> + android:orientation="horizontal"> + android:orientation="horizontal"> + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index c47f9e860..fb7b60b7c 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -42,15 +42,13 @@ Your Key used for Signing Upload Key Key Server + Encrypt and/or Sign + Decrypt and Verify - Sign (Clipboard) - Encrypt to Clipboard - Encrypt and send… - Sign and send… Sign Decrypt - Verify + Decrypt and Verify Select Recipients Encrypt File Save @@ -64,6 +62,9 @@ Upload To Key Server Next Back + Clipboard + Share with… + Settings