diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2012-12-14 19:16:10 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2012-12-14 19:16:10 +0100 |
commit | a9d80902f4dbcee2379ba9d7d8cbc829f109f96d (patch) | |
tree | 4f4e9aa9646fcefa4b4b54326f420ed22e88fb7a | |
parent | be4e3a10b008dfb33caf593b6e68bb7018c2a41c (diff) | |
download | open-keychain-a9d80902f4dbcee2379ba9d7d8cbc829f109f96d.tar.gz open-keychain-a9d80902f4dbcee2379ba9d7d8cbc829f109f96d.tar.bz2 open-keychain-a9d80902f4dbcee2379ba9d7d8cbc829f109f96d.zip |
cleanup, add SCAN_QR_CODE intent
9 files changed, 41 insertions, 26 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 cbd438f2f..c92f2ebed 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 @@ -53,11 +53,23 @@ public class ApgIntentHelper { public static final String ACTION_DECRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX + "DECRYPT_STREAM_AND_RETURN"; + /** + * Select keys, without permission + */ public static final String ACTION_SELECT_PUBLIC_KEYS = APG_INTENT_PREFIX + "SELECT_PUBLIC_KEYS"; public static final String ACTION_SELECT_SECRET_KEY = APG_INTENT_PREFIX + "SELECT_SECRET_KEY"; + + /** + * Create key/edit key, without permission + */ public static final String ACTION_CREATE_KEY = APG_INTENT_PREFIX + "CREATE_KEY"; public static final String ACTION_EDIT_KEY = APG_INTENT_PREFIX + "EDIT_KEY"; + /** + * Scan QR code, without permission + */ + public static final String ACTION_SCAN_QR_CODE = APG_INTENT_PREFIX + "SCAN_QR_CODE"; + public static final String EXTRA_TEXT = "text"; public static final String EXTRA_DATA = "data"; public static final String EXTRA_ERROR = "error"; @@ -80,7 +92,7 @@ public class ApgIntentHelper { public static final String RESULT_EXTRA_MASTER_KEY_IDS = "masterKeyIds"; public static final String RESULT_EXTRA_USER_IDS = "userIds"; - + // result from EditKey public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId"; public static final String RESULT_EXTRA_USER_ID = "userId"; @@ -101,6 +113,23 @@ public class ApgIntentHelper { } /** + * Open activity to scan qr code and import key in it + * + * @return true when activity was found and executed successfully + */ + public boolean scanQrCode() { + Intent intent = new Intent(ACTION_SCAN_QR_CODE); + intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION); + try { + activity.startActivityForResult(intent, -1); + return true; + } catch (ActivityNotFoundException e) { + activityNotFound(); + return false; + } + } + + /** * Opens APG activity to create new key * * @param userIds diff --git a/APG/AndroidManifest.xml b/APG/AndroidManifest.xml index 800655f8b..f76e4f1dc 100644 --- a/APG/AndroidManifest.xml +++ b/APG/AndroidManifest.xml @@ -338,7 +338,13 @@ <activity android:name=".ui.ImportFromQRCodeActivity" android:configChanges="orientation|screenSize|keyboardHidden|keyboard" - android:label="@string/title_importFromQRCode" /> + android:label="@string/title_importFromQRCode" > + <intent-filter> + <action android:name="org.thialfihar.android.apg.intent.SCAN_QR_CODE" /> + + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> <activity android:name=".ui.HelpActivity" android:label="@string/title_help" /> diff --git a/APG/src/org/thialfihar/android/apg/helper/FileHelper.java b/APG/src/org/thialfihar/android/apg/helper/FileHelper.java index 6efee19c0..c5fb2a139 100644 --- a/APG/src/org/thialfihar/android/apg/helper/FileHelper.java +++ b/APG/src/org/thialfihar/android/apg/helper/FileHelper.java @@ -16,8 +16,6 @@ package org.thialfihar.android.apg.helper; -import java.net.URISyntaxException; - import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.R; import org.thialfihar.android.apg.util.Log; @@ -90,7 +88,6 @@ public class FileHelper { * @author paulburke */ public static String getPath(Context context, Uri uri) { - Log.d(Constants.TAG + " File -", "Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment() + ", Port: " + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: " diff --git a/APG/src/org/thialfihar/android/apg/helper/PGPConversionHelper.java b/APG/src/org/thialfihar/android/apg/helper/PGPConversionHelper.java index 7fee97882..5ed320764 100644 --- a/APG/src/org/thialfihar/android/apg/helper/PGPConversionHelper.java +++ b/APG/src/org/thialfihar/android/apg/helper/PGPConversionHelper.java @@ -22,20 +22,15 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; -import org.spongycastle.bcpg.ArmoredOutputStream; import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPObjectFactory; -import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.PGPUtil; import org.thialfihar.android.apg.Constants; -import org.thialfihar.android.apg.provider.ProviderHelper; import org.thialfihar.android.apg.util.Log; -import android.content.Context; - public class PGPConversionHelper { /** diff --git a/APG/src/org/thialfihar/android/apg/helper/PGPHelper.java b/APG/src/org/thialfihar/android/apg/helper/PGPHelper.java index 1571ed023..fed1d2156 100644 --- a/APG/src/org/thialfihar/android/apg/helper/PGPHelper.java +++ b/APG/src/org/thialfihar/android/apg/helper/PGPHelper.java @@ -17,38 +17,26 @@ package org.thialfihar.android.apg.helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.Vector; -import org.spongycastle.bcpg.ArmoredOutputStream; import org.spongycastle.bcpg.sig.KeyFlags; -import org.spongycastle.openpgp.PGPKeyRing; -import org.spongycastle.openpgp.PGPObjectFactory; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.PGPSignature; import org.spongycastle.openpgp.PGPSignatureSubpacketVector; -import org.spongycastle.openpgp.PGPUtil; import org.thialfihar.android.apg.Constants; import org.thialfihar.android.apg.R; -import org.thialfihar.android.apg.provider.ApgContract.KeyRings; import org.thialfihar.android.apg.provider.ProviderHelper; import org.thialfihar.android.apg.util.IterableIterator; import org.thialfihar.android.apg.util.Log; import android.content.Context; -import android.database.Cursor; -import android.database.DatabaseUtils; -import android.net.Uri; public class PGPHelper { diff --git a/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java b/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java index d4859cc86..39074bcea 100644 --- a/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java +++ b/APG/src/org/thialfihar/android/apg/ui/EditKeyActivity.java @@ -299,6 +299,7 @@ public class EditKeyActivity extends SherlockFragmentActivity { * * @param intent */ + @SuppressWarnings("unchecked") private void handleActionEditKey(Intent intent) { Bundle extras = intent.getExtras(); diff --git a/APG/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java b/APG/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java index aac1fd15b..0e4258829 100644 --- a/APG/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java +++ b/APG/src/org/thialfihar/android/apg/ui/ImportFromQRCodeActivity.java @@ -46,8 +46,7 @@ import com.google.zxing.integration.android.IntentResult; public class ImportFromQRCodeActivity extends SherlockFragmentActivity { // Not used in sourcode, but listed in AndroidManifest! - public static final String IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX - + "IMPORT_FROM_QR_CODE"; + public static final String SCAN_QR_CODE = Constants.INTENT_PREFIX + "SCAN_QR_CODE"; // public static final String EXTRA_KEY_ID = "keyId"; diff --git a/APG/src/org/thialfihar/android/apg/ui/KeyListPublicActivity.java b/APG/src/org/thialfihar/android/apg/ui/KeyListPublicActivity.java index f8b8ccc85..556138049 100644 --- a/APG/src/org/thialfihar/android/apg/ui/KeyListPublicActivity.java +++ b/APG/src/org/thialfihar/android/apg/ui/KeyListPublicActivity.java @@ -64,7 +64,7 @@ public class KeyListPublicActivity extends KeyListActivity { } case Id.menu.option.scanQRCode: { Intent intent = new Intent(this, ImportFromQRCodeActivity.class); - intent.setAction(ImportFromQRCodeActivity.IMPORT_FROM_QR_CODE); + intent.setAction(ImportFromQRCodeActivity.SCAN_QR_CODE); startActivityForResult(intent, Id.request.import_from_qr_code); return true; diff --git a/APG/src/org/thialfihar/android/apg/ui/MainActivity.java b/APG/src/org/thialfihar/android/apg/ui/MainActivity.java index 7c25e4533..565b6853b 100644 --- a/APG/src/org/thialfihar/android/apg/ui/MainActivity.java +++ b/APG/src/org/thialfihar/android/apg/ui/MainActivity.java @@ -57,7 +57,7 @@ public class MainActivity extends SherlockActivity { public void scanQrcodeOnClick(View view) { Intent intent = new Intent(this, ImportFromQRCodeActivity.class); - intent.setAction(ImportFromQRCodeActivity.IMPORT_FROM_QR_CODE); + intent.setAction(ImportFromQRCodeActivity.SCAN_QR_CODE); startActivityForResult(intent, Id.request.import_from_qr_code); } |