aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-08-04 14:42:03 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-08-04 14:42:03 +0200
commit839294d27c4f8b3ac22573a1d429bc230f641bd2 (patch)
tree602985e170c040e801ddef45e519f354cf1e9b69 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper
parentb42afcd32cc082d45daf64e37d89ba88f0c3eb56 (diff)
downloadopen-keychain-839294d27c4f8b3ac22573a1d429bc230f641bd2.tar.gz
open-keychain-839294d27c4f8b3ac22573a1d429bc230f641bd2.tar.bz2
open-keychain-839294d27c4f8b3ac22573a1d429bc230f641bd2.zip
Cleanup, prevent encrypt Intent inception
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java21
1 files changed, 12 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java
index 615d89e0c..ca0749a4e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java
@@ -32,6 +32,7 @@ import android.provider.OpenableColumns;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.widget.Toast;
+
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
@@ -136,9 +137,10 @@ public class FileHelper {
/**
* Opens the storage browser on Android 4.4 or later for opening a file
+ *
* @param fragment
- * @param mimeType can be text/plain for example
- * @param multiple allow file chooser to return multiple files
+ * @param mimeType can be text/plain for example
+ * @param multiple allow file chooser to return multiple files
* @param requestCode used to identify the result coming back from storage browser onActivityResult() in your
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
@@ -153,10 +155,11 @@ public class FileHelper {
/**
* Opens the storage browser on Android 4.4 or later for saving a file
+ *
* @param fragment
- * @param mimeType can be text/plain for example
+ * @param mimeType can be text/plain for example
* @param suggestedName a filename desirable for the file to be saved
- * @param requestCode used to identify the result coming back from storage browser onActivityResult() in your
+ * @param requestCode used to identify the result coming back from storage browser onActivityResult() in your
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void saveDocument(Fragment fragment, String mimeType, String suggestedName, int requestCode) {
@@ -210,7 +213,7 @@ public class FileHelper {
* Retrieve thumbnail of file, document api feature and thus KitKat only
*/
public static Bitmap getThumbnail(Context context, Uri uri, Point size) {
- if (Constants.KITKAT) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return DocumentsContract.getDocumentThumbnail(context.getContentResolver(), uri, size, null);
} else {
return null;
@@ -218,10 +221,10 @@ public class FileHelper {
}
public static String readableFileSize(long size) {
- if(size <= 0) return "0";
- final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
- int digitGroups = (int) (Math.log10(size)/Math.log10(1024));
- return new DecimalFormat("#,##0.#").format(size/Math.pow(1024, digitGroups)) + " " + units[digitGroups];
+ if (size <= 0) return "0";
+ final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
+ int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
+ return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
public static interface FileDialogCallback {