mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Merge branch 'development' of github.com:open-keychain/open-keychain into development
This commit is contained in:
commit
b24ff10c43
@ -118,24 +118,21 @@ public class KeychainApplication extends Application {
|
|||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public static void setupAccountAsNeeded(Context context) {
|
public static void setupAccountAsNeeded(Context context) {
|
||||||
// only enabled for Jelly Bean because we need some newer methods in our sync adapter
|
try {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
AccountManager manager = AccountManager.get(context);
|
||||||
try {
|
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
||||||
AccountManager manager = AccountManager.get(context);
|
if (accounts == null || accounts.length == 0) {
|
||||||
Account[] accounts = manager.getAccountsByType(Constants.ACCOUNT_TYPE);
|
Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
|
||||||
if (accounts == null || accounts.length == 0) {
|
if (manager.addAccountExplicitly(account, null, null)) {
|
||||||
Account account = new Account(Constants.ACCOUNT_NAME, Constants.ACCOUNT_TYPE);
|
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
||||||
if (manager.addAccountExplicitly(account, null, null)) {
|
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
||||||
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
} else {
|
||||||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
|
Log.e(Constants.TAG, "Adding account failed!");
|
||||||
} else {
|
|
||||||
Log.e(Constants.TAG, "Adding account failed!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (SecurityException e) {
|
|
||||||
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
|
||||||
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Log.e(Constants.TAG, "SecurityException when adding the account", e);
|
||||||
|
Toast.makeText(context, R.string.reinstall_openkeychain, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
|
|||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keep track if this key result is from a HKP keyserver
|
||||||
|
boolean incomingFromHkpServer = true;
|
||||||
// we’re going to want to try to fetch the key from everywhere we found it, so remember
|
// we’re going to want to try to fetch the key from everywhere we found it, so remember
|
||||||
// all the origins
|
// all the origins
|
||||||
for (String origin : incoming.getOrigins()) {
|
for (String origin : incoming.getOrigins()) {
|
||||||
@ -78,13 +80,24 @@ public class ImportKeysList extends ArrayList<ImportKeysListEntry> {
|
|||||||
// to work properly, Keybase-sourced entries need to pass along the extra
|
// to work properly, Keybase-sourced entries need to pass along the extra
|
||||||
if (KeybaseKeyserver.ORIGIN.equals(origin)) {
|
if (KeybaseKeyserver.ORIGIN.equals(origin)) {
|
||||||
existing.setExtraData(incoming.getExtraData());
|
existing.setExtraData(incoming.getExtraData());
|
||||||
|
// one of the origins is not a HKP keyserver
|
||||||
|
incomingFromHkpServer = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> incomingIDs = incoming.getUserIds();
|
ArrayList<String> incomingIDs = incoming.getUserIds();
|
||||||
ArrayList<String> existingIDs = existing.getUserIds();
|
ArrayList<String> existingIDs = existing.getUserIds();
|
||||||
for (String incomingID : incomingIDs) {
|
for (String incomingID : incomingIDs) {
|
||||||
if (!existingIDs.contains(incomingID)) {
|
if (!existingIDs.contains(incomingID)) {
|
||||||
existingIDs.add(incomingID);
|
// prepend HKP server results to the start of the list,
|
||||||
|
// so that the UI (for cloud key search, which is picking the first list item)
|
||||||
|
// shows the right main email address, as mail addresses returned by HKP servers
|
||||||
|
// are preferred over keybase.io IDs
|
||||||
|
if (incomingFromHkpServer) {
|
||||||
|
existingIDs.add(0, incomingID);
|
||||||
|
} else {
|
||||||
|
existingIDs.add(incomingID);
|
||||||
|
}
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user