From 756ee28fb0bfb63f1d013d6b82bedc13c811b32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 24 Sep 2015 23:15:19 +0200 Subject: Cleanup FileHelper --- .../keychain/ui/DecryptListFragment.java | 4 ++-- .../keychain/ui/EncryptFilesFragment.java | 5 ++--- .../ui/linked/LinkedIdCreateHttpsStep2Fragment.java | 6 ++---- .../keychain/util/FileHelper.java | 21 ++++++++++----------- 4 files changed, 16 insertions(+), 20 deletions(-) (limited to 'OpenKeychain/src/main/java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java index efb1df66b..a0650f8b1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java @@ -265,8 +265,8 @@ public class DecryptListFragment filename = "decrypted" + (ext != null ? "."+ext : ""); } - FileHelper.saveDocument(this, filename, null, metadata.getMimeType(), - R.string.title_decrypt_to_file, R.string.specify_file_to_decrypt_to, REQUEST_CODE_OUTPUT); + FileHelper.saveDocument(this, filename, metadata.getMimeType(), + REQUEST_CODE_OUTPUT); } private void saveFile(Uri saveUri) { 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 71d555cc8..58476fc57 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java @@ -224,9 +224,8 @@ public class EncryptFilesFragment String targetName = (mEncryptFilenames ? "1" : FileHelper.getFilename(getActivity(), model.inputUri)) + (mUseArmor ? Constants.FILE_EXTENSION_ASC : Constants.FILE_EXTENSION_PGP_MAIN); - Uri inputUri = model.inputUri; - FileHelper.saveDocument(this, targetName, inputUri, - R.string.title_encrypt_to_file, R.string.specify_file_to_encrypt_to, REQUEST_CODE_OUTPUT); + FileHelper.saveDocument(this, targetName, + REQUEST_CODE_OUTPUT); } public void addFile(Intent data) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java index 1065bf1ce..44323543f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java @@ -27,7 +27,6 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.EditText; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; import org.sufficientlysecure.keychain.linked.resources.GenericHttpsResource; @@ -35,7 +34,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.util.FileHelper; -import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.net.URI; @@ -136,8 +134,8 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen // TODO: not supported on Android < 4.4 FileHelper.saveDocument(this, - targetName, Uri.fromFile(new File(Constants.Path.APP_DIR, targetName)), - "text/plain", R.string.title_decrypt_to_file, R.string.specify_file_to_decrypt_to, + targetName, + "text/plain", REQUEST_CODE_OUTPUT); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java index 09ea67f42..fea3e65b6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FileHelper.java @@ -74,24 +74,23 @@ import java.text.DecimalFormat; public class FileHelper { public static void openDocument(Fragment fragment, Uri last, String mimeType, boolean multiple, int requestCode) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode); - } else { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { openDocumentKitKat(fragment, mimeType, multiple, requestCode); + } else { + openDocumentPreKitKat(fragment, last, mimeType, multiple, requestCode); } } - public static void saveDocument(Fragment fragment, String targetName, Uri inputUri, - @StringRes int title, @StringRes int message, int requestCode) { - saveDocument(fragment, targetName, inputUri, "*/*", title, message, requestCode); + public static void saveDocument(Fragment fragment, String targetName, int requestCode) { + saveDocument(fragment, targetName, "*/*", requestCode); } - public static void saveDocument(Fragment fragment, String targetName, Uri inputUri, String mimeType, - @StringRes int title, @StringRes int message, int requestCode) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - throw new RuntimeException("saveDocument does not support Android < 4.4!"); - } else { + public static void saveDocument(Fragment fragment, String targetName, String mimeType, + int requestCode) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { saveDocumentKitKat(fragment, mimeType, targetName, requestCode); + } else { + throw new RuntimeException("saveDocument does not support Android < 4.4!"); } } -- cgit v1.2.3