diff options
Diffstat (limited to 'org_apg')
5 files changed, 46 insertions, 24 deletions
diff --git a/org_apg/AndroidManifest.xml b/org_apg/AndroidManifest.xml index 570cf72c2..dfa366de3 100644 --- a/org_apg/AndroidManifest.xml +++ b/org_apg/AndroidManifest.xml @@ -28,7 +28,7 @@ - APG 2 starting with versionCode 20000! - Registration of APG to file types + Association of file types to APG ================================= General remarks about file ending conventions: - *.gpg for binary files diff --git a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java index 624572b7b..89515db07 100644 --- a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java +++ b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java @@ -286,7 +286,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { break; case TARGET_STREAM: /* Encrypting stream from content uri */ - Uri providerUri = Uri.parse(data.getString(PROVIDER_URI)); + Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI); // InputStream InputStream in = getContentResolver().openInputStream(providerUri); @@ -440,7 +440,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { break; case TARGET_STREAM: /* decrypting stream from content uri */ - Uri providerUri = Uri.parse(data.getString(PROVIDER_URI)); + Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI); // InputStream InputStream in = getContentResolver().openInputStream(providerUri); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java index 46bfbdfe5..c41400f5a 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java @@ -254,10 +254,12 @@ public class DecryptActivity extends SherlockFragmentActivity { String action = intent.getAction(); String type = intent.getType(); + mContentUri = intent.getData(); + if (Intent.ACTION_VIEW.equals(action)) { + // Android's Action when opening file associated to APG (see AndroidManifest.xml) // TODO: old implementation of ACTION_VIEW. Is this used in K9? - // Uri uri = mIntent.getData(); // try { // InputStream attachment = getContentResolver().openInputStream(uri); @@ -280,7 +282,10 @@ public class DecryptActivity extends SherlockFragmentActivity { handleActionDecryptFile(intent); decryptImmediately = true; } else if (Intent.ACTION_SEND.equals(action) && type != null) { + // Android's Action when sending to APG Decrypt + if ("text/plain".equals(type)) { + // plain text String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); if (sharedText != null) { intent.putExtra(EXTRA_TEXT, sharedText); @@ -288,10 +293,10 @@ public class DecryptActivity extends SherlockFragmentActivity { decryptImmediately = true; } } else { + // binary via content provider (could also be files) Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { - // TODO: Implement for binary - + mContentUri = uri; } } } else if (ACTION_DECRYPT.equals(action)) { @@ -440,7 +445,6 @@ public class DecryptActivity extends SherlockFragmentActivity { * @param intent */ private void handleActionDecryptAndReturn(Intent intent) { - mContentUri = intent.getData(); Bundle extras = intent.getExtras(); if (extras == null) { extras = new Bundle(); @@ -745,7 +749,7 @@ public class DecryptActivity extends SherlockFragmentActivity { if (mContentUri != null) { data.putInt(ApgService.TARGET, ApgService.TARGET_STREAM); - data.putString(ApgService.PROVIDER_URI, mContentUri.toString()); + data.putParcelable(ApgService.PROVIDER_URI, mContentUri); } else if (mDecryptTarget == Id.target.file) { data.putInt(ApgService.TARGET, ApgService.TARGET_FILE); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java index 1e5159c98..420594e35 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/EncryptActivity.java @@ -346,9 +346,13 @@ public class EncryptActivity extends SherlockFragmentActivity { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); + mContentUri = intent.getData(); if (Intent.ACTION_SEND.equals(action) && type != null) { + // Android's Action when sending to APG Encrypt + if ("text/plain".equals(type)) { + // plain text String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); if (sharedText != null) { intent.setAction(ACTION_ENCRYPT); @@ -357,15 +361,18 @@ public class EncryptActivity extends SherlockFragmentActivity { handleActionEncryptSign(intent); } } else { + // binary via content provider (could also be files) Uri uri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { - // TODO: Implement for binary - + mContentUri = uri; + handleActionEncryptSign(intent); } } } else if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_FILE.equals(action) || ACTION_ENCRYPT_AND_RETURN.equals(action) || ACTION_GENERATE_SIGNATURE.equals(action)) { + // APG's own Actions + handleActionEncryptSign(intent); } @@ -402,8 +409,6 @@ public class EncryptActivity extends SherlockFragmentActivity { */ private void handleActionEncryptSign(Intent intent) { String action = intent.getAction(); - - mContentUri = intent.getData(); Bundle extras = intent.getExtras(); if (extras == null) { extras = new Bundle(); @@ -790,7 +795,7 @@ public class EncryptActivity extends SherlockFragmentActivity { // choose default settings, target and data bundle by target if (mContentUri != null) { data.putInt(ApgService.TARGET, ApgService.TARGET_STREAM); - data.putString(ApgService.PROVIDER_URI, mContentUri.toString()); + data.putParcelable(ApgService.PROVIDER_URI, mContentUri); } else if (mEncryptTarget == Id.target.file) { useAsciiArmour = mAsciiArmour.isChecked(); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java index c77e8b01b..8ca686217 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/KeyListActivity.java @@ -142,20 +142,33 @@ public class KeyListActivity extends SherlockFragmentActivity { mListAdapter = new KeyListAdapter(this, searchString); mList.setAdapter(mListAdapter); - // handled separately from other actions as it uses intent.setAction() - if (Intent.ACTION_VIEW.equals(intent.getAction())) { - // same as ACTION_IMPORT invoked from a file manager - intent.setAction(ACTION_IMPORT); + // Get intent, action + // Intent intent = getIntent(); + String action = intent.getAction(); + + if (Intent.ACTION_VIEW.equals(action)) { + // Android's Action when opening file associated to APG (see AndroidManifest.xml) + + handleActionImport(intent); + } else if (ACTION_IMPORT.equals(action)) { + // APG's own Actions + + handleActionImport(intent); } + } - if (ACTION_IMPORT.equals(intent.getAction())) { - if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { - mImportFilename = intent.getData().getPath(); - } else { - mImportData = intent.getStringExtra(EXTRA_TEXT); - } - importKeys(); + /** + * Handles import action + * + * @param intent + */ + private void handleActionImport(Intent intent) { + if ("file".equals(intent.getScheme()) && intent.getDataString() != null) { + mImportFilename = intent.getData().getPath(); + } else { + mImportData = intent.getStringExtra(EXTRA_TEXT); } + importKeys(); } @Override |