From cf5fadae760ebbf8b06a908027634d76d54f52b4 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 31 May 2015 04:05:15 +0200 Subject: [PATCH] implement sticky preferences --- .../keychain/Constants.java | 3 + .../keychain/ui/EncryptFilesActivity.java | 4 +- .../keychain/ui/EncryptFilesFragment.java | 106 ++++++++++++++++-- .../keychain/ui/EncryptTextFragment.java | 38 ++++++- .../keychain/ui/util/Notify.java | 38 ++++--- .../keychain/util/Preferences.java | 30 +++++ OpenKeychain/src/main/res/values/strings.xml | 8 ++ 7 files changed, 195 insertions(+), 32 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index fc1cb8acc..7c2f093ee 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -84,6 +84,9 @@ public final class Constants { public static final String SEARCH_KEYBASE = "search_keybase_pref"; public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin"; public static final String USE_NUMKEYPAD_FOR_YUBIKEY_PIN = "useNumKeypadForYubikeyPin"; + public static final String ENCRYPT_FILENAMES = "encryptFilenames"; + public static final String USE_COMPRESSION = "useCompression"; + public static final String USE_ARMOR = "useArmor"; } public static final class Defaults { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java index 45700f978..4d23ba9f8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesActivity.java @@ -73,12 +73,10 @@ public class EncryptFilesActivity extends EncryptActivity { uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); } - boolean useArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, false); - if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris, useArmor); + EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris); transaction.replace(R.id.encrypt_file_container, encryptFragment); transaction.commit(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java index f5963dbf0..13de80eb8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java @@ -41,6 +41,7 @@ import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import com.nispok.snackbar.Snackbar; import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -58,9 +59,12 @@ import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; import org.sufficientlysecure.keychain.ui.util.FormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; +import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener; +import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.FileHelper; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Passphrase; +import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.ShareHelper; import java.io.File; @@ -99,11 +103,10 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment uris, boolean useArmor) { + public static EncryptFilesFragment newInstance(ArrayList uris) { EncryptFilesFragment frag = new EncryptFilesFragment(); Bundle args = new Bundle(); - args.putBoolean(ARG_USE_ASCII_ARMOR, useArmor); args.putParcelableArrayList(ARG_URIS, uris); frag.setArguments(args); @@ -167,11 +170,28 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment"Add additional email address" "Unlock" "Add" + "Save as default" + "Saved!" "Settings" @@ -1308,5 +1310,11 @@ "NFC Error: %s" Default PIN was rejected! Error creating temporary file. Bluetooth sharing will fail. + "Filenames are encrypted." + "Filenames are not encrypted." + "Output encoded as Text." + "Output encoded as Binary." + "Compression enabled." + "Compression disabled."