diff options
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java index ec56fe912..d24aeca52 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.helper; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.util.Log; - import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; @@ -30,12 +26,15 @@ import android.net.Uri; import android.os.Environment; import android.support.v4.app.Fragment; import android.widget.Toast; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.Log; public class FileHelper { /** * Checks if external storage is mounted if file is located on external storage - * + * * @param file * @return true if storage is mounted */ @@ -52,15 +51,12 @@ public class FileHelper { /** * Opens the preferred installed file manager on Android and shows a toast if no manager is * installed. - * + * * @param activity - * @param filename - * default selected file, not supported by all file managers - * @param mimeType - * can be text/plain for example - * @param requestCode - * requestCode used to identify the result coming back from file manager to - * onActivityResult() in your activity + * @param filename default selected file, not supported by all file managers + * @param mimeType can be text/plain for example + * @param requestCode requestCode used to identify the result coming back from file manager to + * onActivityResult() in your activity */ public static void openFile(Activity activity, String filename, String mimeType, int requestCode) { Intent intent = buildFileIntent(filename, mimeType); @@ -97,14 +93,13 @@ public class FileHelper { /** * Get a file path from a Uri. - * + * <p/> * from https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/ * afilechooser/utils/FileUtils.java - * + * * @param context * @param uri * @return - * * @author paulburke */ public static String getPath(Context context, Uri uri) { @@ -115,21 +110,19 @@ public class FileHelper { + uri.getPathSegments().toString()); if ("content".equalsIgnoreCase(uri.getScheme())) { - String[] projection = { "_data" }; + String[] projection = {"_data"}; Cursor cursor = null; try { cursor = context.getContentResolver().query(uri, projection, null, null, null); - int column_index = cursor.getColumnIndexOrThrow("_data"); + int columnIndex = cursor.getColumnIndexOrThrow("_data"); if (cursor.moveToFirst()) { - return cursor.getString(column_index); + return cursor.getString(columnIndex); } } catch (Exception e) { // Eat it } - } - - else if ("file".equalsIgnoreCase(uri.getScheme())) { + } else if ("file".equalsIgnoreCase(uri.getScheme())) { return uri.getPath(); } |