aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java7
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java103
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/KeyUpdateHelper.java1
4 files changed, 63 insertions, 56 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
index dafa3aeed..854a90713 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
@@ -73,7 +73,10 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
}
dest.writeString(mFingerprintHex);
dest.writeString(mKeyIdHex);
- dest.writeInt(mBitStrength);
+ dest.writeInt(mBitStrength == null ? 0 : 1);
+ if (mBitStrength != null) {
+ dest.writeInt(mBitStrength);
+ }
dest.writeString(mAlgorithm);
dest.writeByte((byte) (mSecretKey ? 1 : 0));
dest.writeByte((byte) (mSelected ? 1 : 0));
@@ -94,7 +97,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
vr.mDate = source.readInt() != 0 ? new Date(source.readLong()) : null;
vr.mFingerprintHex = source.readString();
vr.mKeyIdHex = source.readString();
- vr.mBitStrength = source.readInt();
+ vr.mBitStrength = source.readInt() != 0 ? source.readInt() : null;
vr.mAlgorithm = source.readString();
vr.mSecretKey = source.readByte() == 1;
vr.mSelected = source.readByte() == 1;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java
index 791c44503..fd013739e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/AddKeysActivity.java
@@ -81,7 +81,9 @@ public class AddKeysActivity extends ActionBarActivity implements
byte[] mImportBytes;
- private static final int REQUEST_CODE_SAFE_SLINGER = 1;
+ private static final int REQUEST_CODE_RESULT = 0;
+ private static final int REQUEST_CODE_RESULT_TO_LIST = 1;
+ private static final int REQUEST_CODE_SAFE_SLINGER = 2;
private static final int LOADER_ID_BYTES = 0;
@@ -130,7 +132,7 @@ public class AddKeysActivity extends ActionBarActivity implements
// show nfc help
Intent intent = new Intent(AddKeysActivity.this, HelpActivity.class);
intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, HelpActivity.TAB_NFC);
- startActivityForResult(intent, 0);
+ startActivityForResult(intent, REQUEST_CODE_RESULT);
}
});
@@ -177,55 +179,62 @@ public class AddKeysActivity extends ActionBarActivity implements
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- // if a result has been returned, display a notify
- if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
- OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
- result.createNotify(this).show();
- } else {
- switch (requestCode) {
- case REQUEST_CODE_SAFE_SLINGER: {
- switch (resultCode) {
- case ExchangeActivity.RESULT_EXCHANGE_OK:
- // import exchanged keys
- mImportBytes = getSlingedKeys(data);
- getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
- break;
- case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
- // do nothing
- break;
- }
- break;
+ switch (requestCode) {
+ case REQUEST_CODE_RESULT: {
+ if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
+ OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
+ result.createNotify(this).show();
}
- case IntentIntegratorSupportV4.REQUEST_CODE: {
- IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
- resultCode, data);
- if (scanResult != null && scanResult.getFormatName() != null) {
- String scannedContent = scanResult.getContents();
-
- Log.d(Constants.TAG, "scannedContent: " + scannedContent);
-
- // look if it's fingerprint only
- if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
- importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
- return;
- }
-
- // is this a full key encoded as qr code?
- if (scannedContent.startsWith("-----BEGIN PGP")) {
- // TODO
-// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
- return;
- }
+ break;
+ }
+ case REQUEST_CODE_RESULT_TO_LIST: {
+ // give it down...
+ setResult(0, data);
+ finish();
+ break;
+ }
+ case REQUEST_CODE_SAFE_SLINGER: {
+ switch (resultCode) {
+ case ExchangeActivity.RESULT_EXCHANGE_OK:
+ // import exchanged keys
+ mImportBytes = getSlingedKeys(data);
+ getSupportLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
+ break;
+ case ExchangeActivity.RESULT_EXCHANGE_CANCELED:
+ // do nothing
+ break;
+ }
+ break;
+ }
+ case IntentIntegratorSupportV4.REQUEST_CODE: {
+ IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
+ resultCode, data);
+ if (scanResult != null && scanResult.getFormatName() != null) {
+ String scannedContent = scanResult.getContents();
- // fail...
- Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
+ Log.d(Constants.TAG, "scannedContent: " + scannedContent);
+
+ // look if it's fingerprint only
+ if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
+ importKeys(null, getFingerprintFromUri(Uri.parse(scanResult.getContents())));
+ return;
}
- break;
+ // is this a full key encoded as qr code?
+ if (scannedContent.startsWith("-----BEGIN PGP")) {
+ // TODO
+// mImportActivity.loadCallback(new ImportKeysListFragment.BytesLoaderState(scannedContent.getBytes(), null));
+ return;
+ }
+
+ // fail...
+ Notify.showNotify(this, R.string.import_qr_code_wrong, Notify.Style.ERROR);
}
+
+ break;
}
- super.onActivityResult(requestCode, resultCode, data);
}
+ super.onActivityResult(requestCode, resultCode, data);
}
private String getFingerprintFromUri(Uri dataUri) {
@@ -383,14 +392,11 @@ public class AddKeysActivity extends ActionBarActivity implements
return;
}
- finish();
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mExchangeMasterKeyId);
- startActivity(certifyIntent);
-
- result.createNotify(AddKeysActivity.this).show();
+ startActivityForResult(certifyIntent, REQUEST_CODE_RESULT_TO_LIST);
}
}
};
@@ -449,7 +455,6 @@ public class AddKeysActivity extends ActionBarActivity implements
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
keyEntry.setFingerprintHex(fingerprint);
- keyEntry.setBitStrength(1337); // TODO: make optional!
keyEntry.addOrigin(cloudPrefs.keyserver);
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
selectedEntries.add(keyEntry);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
index 5eef319c0..ce2aa8368 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
@@ -28,16 +28,16 @@ import android.view.MenuItem;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.util.ExportHelper;
-import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
-import org.sufficientlysecure.keychain.service.results.OperationResult;
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
-import org.sufficientlysecure.keychain.util.Log;
+import org.sufficientlysecure.keychain.service.results.OperationResult;
import org.sufficientlysecure.keychain.ui.util.Notify;
+import org.sufficientlysecure.keychain.util.ExportHelper;
+import org.sufficientlysecure.keychain.util.Log;
+import org.sufficientlysecure.keychain.util.Preferences;
import java.io.IOException;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/KeyUpdateHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/KeyUpdateHelper.java
index 357a9603c..afa2e75fa 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/KeyUpdateHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/KeyUpdateHelper.java
@@ -59,7 +59,6 @@ public class KeyUpdateHelper {
for (String fprint : providerHelper.getAllFingerprints(KeychainContract.KeyRings.buildUnifiedKeyRingsUri())) {
ImportKeysListEntry key = new ImportKeysListEntry();
key.setFingerprintHex(fprint);
- key.setBitStrength(1337);
key.addOrigin(servers[0]);
keys.add(key);
}