diff options
author | mar-v-in <github@rvin.mooo.com> | 2014-06-22 16:31:28 +0200 |
---|---|---|
committer | mar-v-in <github@rvin.mooo.com> | 2014-06-22 16:31:28 +0200 |
commit | 79fb23b095fba273d77066204ee44d2b8d1edf8d (patch) | |
tree | 69aa452c547cb6bc6b882abf6d8e22836bfb2303 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java | |
parent | 313e571a61e22a7152e32366d747114233d25b6e (diff) | |
download | open-keychain-79fb23b095fba273d77066204ee44d2b8d1edf8d.tar.gz open-keychain-79fb23b095fba273d77066204ee44d2b8d1edf8d.tar.bz2 open-keychain-79fb23b095fba273d77066204ee44d2b8d1edf8d.zip |
Improve file more, Part 1
- Use Uris where it makes sense, Use File class to clarify it's a file (and not whatever else a string could be)
- Show sdcard in side menu in storage API #665
- Propose filename with gpg ending when storing it using the storage API #665
- Don't show output dialog on Android 4.4 #665
- Only show filename on Android < 4.4 #665
TODO:
- File deletion for Android < 4.4
- Testing (especially with Android < 4.4)
- Batch-encryption
- UI
- Temporary content provider (see #665 discussion)
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java | 21 |
1 files changed, 16 insertions, 5 deletions
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 e1514b16f..a2676b1a4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -139,6 +139,7 @@ public class KeychainIntentService extends IntentService // export key public static final String EXPORT_OUTPUT_STREAM = "export_output_stream"; public static final String EXPORT_FILENAME = "export_filename"; + public static final String EXPORT_URI = "export_uri"; public static final String EXPORT_SECRET = "export_secret"; public static final String EXPORT_ALL = "export_all"; public static final String EXPORT_KEY_RING_MASTER_KEY_ID = "export_key_ring_id"; @@ -393,13 +394,16 @@ public class KeychainIntentService extends IntentService boolean exportSecret = data.getBoolean(EXPORT_SECRET, false); long[] masterKeyIds = data.getLongArray(EXPORT_KEY_RING_MASTER_KEY_ID); String outputFile = data.getString(EXPORT_FILENAME); + Uri outputUri = data.getParcelable(EXPORT_URI); // If not exporting all keys get the masterKeyIds of the keys to export from the intent boolean exportAll = data.getBoolean(EXPORT_ALL); - // check if storage is ready - if (!FileHelper.isStorageMounted(outputFile)) { - throw new PgpGeneralException(getString(R.string.error_external_storage_not_ready)); + if (outputFile != null) { + // check if storage is ready + if (!FileHelper.isStorageMounted(outputFile)) { + throw new PgpGeneralException(getString(R.string.error_external_storage_not_ready)); + } } ArrayList<Long> publicMasterKeyIds = new ArrayList<Long>(); @@ -431,12 +435,19 @@ public class KeychainIntentService extends IntentService } } + OutputStream outStream; + if (outputFile != null) { + outStream = new FileOutputStream(outputFile); + } else { + outStream = getContentResolver().openOutputStream(outputUri); + } + PgpImportExport pgpImportExport = new PgpImportExport(this, this, this); Bundle resultData = pgpImportExport .exportKeyRings(publicMasterKeyIds, secretMasterKeyIds, - new FileOutputStream(outputFile)); + outStream); - if (mIsCanceled) { + if (mIsCanceled && outputFile != null) { boolean isDeleted = new File(outputFile).delete(); } |