diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-01-08 20:42:22 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-01-08 20:42:22 +0100 |
commit | 049dc908f8cc00b153e80a975c28325e8b4174ba (patch) | |
tree | 2ecaf63a6a03b315cb28c0125199f3a0f1612764 /APG-API-Lib | |
parent | 55530597dfc02453aaf211b80703553fe87ff8f5 (diff) | |
download | open-keychain-049dc908f8cc00b153e80a975c28325e8b4174ba.tar.gz open-keychain-049dc908f8cc00b153e80a975c28325e8b4174ba.tar.bz2 open-keychain-049dc908f8cc00b153e80a975c28325e8b4174ba.zip |
Fixes, update Integration lib
Diffstat (limited to 'APG-API-Lib')
-rw-r--r-- | APG-API-Lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java | 61 |
1 files changed, 57 insertions, 4 deletions
diff --git a/APG-API-Lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java b/APG-API-Lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java index acdefd874..1362412fb 100644 --- a/APG-API-Lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java +++ b/APG-API-Lib/src/org/thialfihar/android/apg/integration/ApgIntentHelper.java @@ -66,9 +66,26 @@ public class ApgIntentHelper { public static final String ACTION_EDIT_KEY = APG_INTENT_PREFIX + "EDIT_KEY"; /** - * Scan QR code, without permission + * Import actions */ - public static final String ACTION_SCAN_QR_CODE = APG_INTENT_PREFIX + "SCAN_QR_CODE"; + public static final String ACTION_IMPORT = APG_INTENT_PREFIX + "IMPORT"; + + // only used by IMPORT + public static final String EXTRA_IMPORT_TEXT = "text"; + public static final String EXTRA_IMPORT_KEYRING_BYTES = "keyringBytes"; + + public static final String ACTION_IMPORT_FROM_FILE = APG_INTENT_PREFIX + "IMPORT_FROM_FILE"; + public static final String ACTION_IMPORT_FROM_QR_CODE = APG_INTENT_PREFIX + + "IMPORT_FROM_QR_CODE"; + + /** + * Share actions + */ + public static final String ACTION_SHARE_WITH_QR_CODE = APG_INTENT_PREFIX + "SHARE_WITH_QR_CODE"; + public static final String ACTION_SHARE_WITH_NFC = APG_INTENT_PREFIX + "SHARE_WITH_NFC"; + + // used by SHARE_WITH_QR_CODE and SHARE_WITH_NFC + public static final String EXTRA_MASTER_KEY_ID = "masterKeyId"; public static final String EXTRA_TEXT = "text"; public static final String EXTRA_DATA = "data"; @@ -133,9 +150,45 @@ public class ApgIntentHelper { * * @return true when activity was found and executed successfully */ - public boolean scanQrCode() { - Intent intent = new Intent(ACTION_SCAN_QR_CODE); + public boolean importFromQrCode() { + Intent intent = new Intent(ACTION_IMPORT_FROM_QR_CODE); + intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION); + try { + startActivityForResult(intent, -1); + return true; + } catch (ActivityNotFoundException e) { + activityNotFound(); + return false; + } + } + + /** + * Opens activity with qr code for masterKeyId + * + * @return true when activity was found and executed successfully + */ + public boolean shareWithQrCode(long masterKeyId) { + Intent intent = new Intent(ACTION_SHARE_WITH_QR_CODE); + intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION); + intent.putExtra(EXTRA_MASTER_KEY_ID, masterKeyId); + try { + startActivityForResult(intent, -1); + return true; + } catch (ActivityNotFoundException e) { + activityNotFound(); + return false; + } + } + + /** + * Opens activity to share keyring withnc based on given masterKeyId + * + * @return true when activity was found and executed successfully + */ + public boolean shareWithNfc(long masterKeyId) { + Intent intent = new Intent(ACTION_SHARE_WITH_NFC); intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION); + intent.putExtra(EXTRA_MASTER_KEY_ID, masterKeyId); try { startActivityForResult(intent, -1); return true; |