From 2712c18a7a921118e6fe18563b4b38a003cd013a Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Mon, 4 Aug 2014 20:34:00 +0200 Subject: Use size of input uris for progress bar in encrypt/decrypt --- .../java/org/sufficientlysecure/keychain/helper/FileHelper.java | 6 +++++- .../sufficientlysecure/keychain/service/KeychainIntentService.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain') 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 ca0749a4e..1b36ba3fc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/FileHelper.java @@ -193,7 +193,11 @@ public class FileHelper { } public static long getFileSize(Context context, Uri uri) { - long size = -1; + return getFileSize(context, uri, -1); + } + + public static long getFileSize(Context context, Uri uri, long def) { + long size = def; try { Cursor cursor = context.getContentResolver().query(uri, new String[]{OpenableColumns.SIZE}, null, null, null); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 601f45fed..19f7bc9bb 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -719,13 +719,13 @@ public class KeychainIntentService extends IntentService Uri providerUri = data.getParcelable(ENCRYPT_INPUT_URI); // InputStream - return new InputData(getContentResolver().openInputStream(providerUri), 0); + return new InputData(getContentResolver().openInputStream(providerUri), FileHelper.getFileSize(this, providerUri, 0)); case IO_URIS: providerUri = data.getParcelableArrayList(ENCRYPT_INPUT_URIS).get(data.getInt(SELECTED_URI)); // InputStream - return new InputData(getContentResolver().openInputStream(providerUri), 0); + return new InputData(getContentResolver().openInputStream(providerUri), FileHelper.getFileSize(this, providerUri, 0)); default: throw new PgpGeneralException("No target choosen!"); -- cgit v1.2.3