mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
commit
67e572cf4f
@ -38,8 +38,8 @@ import org.spongycastle.bcpg.UserIDPacket;
|
|||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
|
@ -46,7 +46,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
@ -75,7 +75,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
UncachedKeyRing ring;
|
UncachedKeyRing ring;
|
||||||
ArrayList<RawPacket> onlyA = new ArrayList<RawPacket>();
|
ArrayList<RawPacket> onlyA = new ArrayList<RawPacket>();
|
||||||
ArrayList<RawPacket> onlyB = new ArrayList<RawPacket>();
|
ArrayList<RawPacket> onlyB = new ArrayList<RawPacket>();
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
PGPSignatureSubpacketGenerator subHashedPacketsGen;
|
PGPSignatureSubpacketGenerator subHashedPacketsGen;
|
||||||
PGPSecretKey secretKey;
|
PGPSecretKey secretKey;
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
parcel.mAddUserIds.add("trix");
|
parcel.mAddUserIds.add("trix");
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
UncachedKeyRing foreign = op.createSecretKeyRing(parcel).getRing();
|
UncachedKeyRing foreign = op.createSecretKeyRing(parcel).getRing();
|
||||||
|
|
||||||
Assert.assertNotNull("initial test key creation must succeed", foreign);
|
Assert.assertNotNull("initial test key creation must succeed", foreign);
|
||||||
@ -532,7 +532,7 @@ public class UncachedKeyringCanonicalizeTest {
|
|||||||
|
|
||||||
private static void injectEverywhere(UncachedKeyRing ring, byte[] packet) throws Exception {
|
private static void injectEverywhere(UncachedKeyRing ring, byte[] packet) throws Exception {
|
||||||
|
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
|
|
||||||
byte[] encodedRing = ring.getEncoded();
|
byte[] encodedRing = ring.getEncoded();
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import org.spongycastle.bcpg.SecretKeyPacket;
|
|||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
@ -77,7 +77,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
UncachedKeyRing ringA, ringB;
|
UncachedKeyRing ringA, ringB;
|
||||||
ArrayList<RawPacket> onlyA = new ArrayList<RawPacket>();
|
ArrayList<RawPacket> onlyA = new ArrayList<RawPacket>();
|
||||||
ArrayList<RawPacket> onlyB = new ArrayList<RawPacket>();
|
ArrayList<RawPacket> onlyB = new ArrayList<RawPacket>();
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
PgpKeyOperation op;
|
PgpKeyOperation op;
|
||||||
SaveKeyringParcel parcel;
|
SaveKeyringParcel parcel;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
parcel.mNewPassphrase = "";
|
parcel.mNewPassphrase = "";
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
|
|
||||||
EditKeyResult result = op.createSecretKeyRing(parcel);
|
EditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
staticRingA = result.getRing();
|
staticRingA = result.getRing();
|
||||||
@ -115,7 +115,7 @@ public class UncachedKeyringMergeTest {
|
|||||||
parcel.mNewPassphrase = "";
|
parcel.mNewPassphrase = "";
|
||||||
PgpKeyOperation op = new PgpKeyOperation(null);
|
PgpKeyOperation op = new PgpKeyOperation(null);
|
||||||
|
|
||||||
OperationResultParcel.OperationLog log = new OperationResultParcel.OperationLog();
|
OperationResult.OperationLog log = new OperationResult.OperationLog();
|
||||||
EditKeyResult result = op.createSecretKeyRing(parcel);
|
EditKeyResult result = op.createSecretKeyRing(parcel);
|
||||||
staticRingB = result.getRing();
|
staticRingB = result.getRing();
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ public final class Constants {
|
|||||||
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
public static final String CACHED_CONSOLIDATE = "cachedConsolidate";
|
||||||
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
|
public static final String CACHED_CONSOLIDATE_SECRETS = "cachedConsolidateSecrets";
|
||||||
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";
|
public static final String CACHED_CONSOLIDATE_PUBLICS = "cachedConsolidatePublics";
|
||||||
|
public static final String SEARCH_KEYSERVER = "search_keyserver_pref";
|
||||||
|
public static final String SEARCH_KEYBASE = "search_keybase_pref";
|
||||||
public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin";
|
public static final String USE_DEFAULT_YUBIKEY_PIN = "useDefaultYubikeyPin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +61,9 @@ public class EmailKeyHelper {
|
|||||||
|
|
||||||
if (keys.isEmpty()) {
|
if (keys.isEmpty()) {
|
||||||
// Most users don't have the SRV record, so ask a default server as well
|
// Most users don't have the SRV record, so ask a default server as well
|
||||||
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
String server = Preferences.getPreferences(context).getPreferredKeyserver();
|
||||||
if (servers != null && servers.length != 0) {
|
if (server != null) {
|
||||||
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
HkpKeyserver hkp = new HkpKeyserver(server);
|
||||||
keys.addAll(getEmailKeys(mail, hkp));
|
keys.addAll(getEmailKeys(mail, hkp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class KeyUpdateHelper {
|
|||||||
ImportKeysListEntry key = new ImportKeysListEntry();
|
ImportKeysListEntry key = new ImportKeysListEntry();
|
||||||
key.setFingerprintHex(fprint);
|
key.setFingerprintHex(fprint);
|
||||||
key.setBitStrength(1337);
|
key.setBitStrength(1337);
|
||||||
key.setOrigin(servers[0]);
|
key.addOrigin(servers[0]);
|
||||||
keys.add(key);
|
keys.add(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +220,9 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
return servers.toArray(chunks);
|
return servers.toArray(chunks);
|
||||||
}
|
}
|
||||||
|
public String getPreferredKeyserver() {
|
||||||
|
return getKeyServers()[0];
|
||||||
|
}
|
||||||
|
|
||||||
public void setKeyServers(String[] value) {
|
public void setKeyServers(String[] value) {
|
||||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
@ -248,6 +251,35 @@ public class Preferences {
|
|||||||
return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false);
|
return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSearchKeyserver(boolean searchKeyserver) {
|
||||||
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
|
editor.putBoolean(Pref.SEARCH_KEYSERVER, searchKeyserver);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
public void setSearchKeybase(boolean searchKeybase) {
|
||||||
|
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||||
|
editor.putBoolean(Pref.SEARCH_KEYBASE, searchKeybase);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloudSearchPrefs getCloudSearchPrefs() {
|
||||||
|
return new CloudSearchPrefs(mSharedPreferences.getBoolean(Pref.SEARCH_KEYSERVER, true),
|
||||||
|
mSharedPreferences.getBoolean(Pref.SEARCH_KEYBASE, true),
|
||||||
|
getPreferredKeyserver());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CloudSearchPrefs {
|
||||||
|
public final boolean searchKeyserver;
|
||||||
|
public final boolean searchKeybase;
|
||||||
|
public final String keyserver;
|
||||||
|
|
||||||
|
public CloudSearchPrefs(boolean searchKeyserver, boolean searchKeybase, String keyserver) {
|
||||||
|
this.searchKeyserver = searchKeyserver;
|
||||||
|
this.searchKeybase = searchKeybase;
|
||||||
|
this.keyserver = keyserver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updatePreferences() {
|
public void updatePreferences() {
|
||||||
if (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0) !=
|
if (mSharedPreferences.getInt(Constants.Pref.PREF_DEFAULT_VERSION, 0) !=
|
||||||
Constants.Defaults.PREF_VERSION) {
|
Constants.Defaults.PREF_VERSION) {
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Tim Bray <tbray@textuality.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.sufficientlysecure.keychain.keyimport;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search two or more types of server for online keys.
|
||||||
|
*/
|
||||||
|
public class CloudSearch {
|
||||||
|
|
||||||
|
private final static long SECONDS = 1000;
|
||||||
|
|
||||||
|
public static ArrayList<ImportKeysListEntry> search(final String query, Preferences.CloudSearchPrefs cloudPrefs)
|
||||||
|
throws Keyserver.CloudSearchFailureException {
|
||||||
|
final ArrayList<Keyserver> servers = new ArrayList<Keyserver>();
|
||||||
|
|
||||||
|
// it's a Vector for sync, multiple threads might report problems
|
||||||
|
final Vector<Keyserver.CloudSearchFailureException> problems = new Vector<Keyserver.CloudSearchFailureException>();
|
||||||
|
|
||||||
|
if (cloudPrefs.searchKeyserver) {
|
||||||
|
servers.add(new HkpKeyserver(cloudPrefs.keyserver));
|
||||||
|
}
|
||||||
|
if (cloudPrefs.searchKeybase) {
|
||||||
|
servers.add(new KeybaseKeyserver());
|
||||||
|
}
|
||||||
|
final ImportKeysList results = new ImportKeysList(servers.size());
|
||||||
|
|
||||||
|
for (final Keyserver keyserver : servers) {
|
||||||
|
Runnable r = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
results.addAll(keyserver.search(query));
|
||||||
|
} catch (Keyserver.CloudSearchFailureException e) {
|
||||||
|
problems.add(e);
|
||||||
|
}
|
||||||
|
results.finishedAdding(); // notifies if all searchers done
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new Thread(r).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait for either all the searches to come back, or 10 seconds
|
||||||
|
synchronized(results) {
|
||||||
|
try {
|
||||||
|
results.wait(10 * SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.outstandingSuppliers() > 0) {
|
||||||
|
String message = "Launched " + servers.size() + " cloud searchers, but" +
|
||||||
|
results.outstandingSuppliers() + "failed to complete.";
|
||||||
|
problems.add(new Keyserver.QueryFailedException(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!problems.isEmpty()) {
|
||||||
|
for (Keyserver.CloudSearchFailureException e : problems) {
|
||||||
|
Log.d(Constants.TAG, "Cloud search exception: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// only throw exception if we didn’t get any results
|
||||||
|
if (results.isEmpty()) {
|
||||||
|
throw problems.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
@ -278,7 +278,7 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||||
entry.setQuery(query);
|
entry.setQuery(query);
|
||||||
entry.setOrigin(getUrlPrefix() + mHost + ":" + mPort);
|
entry.addOrigin(getUrlPrefix() + mHost + ":" + mPort);
|
||||||
|
|
||||||
int bitSize = Integer.parseInt(matcher.group(3));
|
int bitSize = Integer.parseInt(matcher.group(3));
|
||||||
entry.setBitStrength(bitSize);
|
entry.setBitStrength(bitSize);
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Tim Bray <tbray@textuality.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.sufficientlysecure.keychain.keyimport;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Just an ArrayList, only with a synchronized dupe-merging add/addAll, and a sign-off method
|
||||||
|
*/
|
||||||
|
public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
|
||||||
|
|
||||||
|
private int mSupplierCount;
|
||||||
|
|
||||||
|
public ImportKeysList(int supplierCount) {
|
||||||
|
mSupplierCount = supplierCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(ImportKeysListEntry toAdd) {
|
||||||
|
addOrMerge(toAdd);
|
||||||
|
return true; // that’s what the ArrayList#add contract says
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(Collection<? extends ImportKeysListEntry> addThese) {
|
||||||
|
boolean modified = false;
|
||||||
|
for (ImportKeysListEntry toAdd : addThese) {
|
||||||
|
modified = addOrMerge(toAdd) || modified;
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: side-effects
|
||||||
|
// NOTE: synchronized
|
||||||
|
private synchronized boolean addOrMerge(ImportKeysListEntry toAdd) {
|
||||||
|
for (ImportKeysListEntry existing : this) {
|
||||||
|
if (toAdd.hasSameKeyAs(existing)) {
|
||||||
|
return mergeDupes(toAdd, existing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.add(toAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// being a little anal about the ArrayList#addAll contract here
|
||||||
|
private boolean mergeDupes(ImportKeysListEntry incoming, ImportKeysListEntry existing) {
|
||||||
|
boolean modified = false;
|
||||||
|
if (incoming.isRevoked()) {
|
||||||
|
existing.setRevoked(true);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
if (incoming.isExpired()) {
|
||||||
|
existing.setExpired(true);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
for (String origin : incoming.getOrigins()) {
|
||||||
|
existing.addOrigin(origin);
|
||||||
|
}
|
||||||
|
ArrayList<String> incomingIDs = incoming.getUserIds();
|
||||||
|
ArrayList<String> existingIDs = existing.getUserIds();
|
||||||
|
for (String incomingID : incomingIDs) {
|
||||||
|
if (!existingIDs.contains(incomingID)) {
|
||||||
|
existingIDs.add(incomingID);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: synchronized
|
||||||
|
public synchronized void finishedAdding() {
|
||||||
|
mSupplierCount--;
|
||||||
|
if (mSupplierCount == 0) {
|
||||||
|
this.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int outstandingSuppliers() {
|
||||||
|
return mSupplierCount;
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
private String mPrimaryUserId;
|
private String mPrimaryUserId;
|
||||||
private String mExtraData;
|
private String mExtraData;
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
private String mOrigin;
|
private ArrayList<String> mOrigins;
|
||||||
private Integer mHashCode = null;
|
private Integer mHashCode = null;
|
||||||
|
|
||||||
private boolean mSelected;
|
private boolean mSelected;
|
||||||
@ -70,7 +70,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
||||||
dest.writeByte((byte) (mSelected ? 1 : 0));
|
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||||
dest.writeString(mExtraData);
|
dest.writeString(mExtraData);
|
||||||
dest.writeString(mOrigin);
|
dest.writeStringList(mOrigins);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
||||||
@ -90,7 +90,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
vr.mSecretKey = source.readByte() == 1;
|
vr.mSecretKey = source.readByte() == 1;
|
||||||
vr.mSelected = source.readByte() == 1;
|
vr.mSelected = source.readByte() == 1;
|
||||||
vr.mExtraData = source.readString();
|
vr.mExtraData = source.readString();
|
||||||
vr.mOrigin = source.readString();
|
vr.mOrigins = new ArrayList<String>();
|
||||||
|
source.readStringList(vr.mOrigins);
|
||||||
|
|
||||||
return vr;
|
return vr;
|
||||||
}
|
}
|
||||||
@ -107,6 +108,13 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
return super.hashCode();
|
return super.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasSameKeyAs(Object o) {
|
||||||
|
if (mFingerprintHex == null || o == null || !(o instanceof ImportKeysListEntry)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mFingerprintHex.equals(((ImportKeysListEntry) o).mFingerprintHex);
|
||||||
|
}
|
||||||
|
|
||||||
public String getKeyIdHex() {
|
public String getKeyIdHex() {
|
||||||
return mKeyIdHex;
|
return mKeyIdHex;
|
||||||
}
|
}
|
||||||
@ -223,12 +231,12 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
mQuery = query;
|
mQuery = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOrigin() {
|
public ArrayList<String> getOrigins() {
|
||||||
return mOrigin;
|
return mOrigins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrigin(String origin) {
|
public void addOrigin(String origin) {
|
||||||
mOrigin = origin;
|
mOrigins.add(origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -240,6 +248,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
|||||||
// do not select by default
|
// do not select by default
|
||||||
mSelected = false;
|
mSelected = false;
|
||||||
mUserIds = new ArrayList<String>();
|
mUserIds = new ArrayList<String>();
|
||||||
|
mOrigins = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +63,9 @@ public class KeybaseKeyserver extends Keyserver {
|
|||||||
private ImportKeysListEntry makeEntry(Match match) throws KeybaseException {
|
private ImportKeysListEntry makeEntry(Match match) throws KeybaseException {
|
||||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||||
entry.setQuery(mQuery);
|
entry.setQuery(mQuery);
|
||||||
entry.setOrigin(ORIGIN);
|
entry.addOrigin(ORIGIN);
|
||||||
|
|
||||||
|
entry.setRevoked(false); // keybase doesn’t say anything about revoked keys
|
||||||
|
|
||||||
String username = match.getUsername();
|
String username = match.getUsername();
|
||||||
String fullName = match.getFullName();
|
String fullName = match.getFullName();
|
||||||
|
@ -24,7 +24,19 @@ import java.io.InputStream;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class Keyserver {
|
public abstract class Keyserver {
|
||||||
public static class QueryFailedException extends Exception {
|
|
||||||
|
public static class CloudSearchFailureException extends Exception {
|
||||||
|
private static final long serialVersionUID = 2703768928624654515L;
|
||||||
|
|
||||||
|
public CloudSearchFailureException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
public CloudSearchFailureException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class QueryFailedException extends CloudSearchFailureException {
|
||||||
private static final long serialVersionUID = 2703768928624654512L;
|
private static final long serialVersionUID = 2703768928624654512L;
|
||||||
|
|
||||||
public QueryFailedException(String message) {
|
public QueryFailedException(String message) {
|
||||||
@ -32,7 +44,7 @@ public abstract class Keyserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class QueryNeedsRepairException extends Exception {
|
public static class QueryNeedsRepairException extends CloudSearchFailureException {
|
||||||
private static final long serialVersionUID = 2693768928624654512L;
|
private static final long serialVersionUID = 2693768928624654512L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
import org.sufficientlysecure.keychain.util.ProgressScaler;
|
||||||
|
@ -33,9 +33,9 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
|
@ -46,10 +46,10 @@ import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder;
|
|||||||
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
@ -949,7 +949,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
progress(R.string.progress_done, 100);
|
progress(R.string.progress_done, 100);
|
||||||
log.add(LogLevel.OK, LogType.MSG_MF_SUCCESS, indent);
|
log.add(LogLevel.OK, LogType.MSG_MF_SUCCESS, indent);
|
||||||
return new EditKeyResult(OperationResultParcel.RESULT_OK, log, new UncachedKeyRing(sKR));
|
return new EditKeyResult(OperationResult.RESULT_OK, log, new UncachedKeyRing(sKR));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
|
* Copyright (C) 2010-2014 Thialfihar <thi@thialfihar.org>
|
||||||
|
* Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -35,9 +36,9 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.SignEncryptResult;
|
import org.sufficientlysecure.keychain.service.results.SignEncryptResult;
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@ -366,7 +367,7 @@ public class PgpSignEncrypt {
|
|||||||
KeyRings.buildUnifiedKeyRingUri(id));
|
KeyRings.buildUnifiedKeyRingUri(id));
|
||||||
CanonicalizedPublicKey key = keyRing.getEncryptionSubKey();
|
CanonicalizedPublicKey key = keyRing.getEncryptionSubKey();
|
||||||
cPk.addMethod(key.getPubKeyEncryptionGenerator());
|
cPk.addMethod(key.getPubKeyEncryptionGenerator());
|
||||||
log.add(LogLevel.DEBUG, LogType.MSG_SE_KEY_OK, indent +1,
|
log.add(LogLevel.DEBUG, LogType.MSG_SE_KEY_OK, indent + 1,
|
||||||
PgpKeyHelper.convertKeyIdToHex(id));
|
PgpKeyHelper.convertKeyIdToHex(id));
|
||||||
} catch (PgpGeneralException e) {
|
} catch (PgpGeneralException e) {
|
||||||
log.add(LogLevel.WARN, LogType.MSG_SE_KEY_WARN, indent +1,
|
log.add(LogLevel.WARN, LogType.MSG_SE_KEY_WARN, indent +1,
|
||||||
|
@ -34,12 +34,11 @@ import org.spongycastle.openpgp.PGPSignatureList;
|
|||||||
import org.spongycastle.openpgp.PGPUtil;
|
import org.spongycastle.openpgp.PGPUtil;
|
||||||
import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
|
import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
|
||||||
import org.spongycastle.util.Strings;
|
import org.spongycastle.util.Strings;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Utf8Util;
|
import org.sufficientlysecure.keychain.util.Utf8Util;
|
||||||
|
@ -55,9 +55,9 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
import org.sufficientlysecure.keychain.remote.AppSettings;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
||||||
|
@ -32,7 +32,6 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
|
|||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.sufficientlysecure.keychain.nfc.NfcActivity;
|
import org.sufficientlysecure.keychain.nfc.NfcActivity;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
import org.sufficientlysecure.keychain.service.results.DecryptVerifyResult;
|
||||||
@ -45,7 +44,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity;
|
import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogEntryParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogEntryParcel;
|
||||||
import org.sufficientlysecure.keychain.service.results.SignEncryptResult;
|
import org.sufficientlysecure.keychain.service.results.SignEncryptResult;
|
||||||
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
|
import org.sufficientlysecure.keychain.ui.ImportKeysActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
import org.sufficientlysecure.keychain.ui.ViewKeyActivity;
|
||||||
|
@ -30,7 +30,10 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class AccountSettingsActivity extends ActionBarActivity {
|
public class AccountSettingsActivity extends ActionBarActivity {
|
||||||
@ -105,9 +108,10 @@ public class AccountSettingsActivity extends ActionBarActivity {
|
|||||||
private void save() {
|
private void save() {
|
||||||
new ProviderHelper(this).updateApiAccount(mAccountUri, mAccountSettingsFragment.getAccSettings());
|
new ProviderHelper(this).updateApiAccount(mAccountUri, mAccountSettingsFragment.getAccSettings());
|
||||||
// TODO: show "account saved" instead of "operation succeeded"
|
// TODO: show "account saved" instead of "operation succeeded"
|
||||||
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
|
SingletonResult result = new SingletonResult(
|
||||||
|
SingletonResult.RESULT_OK, LogLevel.OK, LogType.MSG_ACC_SAVED);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
|
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -115,8 +119,8 @@ public class AccountSettingsActivity extends ActionBarActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// if a result has been returned, display a notify
|
// if a result has been returned, display a notify
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
result.createNotify(this).show();
|
result.createNotify(this).show();
|
||||||
} else {
|
} else {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -33,7 +33,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
||||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
|
||||||
@ -171,8 +171,8 @@ public class AccountSettingsFragment extends Fragment {
|
|||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case REQUEST_CODE_CREATE_KEY: {
|
case REQUEST_CODE_CREATE_KEY: {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
SaveKeyringResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
mSelectKeySpinner.setSelectedKeyId(result.mRingMasterKeyId);
|
mSelectKeySpinner.setSelectedKeyId(result.mRingMasterKeyId);
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG, "missing result!");
|
Log.e(Constants.TAG, "missing result!");
|
||||||
|
@ -32,7 +32,7 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
import org.sufficientlysecure.keychain.remote.AppSettings;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class AppSettingsActivity extends ActionBarActivity {
|
public class AppSettingsActivity extends ActionBarActivity {
|
||||||
@ -158,8 +158,8 @@ public class AppSettingsActivity extends ActionBarActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// if a result has been returned, display a notify
|
// if a result has been returned, display a notify
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
result.createNotify(this).show();
|
result.createNotify(this).show();
|
||||||
} else {
|
} else {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -55,10 +55,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingData;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.OperationLog;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.OperationLog;
|
||||||
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
import org.sufficientlysecure.keychain.service.results.EditKeyResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
||||||
@ -364,7 +364,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
outStream.close();
|
outStream.close();
|
||||||
|
|
||||||
resultData.putParcelable(RESULT_DECRYPT_VERIFY_RESULT, decryptVerifyResult);
|
resultData.putParcelable(DecryptVerifyResult.EXTRA_RESULT, decryptVerifyResult);
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
|
|
||||||
@ -411,7 +411,7 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
|
|
||||||
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
|
||||||
|
|
||||||
resultData.putParcelable(RESULT_DECRYPT_VERIFY_RESULT, decryptVerifyResult);
|
resultData.putParcelable(DecryptVerifyResult.EXTRA_RESULT, decryptVerifyResult);
|
||||||
|
|
||||||
/* Output */
|
/* Output */
|
||||||
OtherHelper.logDebugBundle(resultData, "resultData");
|
OtherHelper.logDebugBundle(resultData, "resultData");
|
||||||
@ -652,27 +652,35 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
for (ImportKeysListEntry entry : entries) {
|
for (ImportKeysListEntry entry : entries) {
|
||||||
try {
|
try {
|
||||||
Keyserver server;
|
Keyserver server;
|
||||||
if (entry.getOrigin() == null) {
|
ArrayList<String> origins = entry.getOrigins();
|
||||||
server = new HkpKeyserver(keyServer);
|
if (origins == null) {
|
||||||
} else if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
|
origins = new ArrayList<String>();
|
||||||
server = new KeybaseKeyserver();
|
|
||||||
} else {
|
|
||||||
server = new HkpKeyserver(entry.getOrigin());
|
|
||||||
}
|
}
|
||||||
|
if (origins.isEmpty()) {
|
||||||
// if available use complete fingerprint for get request
|
origins.add(keyServer);
|
||||||
byte[] downloadedKeyBytes;
|
|
||||||
if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
|
|
||||||
downloadedKeyBytes = server.get(entry.getExtraData()).getBytes();
|
|
||||||
} else if (entry.getFingerprintHex() != null) {
|
|
||||||
downloadedKeyBytes = server.get("0x" + entry.getFingerprintHex()).getBytes();
|
|
||||||
} else {
|
|
||||||
downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes();
|
|
||||||
}
|
}
|
||||||
|
for (String origin : origins) {
|
||||||
|
if (KeybaseKeyserver.ORIGIN.equals(origin)) {
|
||||||
|
server = new KeybaseKeyserver();
|
||||||
|
} else {
|
||||||
|
server = new HkpKeyserver(origin);
|
||||||
|
}
|
||||||
|
Log.d(Constants.TAG, "IMPORTING " + entry.getKeyIdHex() + " FROM: " + server);
|
||||||
|
|
||||||
// save key bytes in entry object for doing the
|
// if available use complete fingerprint for get request
|
||||||
// actual import afterwards
|
byte[] downloadedKeyBytes;
|
||||||
keyRings.add(new ParcelableKeyRing(downloadedKeyBytes, entry.getFingerprintHex()));
|
if (KeybaseKeyserver.ORIGIN.equals(origin)) {
|
||||||
|
downloadedKeyBytes = server.get(entry.getExtraData()).getBytes();
|
||||||
|
} else if (entry.getFingerprintHex() != null) {
|
||||||
|
downloadedKeyBytes = server.get("0x" + entry.getFingerprintHex()).getBytes();
|
||||||
|
} else {
|
||||||
|
downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// save key bytes in entry object for doing the
|
||||||
|
// actual import afterwards
|
||||||
|
keyRings.add(new ParcelableKeyRing(downloadedKeyBytes, entry.getFingerprintHex()));
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendErrorToHandler(e);
|
sendErrorToHandler(e);
|
||||||
}
|
}
|
||||||
@ -813,9 +821,9 @@ public class KeychainIntentService extends IntentService implements Progressable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToHandler(Integer arg1, OperationResultParcel data) {
|
private void sendMessageToHandler(Integer arg1, OperationResult data) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putParcelable(OperationResultParcel.EXTRA_RESULT, data);
|
bundle.putParcelable(OperationResult.EXTRA_RESULT, data);
|
||||||
sendMessageToHandler(arg1, null, bundle);
|
sendMessageToHandler(arg1, null, bundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.service.results;
|
package org.sufficientlysecure.keychain.service.results;
|
||||||
|
|
||||||
public class ConsolidateResult extends OperationResultParcel {
|
public class ConsolidateResult extends OperationResult {
|
||||||
|
|
||||||
public ConsolidateResult(int result, OperationLog log) {
|
public ConsolidateResult(int result, OperationLog log) {
|
||||||
super(result, log);
|
super(result, log);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
* Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -22,10 +23,10 @@ import android.os.Parcel;
|
|||||||
import org.openintents.openpgp.OpenPgpMetadata;
|
import org.openintents.openpgp.OpenPgpMetadata;
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
|
|
||||||
public class DecryptVerifyResult extends OperationResultParcel {
|
public class DecryptVerifyResult extends OperationResult {
|
||||||
|
|
||||||
// the fourth bit indicates a "data pending" result!
|
// the fourth bit indicates a "data pending" result! (it's also a form of non-success)
|
||||||
public static final int RESULT_PENDING = 8;
|
public static final int RESULT_PENDING = RESULT_ERROR +8;
|
||||||
|
|
||||||
// fifth to sixth bit in addition indicate specific type of pending
|
// fifth to sixth bit in addition indicate specific type of pending
|
||||||
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING +16;
|
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING +16;
|
||||||
|
@ -23,7 +23,7 @@ import android.os.Parcel;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||||
|
|
||||||
public class EditKeyResult extends OperationResultParcel {
|
public class EditKeyResult extends OperationResult {
|
||||||
|
|
||||||
private transient UncachedKeyRing mRing;
|
private transient UncachedKeyRing mRing;
|
||||||
public final long mRingMasterKeyId;
|
public final long mRingMasterKeyId;
|
||||||
|
@ -34,7 +34,7 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.ui.LogDisplayActivity;
|
import org.sufficientlysecure.keychain.ui.LogDisplayActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.LogDisplayFragment;
|
import org.sufficientlysecure.keychain.ui.LogDisplayFragment;
|
||||||
|
|
||||||
public class ImportKeyResult extends OperationResultParcel {
|
public class ImportKeyResult extends OperationResult {
|
||||||
|
|
||||||
public final int mNewKeys, mUpdatedKeys, mBadKeys, mSecret;
|
public final int mNewKeys, mUpdatedKeys, mBadKeys, mSecret;
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public class ImportKeyResult extends OperationResultParcel {
|
|||||||
int duration, color;
|
int duration, color;
|
||||||
|
|
||||||
// Not an overall failure
|
// Not an overall failure
|
||||||
if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) {
|
if ((resultType & OperationResult.RESULT_ERROR) == 0) {
|
||||||
String withWarnings;
|
String withWarnings;
|
||||||
|
|
||||||
duration = Duration.EXTRA_LONG;
|
duration = Duration.EXTRA_LONG;
|
||||||
|
@ -52,7 +52,7 @@ import java.util.List;
|
|||||||
* TODO ideally, this class should be abstract, and all actual results of a specific subclass
|
* TODO ideally, this class should be abstract, and all actual results of a specific subclass
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OperationResultParcel implements Parcelable {
|
public abstract class OperationResult implements Parcelable {
|
||||||
|
|
||||||
public static final String EXTRA_RESULT = "operation_result";
|
public static final String EXTRA_RESULT = "operation_result";
|
||||||
|
|
||||||
@ -71,12 +71,12 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
/// A list of log entries tied to the operation result.
|
/// A list of log entries tied to the operation result.
|
||||||
final OperationLog mLog;
|
final OperationLog mLog;
|
||||||
|
|
||||||
public OperationResultParcel(int result, OperationLog log) {
|
public OperationResult(int result, OperationLog log) {
|
||||||
mResult = result;
|
mResult = result;
|
||||||
mLog = log;
|
mLog = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OperationResultParcel(Parcel source) {
|
public OperationResult(Parcel source) {
|
||||||
mResult = source.readInt();
|
mResult = source.readInt();
|
||||||
mLog = new OperationLog();
|
mLog = new OperationLog();
|
||||||
mLog.addAll(source.createTypedArrayList(LogEntryParcel.CREATOR));
|
mLog.addAll(source.createTypedArrayList(LogEntryParcel.CREATOR));
|
||||||
@ -156,25 +156,22 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
|
|
||||||
public SuperCardToast createNotify(final Activity activity) {
|
public SuperCardToast createNotify(final Activity activity) {
|
||||||
|
|
||||||
String str;
|
|
||||||
int color;
|
int color;
|
||||||
|
|
||||||
|
// Take the last message as string
|
||||||
|
String str = activity.getString(mLog.getLast().mType.getMsgId());
|
||||||
|
|
||||||
// Not an overall failure
|
// Not an overall failure
|
||||||
if (cancelled()) {
|
if (cancelled()) {
|
||||||
color = Style.RED;
|
color = Style.RED;
|
||||||
str = "operation cancelled!";
|
|
||||||
} else if (success()) {
|
} else if (success()) {
|
||||||
if (getLog().containsWarnings()) {
|
if (getLog().containsWarnings()) {
|
||||||
color = Style.ORANGE;
|
color = Style.ORANGE;
|
||||||
} else {
|
} else {
|
||||||
color = Style.GREEN;
|
color = Style.GREEN;
|
||||||
}
|
}
|
||||||
str = "operation succeeded!";
|
|
||||||
// str = activity.getString(R.string.import_error);
|
|
||||||
} else {
|
} else {
|
||||||
color = Style.RED;
|
color = Style.RED;
|
||||||
str = "operation failed";
|
|
||||||
// str = activity.getString(R.string.import_error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean button = getLog() != null && !getLog().isEmpty();
|
boolean button = getLog() != null && !getLog().isEmpty();
|
||||||
@ -197,7 +194,7 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
public void onClick(View view, Parcelable token) {
|
public void onClick(View view, Parcelable token) {
|
||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
activity, LogDisplayActivity.class);
|
activity, LogDisplayActivity.class);
|
||||||
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResultParcel.this);
|
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, OperationResult.this);
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,6 +495,11 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
MSG_SE_SIGCRYPTING (R.string.msg_se_sigcrypting),
|
MSG_SE_SIGCRYPTING (R.string.msg_se_sigcrypting),
|
||||||
MSG_SE_SYMMETRIC (R.string.msg_se_symmetric),
|
MSG_SE_SYMMETRIC (R.string.msg_se_symmetric),
|
||||||
|
|
||||||
|
MSG_CRT_UPLOAD_SUCCESS (R.string.msg_crt_upload_success),
|
||||||
|
MSG_CRT_SUCCESS (R.string.msg_crt_success),
|
||||||
|
|
||||||
|
MSG_ACC_SAVED (R.string.api_settings_save)
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final int mMsgId;
|
private final int mMsgId;
|
||||||
@ -533,27 +535,17 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() {
|
|
||||||
public OperationResultParcel createFromParcel(final Parcel source) {
|
|
||||||
return new OperationResultParcel(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationResultParcel[] newArray(final int size) {
|
|
||||||
return new OperationResultParcel[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static class OperationLog implements Iterable<LogEntryParcel> {
|
public static class OperationLog implements Iterable<LogEntryParcel> {
|
||||||
|
|
||||||
private final List<LogEntryParcel> mParcels = new ArrayList<LogEntryParcel>();
|
private final List<LogEntryParcel> mParcels = new ArrayList<LogEntryParcel>();
|
||||||
|
|
||||||
/// Simple convenience method
|
/// Simple convenience method
|
||||||
public void add(LogLevel level, LogType type, int indent, Object... parameters) {
|
public void add(LogLevel level, LogType type, int indent, Object... parameters) {
|
||||||
mParcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, parameters));
|
mParcels.add(new OperationResult.LogEntryParcel(level, type, indent, parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(LogLevel level, LogType type, int indent) {
|
public void add(LogLevel level, LogType type, int indent) {
|
||||||
mParcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, (Object[]) null));
|
mParcels.add(new OperationResult.LogEntryParcel(level, type, indent, (Object[]) null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsType(LogType type) {
|
public boolean containsType(LogType type) {
|
@ -23,7 +23,7 @@ import android.os.Parcel;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||||
|
|
||||||
public class SaveKeyringResult extends OperationResultParcel {
|
public class SaveKeyringResult extends OperationResult {
|
||||||
|
|
||||||
public final long mRingMasterKeyId;
|
public final long mRingMasterKeyId;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
* Copyright (C) 2014 Vincent Breitmoser <v.breitmoser@mugenguild.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,15 +19,12 @@ package org.sufficientlysecure.keychain.service.results;
|
|||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpMetadata;
|
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class SignEncryptResult extends OperationResultParcel {
|
public class SignEncryptResult extends OperationResult {
|
||||||
|
|
||||||
// the fourth bit indicates a "data pending" result!
|
// the fourth bit indicates a "data pending" result! (it's also a form of non-success)
|
||||||
public static final int RESULT_PENDING = 8;
|
public static final int RESULT_PENDING = RESULT_ERROR +8;
|
||||||
|
|
||||||
// fifth to sixth bit in addition indicate specific type of pending
|
// fifth to sixth bit in addition indicate specific type of pending
|
||||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING +16;
|
public static final int RESULT_PENDING_NFC = RESULT_PENDING +16;
|
||||||
|
@ -27,7 +27,7 @@ import com.github.johnpersano.supertoasts.util.Style;
|
|||||||
|
|
||||||
/** This is a simple subclass meant to contain only a single log message. This log
|
/** This is a simple subclass meant to contain only a single log message. This log
|
||||||
* message is also shown without a log button in the createNotify SuperToast. */
|
* message is also shown without a log button in the createNotify SuperToast. */
|
||||||
public class SingletonResult extends OperationResultParcel {
|
public class SingletonResult extends OperationResult {
|
||||||
|
|
||||||
/** Construct from a parcel - trivial because we have no extra data. */
|
/** Construct from a parcel - trivial because we have no extra data. */
|
||||||
public SingletonResult(Parcel source) {
|
public SingletonResult(Parcel source) {
|
||||||
|
@ -54,8 +54,11 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
|
import org.sufficientlysecure.keychain.service.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
|
import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
|
||||||
@ -327,12 +330,10 @@ public class CertifyKeyFragment extends LoaderFragment
|
|||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||||
|
|
||||||
// Notify.showNotify(CertifyKeyActivity.this, R.string.key_certify_success,
|
SingletonResult result = new SingletonResult(
|
||||||
// Notify.Style.INFO);
|
SingletonResult.RESULT_OK, LogLevel.OK, LogType.MSG_CRT_SUCCESS);
|
||||||
|
|
||||||
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
|
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
||||||
mActivity.setResult(CertifyKeyActivity.RESULT_OK, intent);
|
mActivity.setResult(CertifyKeyActivity.RESULT_OK, intent);
|
||||||
|
|
||||||
// check if we need to send the key to the server or not
|
// check if we need to send the key to the server or not
|
||||||
@ -383,12 +384,10 @@ public class CertifyKeyFragment extends LoaderFragment
|
|||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||||
//Notify.showNotify(CertifyKeyActivity.this, R.string.key_send_success,
|
SingletonResult result = new SingletonResult(SingletonResult.RESULT_OK,
|
||||||
//Notify.Style.INFO);
|
LogLevel.OK, LogType.MSG_CRT_UPLOAD_SUCCESS);
|
||||||
|
|
||||||
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
|
intent.putExtra(SingletonResult.EXTRA_RESULT, result);
|
||||||
mActivity.setResult(CertifyKeyActivity.RESULT_OK, intent);
|
mActivity.setResult(CertifyKeyActivity.RESULT_OK, intent);
|
||||||
mActivity.finish();
|
mActivity.finish();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
|
||||||
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
import org.sufficientlysecure.keychain.service.results.SaveKeyringResult;
|
||||||
@ -141,7 +141,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final SaveKeyringResult result =
|
final SaveKeyringResult result =
|
||||||
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
|
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
Log.e(Constants.TAG, "result == null");
|
Log.e(Constants.TAG, "result == null");
|
||||||
return;
|
return;
|
||||||
@ -152,7 +152,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
uploadKey(result);
|
uploadKey(result);
|
||||||
} else {
|
} else {
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
data.putExtra(OperationResultParcel.EXTRA_RESULT, result);
|
data.putExtra(OperationResult.EXTRA_RESULT, result);
|
||||||
getActivity().setResult(Activity.RESULT_OK, data);
|
getActivity().setResult(Activity.RESULT_OK, data);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
|
|
||||||
// upload to favorite keyserver
|
// upload to favorite keyserver
|
||||||
String keyserver = Preferences.getPreferences(getActivity()).getKeyServers()[0];
|
String keyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver();
|
||||||
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver);
|
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver);
|
||||||
|
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||||
@ -223,7 +223,7 @@ public class CreateKeyFinalFragment extends Fragment {
|
|||||||
//Notify.Style.INFO);
|
//Notify.Style.INFO);
|
||||||
|
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
data.putExtra(OperationResultParcel.EXTRA_RESULT, saveKeyResult);
|
data.putExtra(OperationResult.EXTRA_RESULT, saveKeyResult);
|
||||||
getActivity().setResult(Activity.RESULT_OK, data);
|
getActivity().setResult(Activity.RESULT_OK, data);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
DecryptVerifyResult result =
|
DecryptVerifyResult result =
|
||||||
returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT);
|
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
switch (result.getResult()) {
|
switch (result.getResult()) {
|
||||||
case DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE:
|
case DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE:
|
||||||
@ -285,7 +285,7 @@ public class DecryptFilesFragment extends DecryptFragment {
|
|||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
DecryptVerifyResult result =
|
DecryptVerifyResult result =
|
||||||
returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT);
|
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
if (result.isPending()) {
|
if (result.isPending()) {
|
||||||
switch (result.getResult()) {
|
switch (result.getResult()) {
|
||||||
|
@ -127,7 +127,7 @@ public class DecryptTextFragment extends DecryptFragment {
|
|||||||
Bundle returnData = message.getData();
|
Bundle returnData = message.getData();
|
||||||
|
|
||||||
DecryptVerifyResult result =
|
DecryptVerifyResult result =
|
||||||
returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT);
|
returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);
|
||||||
|
|
||||||
if (result.isPending()) {
|
if (result.isPending()) {
|
||||||
switch (result.getResult()) {
|
switch (result.getResult()) {
|
||||||
|
@ -48,9 +48,9 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogType;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogType;
|
||||||
import org.sufficientlysecure.keychain.service.results.SingletonResult;
|
import org.sufficientlysecure.keychain.service.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
@ -541,8 +541,8 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
if (returnData == null) {
|
if (returnData == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final OperationResultParcel result =
|
final OperationResult result =
|
||||||
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
|
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
// if good -> finish, return result to showkey and display there!
|
// if good -> finish, return result to showkey and display there!
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
|
intent.putExtra(OperationResult.EXTRA_RESULT, result);
|
||||||
getActivity().setResult(EditKeyActivity.RESULT_OK, intent);
|
getActivity().setResult(EditKeyActivity.RESULT_OK, intent);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
// Prepare an intent with an EXTRA_RESULT
|
// Prepare an intent with an EXTRA_RESULT
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResultParcel.EXTRA_RESULT,
|
intent.putExtra(OperationResult.EXTRA_RESULT,
|
||||||
new SingletonResult(SingletonResult.RESULT_ERROR, LogLevel.ERROR, reason));
|
new SingletonResult(SingletonResult.RESULT_ERROR, LogLevel.ERROR, reason));
|
||||||
|
|
||||||
// Finish with result
|
// Finish with result
|
||||||
|
@ -46,7 +46,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.service.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||||
@ -68,8 +68,6 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
+ "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN";
|
+ "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN";
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX
|
public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "IMPORT_KEY_FROM_FILE_AND_RETURN";
|
+ "IMPORT_KEY_FROM_FILE_AND_RETURN";
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_KEYBASE = Constants.INTENT_PREFIX
|
|
||||||
+ "IMPORT_KEY_FROM_KEYBASE";
|
|
||||||
|
|
||||||
// Actions for internal use only:
|
// Actions for internal use only:
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_FILE = Constants.INTENT_PREFIX
|
public static final String ACTION_IMPORT_KEY_FROM_FILE = Constants.INTENT_PREFIX
|
||||||
@ -101,12 +99,11 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
public static final int VIEW_PAGER_HEIGHT = 64; // dp
|
public static final int VIEW_PAGER_HEIGHT = 64; // dp
|
||||||
|
|
||||||
private static final int ALL_TABS = -1;
|
private static final int ALL_TABS = -1;
|
||||||
private static final int TAB_KEYSERVER = 0;
|
private static final int TAB_CLOUD = 0;
|
||||||
private static final int TAB_QR_CODE = 1;
|
private static final int TAB_QR_CODE = 1;
|
||||||
private static final int TAB_FILE = 2;
|
private static final int TAB_FILE = 2;
|
||||||
private static final int TAB_KEYBASE = 3;
|
|
||||||
|
|
||||||
private int mSwitchToTab = TAB_KEYSERVER;
|
private int mSwitchToTab = TAB_CLOUD;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -193,8 +190,8 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
if (query != null && query.length() > 0) {
|
if (query != null && query.length() > 0) {
|
||||||
// display keyserver fragment with query
|
// display keyserver fragment with query
|
||||||
serverBundle = new Bundle();
|
serverBundle = new Bundle();
|
||||||
serverBundle.putString(ImportKeysServerFragment.ARG_QUERY, query);
|
serverBundle.putString(ImportKeysCloudFragment.ARG_QUERY, query);
|
||||||
mSwitchToTab = TAB_KEYSERVER;
|
mSwitchToTab = TAB_CLOUD;
|
||||||
|
|
||||||
// action: search immediately
|
// action: search immediately
|
||||||
startListFragment(savedInstanceState, null, null, query);
|
startListFragment(savedInstanceState, null, null, query);
|
||||||
@ -214,11 +211,11 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// display keyserver fragment with query
|
// display keyserver fragment with query
|
||||||
serverBundle = new Bundle();
|
serverBundle = new Bundle();
|
||||||
serverBundle.putString(ImportKeysServerFragment.ARG_QUERY, query);
|
serverBundle.putString(ImportKeysCloudFragment.ARG_QUERY, query);
|
||||||
serverBundle.putBoolean(ImportKeysServerFragment.ARG_DISABLE_QUERY_EDIT, true);
|
serverBundle.putBoolean(ImportKeysCloudFragment.ARG_DISABLE_QUERY_EDIT, true);
|
||||||
// display server tab only
|
// display server tab only
|
||||||
showTabOnly = TAB_KEYSERVER;
|
showTabOnly = TAB_CLOUD;
|
||||||
mSwitchToTab = TAB_KEYSERVER;
|
mSwitchToTab = TAB_CLOUD;
|
||||||
|
|
||||||
// action: search immediately
|
// action: search immediately
|
||||||
startListFragment(savedInstanceState, null, null, query);
|
startListFragment(savedInstanceState, null, null, query);
|
||||||
@ -257,12 +254,6 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
// NOTE: this only displays the appropriate fragment, no actions are taken
|
||||||
mSwitchToTab = TAB_QR_CODE;
|
mSwitchToTab = TAB_QR_CODE;
|
||||||
|
|
||||||
// no immediate actions!
|
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
|
||||||
} else if (ACTION_IMPORT_KEY_FROM_KEYBASE.equals(action)) {
|
|
||||||
// NOTE: this only displays the appropriate fragment, no actions are taken
|
|
||||||
mSwitchToTab = TAB_KEYBASE;
|
|
||||||
|
|
||||||
// no immediate actions!
|
// no immediate actions!
|
||||||
startListFragment(savedInstanceState, null, null, null);
|
startListFragment(savedInstanceState, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
@ -299,19 +290,17 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
switch (showTabOnly) {
|
switch (showTabOnly) {
|
||||||
case ALL_TABS:
|
case ALL_TABS:
|
||||||
// show all tabs
|
// show default tabs
|
||||||
mTabsAdapter.addTab(ImportKeysServerFragment.class,
|
mTabsAdapter.addTab(ImportKeysCloudFragment.class,
|
||||||
serverBundle, getString(R.string.import_tab_keyserver));
|
serverBundle, getString(R.string.import_tab_cloud));
|
||||||
mTabsAdapter.addTab(ImportKeysQrCodeFragment.class,
|
mTabsAdapter.addTab(ImportKeysQrCodeFragment.class,
|
||||||
null, getString(R.string.import_tab_qr_code));
|
null, getString(R.string.import_tab_qr_code));
|
||||||
mTabsAdapter.addTab(ImportKeysFileFragment.class,
|
mTabsAdapter.addTab(ImportKeysFileFragment.class,
|
||||||
null, getString(R.string.import_tab_direct));
|
null, getString(R.string.import_tab_direct));
|
||||||
mTabsAdapter.addTab(ImportKeysKeybaseFragment.class,
|
|
||||||
null, getString(R.string.import_tab_keybase));
|
|
||||||
break;
|
break;
|
||||||
case TAB_KEYSERVER:
|
case TAB_CLOUD:
|
||||||
mTabsAdapter.addTab(ImportKeysServerFragment.class,
|
mTabsAdapter.addTab(ImportKeysCloudFragment.class,
|
||||||
serverBundle, getString(R.string.import_tab_keyserver));
|
serverBundle, getString(R.string.import_tab_cloud));
|
||||||
break;
|
break;
|
||||||
case TAB_QR_CODE:
|
case TAB_QR_CODE:
|
||||||
mTabsAdapter.addTab(ImportKeysQrCodeFragment.class,
|
mTabsAdapter.addTab(ImportKeysQrCodeFragment.class,
|
||||||
@ -321,10 +310,6 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
mTabsAdapter.addTab(ImportKeysFileFragment.class,
|
mTabsAdapter.addTab(ImportKeysFileFragment.class,
|
||||||
null, getString(R.string.import_tab_direct));
|
null, getString(R.string.import_tab_direct));
|
||||||
break;
|
break;
|
||||||
case TAB_KEYBASE:
|
|
||||||
mTabsAdapter.addTab(ImportKeysKeybaseFragment.class,
|
|
||||||
null, getString(R.string.import_tab_keybase));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update layout after operations
|
// update layout after operations
|
||||||
@ -380,18 +365,17 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
if (mViewPager.getAdapter() != null)
|
if (mViewPager.getAdapter() != null)
|
||||||
mViewPager.setAdapter(null);
|
mViewPager.setAdapter(null);
|
||||||
mViewPager.setAdapter(mTabsAdapter);
|
mViewPager.setAdapter(mTabsAdapter);
|
||||||
mViewPager.setCurrentItem(TAB_KEYSERVER);
|
mViewPager.setCurrentItem(TAB_CLOUD);
|
||||||
|
|
||||||
ImportKeysServerFragment f = (ImportKeysServerFragment)
|
ImportKeysCloudFragment f = (ImportKeysCloudFragment)
|
||||||
getActiveFragment(mViewPager, TAB_KEYSERVER);
|
getActiveFragment(mViewPager, TAB_CLOUD);
|
||||||
|
|
||||||
// ask favorite keyserver
|
// search config
|
||||||
String keyserver = Preferences.getPreferences(ImportKeysActivity.this).getKeyServers()[0];
|
Preferences prefs = Preferences.getPreferences(ImportKeysActivity.this);
|
||||||
|
Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
|
||||||
|
|
||||||
// set fields of ImportKeysServerFragment
|
|
||||||
f.setQueryAndKeyserver(query, keyserver);
|
|
||||||
// search directly
|
// search directly
|
||||||
loadCallback(new ImportKeysListFragment.KeyserverLoaderState(query, keyserver));
|
loadCallback(new ImportKeysListFragment.CloudLoaderState(query, cloudPrefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://stackoverflow.com/a/9293207
|
// http://stackoverflow.com/a/9293207
|
||||||
@ -459,7 +443,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ImportKeyResult result =
|
final ImportKeyResult result =
|
||||||
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
|
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
Log.e(Constants.TAG, "result == null");
|
Log.e(Constants.TAG, "result == null");
|
||||||
return;
|
return;
|
||||||
@ -522,8 +506,8 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
Log.e(Constants.TAG, "Problem writing cache file", e);
|
Log.e(Constants.TAG, "Problem writing cache file", e);
|
||||||
Notify.showNotify(this, "Problem writing cache file!", Notify.Style.ERROR);
|
Notify.showNotify(this, "Problem writing cache file!", Notify.Style.ERROR);
|
||||||
}
|
}
|
||||||
} else if (ls instanceof ImportKeysListFragment.KeyserverLoaderState) {
|
} else if (ls instanceof ImportKeysListFragment.CloudLoaderState) {
|
||||||
ImportKeysListFragment.KeyserverLoaderState sls = (ImportKeysListFragment.KeyserverLoaderState) ls;
|
ImportKeysListFragment.CloudLoaderState sls = (ImportKeysListFragment.CloudLoaderState) ls;
|
||||||
|
|
||||||
// Send all information needed to service to query keys in other thread
|
// Send all information needed to service to query keys in other thread
|
||||||
Intent intent = new Intent(this, KeychainIntentService.class);
|
Intent intent = new Intent(this, KeychainIntentService.class);
|
||||||
@ -533,7 +517,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
// fill values for this action
|
// fill values for this action
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
|
|
||||||
data.putString(KeychainIntentService.DOWNLOAD_KEY_SERVER, sls.keyserver);
|
data.putString(KeychainIntentService.DOWNLOAD_KEY_SERVER, sls.mCloudPrefs.keyserver);
|
||||||
|
|
||||||
// get selected key entries
|
// get selected key entries
|
||||||
ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedEntries();
|
ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedEntries();
|
||||||
@ -550,31 +534,6 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// start service with intent
|
// start service with intent
|
||||||
startService(intent);
|
startService(intent);
|
||||||
} else if (ls instanceof ImportKeysListFragment.KeybaseLoaderState) {
|
|
||||||
// Send all information needed to service to query keys in other thread
|
|
||||||
Intent intent = new Intent(this, KeychainIntentService.class);
|
|
||||||
|
|
||||||
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYBASE_KEYS);
|
|
||||||
|
|
||||||
// fill values for this action
|
|
||||||
Bundle data = new Bundle();
|
|
||||||
|
|
||||||
// get selected key entries
|
|
||||||
ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedEntries();
|
|
||||||
data.putParcelableArrayList(KeychainIntentService.DOWNLOAD_KEY_LIST, selectedEntries);
|
|
||||||
|
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
|
||||||
|
|
||||||
// Create a new Messenger for the communication back
|
|
||||||
Messenger messenger = new Messenger(saveHandler);
|
|
||||||
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
|
||||||
|
|
||||||
// show progress dialog
|
|
||||||
saveHandler.showProgressDialog(this);
|
|
||||||
|
|
||||||
// start service with intent
|
|
||||||
startService(intent);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Notify.showNotify(this, R.string.error_nothing_import, Notify.Style.ERROR);
|
Notify.showNotify(this, R.string.error_nothing_import, Notify.Style.ERROR);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@ -30,8 +31,6 @@ import android.view.inputmethod.EditorInfo;
|
|||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
@ -42,9 +41,8 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ImportKeysServerFragment extends Fragment {
|
public class ImportKeysCloudFragment extends Fragment {
|
||||||
public static final String ARG_QUERY = "query";
|
public static final String ARG_QUERY = "query";
|
||||||
public static final String ARG_KEYSERVER = "keyserver";
|
|
||||||
public static final String ARG_DISABLE_QUERY_EDIT = "disable_query_edit";
|
public static final String ARG_DISABLE_QUERY_EDIT = "disable_query_edit";
|
||||||
|
|
||||||
private ImportKeysActivity mImportActivity;
|
private ImportKeysActivity mImportActivity;
|
||||||
@ -52,19 +50,16 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
private View mSearchButton;
|
private View mSearchButton;
|
||||||
private AutoCompleteTextView mQueryEditText;
|
private AutoCompleteTextView mQueryEditText;
|
||||||
private View mConfigButton;
|
private View mConfigButton;
|
||||||
private View mConfigLayout;
|
|
||||||
private Spinner mServerSpinner;
|
|
||||||
private ArrayAdapter<String> mServerAdapter;
|
private ArrayAdapter<String> mServerAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new instance of this fragment
|
* Creates new instance of this fragment
|
||||||
*/
|
*/
|
||||||
public static ImportKeysServerFragment newInstance(String query, String keyserver) {
|
public static ImportKeysCloudFragment newInstance(String query, String keyserver, boolean doKeyserver, boolean doKeybase) {
|
||||||
ImportKeysServerFragment frag = new ImportKeysServerFragment();
|
ImportKeysCloudFragment frag = new ImportKeysCloudFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(ARG_QUERY, query);
|
args.putString(ARG_QUERY, query);
|
||||||
args.putString(ARG_KEYSERVER, keyserver);
|
|
||||||
|
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
|
|
||||||
@ -76,26 +71,11 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.import_keys_server_fragment, container, false);
|
View view = inflater.inflate(R.layout.import_keys_cloud_fragment, container, false);
|
||||||
|
|
||||||
mSearchButton = view.findViewById(R.id.import_server_search);
|
mSearchButton = view.findViewById(R.id.cloud_import_server_search);
|
||||||
mQueryEditText = (AutoCompleteTextView) view.findViewById(R.id.import_server_query);
|
mQueryEditText = (AutoCompleteTextView) view.findViewById(R.id.cloud_import_server_query);
|
||||||
mConfigButton = view.findViewById(R.id.import_server_config_button);
|
mConfigButton = view.findViewById(R.id.cloud_import_server_config_button);
|
||||||
mConfigLayout = view.findViewById(R.id.import_server_config);
|
|
||||||
mServerSpinner = (Spinner) view.findViewById(R.id.import_server_spinner);
|
|
||||||
|
|
||||||
// add keyservers to spinner
|
|
||||||
mServerAdapter = new ArrayAdapter<String>(getActivity(),
|
|
||||||
android.R.layout.simple_spinner_item, Preferences.getPreferences(getActivity())
|
|
||||||
.getKeyServers()
|
|
||||||
);
|
|
||||||
mServerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
||||||
mServerSpinner.setAdapter(mServerAdapter);
|
|
||||||
if (mServerAdapter.getCount() > 0) {
|
|
||||||
mServerSpinner.setSelection(0);
|
|
||||||
} else {
|
|
||||||
mSearchButton.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> namesAndEmails = ContactHelper.getContactNames(getActivity());
|
List<String> namesAndEmails = ContactHelper.getContactNames(getActivity());
|
||||||
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
namesAndEmails.addAll(ContactHelper.getContactMails(getActivity()));
|
||||||
@ -110,9 +90,7 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
mSearchButton.setOnClickListener(new OnClickListener() {
|
mSearchButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
String query = mQueryEditText.getText().toString();
|
search(mQueryEditText.getText().toString());
|
||||||
String keyServer = (String) mServerSpinner.getSelectedItem();
|
|
||||||
search(query, keyServer);
|
|
||||||
|
|
||||||
// close keyboard after pressing search
|
// close keyboard after pressing search
|
||||||
InputMethodManager imm =
|
InputMethodManager imm =
|
||||||
@ -125,9 +103,7 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
String query = mQueryEditText.getText().toString();
|
search(mQueryEditText.getText().toString());
|
||||||
String keyServer = (String) mServerSpinner.getSelectedItem();
|
|
||||||
search(query, keyServer);
|
|
||||||
|
|
||||||
// Don't return true to let the keyboard close itself after pressing search
|
// Don't return true to let the keyboard close itself after pressing search
|
||||||
return false;
|
return false;
|
||||||
@ -139,11 +115,11 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
mConfigButton.setOnClickListener(new OnClickListener() {
|
mConfigButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (mImportActivity.getViewPagerHeight() > ImportKeysActivity.VIEW_PAGER_HEIGHT) {
|
Intent i = new Intent(mImportActivity, PreferencesActivity.class);
|
||||||
mImportActivity.resizeViewPager(ImportKeysActivity.VIEW_PAGER_HEIGHT);
|
// GRR, for some reason I can’t set the Action or I get an incomprehensible
|
||||||
} else {
|
// exception about “modern two-pane layouts”
|
||||||
mImportActivity.resizeViewPager(ImportKeysActivity.VIEW_PAGER_HEIGHT + 41);
|
// i.setAction(PreferencesActivity.ACTION_PREFS_CLOUD);
|
||||||
}
|
startActivity(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -163,14 +139,6 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
Log.d(Constants.TAG, "query: " + query);
|
Log.d(Constants.TAG, "query: " + query);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getArguments().containsKey(ARG_KEYSERVER)) {
|
|
||||||
String keyserver = getArguments().getString(ARG_KEYSERVER);
|
|
||||||
int keyserverPos = mServerAdapter.getPosition(keyserver);
|
|
||||||
mServerSpinner.setSelection(keyserverPos);
|
|
||||||
|
|
||||||
Log.d(Constants.TAG, "keyserver: " + keyserver);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArguments().getBoolean(ARG_DISABLE_QUERY_EDIT, false)) {
|
if (getArguments().getBoolean(ARG_DISABLE_QUERY_EDIT, false)) {
|
||||||
mQueryEditText.setEnabled(false);
|
mQueryEditText.setEnabled(false);
|
||||||
}
|
}
|
||||||
@ -184,14 +152,9 @@ public class ImportKeysServerFragment extends Fragment {
|
|||||||
mImportActivity = (ImportKeysActivity) activity;
|
mImportActivity = (ImportKeysActivity) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void search(String query, String keyserver) {
|
private void search(String query) {
|
||||||
mImportActivity.loadCallback(new ImportKeysListFragment.KeyserverLoaderState(query, keyserver));
|
Preferences prefs = Preferences.getPreferences(getActivity());
|
||||||
}
|
mImportActivity.loadCallback(new ImportKeysListFragment.CloudLoaderState(query, prefs.getCloudSearchPrefs()));
|
||||||
|
|
||||||
public void setQueryAndKeyserver(String query, String keyserver) {
|
|
||||||
mQueryEditText.setText(query, TextView.BufferType.EDITABLE);
|
|
||||||
int keyServerPos = mServerAdapter.getPosition(keyserver);
|
|
||||||
mServerSpinner.setSelection(keyServerPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,122 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Import public keys from the Keybase.io directory. First cut: just raw search.
|
|
||||||
* TODO: make a pick list of the people you’re following on keybase
|
|
||||||
*/
|
|
||||||
public class ImportKeysKeybaseFragment extends Fragment {
|
|
||||||
|
|
||||||
private ImportKeysActivity mImportActivity;
|
|
||||||
private View mSearchButton;
|
|
||||||
private EditText mQueryEditText;
|
|
||||||
|
|
||||||
public static final String ARG_QUERY = "query";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new instance of this fragment
|
|
||||||
*/
|
|
||||||
public static ImportKeysKeybaseFragment newInstance() {
|
|
||||||
ImportKeysKeybaseFragment frag = new ImportKeysKeybaseFragment();
|
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
frag.setArguments(args);
|
|
||||||
|
|
||||||
return frag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inflate the layout for this fragment
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View view = inflater.inflate(R.layout.import_keys_keybase_fragment, container, false);
|
|
||||||
|
|
||||||
mQueryEditText = (EditText) view.findViewById(R.id.import_keybase_query);
|
|
||||||
|
|
||||||
mSearchButton = view.findViewById(R.id.import_keybase_search);
|
|
||||||
mSearchButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String query = mQueryEditText.getText().toString();
|
|
||||||
search(query);
|
|
||||||
|
|
||||||
// close keyboard after pressing search
|
|
||||||
InputMethodManager imm =
|
|
||||||
(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mQueryEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
|
||||||
String query = mQueryEditText.getText().toString();
|
|
||||||
search(query);
|
|
||||||
|
|
||||||
// Don't return true to let the keyboard close itself after pressing search
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
|
||||||
super.onActivityCreated(savedInstanceState);
|
|
||||||
|
|
||||||
// set displayed values
|
|
||||||
if (getArguments() != null) {
|
|
||||||
if (getArguments().containsKey(ARG_QUERY)) {
|
|
||||||
String query = getArguments().getString(ARG_QUERY);
|
|
||||||
mQueryEditText.setText(query, TextView.BufferType.EDITABLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
|
|
||||||
mImportActivity = (ImportKeysActivity) activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void search(String query) {
|
|
||||||
mImportActivity.loadCallback(new ImportKeysListFragment.KeybaseLoaderState(query));
|
|
||||||
}
|
|
||||||
}
|
|
@ -37,9 +37,8 @@ import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|||||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.AsyncTaskResultWrapper;
|
import org.sufficientlysecure.keychain.ui.adapter.AsyncTaskResultWrapper;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListKeybaseLoader;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListCloudLoader;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader;
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListServerLoader;
|
|
||||||
import org.sufficientlysecure.keychain.util.InputData;
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Notify;
|
import org.sufficientlysecure.keychain.util.Notify;
|
||||||
@ -63,8 +62,7 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
private LoaderState mLoaderState;
|
private LoaderState mLoaderState;
|
||||||
|
|
||||||
private static final int LOADER_ID_BYTES = 0;
|
private static final int LOADER_ID_BYTES = 0;
|
||||||
private static final int LOADER_ID_SERVER_QUERY = 1;
|
private static final int LOADER_ID_CLOUD = 1;
|
||||||
private static final int LOADER_ID_KEYBASE = 2;
|
|
||||||
|
|
||||||
private LongSparseArray<ParcelableKeyRing> mCachedKeyData;
|
private LongSparseArray<ParcelableKeyRing> mCachedKeyData;
|
||||||
|
|
||||||
@ -118,21 +116,13 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public class KeyserverLoaderState extends LoaderState {
|
static public class CloudLoaderState extends LoaderState {
|
||||||
String serverQuery;
|
Preferences.CloudSearchPrefs mCloudPrefs;
|
||||||
String keyserver;
|
String mServerQuery;
|
||||||
|
|
||||||
KeyserverLoaderState(String serverQuery, String keyserver) {
|
CloudLoaderState(String serverQuery, Preferences.CloudSearchPrefs cloudPrefs) {
|
||||||
this.serverQuery = serverQuery;
|
mServerQuery = serverQuery;
|
||||||
this.keyserver = keyserver;
|
mCloudPrefs = cloudPrefs;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static public class KeybaseLoaderState extends LoaderState {
|
|
||||||
String keybaseQuery;
|
|
||||||
|
|
||||||
KeybaseLoaderState(String keybaseQuery) {
|
|
||||||
this.keybaseQuery = keybaseQuery;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +151,8 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
} else if (query != null) {
|
} else if (query != null) {
|
||||||
// TODO: this is used when updating a key.
|
// TODO: this is used when updating a key.
|
||||||
// Currently it simply uses keyserver nr 0
|
// Currently it simply uses keyserver nr 0
|
||||||
String keyserver = Preferences.getPreferences(getActivity())
|
Preferences prefs = Preferences.getPreferences(getActivity());
|
||||||
.getKeyServers()[0];
|
mLoaderState = new CloudLoaderState(query, prefs.getCloudSearchPrefs());
|
||||||
mLoaderState = new KeyserverLoaderState(query, keyserver);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getListView().setOnTouchListener(new OnTouchListener() {
|
getListView().setOnTouchListener(new OnTouchListener() {
|
||||||
@ -202,11 +191,8 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
if (getLoaderManager().getLoader(LOADER_ID_BYTES) != null) {
|
if (getLoaderManager().getLoader(LOADER_ID_BYTES) != null) {
|
||||||
getLoaderManager().destroyLoader(LOADER_ID_BYTES);
|
getLoaderManager().destroyLoader(LOADER_ID_BYTES);
|
||||||
}
|
}
|
||||||
if (getLoaderManager().getLoader(LOADER_ID_SERVER_QUERY) != null) {
|
if (getLoaderManager().getLoader(LOADER_ID_CLOUD) != null) {
|
||||||
getLoaderManager().destroyLoader(LOADER_ID_SERVER_QUERY);
|
getLoaderManager().destroyLoader(LOADER_ID_CLOUD);
|
||||||
}
|
|
||||||
if (getLoaderManager().getLoader(LOADER_ID_KEYBASE) != null) {
|
|
||||||
getLoaderManager().destroyLoader(LOADER_ID_KEYBASE);
|
|
||||||
}
|
}
|
||||||
if (getView() != null) {
|
if (getView() != null) {
|
||||||
setListShown(true);
|
setListShown(true);
|
||||||
@ -219,16 +205,11 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
setListShown(false);
|
setListShown(false);
|
||||||
|
|
||||||
getLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
|
getLoaderManager().restartLoader(LOADER_ID_BYTES, null, this);
|
||||||
} else if (mLoaderState instanceof KeyserverLoaderState) {
|
} else if (mLoaderState instanceof CloudLoaderState) {
|
||||||
// Start out with a progress indicator.
|
// Start out with a progress indicator.
|
||||||
setListShown(false);
|
setListShown(false);
|
||||||
|
|
||||||
getLoaderManager().restartLoader(LOADER_ID_SERVER_QUERY, null, this);
|
getLoaderManager().restartLoader(LOADER_ID_CLOUD, null, this);
|
||||||
} else if (mLoaderState instanceof KeybaseLoaderState) {
|
|
||||||
// Start out with a progress indicator.
|
|
||||||
setListShown(false);
|
|
||||||
|
|
||||||
getLoaderManager().restartLoader(LOADER_ID_KEYBASE, null, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,13 +222,9 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
InputData inputData = getInputData(ls.keyBytes, ls.dataUri);
|
InputData inputData = getInputData(ls.keyBytes, ls.dataUri);
|
||||||
return new ImportKeysListLoader(mActivity, inputData);
|
return new ImportKeysListLoader(mActivity, inputData);
|
||||||
}
|
}
|
||||||
case LOADER_ID_SERVER_QUERY: {
|
case LOADER_ID_CLOUD: {
|
||||||
KeyserverLoaderState ls = (KeyserverLoaderState) mLoaderState;
|
CloudLoaderState ls = (CloudLoaderState) mLoaderState;
|
||||||
return new ImportKeysListServerLoader(getActivity(), ls.serverQuery, ls.keyserver);
|
return new ImportKeysListCloudLoader(getActivity(), ls.mServerQuery, ls.mCloudPrefs);
|
||||||
}
|
|
||||||
case LOADER_ID_KEYBASE: {
|
|
||||||
KeybaseLoaderState ls = (KeybaseLoaderState) mLoaderState;
|
|
||||||
return new ImportKeysListKeybaseLoader(getActivity(), ls.keybaseQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -301,8 +278,7 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOADER_ID_SERVER_QUERY:
|
case LOADER_ID_CLOUD:
|
||||||
case LOADER_ID_KEYBASE:
|
|
||||||
|
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
// No error
|
// No error
|
||||||
@ -333,11 +309,7 @@ public class ImportKeysListFragment extends ListFragment implements
|
|||||||
// Clear the data in the adapter.
|
// Clear the data in the adapter.
|
||||||
mAdapter.clear();
|
mAdapter.clear();
|
||||||
break;
|
break;
|
||||||
case LOADER_ID_SERVER_QUERY:
|
case LOADER_ID_CLOUD:
|
||||||
// Clear the data in the adapter.
|
|
||||||
mAdapter.clear();
|
|
||||||
break;
|
|
||||||
case LOADER_ID_KEYBASE:
|
|
||||||
// Clear the data in the adapter.
|
// Clear the data in the adapter.
|
||||||
mAdapter.clear();
|
mAdapter.clear();
|
||||||
break;
|
break;
|
||||||
|
@ -34,7 +34,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
import org.sufficientlysecure.keychain.service.results.ConsolidateResult;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
import org.sufficientlysecure.keychain.util.Notify;
|
import org.sufficientlysecure.keychain.util.Notify;
|
||||||
@ -166,7 +166,7 @@ public class KeyListActivity extends DrawerActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ConsolidateResult result =
|
final ConsolidateResult result =
|
||||||
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
|
returnData.getParcelable(OperationResult.EXTRA_RESULT);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -201,8 +201,8 @@ public class KeyListActivity extends DrawerActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// if a result has been returned, display a notify
|
// if a result has been returned, display a notify
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
result.createNotify(this).show();
|
result.createNotify(this).show();
|
||||||
} else {
|
} else {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -37,9 +37,9 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogEntryParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogEntryParcel;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel.LogLevel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult.LogLevel;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -50,7 +50,7 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener
|
|||||||
LogAdapter mAdapter;
|
LogAdapter mAdapter;
|
||||||
LogLevel mLevel = LogLevel.DEBUG;
|
LogLevel mLevel = LogLevel.DEBUG;
|
||||||
|
|
||||||
OperationResultParcel mResult;
|
OperationResult mResult;
|
||||||
|
|
||||||
GestureDetector mDetector;
|
GestureDetector mDetector;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mResult = intent.<OperationResultParcel>getParcelableExtra(EXTRA_RESULT);
|
mResult = intent.<OperationResult>getParcelableExtra(EXTRA_RESULT);
|
||||||
if (mResult == null) {
|
if (mResult == null) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
return;
|
return;
|
||||||
@ -135,7 +135,7 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener
|
|||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private int dipFactor;
|
private int dipFactor;
|
||||||
|
|
||||||
public LogAdapter(Context context, OperationResultParcel.OperationLog log, LogLevel level) {
|
public LogAdapter(Context context, OperationResult.OperationLog log, LogLevel level) {
|
||||||
super(context, R.layout.log_display_item);
|
super(context, R.layout.log_display_item);
|
||||||
mInflater = LayoutInflater.from(getContext());
|
mInflater = LayoutInflater.from(getContext());
|
||||||
dipFactor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
dipFactor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -40,7 +41,7 @@ import java.util.List;
|
|||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public class PreferencesActivity extends PreferenceActivity {
|
public class PreferencesActivity extends PreferenceActivity {
|
||||||
|
|
||||||
public static final String ACTION_PREFS_GEN = "org.sufficientlysecure.keychain.ui.PREFS_GEN";
|
public static final String ACTION_PREFS_CLOUD = "org.sufficientlysecure.keychain.ui.PREFS_CLOUD";
|
||||||
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
||||||
|
|
||||||
public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005;
|
public static final int REQUEST_CODE_KEYSERVER_PREF = 0x00007005;
|
||||||
@ -55,16 +56,11 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
String action = getIntent().getAction();
|
String action = getIntent().getAction();
|
||||||
|
|
||||||
if (action != null && action.equals(ACTION_PREFS_GEN)) {
|
if (action != null && action.equals(ACTION_PREFS_CLOUD)) {
|
||||||
addPreferencesFromResource(R.xml.gen_preferences);
|
addPreferencesFromResource(R.xml.cloud_search_prefs);
|
||||||
|
|
||||||
initializePassPassphraceCacheTtl(
|
|
||||||
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
|
||||||
|
|
||||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
||||||
String servers[] = sPreferences.getKeyServers();
|
mKeyServerPreference.setSummary(keyserverSummary(this));
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_keyservers,
|
|
||||||
servers.length, servers.length));
|
|
||||||
mKeyServerPreference
|
mKeyServerPreference
|
||||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
@ -76,10 +72,19 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
initializeSearchKeyserver(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
|
||||||
|
);
|
||||||
|
initializeSearchKeybase(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
|
||||||
|
);
|
||||||
|
|
||||||
} else if (action != null && action.equals(ACTION_PREFS_ADV)) {
|
} else if (action != null && action.equals(ACTION_PREFS_ADV)) {
|
||||||
addPreferencesFromResource(R.xml.adv_preferences);
|
addPreferencesFromResource(R.xml.adv_preferences);
|
||||||
|
|
||||||
|
initializePassPassphraceCacheTtl(
|
||||||
|
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
||||||
|
|
||||||
initializeEncryptionAlgorithm(
|
initializeEncryptionAlgorithm(
|
||||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||||
|
|
||||||
@ -136,8 +141,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
String servers[] = data
|
String servers[] = data
|
||||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||||
sPreferences.setKeyServers(servers);
|
sPreferences.setKeyServers(servers);
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
mKeyServerPreference.setSummary(keyserverSummary(this));
|
||||||
R.plurals.n_keyservers, servers.length, servers.length));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +160,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This fragment shows the general preferences in android 3.0+
|
* This fragment shows the Cloud Search preferences in android 3.0+
|
||||||
*/
|
*/
|
||||||
public static class GeneralPrefsFragment extends PreferenceFragment {
|
public static class CloudSearchPrefsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
private PreferenceScreen mKeyServerPreference = null;
|
private PreferenceScreen mKeyServerPreference = null;
|
||||||
|
|
||||||
@ -167,15 +171,11 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.gen_preferences);
|
addPreferencesFromResource(R.xml.cloud_search_prefs);
|
||||||
|
|
||||||
initializePassPassphraceCacheTtl(
|
|
||||||
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
|
||||||
|
|
||||||
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS);
|
||||||
String servers[] = sPreferences.getKeyServers();
|
mKeyServerPreference.setSummary(keyserverSummary(getActivity()));
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_keyservers,
|
|
||||||
servers.length, servers.length));
|
|
||||||
mKeyServerPreference
|
mKeyServerPreference
|
||||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
@ -187,6 +187,12 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
initializeSearchKeyserver(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYSERVER)
|
||||||
|
);
|
||||||
|
initializeSearchKeybase(
|
||||||
|
(CheckBoxPreference) findPreference(Constants.Pref.SEARCH_KEYBASE)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,8 +205,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
String servers[] = data
|
String servers[] = data
|
||||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||||
sPreferences.setKeyServers(servers);
|
sPreferences.setKeyServers(servers);
|
||||||
mKeyServerPreference.setSummary(getResources().getQuantityString(
|
mKeyServerPreference.setSummary(keyserverSummary(getActivity()));
|
||||||
R.plurals.n_keyservers, servers.length, servers.length));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +229,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
// Load the preferences from an XML resource
|
// Load the preferences from an XML resource
|
||||||
addPreferencesFromResource(R.xml.adv_preferences);
|
addPreferencesFromResource(R.xml.adv_preferences);
|
||||||
|
|
||||||
|
initializePassPassphraceCacheTtl(
|
||||||
|
(IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL));
|
||||||
|
|
||||||
initializeEncryptionAlgorithm(
|
initializeEncryptionAlgorithm(
|
||||||
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
(IntegerListPreference) findPreference(Constants.Pref.DEFAULT_ENCRYPTION_ALGORITHM));
|
||||||
|
|
||||||
@ -271,7 +279,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
protected boolean isValidFragment(String fragmentName) {
|
protected boolean isValidFragment(String fragmentName) {
|
||||||
return AdvancedPrefsFragment.class.getName().equals(fragmentName)
|
return AdvancedPrefsFragment.class.getName().equals(fragmentName)
|
||||||
|| GeneralPrefsFragment.class.getName().equals(fragmentName)
|
|| CloudSearchPrefsFragment.class.getName().equals(fragmentName)
|
||||||
|| super.isValidFragment(fragmentName);
|
|| super.isValidFragment(fragmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,6 +406,39 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initializeSearchKeyserver(final CheckBoxPreference mSearchKeyserver) {
|
||||||
|
Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs();
|
||||||
|
mSearchKeyserver.setChecked(prefs.searchKeyserver);
|
||||||
|
mSearchKeyserver.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
mSearchKeyserver.setChecked((Boolean) newValue);
|
||||||
|
sPreferences.setSearchKeyserver((Boolean) newValue);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initializeSearchKeybase(final CheckBoxPreference mSearchKeybase) {
|
||||||
|
Preferences.CloudSearchPrefs prefs = sPreferences.getCloudSearchPrefs();
|
||||||
|
mSearchKeybase.setChecked(prefs.searchKeybase);
|
||||||
|
mSearchKeybase.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
mSearchKeybase.setChecked((Boolean) newValue);
|
||||||
|
sPreferences.setSearchKeybase((Boolean) newValue);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String keyserverSummary(Context context) {
|
||||||
|
String[] servers = sPreferences.getKeyServers();
|
||||||
|
String serverSummary = context.getResources().getQuantityString(
|
||||||
|
R.plurals.n_keyservers, servers.length, servers.length);
|
||||||
|
return serverSummary + "; " + context.getString(R.string.label_preferred) + ": " + sPreferences.getPreferredKeyserver();
|
||||||
|
}
|
||||||
|
|
||||||
private static void initializeUseDefaultYubikeyPin(final CheckBoxPreference mUseDefaultYubikeyPin) {
|
private static void initializeUseDefaultYubikeyPin(final CheckBoxPreference mUseDefaultYubikeyPin) {
|
||||||
mUseDefaultYubikeyPin.setChecked(sPreferences.useDefaultYubikeyPin());
|
mUseDefaultYubikeyPin.setChecked(sPreferences.useDefaultYubikeyPin());
|
||||||
mUseDefaultYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
mUseDefaultYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@ -408,4 +449,5 @@ public class PreferencesActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O
|
|||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ViewGroup mEditors;
|
private ViewGroup mEditors;
|
||||||
private View mAdd;
|
private View mAdd;
|
||||||
|
private View mRotate;
|
||||||
private TextView mTitle;
|
private TextView mTitle;
|
||||||
private TextView mSummary;
|
private TextView mSummary;
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O
|
|||||||
|
|
||||||
mTitle = (TextView) findViewById(R.id.title);
|
mTitle = (TextView) findViewById(R.id.title);
|
||||||
mSummary = (TextView) findViewById(R.id.summary);
|
mSummary = (TextView) findViewById(R.id.summary);
|
||||||
|
mSummary.setText(getText(R.string.label_first_keyserver_is_used));
|
||||||
|
|
||||||
mTitle.setText(R.string.label_keyservers);
|
mTitle.setText(R.string.label_keyservers);
|
||||||
|
|
||||||
@ -80,9 +82,29 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O
|
|||||||
mAdd = findViewById(R.id.add);
|
mAdd = findViewById(R.id.add);
|
||||||
mAdd.setOnClickListener(this);
|
mAdd.setOnClickListener(this);
|
||||||
|
|
||||||
|
mRotate = findViewById(R.id.rotate);
|
||||||
|
mRotate.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Vector<String> servers = serverList();
|
||||||
|
String first = servers.get(0);
|
||||||
|
if (first != null) {
|
||||||
|
servers.remove(0);
|
||||||
|
servers.add(first);
|
||||||
|
String[] dummy = {};
|
||||||
|
makeServerList(servers.toArray(dummy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String servers[] = intent.getStringArrayExtra(EXTRA_KEY_SERVERS);
|
String servers[] = intent.getStringArrayExtra(EXTRA_KEY_SERVERS);
|
||||||
|
makeServerList(servers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeServerList(String[] servers) {
|
||||||
if (servers != null) {
|
if (servers != null) {
|
||||||
|
mEditors.removeAllViews();
|
||||||
for (String serv : servers) {
|
for (String serv : servers) {
|
||||||
KeyServerEditor view = (KeyServerEditor) mInflater.inflate(
|
KeyServerEditor view = (KeyServerEditor) mInflater.inflate(
|
||||||
R.layout.key_server_editor, mEditors, false);
|
R.layout.key_server_editor, mEditors, false);
|
||||||
@ -114,6 +136,18 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector<String> serverList() {
|
||||||
|
Vector<String> servers = new Vector<String>();
|
||||||
|
for (int i = 0; i < mEditors.getChildCount(); ++i) {
|
||||||
|
KeyServerEditor editor = (KeyServerEditor) mEditors.getChildAt(i);
|
||||||
|
String tmp = editor.getValue();
|
||||||
|
if (tmp.length() > 0) {
|
||||||
|
servers.add(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return servers;
|
||||||
|
}
|
||||||
|
|
||||||
private void okClicked() {
|
private void okClicked() {
|
||||||
Intent data = new Intent();
|
Intent data = new Intent();
|
||||||
Vector<String> servers = new Vector<String>();
|
Vector<String> servers = new Vector<String>();
|
||||||
|
@ -56,7 +56,7 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.service.results.OperationResultParcel;
|
import org.sufficientlysecure.keychain.service.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout.TabColorizer;
|
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout.TabColorizer;
|
||||||
@ -322,8 +322,8 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
// if a result has been returned, display a notify
|
// if a result has been returned, display a notify
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
result.createNotify(this).show();
|
result.createNotify(this).show();
|
||||||
} else {
|
} else {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -21,28 +21,29 @@ import android.content.Context;
|
|||||||
import android.support.v4.content.AsyncTaskLoader;
|
import android.support.v4.content.AsyncTaskLoader;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||||
|
import org.sufficientlysecure.keychain.keyimport.CloudSearch;
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ImportKeysListServerLoader
|
public class ImportKeysListCloudLoader
|
||||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
|
|
||||||
|
Preferences.CloudSearchPrefs mCloudPrefs;
|
||||||
String mServerQuery;
|
String mServerQuery;
|
||||||
String mKeyServer;
|
|
||||||
|
|
||||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
||||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
||||||
|
|
||||||
public ImportKeysListServerLoader(Context context, String serverQuery, String keyServer) {
|
public ImportKeysListCloudLoader(Context context, String serverQuery, Preferences.CloudSearchPrefs cloudPrefs) {
|
||||||
super(context);
|
super(context);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mServerQuery = serverQuery;
|
mServerQuery = serverQuery;
|
||||||
mKeyServer = keyServer;
|
mCloudPrefs = cloudPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,9 +57,9 @@ public class ImportKeysListServerLoader
|
|||||||
|
|
||||||
if (mServerQuery.startsWith("0x") && mServerQuery.length() == 42) {
|
if (mServerQuery.startsWith("0x") && mServerQuery.length() == 42) {
|
||||||
Log.d(Constants.TAG, "This search is based on a unique fingerprint. Enforce a fingerprint check!");
|
Log.d(Constants.TAG, "This search is based on a unique fingerprint. Enforce a fingerprint check!");
|
||||||
queryServer(mServerQuery, mKeyServer, true);
|
queryServer(true);
|
||||||
} else {
|
} else {
|
||||||
queryServer(mServerQuery, mKeyServer, false);
|
queryServer(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mEntryListWrapper;
|
return mEntryListWrapper;
|
||||||
@ -90,15 +91,14 @@ public class ImportKeysListServerLoader
|
|||||||
/**
|
/**
|
||||||
* Query keyserver
|
* Query keyserver
|
||||||
*/
|
*/
|
||||||
private void queryServer(String query, String keyServer, boolean enforceFingerprint) {
|
private void queryServer(boolean enforceFingerprint) {
|
||||||
HkpKeyserver server = new HkpKeyserver(keyServer);
|
|
||||||
try {
|
try {
|
||||||
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
ArrayList<ImportKeysListEntry> searchResult = CloudSearch.search(mServerQuery, mCloudPrefs);
|
||||||
|
|
||||||
mEntryList.clear();
|
mEntryList.clear();
|
||||||
// add result to data
|
// add result to data
|
||||||
if (enforceFingerprint) {
|
if (enforceFingerprint) {
|
||||||
String fingerprint = query.substring(2);
|
String fingerprint = mServerQuery.substring(2);
|
||||||
Log.d(Constants.TAG, "fingerprint: " + fingerprint);
|
Log.d(Constants.TAG, "fingerprint: " + fingerprint);
|
||||||
// query must return only one result!
|
// query must return only one result!
|
||||||
if (searchResult.size() == 1) {
|
if (searchResult.size() == 1) {
|
||||||
@ -115,11 +115,8 @@ public class ImportKeysListServerLoader
|
|||||||
mEntryList.addAll(searchResult);
|
mEntryList.addAll(searchResult);
|
||||||
}
|
}
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
||||||
} catch (Keyserver.QueryFailedException e) {
|
} catch (Exception e) {
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
|
||||||
} catch (Keyserver.QueryNeedsRepairException e) {
|
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
|
|
||||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class ImportKeysListKeybaseLoader
|
|
||||||
extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> {
|
|
||||||
Context mContext;
|
|
||||||
|
|
||||||
String mKeybaseQuery;
|
|
||||||
|
|
||||||
private ArrayList<ImportKeysListEntry> mEntryList = new ArrayList<ImportKeysListEntry>();
|
|
||||||
private AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper;
|
|
||||||
|
|
||||||
public ImportKeysListKeybaseLoader(Context context, String keybaseQuery) {
|
|
||||||
super(context);
|
|
||||||
mContext = context;
|
|
||||||
mKeybaseQuery = keybaseQuery;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() {
|
|
||||||
|
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
|
||||||
|
|
||||||
if (mKeybaseQuery == null) {
|
|
||||||
Log.e(Constants.TAG, "mKeybaseQery is null!");
|
|
||||||
return mEntryListWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
queryServer(mKeybaseQuery);
|
|
||||||
|
|
||||||
return mEntryListWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onReset() {
|
|
||||||
super.onReset();
|
|
||||||
|
|
||||||
// Ensure the loader is stopped
|
|
||||||
onStopLoading();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStartLoading() {
|
|
||||||
forceLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStopLoading() {
|
|
||||||
cancelLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deliverResult(AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data) {
|
|
||||||
super.deliverResult(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query keybase
|
|
||||||
*/
|
|
||||||
private void queryServer(String query) {
|
|
||||||
|
|
||||||
KeybaseKeyserver server = new KeybaseKeyserver();
|
|
||||||
try {
|
|
||||||
ArrayList<ImportKeysListEntry> searchResult = server.search(query);
|
|
||||||
|
|
||||||
mEntryList.clear();
|
|
||||||
|
|
||||||
mEntryList.addAll(searchResult);
|
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, null);
|
|
||||||
} catch (Keyserver.QueryFailedException e) {
|
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
|
||||||
} catch (Keyserver.QueryNeedsRepairException e) {
|
|
||||||
mEntryListWrapper = new AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>(mEntryList, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
37
OpenKeychain/src/main/res/drawable/button_rounded_blue.xml
Normal file
37
OpenKeychain/src/main/res/drawable/button_rounded_blue.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" >
|
||||||
|
<shape android:shape="rectangle" >
|
||||||
|
<padding
|
||||||
|
android:bottom="3dip"
|
||||||
|
android:left="2dip"
|
||||||
|
android:right="2dip"
|
||||||
|
android:top="1dip" />
|
||||||
|
<corners android:radius="6dip" />
|
||||||
|
<solid android:color="#4444cc" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:state_focused="true">
|
||||||
|
<shape android:shape="rectangle" >
|
||||||
|
<padding
|
||||||
|
android:bottom="3dip"
|
||||||
|
android:left="2dip"
|
||||||
|
android:right="2dip"
|
||||||
|
android:top="1dip" />
|
||||||
|
<corners android:radius="6dip" />
|
||||||
|
<solid android:color="#4444cc"/>
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item >
|
||||||
|
<shape android:shape="rectangle" >
|
||||||
|
<padding
|
||||||
|
android:bottom="3dip"
|
||||||
|
android:left="2dip"
|
||||||
|
android:right="2dip"
|
||||||
|
android:top="1dip" />
|
||||||
|
<corners android:radius="6dip" />
|
||||||
|
<solid android:color="#5555ee" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
@ -11,12 +11,12 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/import_server_query"
|
android:id="@+id/cloud_import_server_query"
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="top|left"
|
android:gravity="top|left"
|
||||||
android:hint="@string/hint_keyserver_search_hint"
|
android:hint="@string/hint_cloud_search_hint"
|
||||||
android:imeOptions="actionSearch"
|
android:imeOptions="actionSearch"
|
||||||
android:inputType="textNoSuggestions"
|
android:inputType="textNoSuggestions"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
@ -26,7 +26,7 @@
|
|||||||
android:layout_gravity="center_vertical" />
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/import_server_search"
|
android:id="@+id/cloud_import_server_search"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:background="?android:attr/listDivider" />
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/import_server_config_button"
|
android:id="@+id/cloud_import_server_config_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
@ -53,24 +53,5 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/import_server_config"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dip"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/import_server_spinner"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -1,32 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/import_keybase_query"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_width="0dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="top|left"
|
|
||||||
android:hint="@string/hint_keybase_search_hint"
|
|
||||||
android:imeOptions="actionSearch"
|
|
||||||
android:inputType="textNoSuggestions"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:lines="1"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:minLines="1"
|
|
||||||
android:layout_gravity="center_vertical" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/import_keybase_search"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:src="@drawable/ic_action_search"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
style="@style/SelectableItem" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -30,6 +30,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:gravity="top|center"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:focusableInTouchMode="false" />
|
android:focusableInTouchMode="false" />
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="6sp"
|
android:layout_marginBottom="6sp"
|
||||||
@ -21,6 +21,7 @@
|
|||||||
android:layout_marginTop="6sp"
|
android:layout_marginTop="6sp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@android:drawable/menuitem_background"
|
android:background="@android:drawable/menuitem_background"
|
||||||
|
android:orientation="vertical"
|
||||||
android:focusable="true" >
|
android:focusable="true" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -35,20 +36,26 @@
|
|||||||
android:id="@+id/summary"
|
android:id="@+id/summary"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignLeft="@android:id/title"
|
|
||||||
android:layout_below="@android:id/title"
|
|
||||||
android:maxLines="2"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
</RelativeLayout>
|
</LinearLayout>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/rotate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="31dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="4dip"
|
||||||
|
android:layout_marginRight="6dip"
|
||||||
|
android:text="rotate"
|
||||||
|
android:textColor="#ffffffff"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:background="@drawable/button_rounded_blue"
|
||||||
|
/>
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_marginLeft="4dip"
|
|
||||||
android:layout_marginRight="6dip"
|
|
||||||
android:src="@drawable/plus"
|
android:src="@drawable/plus"
|
||||||
android:background="@drawable/button_rounded_green"/>
|
android:background="@drawable/button_rounded_green"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<string name="title_add_subkey">"Add subkey"</string>
|
<string name="title_add_subkey">"Add subkey"</string>
|
||||||
<string name="title_edit_key">"Edit Key"</string>
|
<string name="title_edit_key">"Edit Key"</string>
|
||||||
<string name="title_preferences">"Preferences"</string>
|
<string name="title_preferences">"Preferences"</string>
|
||||||
|
<string name="title_cloud_search_preferences">"Cloud Search Preferences"</string>
|
||||||
<string name="title_api_registered_apps">"Apps"</string>
|
<string name="title_api_registered_apps">"Apps"</string>
|
||||||
<string name="title_key_server_preference">"Keyserver Preference"</string>
|
<string name="title_key_server_preference">"Keyserver Preference"</string>
|
||||||
<string name="title_change_passphrase">"Change Passphrase"</string>
|
<string name="title_change_passphrase">"Change Passphrase"</string>
|
||||||
@ -39,6 +40,7 @@
|
|||||||
<!-- section -->
|
<!-- section -->
|
||||||
<string name="section_user_ids">"Identities"</string>
|
<string name="section_user_ids">"Identities"</string>
|
||||||
<string name="section_keys">"Subkeys"</string>
|
<string name="section_keys">"Subkeys"</string>
|
||||||
|
<string name="section_cloud_search">"Cloud search"</string>
|
||||||
<string name="section_general">"General"</string>
|
<string name="section_general">"General"</string>
|
||||||
<string name="section_defaults">"Defaults"</string>
|
<string name="section_defaults">"Defaults"</string>
|
||||||
<string name="section_advanced">"Advanced"</string>
|
<string name="section_advanced">"Advanced"</string>
|
||||||
@ -125,6 +127,8 @@
|
|||||||
<string name="label_send_key">"Upload key to selected keyserver after certification"</string>
|
<string name="label_send_key">"Upload key to selected keyserver after certification"</string>
|
||||||
<string name="label_fingerprint">"Fingerprint"</string>
|
<string name="label_fingerprint">"Fingerprint"</string>
|
||||||
<string name="expiry_date_dialog_title">"Set expiry date"</string>
|
<string name="expiry_date_dialog_title">"Set expiry date"</string>
|
||||||
|
<string name="label_first_keyserver_is_used">"(First keyserver listed is preferred)"</string>
|
||||||
|
<string name="label_preferred">"preferred"</string>
|
||||||
|
|
||||||
<string name="user_id_no_name">"<no name>"</string>
|
<string name="user_id_no_name">"<no name>"</string>
|
||||||
<string name="none">"<none>"</string>
|
<string name="none">"<none>"</string>
|
||||||
@ -214,8 +218,6 @@
|
|||||||
<item quantity="other">"%d bad secret keys ignored. Perhaps you exported with the option\n --export-secret-subkeys\nMake sure you export with\n --export-secret-keys\ninstead.""</item>
|
<item quantity="other">"%d bad secret keys ignored. Perhaps you exported with the option\n --export-secret-subkeys\nMake sure you export with\n --export-secret-keys\ninstead.""</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
|
||||||
<string name="key_send_success">"Successfully uploaded key to server"</string>
|
|
||||||
<string name="key_certify_success">"Successfully certified identities"</string>
|
|
||||||
<string name="list_empty">"This list is empty!"</string>
|
<string name="list_empty">"This list is empty!"</string>
|
||||||
<string name="nfc_successful">"Successfully sent key with NFC Beam!"</string>
|
<string name="nfc_successful">"Successfully sent key with NFC Beam!"</string>
|
||||||
<string name="key_copied_to_clipboard">"Key has been copied to the clipboard!"</string>
|
<string name="key_copied_to_clipboard">"Key has been copied to the clipboard!"</string>
|
||||||
@ -325,7 +327,7 @@
|
|||||||
|
|
||||||
<!-- action strings -->
|
<!-- action strings -->
|
||||||
<string name="hint_keyserver_search_hint">"Name/Email/Key ID…"</string>
|
<string name="hint_keyserver_search_hint">"Name/Email/Key ID…"</string>
|
||||||
<string name="hint_keybase_search_hint">"Name/Email/Proof/Key…"</string>
|
<string name="hint_cloud_search_hint">"Name/Email/Proof/Key…"</string>
|
||||||
|
|
||||||
<!-- key bit length selections -->
|
<!-- key bit length selections -->
|
||||||
<string name="key_size_512">"512"</string>
|
<string name="key_size_512">"512"</string>
|
||||||
@ -366,9 +368,9 @@
|
|||||||
|
|
||||||
<!-- Import -->
|
<!-- Import -->
|
||||||
<string name="import_tab_keyserver">"Keyserver"</string>
|
<string name="import_tab_keyserver">"Keyserver"</string>
|
||||||
|
<string name="import_tab_cloud">"Search Cloud"</string>
|
||||||
<string name="import_tab_direct">"File/Clipboard"</string>
|
<string name="import_tab_direct">"File/Clipboard"</string>
|
||||||
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
<string name="import_tab_qr_code">"QR Code/NFC"</string>
|
||||||
<string name="import_tab_keybase">"Keybase.io"</string>
|
|
||||||
<string name="import_import">"Import selected keys"</string>
|
<string name="import_import">"Import selected keys"</string>
|
||||||
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
<string name="import_qr_code_wrong">"QR Code malformed! Please try again!"</string>
|
||||||
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short (< 16 characters)"</string>
|
<string name="import_qr_code_too_short_fingerprint">"Fingerprint is too short (< 16 characters)"</string>
|
||||||
@ -826,6 +828,11 @@
|
|||||||
<string name="msg_se">"Starting sign and/or encrypt operation"</string>
|
<string name="msg_se">"Starting sign and/or encrypt operation"</string>
|
||||||
<string name="msg_se_symmetric">"Preparing symmetric encryption"</string>
|
<string name="msg_se_symmetric">"Preparing symmetric encryption"</string>
|
||||||
|
|
||||||
|
<string name="msg_crt_upload_success">"Successfully uploaded key to server"</string>
|
||||||
|
<string name="msg_crt_success">"Successfully certified identities"</string>
|
||||||
|
|
||||||
|
<string name="msg_acc_saved">"Account saved"</string>
|
||||||
|
|
||||||
<!-- PassphraseCache -->
|
<!-- PassphraseCache -->
|
||||||
<string name="passp_cache_notif_click_to_clear">"Click to clear cached passphrases"</string>
|
<string name="passp_cache_notif_click_to_clear">"Click to clear cached passphrases"</string>
|
||||||
<string name="passp_cache_notif_n_keys">"OpenKeychain has cached %d passphrases"</string>
|
<string name="passp_cache_notif_n_keys">"OpenKeychain has cached %d passphrases"</string>
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory android:title="@string/section_defaults">
|
<PreferenceCategory android:title="@string/section_defaults">
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.IntegerListPreference
|
||||||
|
android:entries="@array/passphrase_cache_ttl_entries"
|
||||||
|
android:entryValues="@array/passphrase_cache_ttl_values"
|
||||||
|
android:key="passphraseCacheTtl"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/label_passphrase_cache_ttl" />
|
||||||
<org.sufficientlysecure.keychain.ui.widget.IntegerListPreference
|
<org.sufficientlysecure.keychain.ui.widget.IntegerListPreference
|
||||||
android:key="defaultEncryptionAlgorithm"
|
android:key="defaultEncryptionAlgorithm"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
|
20
OpenKeychain/src/main/res/xml/cloud_search_prefs.xml
Normal file
20
OpenKeychain/src/main/res/xml/cloud_search_prefs.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:title="Search Keyserver"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:summary="Search HKP keyserver"
|
||||||
|
android:key="search_keyserver_pref" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:title="Search Keybase.io"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:summary="Search Keybase.io index"
|
||||||
|
android:key="search_keybase_pref" />
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:key="keyServers"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/label_keyservers" />
|
||||||
|
</PreferenceScreen>
|
@ -1,15 +0,0 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<PreferenceCategory android:title="@string/section_general">
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.IntegerListPreference
|
|
||||||
android:entries="@array/passphrase_cache_ttl_entries"
|
|
||||||
android:entryValues="@array/passphrase_cache_ttl_values"
|
|
||||||
android:key="passphraseCacheTtl"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/label_passphrase_cache_ttl" />
|
|
||||||
|
|
||||||
<PreferenceScreen
|
|
||||||
android:key="keyServers"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/label_keyservers" />
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
|
@ -1,7 +1,7 @@
|
|||||||
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<header
|
<header
|
||||||
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$GeneralPrefsFragment"
|
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$CloudSearchPrefsFragment"
|
||||||
android:title="@string/section_general" />
|
android:title="@string/section_cloud_search" />
|
||||||
<header
|
<header
|
||||||
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$AdvancedPrefsFragment"
|
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$AdvancedPrefsFragment"
|
||||||
android:title="@string/section_advanced" />
|
android:title="@string/section_advanced" />
|
||||||
|
Loading…
Reference in New Issue
Block a user