mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-14 04:45:04 -05:00
cleanup, add SCAN_QR_CODE intent
This commit is contained in:
parent
be4e3a10b0
commit
a9d80902f4
@ -53,11 +53,23 @@ public class ApgIntentHelper {
|
|||||||
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
|
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
|
||||||
+ "DECRYPT_STREAM_AND_RETURN";
|
+ "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_PUBLIC_KEYS = APG_INTENT_PREFIX + "SELECT_PUBLIC_KEYS";
|
||||||
public static final String ACTION_SELECT_SECRET_KEY = APG_INTENT_PREFIX + "SELECT_SECRET_KEY";
|
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_CREATE_KEY = APG_INTENT_PREFIX + "CREATE_KEY";
|
||||||
public static final String ACTION_EDIT_KEY = APG_INTENT_PREFIX + "EDIT_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_TEXT = "text";
|
||||||
public static final String EXTRA_DATA = "data";
|
public static final String EXTRA_DATA = "data";
|
||||||
public static final String EXTRA_ERROR = "error";
|
public static final String EXTRA_ERROR = "error";
|
||||||
@ -100,6 +112,23 @@ public class ApgIntentHelper {
|
|||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Opens APG activity to create new key
|
||||||
*
|
*
|
||||||
|
@ -338,7 +338,13 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".ui.ImportFromQRCodeActivity"
|
android:name=".ui.ImportFromQRCodeActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
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
|
<activity
|
||||||
android:name=".ui.HelpActivity"
|
android:name=".ui.HelpActivity"
|
||||||
android:label="@string/title_help" />
|
android:label="@string/title_help" />
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.helper;
|
package org.thialfihar.android.apg.helper;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.util.Log;
|
import org.thialfihar.android.apg.util.Log;
|
||||||
@ -90,7 +88,6 @@ public class FileHelper {
|
|||||||
* @author paulburke
|
* @author paulburke
|
||||||
*/
|
*/
|
||||||
public static String getPath(Context context, Uri uri) {
|
public static String getPath(Context context, Uri uri) {
|
||||||
|
|
||||||
Log.d(Constants.TAG + " File -",
|
Log.d(Constants.TAG + " File -",
|
||||||
"Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment()
|
"Authority: " + uri.getAuthority() + ", Fragment: " + uri.getFragment()
|
||||||
+ ", Port: " + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: "
|
+ ", Port: " + uri.getPort() + ", Query: " + uri.getQuery() + ", Scheme: "
|
||||||
|
@ -22,20 +22,15 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
|
||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
import org.spongycastle.openpgp.PGPKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPObjectFactory;
|
import org.spongycastle.openpgp.PGPObjectFactory;
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPUtil;
|
import org.spongycastle.openpgp.PGPUtil;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.provider.ProviderHelper;
|
|
||||||
import org.thialfihar.android.apg.util.Log;
|
import org.thialfihar.android.apg.util.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public class PGPConversionHelper {
|
public class PGPConversionHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,38 +17,26 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.helper;
|
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.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
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.PGPPublicKey;
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
||||||
import org.spongycastle.openpgp.PGPUtil;
|
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
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.provider.ProviderHelper;
|
||||||
import org.thialfihar.android.apg.util.IterableIterator;
|
import org.thialfihar.android.apg.util.IterableIterator;
|
||||||
import org.thialfihar.android.apg.util.Log;
|
import org.thialfihar.android.apg.util.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.database.DatabaseUtils;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
public class PGPHelper {
|
public class PGPHelper {
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
*
|
*
|
||||||
* @param intent
|
* @param intent
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void handleActionEditKey(Intent intent) {
|
private void handleActionEditKey(Intent intent) {
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ import com.google.zxing.integration.android.IntentResult;
|
|||||||
public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
|
public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
// Not used in sourcode, but listed in AndroidManifest!
|
// Not used in sourcode, but listed in AndroidManifest!
|
||||||
public static final String IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX
|
public static final String SCAN_QR_CODE = Constants.INTENT_PREFIX + "SCAN_QR_CODE";
|
||||||
+ "IMPORT_FROM_QR_CODE";
|
|
||||||
|
|
||||||
// public static final String EXTRA_KEY_ID = "keyId";
|
// public static final String EXTRA_KEY_ID = "keyId";
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class KeyListPublicActivity extends KeyListActivity {
|
|||||||
}
|
}
|
||||||
case Id.menu.option.scanQRCode: {
|
case Id.menu.option.scanQRCode: {
|
||||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
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);
|
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -57,7 +57,7 @@ public class MainActivity extends SherlockActivity {
|
|||||||
|
|
||||||
public void scanQrcodeOnClick(View view) {
|
public void scanQrcodeOnClick(View view) {
|
||||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
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);
|
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user