diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml
index f98a7f3e3..50aa4c480 100644
--- a/OpenKeychain/src/main/AndroidManifest.xml
+++ b/OpenKeychain/src/main/AndroidManifest.xml
@@ -850,10 +850,6 @@
android:exported="true" />
-
-
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
index 8e99e59b1..e5840d9f5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/OperationResult.java
@@ -805,8 +805,6 @@ public abstract class OperationResult implements Parcelable {
MSG_CRT_UPLOAD_SUCCESS (LogLevel.OK, R.string.msg_crt_upload_success),
- MSG_ACC_SAVED (LogLevel.INFO, R.string.api_settings_save_msg),
-
MSG_WRONG_QR_CODE (LogLevel.ERROR, R.string.import_qr_code_wrong),
MSG_WRONG_QR_CODE_FP(LogLevel.ERROR, R.string.import_qr_code_fp),
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ApiDataAccessObject.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ApiDataAccessObject.java
index 43df29745..3776f198d 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ApiDataAccessObject.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ApiDataAccessObject.java
@@ -31,11 +31,8 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.RemoteException;
-import org.bouncycastle.bcpg.CompressionAlgorithmTags;
-import org.sufficientlysecure.keychain.pgp.PgpSecurityConstants;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAllowedKeys;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
-import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.remote.AppSettings;
@@ -102,20 +99,6 @@ public class ApiDataAccessObject {
return values;
}
- private ContentValues contentValueForApiAccounts(AccountSettings accSettings) {
- ContentValues values = new ContentValues();
- values.put(KeychainContract.ApiAccounts.ACCOUNT_NAME, accSettings.getAccountName());
- values.put(KeychainContract.ApiAccounts.KEY_ID, accSettings.getKeyId());
-
- // DEPRECATED and thus hardcoded
- values.put(KeychainContract.ApiAccounts.COMPRESSION, CompressionAlgorithmTags.ZLIB);
- values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM,
- PgpSecurityConstants.OpenKeychainSymmetricKeyAlgorithmTags.USE_DEFAULT);
- values.put(KeychainContract.ApiAccounts.HASH_ALORITHM,
- PgpSecurityConstants.OpenKeychainHashAlgorithmTags.USE_DEFAULT);
- return values;
- }
-
public void insertApiApp(AppSettings appSettings) {
mQueryInterface.insert(ApiApps.CONTENT_URI,
contentValueForApiApps(appSettings));
@@ -125,17 +108,6 @@ public class ApiDataAccessObject {
mQueryInterface.delete(ApiApps.buildByPackageNameUri(packageName), null, null);
}
- public void insertApiAccount(Uri uri, AccountSettings accSettings) {
- mQueryInterface.insert(uri, contentValueForApiAccounts(accSettings));
- }
-
- public void updateApiAccount(Uri uri, AccountSettings accSettings) {
- if (mQueryInterface.update(uri, contentValueForApiAccounts(accSettings), null,
- null) <= 0) {
- throw new RuntimeException();
- }
- }
-
/**
* Must be an uri pointing to an account
*/
@@ -160,48 +132,6 @@ public class ApiDataAccessObject {
return settings;
}
- public AccountSettings getApiAccountSettings(Uri accountUri) {
- AccountSettings settings = null;
-
- Cursor cursor = mQueryInterface.query(accountUri, null, null, null, null);
- try {
- if (cursor != null && cursor.moveToFirst()) {
- settings = new AccountSettings();
-
- settings.setAccountName(cursor.getString(
- cursor.getColumnIndex(KeychainContract.ApiAccounts.ACCOUNT_NAME)));
- settings.setKeyId(cursor.getLong(
- cursor.getColumnIndex(KeychainContract.ApiAccounts.KEY_ID)));
- }
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
-
- return settings;
- }
-
- public Set getAllKeyIdsForApp(Uri uri) {
- Set keyIds = new HashSet<>();
-
- Cursor cursor = mQueryInterface.query(uri, null, null, null, null);
- try {
- if (cursor != null) {
- int keyIdColumn = cursor.getColumnIndex(KeychainContract.ApiAccounts.KEY_ID);
- while (cursor.moveToNext()) {
- keyIds.add(cursor.getLong(keyIdColumn));
- }
- }
- } finally {
- if (cursor != null) {
- cursor.close();
- }
- }
-
- return keyIds;
- }
-
public HashSet getAllowedKeyIdsForApp(Uri uri) {
HashSet keyIds = new HashSet<>();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
index 9f05cc940..a45e943e2 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java
@@ -85,15 +85,6 @@ public class KeychainContract {
String PACKAGE_CERTIFICATE = "package_signature";
}
- interface ApiAppsAccountsColumns {
- String ACCOUNT_NAME = "account_name";
- String KEY_ID = "key_id"; // not a database id
- String ENCRYPTION_ALGORITHM = "encryption_algorithm";
- String HASH_ALORITHM = "hash_algorithm";
- String COMPRESSION = "compression";
- String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name
- }
-
interface ApiAppsAllowedKeysColumns {
String KEY_ID = "key_id"; // not a database id
String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name
@@ -123,7 +114,6 @@ public class KeychainContract {
public static final String PATH_CERTS = "certs";
public static final String BASE_API_APPS = "api_apps";
- public static final String PATH_ACCOUNTS = "accounts";
public static final String PATH_ALLOWED_KEYS = "allowed_keys";
public static class KeyRings implements BaseColumns, KeysColumns, UserPacketsColumns {
@@ -317,33 +307,6 @@ public class KeychainContract {
}
}
- public static class ApiAccounts implements ApiAppsAccountsColumns, BaseColumns {
- public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
- .appendPath(BASE_API_APPS).build();
-
- /**
- * Use if multiple items get returned
- */
- public static final String CONTENT_TYPE
- = "vnd.android.cursor.dir/vnd.org.sufficientlysecure.keychain.provider.api_apps.accounts";
-
- /**
- * Use if a single item is returned
- */
- public static final String CONTENT_ITEM_TYPE
- = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.provider.api_apps.accounts";
-
- public static Uri buildBaseUri(String packageName) {
- return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS)
- .build();
- }
-
- public static Uri buildByPackageAndAccountUri(String packageName, String accountName) {
- return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS)
- .appendEncodedPath(accountName).build();
- }
- }
-
public static class ApiAllowedKeys implements ApiAppsAllowedKeysColumns, BaseColumns {
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
.appendPath(BASE_API_APPS).build();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
index dd897c84a..ae822515e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java
@@ -31,7 +31,6 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAllowedKeysColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns;
import org.sufficientlysecure.keychain.provider.KeychainContract.CertsColumns;
@@ -63,7 +62,6 @@ public class KeychainDatabase extends SQLiteOpenHelper {
String USER_PACKETS = "user_packets";
String CERTS = "certs";
String API_APPS = "api_apps";
- String API_ACCOUNTS = "api_accounts";
String API_ALLOWED_KEYS = "api_allowed_keys";
}
@@ -162,22 +160,6 @@ public class KeychainDatabase extends SQLiteOpenHelper {
+ ApiAppsColumns.PACKAGE_CERTIFICATE + " BLOB"
+ ")";
- private static final String CREATE_API_APPS_ACCOUNTS =
- "CREATE TABLE IF NOT EXISTS " + Tables.API_ACCOUNTS + " ("
- + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
- + ApiAppsAccountsColumns.ACCOUNT_NAME + " TEXT NOT NULL, "
- + ApiAppsAccountsColumns.KEY_ID + " INTEGER, "
- + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, "
- + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, "
- + ApiAppsAccountsColumns.COMPRESSION + " INTEGER, "
- + ApiAppsAccountsColumns.PACKAGE_NAME + " TEXT NOT NULL, "
-
- + "UNIQUE(" + ApiAppsAccountsColumns.ACCOUNT_NAME + ", "
- + ApiAppsAccountsColumns.PACKAGE_NAME + "), "
- + "FOREIGN KEY(" + ApiAppsAccountsColumns.PACKAGE_NAME + ") REFERENCES "
- + Tables.API_APPS + "(" + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE"
- + ")";
-
private static final String CREATE_API_APPS_ALLOWED_KEYS =
"CREATE TABLE IF NOT EXISTS " + Tables.API_ALLOWED_KEYS + " ("
+ BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
@@ -206,7 +188,6 @@ public class KeychainDatabase extends SQLiteOpenHelper {
db.execSQL(CREATE_CERTS);
db.execSQL(CREATE_UPDATE_KEYS);
db.execSQL(CREATE_API_APPS);
- db.execSQL(CREATE_API_APPS_ACCOUNTS);
db.execSQL(CREATE_API_APPS_ALLOWED_KEYS);
db.execSQL("CREATE INDEX keys_by_rank ON keys (" + KeysColumns.RANK + ");");
@@ -281,7 +262,8 @@ public class KeychainDatabase extends SQLiteOpenHelper {
case 10:
// fix problems in database, see #1402 for details
// https://github.com/open-keychain/open-keychain/issues/1402
- db.execSQL("DELETE FROM api_accounts WHERE key_id BETWEEN 0 AND 3");
+ // no longer needed, api_accounts is deprecated
+ // db.execSQL("DELETE FROM api_accounts WHERE key_id BETWEEN 0 AND 3");
case 11:
db.execSQL(CREATE_UPDATE_KEYS);
case 12:
@@ -316,6 +298,14 @@ public class KeychainDatabase extends SQLiteOpenHelper {
// no consolidate for now, often crashes!
return;
}
+ /* TODO actually drop this table. leaving it around for now!
+ case 20:
+ db.execSQL("DROP TABLE api_accounts");
+ if (oldVersion == 20) {
+ // no need to consolidate
+ return;
+ }
+ */
}
// TODO: don't depend on consolidate! make migrations inline!
@@ -380,7 +370,6 @@ public class KeychainDatabase extends SQLiteOpenHelper {
// DANGEROUS, use in test code ONLY!
public void clearDatabase() {
getWritableDatabase().execSQL("delete from " + Tables.KEY_RINGS_PUBLIC);
- getWritableDatabase().execSQL("delete from " + Tables.API_ACCOUNTS);
getWritableDatabase().execSQL("delete from " + Tables.API_ALLOWED_KEYS);
getWritableDatabase().execSQL("delete from " + Tables.API_APPS);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
index 4115cbadf..1554cd46b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2012-2014 Dominik Schürmann
* Copyright (C) 2010-2014 Thialfihar
- * Copyright (C) 2014-2016 Vincent Breitmoser
+ * Copyright (C) 2014-2017 Vincent Breitmoser
*
* 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
@@ -33,7 +33,6 @@ import android.text.TextUtils;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute;
-import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAllowedKeys;
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
@@ -70,8 +69,6 @@ public class KeychainProvider extends ContentProvider {
private static final int API_APPS = 301;
private static final int API_APPS_BY_PACKAGE_NAME = 302;
- private static final int API_ACCOUNTS = 303;
- private static final int API_ACCOUNTS_BY_ACCOUNT_NAME = 304;
private static final int API_ALLOWED_KEYS = 305;
private static final int KEY_RINGS_FIND_BY_EMAIL = 400;
@@ -184,20 +181,12 @@ public class KeychainProvider extends ContentProvider {
* api_apps
* api_apps/_ (package name)
*
- * api_apps/_/accounts
- * api_apps/_/accounts/_ (account name)
- *
* api_apps/_/allowed_keys
*
*/
matcher.addURI(authority, KeychainContract.BASE_API_APPS, API_APPS);
matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*", API_APPS_BY_PACKAGE_NAME);
- matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*/"
- + KeychainContract.PATH_ACCOUNTS, API_ACCOUNTS);
- matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*/"
- + KeychainContract.PATH_ACCOUNTS + "/*", API_ACCOUNTS_BY_ACCOUNT_NAME);
-
matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*/"
+ KeychainContract.PATH_ALLOWED_KEYS, API_ALLOWED_KEYS);
@@ -257,12 +246,6 @@ public class KeychainProvider extends ContentProvider {
case API_APPS_BY_PACKAGE_NAME:
return ApiApps.CONTENT_ITEM_TYPE;
- case API_ACCOUNTS:
- return ApiAccounts.CONTENT_TYPE;
-
- case API_ACCOUNTS_BY_ACCOUNT_NAME:
- return ApiAccounts.CONTENT_ITEM_TYPE;
-
case API_ALLOWED_KEYS:
return ApiAllowedKeys.CONTENT_TYPE;
@@ -680,26 +663,9 @@ public class KeychainProvider extends ContentProvider {
break;
}
- case API_ACCOUNTS: {
- qb.setTables(Tables.API_ACCOUNTS);
- qb.appendWhere(Tables.API_ACCOUNTS + "." + ApiAccounts.PACKAGE_NAME + " = ");
- qb.appendWhereEscapeString(uri.getPathSegments().get(1));
-
- break;
- }
- case API_ACCOUNTS_BY_ACCOUNT_NAME: {
- qb.setTables(Tables.API_ACCOUNTS);
- qb.appendWhere(Tables.API_ACCOUNTS + "." + ApiAccounts.PACKAGE_NAME + " = ");
- qb.appendWhereEscapeString(uri.getPathSegments().get(1));
-
- qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + ApiAccounts.ACCOUNT_NAME + " = ");
- qb.appendWhereEscapeString(uri.getLastPathSegment());
-
- break;
- }
case API_ALLOWED_KEYS: {
qb.setTables(Tables.API_ALLOWED_KEYS);
- qb.appendWhere(Tables.API_ALLOWED_KEYS + "." + ApiAccounts.PACKAGE_NAME + " = ");
+ qb.appendWhere(Tables.API_ALLOWED_KEYS + "." + ApiAllowedKeys.PACKAGE_NAME + " = ");
qb.appendWhereEscapeString(uri.getPathSegments().get(1));
break;
@@ -823,15 +789,6 @@ public class KeychainProvider extends ContentProvider {
db.insertOrThrow(Tables.API_APPS, null, values);
break;
}
- case API_ACCOUNTS: {
- // set foreign key automatically based on given uri
- // e.g., api_apps/com.example.app/accounts/
- String packageName = uri.getPathSegments().get(1);
- values.put(ApiAccounts.PACKAGE_NAME, packageName);
-
- db.insertOrThrow(Tables.API_ACCOUNTS, null, values);
- break;
- }
case API_ALLOWED_KEYS: {
// set foreign key automatically based on given uri
// e.g., api_apps/com.example.app/allowed_keys/
@@ -906,11 +863,6 @@ public class KeychainProvider extends ContentProvider {
selectionArgs);
break;
}
- case API_ACCOUNTS_BY_ACCOUNT_NAME: {
- count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, additionalSelection),
- selectionArgs);
- break;
- }
case API_ALLOWED_KEYS: {
count = db.delete(Tables.API_ALLOWED_KEYS, buildDefaultApiAllowedKeysSelection(uri, additionalSelection),
selectionArgs);
@@ -959,11 +911,6 @@ public class KeychainProvider extends ContentProvider {
buildDefaultApiAppsSelection(uri, selection), selectionArgs);
break;
}
- case API_ACCOUNTS_BY_ACCOUNT_NAME: {
- count = db.update(Tables.API_ACCOUNTS, values,
- buildDefaultApiAccountsSelection(uri, selection), selectionArgs);
- break;
- }
default: {
throw new UnsupportedOperationException("Unknown uri: " + uri);
}
@@ -998,20 +945,6 @@ public class KeychainProvider extends ContentProvider {
return ApiApps.PACKAGE_NAME + "=" + packageName + andSelection;
}
- private String buildDefaultApiAccountsSelection(Uri uri, String selection) {
- String packageName = DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(1));
- String accountName = DatabaseUtils.sqlEscapeString(uri.getLastPathSegment());
-
- String andSelection = "";
- if (!TextUtils.isEmpty(selection)) {
- andSelection = " AND (" + selection + ")";
- }
-
- return ApiAccounts.PACKAGE_NAME + "=" + packageName + " AND "
- + ApiAccounts.ACCOUNT_NAME + "=" + accountName
- + andSelection;
- }
-
private String buildDefaultApiAllowedKeysSelection(Uri uri, String selection) {
String packageName = DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(1));
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java
deleted file mode 100644
index 5d23176be..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Dominik Schürmann
- *
- * 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 .
- */
-
-package org.sufficientlysecure.keychain.remote;
-
-import org.sufficientlysecure.keychain.Constants;
-
-/**
- * DEPRECATED API
- */
-public class AccountSettings {
- private String mAccountName;
- private long mKeyId = Constants.key.none;
-
- public AccountSettings() {
-
- }
-
- public AccountSettings(String accountName) {
- super();
- this.mAccountName = accountName;
- }
-
- public String getAccountName() {
- return mAccountName;
- }
-
- public void setAccountName(String mAccountName) {
- this.mAccountName = mAccountName;
- }
-
- public long getKeyId() {
- return mKeyId;
- }
-
- public void setKeyId(long scretKeyId) {
- this.mKeyId = scretKeyId;
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java
index c8838d86c..ea2298b23 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPendingIntentFactory.java
@@ -27,7 +27,6 @@ import android.os.Build;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.remote.ui.RemoteBackupActivity;
-import org.sufficientlysecure.keychain.remote.ui.RemoteCreateAccountActivity;
import org.sufficientlysecure.keychain.remote.ui.RemoteErrorActivity;
import org.sufficientlysecure.keychain.remote.ui.RemoteImportKeysActivity;
import org.sufficientlysecure.keychain.remote.ui.RemotePassphraseDialogActivity;
@@ -135,15 +134,6 @@ public class ApiPendingIntentFactory {
return createInternal(data, intent);
}
- @Deprecated
- PendingIntent createAccountCreationPendingIntent(Intent data, String packageName, String accountName) {
- Intent intent = new Intent(mContext, RemoteCreateAccountActivity.class);
- intent.putExtra(RemoteCreateAccountActivity.EXTRA_PACKAGE_NAME, packageName);
- intent.putExtra(RemoteCreateAccountActivity.EXTRA_ACC_NAME, accountName);
-
- return createInternal(data, intent);
- }
-
PendingIntent createErrorPendingIntent(Intent data, String errorMessage) {
Intent intent = new Intent(mContext, RemoteErrorActivity.class);
intent.putExtra(RemoteErrorActivity.EXTRA_ERROR_MESSAGE, errorMessage);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java
index a40296ef3..3bd43b1e4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ApiPermissionHelper.java
@@ -30,7 +30,6 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
-import android.net.Uri;
import android.os.Binder;
import org.openintents.openpgp.OpenPgpError;
@@ -38,7 +37,6 @@ import org.openintents.openpgp.util.OpenPgpApi;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
-import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.util.Log;
@@ -166,37 +164,6 @@ public class ApiPermissionHelper {
return currentPkg;
}
- /**
- * Retrieves AccountSettings from database for the application calling this remote service
- */
- @Deprecated
- protected AccountSettings getAccSettings(String accountName) {
- String currentPkg = getCurrentCallingPackage();
- Log.d(Constants.TAG, "getAccSettings accountName: " + accountName);
-
- Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(currentPkg, accountName);
-
- return mApiDao.getApiAccountSettings(uri); // can be null!
- }
-
- @Deprecated
- protected Intent getCreateAccountIntent(Intent data, String accountName) {
- String packageName = getCurrentCallingPackage();
- Log.d(Constants.TAG, "getCreateAccountIntent accountName: " + accountName);
-
- ApiPendingIntentFactory piFactory = new ApiPendingIntentFactory(mContext);
-
- PendingIntent pi = piFactory.createAccountCreationPendingIntent(data,
- packageName, accountName);
-
- // return PendingIntent to be executed by client
- Intent result = new Intent();
- result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED);
- result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
-
- return result;
- }
-
/**
* Checks if process that binds to this service (i.e. the package name corresponding to the
* process) is in the list of allowed package names.
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
index 164794af1..252124043 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java
@@ -38,7 +38,6 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.text.TextUtils;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.openintents.openpgp.IOpenPgpService;
@@ -65,7 +64,6 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
import org.sufficientlysecure.keychain.provider.KeyRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract;
-import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.remote.OpenPgpServiceKeyIdExtractor.KeyIdResult;
import org.sufficientlysecure.keychain.service.BackupKeyringParcel;
@@ -76,16 +74,13 @@ import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase;
public class OpenPgpService extends Service {
- public static final int API_VERSION_WITH_RESULT_METADATA = 4;
- public static final int API_VERSION_WITH_KEY_REVOKED_EXPIRED = 5;
- public static final int API_VERSION_HIGHEST_WITH_ACCOUNTS = 6;
public static final int API_VERSION_WITH_KEY_INVALID_INSECURE = 8;
public static final int API_VERSION_WITHOUT_SIGNATURE_ONLY_FLAG = 8;
public static final int API_VERSION_WITH_DECRYPTION_RESULT = 8;
public static final int API_VERSION_WITH_RESULT_NO_SIGNATURE = 8;
public static final List SUPPORTED_VERSIONS =
- Collections.unmodifiableList(Arrays.asList(3, 4, 5, 6, 7, 8, 9, 10, 11));
+ Collections.unmodifiableList(Arrays.asList(7, 8, 9, 10, 11));
private ApiPermissionHelper mApiPermissionHelper;
private KeyRepository mKeyRepository;
@@ -109,8 +104,6 @@ public class OpenPgpService extends Service {
try {
boolean asciiArmor = cleartextSign || data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
- int targetApiVersion = data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1);
-
// sign-only
PgpSignEncryptData pgpData = new PgpSignEncryptData();
pgpData.setEnableAsciiArmorOutput(asciiArmor)
@@ -145,7 +138,7 @@ public class OpenPgpService extends Service {
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData);
- pseInput.setAllowedKeyIds(getAllowedKeyIds(targetApiVersion));
+ pseInput.setAllowedKeyIds(getAllowedKeyIds());
// Get Input- and OutputStream from ParcelFileDescriptor
if (!cleartextSign) {
@@ -207,7 +200,6 @@ public class OpenPgpService extends Service {
OutputStream outputStream, boolean sign) {
try {
boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
- int targetApiVersion = data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1);
String originalFilename = data.getStringExtra(OpenPgpApi.EXTRA_ORIGINAL_FILENAME);
if (originalFilename == null) {
originalFilename = "";
@@ -267,22 +259,8 @@ public class OpenPgpService extends Service {
.setAdditionalEncryptId(signKeyId); // add sign key for encryption
}
- // OLD: Even if the message is not signed: Do self-encrypt to account key id
- if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 7) {
- String accName = data.getStringExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME);
- // if no account name is given use name "default"
- if (TextUtils.isEmpty(accName)) {
- accName = "default";
- }
- final AccountSettings accSettings = mApiPermissionHelper.getAccSettings(accName);
- if (accSettings == null || (accSettings.getKeyId() == Constants.key.none)) {
- return mApiPermissionHelper.getCreateAccountIntent(data, accName);
- }
- pgpData.setAdditionalEncryptId(accSettings.getKeyId());
- }
-
PgpSignEncryptInputParcel pseInput = new PgpSignEncryptInputParcel(pgpData);
- pseInput.setAllowedKeyIds(getAllowedKeyIds(targetApiVersion));
+ pseInput.setAllowedKeyIds(getAllowedKeyIds());
CryptoInputParcel inputParcel = CryptoInputParcelCacheService.getCryptoInputParcel(this, data);
if (inputParcel == null) {
@@ -365,7 +343,7 @@ public class OpenPgpService extends Service {
// no support for symmetric encryption
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel()
.setAllowSymmetricDecryption(false)
- .setAllowedKeyIds(getAllowedKeyIds(targetApiVersion))
+ .setAllowedKeyIds(getAllowedKeyIds())
.setDecryptMetadataOnly(decryptMetadataOnly)
.setDetachedSignature(detachedSignature)
.setSenderAddress(senderAddress);
@@ -387,7 +365,7 @@ public class OpenPgpService extends Service {
Intent result = new Intent();
processDecryptionResultForResultIntent(targetApiVersion, result, pgpResult.getDecryptionResult());
- processMetadataForResultIntent(targetApiVersion, result, pgpResult.getDecryptionMetadata());
+ processMetadataForResultIntent(result, pgpResult.getDecryptionMetadata());
processSignatureResultForResultIntent(targetApiVersion, data, result, pgpResult);
result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
@@ -437,14 +415,6 @@ public class OpenPgpService extends Service {
int targetApiVersion, DecryptVerifyResult pgpResult) {
OpenPgpSignatureResult signatureResult = pgpResult.getSignatureResult();
- if (targetApiVersion < API_VERSION_WITH_KEY_REVOKED_EXPIRED) {
- // RESULT_INVALID_KEY_REVOKED and RESULT_INVALID_KEY_EXPIRED have been added in version 5
- if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_REVOKED
- || signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_EXPIRED) {
- signatureResult = OpenPgpSignatureResult.createWithInvalidSignature();
- }
- }
-
if (targetApiVersion < API_VERSION_WITH_KEY_INVALID_INSECURE) {
// RESULT_INVALID_INSECURE has been added in version 8, fallback to RESULT_INVALID_SIGNATURE
if (signatureResult.getResult() == OpenPgpSignatureResult.RESULT_INVALID_KEY_INSECURE) {
@@ -464,16 +434,12 @@ public class OpenPgpService extends Service {
return signatureResult;
}
- private void processMetadataForResultIntent(int targetApiVersion, Intent result, OpenPgpMetadata metadata) {
+ private void processMetadataForResultIntent(Intent result, OpenPgpMetadata metadata) {
String charset = metadata != null ? metadata.getCharset() : null;
if (charset != null) {
result.putExtra(OpenPgpApi.RESULT_CHARSET, charset);
}
- if (targetApiVersion < API_VERSION_WITH_RESULT_METADATA) {
- return;
- }
-
if (metadata != null) {
result.putExtra(OpenPgpApi.RESULT_METADATA, metadata);
}
@@ -666,45 +632,18 @@ public class OpenPgpService extends Service {
}
private Intent getSignKeyMasterId(Intent data) {
- // NOTE: Accounts are deprecated on API version >= 7
- if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) < 7) {
- String accName = data.getStringExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME);
- // if no account name is given use name "default"
- if (TextUtils.isEmpty(accName)) {
- accName = "default";
- }
- Log.d(Constants.TAG, "accName: " + accName);
- // fallback to old API
- final AccountSettings accSettings = mApiPermissionHelper.getAccSettings(accName);
- if (accSettings == null || (accSettings.getKeyId() == Constants.key.none)) {
- return mApiPermissionHelper.getCreateAccountIntent(data, accName);
- }
-
- // NOTE: just wrapping the key id
- Intent result = new Intent();
- result.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, accSettings.getKeyId());
- return result;
- } else {
- long signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, Constants.key.none);
- if (signKeyId == Constants.key.none) {
- return getSignKeyIdImpl(data);
- }
-
- return data;
+ long signKeyId = data.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, Constants.key.none);
+ if (signKeyId == Constants.key.none) {
+ return getSignKeyIdImpl(data);
}
+
+ return data;
}
- private HashSet getAllowedKeyIds(int targetApiVersion) {
+ private HashSet getAllowedKeyIds() {
String currentPkg = mApiPermissionHelper.getCurrentCallingPackage();
- HashSet allowedKeyIds = mApiDao.getAllowedKeyIdsForApp(
+ return mApiDao.getAllowedKeyIdsForApp(
KeychainContract.ApiAllowedKeys.buildBaseUri(currentPkg));
-
- if (targetApiVersion <= API_VERSION_HIGHEST_WITH_ACCOUNTS) {
- allowedKeyIds.addAll(mApiDao.getAllKeyIdsForApp(
- ApiAccounts.buildBaseUri(currentPkg)));
- }
-
- return allowedKeyIds;
}
/**
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java
deleted file mode 100644
index 27700b5e6..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Dominik Schürmann
- *
- * 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 .
- */
-
-package org.sufficientlysecure.keychain.remote.ui;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.operations.results.OperationResult;
-import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
-import org.sufficientlysecure.keychain.operations.results.SingletonResult;
-import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
-import org.sufficientlysecure.keychain.remote.AccountSettings;
-import org.sufficientlysecure.keychain.ui.base.BaseActivity;
-import org.sufficientlysecure.keychain.util.Log;
-
-public class AccountSettingsActivity extends BaseActivity {
- private Uri mAccountUri;
-
- private AccountSettingsFragment mAccountSettingsFragment;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Inflate a "Done" custom action bar
- setFullScreenDialogDoneClose(R.string.api_settings_save,
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- save();
- }
- },
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
- setTitle(null);
-
- mAccountSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById(
- R.id.api_account_settings_fragment);
-
- Intent intent = getIntent();
- mAccountUri = intent.getData();
- if (mAccountUri == null) {
- Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
- finish();
- return;
- } else {
- Log.d(Constants.TAG, "uri: " + mAccountUri);
- loadData(mAccountUri);
- }
- }
-
- @Override
- protected void initLayout() {
- setContentView(R.layout.api_account_settings_activity);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- getMenuInflater().inflate(R.menu.api_account_settings, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_account_settings_delete: {
- deleteAccount();
- return true;
- }
- }
- return super.onOptionsItemSelected(item);
- }
-
- private void loadData(Uri accountUri) {
- AccountSettings settings = new ApiDataAccessObject(this).getApiAccountSettings(accountUri);
- mAccountSettingsFragment.setAccSettings(settings);
- }
-
- private void deleteAccount() {
- if (getContentResolver().delete(mAccountUri, null, null) <= 0) {
- throw new RuntimeException();
- }
- finish();
- }
-
- private void save() {
- new ApiDataAccessObject(this).updateApiAccount(mAccountUri, mAccountSettingsFragment.getAccSettings());
- SingletonResult result = new SingletonResult(
- SingletonResult.RESULT_OK, LogType.MSG_ACC_SAVED);
- Intent intent = new Intent();
- intent.putExtra(SingletonResult.EXTRA_RESULT, result);
- setResult(RESULT_OK, intent);
- finish();
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- // if a result has been returned, display a notify
- if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
- OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
- result.createNotify(this).show();
- } else {
- super.onActivityResult(requestCode, resultCode, data);
- }
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java
deleted file mode 100644
index bcfe54f93..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2013-2014 Dominik Schürmann
- *
- * 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 .
- */
-
-package org.sufficientlysecure.keychain.remote.ui;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import org.openintents.openpgp.util.OpenPgpUtils;
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
-import org.sufficientlysecure.keychain.operations.results.OperationResult;
-import org.sufficientlysecure.keychain.pgp.KeyRing;
-import org.sufficientlysecure.keychain.remote.AccountSettings;
-import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
-import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
-import org.sufficientlysecure.keychain.ui.widget.SignKeySpinner;
-import org.sufficientlysecure.keychain.util.Log;
-
-public class AccountSettingsFragment extends Fragment {
-
- private static final int REQUEST_CODE_CREATE_KEY = 0x00008884;
-
- // model
- private AccountSettings mAccSettings;
-
- // view
- private TextView mAccNameView;
-
- private SignKeySpinner mSelectKeySpinner;
- private View mCreateKeyButton;
-
- public AccountSettings getAccSettings() {
- return mAccSettings;
- }
-
- public void setAccSettings(AccountSettings accountSettings) {
- this.mAccSettings = accountSettings;
-
- mAccNameView.setText(accountSettings.getAccountName());
- mSelectKeySpinner.setPreSelectedKeyId(accountSettings.getKeyId());
- }
-
- /**
- * Inflate the layout for this fragment
- */
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.api_account_settings_fragment, container, false);
- initView(view);
- return view;
- }
-
- private void initView(View view) {
- mSelectKeySpinner = (SignKeySpinner) view.findViewById(R.id.api_account_settings_key_spinner);
- mAccNameView = (TextView) view.findViewById(R.id.api_account_settings_acc_name);
- mCreateKeyButton = view.findViewById(R.id.api_account_settings_create_key);
-
- mSelectKeySpinner.setOnKeyChangedListener(new KeySpinner.OnKeyChangedListener() {
- @Override
- public void onKeyChanged(long masterKeyId) {
- mAccSettings.setKeyId(masterKeyId);
- }
- });
-
- mCreateKeyButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- createKey();
- }
- });
- }
-
- private void createKey() {
- OpenPgpUtils.UserId userId = KeyRing.splitUserId(mAccSettings.getAccountName());
-
- Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
- intent.putExtra(CreateKeyActivity.EXTRA_NAME, userId.name);
- intent.putExtra(CreateKeyActivity.EXTRA_EMAIL, userId.email);
- startActivityForResult(intent, REQUEST_CODE_CREATE_KEY);
- }
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- switch (requestCode) {
- case REQUEST_CODE_CREATE_KEY: {
- if (resultCode == Activity.RESULT_OK) {
- if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
- EditKeyResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
- mSelectKeySpinner.setPreSelectedKeyId(result.mMasterKeyId);
- } else {
- Log.e(Constants.TAG, "missing result!");
- }
- }
- break;
- }
- }
-
- // execute activity's onActivityResult to show log notify
- super.onActivityResult(requestCode, resultCode, data);
- }
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java
deleted file mode 100644
index d00a74927..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2014 Dominik Schürmann
- *
- * 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 .
- */
-
-package org.sufficientlysecure.keychain.remote.ui;
-
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.net.Uri;
-import android.os.Bundle;
-import android.support.v4.app.ListFragment;
-import android.support.v4.app.LoaderManager;
-import android.support.v4.content.CursorLoader;
-import android.support.v4.content.Loader;
-import android.support.v4.widget.CursorAdapter;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.provider.KeychainContract;
-import org.sufficientlysecure.keychain.ui.widget.FixedListView;
-import org.sufficientlysecure.keychain.util.Log;
-
-public class AccountsListFragment extends ListFragment implements
- LoaderManager.LoaderCallbacks {
-
- private static final String ARG_DATA_URI = "uri";
-
- // This is the Adapter being used to display the list's data.
- AccountsAdapter mAdapter;
-
- private Uri mDataUri;
-
- /**
- * Creates new instance of this fragment
- */
- public static AccountsListFragment newInstance(Uri dataUri) {
- AccountsListFragment frag = new AccountsListFragment();
-
- Bundle args = new Bundle();
- args.putParcelable(ARG_DATA_URI, dataUri);
-
- frag.setArguments(args);
-
- return frag;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View layout = super.onCreateView(inflater, container,
- savedInstanceState);
- ListView lv = (ListView) layout.findViewById(android.R.id.list);
- ViewGroup parent = (ViewGroup) lv.getParent();
-
- /*
- * http://stackoverflow.com/a/15880684
- * Remove ListView and add FixedListView in its place.
- * This is done here programatically to be still able to use the progressBar of ListFragment.
- *
- * We want FixedListView to be able to put this ListFragment inside a ScrollView
- */
- int lvIndex = parent.indexOfChild(lv);
- parent.removeViewAt(lvIndex);
- FixedListView newLv = new FixedListView(getActivity());
- newLv.setId(android.R.id.list);
- parent.addView(newLv, lvIndex, lv.getLayoutParams());
- return layout;
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
-
- mDataUri = getArguments().getParcelable(ARG_DATA_URI);
-
- getListView().setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
- String selectedAccountName = mAdapter.getItemAccountName(position);
- Uri accountUri = mDataUri.buildUpon().appendEncodedPath(selectedAccountName).build();
- Log.d(Constants.TAG, "accountUri: " + accountUri);
-
- // edit account settings
- Intent intent = new Intent(getActivity(), AccountSettingsActivity.class);
- intent.setData(accountUri);
- startActivityForResult(intent, 0);
- }
- });
-
- // Give some text to display if there is no data. In a real
- // application this would come from a resource.
- setEmptyText(getString(R.string.api_settings_accounts_empty));
-
- // We have a menu item to show in action bar.
- setHasOptionsMenu(true);
-
- // Create an empty adapter we will use to display the loaded data.
- mAdapter = new AccountsAdapter(getActivity(), null, 0);
- setListAdapter(mAdapter);
-
- // Prepare the loader. Either re-connect with an existing one,
- // or start a new one.
- getLoaderManager().initLoader(0, null, this);
- }
-
- // These are the Contacts rows that we will retrieve.
- static final String[] PROJECTION = new String[]{
- KeychainContract.ApiAccounts._ID, // 0
- KeychainContract.ApiAccounts.ACCOUNT_NAME // 1
- };
-
- public Loader onCreateLoader(int id, Bundle args) {
- // This is called when a new Loader needs to be created. This
- // sample only has one Loader, so we don't care about the ID.
-
- // Now create and return a CursorLoader that will take care of
- // creating a Cursor for the data being displayed.
- return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null,
- KeychainContract.ApiAccounts.ACCOUNT_NAME + " COLLATE LOCALIZED ASC");
- }
-
- public void onLoadFinished(Loader loader, Cursor data) {
- // Swap the new cursor in. (The framework will take care of closing the
- // old cursor once we return.)
- mAdapter.swapCursor(data);
- }
-
- public void onLoaderReset(Loader loader) {
- // This is called when the last Cursor provided to onLoadFinished()
- // above is about to be closed. We need to make sure we are no
- // longer using it.
- mAdapter.swapCursor(null);
- }
-
- private class AccountsAdapter extends CursorAdapter {
- private LayoutInflater mInflater;
-
- public AccountsAdapter(Context context, Cursor c, int flags) {
- super(context, c, flags);
-
- mInflater = LayoutInflater.from(context);
- }
-
- /**
- * Similar to CursorAdapter.getItemId().
- * Required to build Uris for api accounts, which are not based on row ids
- *
- * @param position
- * @return
- */
- public String getItemAccountName(int position) {
- if (mDataValid && mCursor != null) {
- if (mCursor.moveToPosition(position)) {
- return mCursor.getString(1);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- @Override
- public void bindView(View view, Context context, Cursor cursor) {
- TextView text = (TextView) view.findViewById(R.id.api_accounts_adapter_item_name);
-
- String accountName = cursor.getString(1);
- text.setText(accountName);
- }
-
- @Override
- public View newView(Context context, Cursor cursor, ViewGroup parent) {
- return mInflater.inflate(R.layout.api_accounts_adapter_list_item, null);
- }
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
index 249c0c208..194d5f475 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java
@@ -17,11 +17,14 @@
package org.sufficientlysecure.keychain.remote.ui;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
-import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
@@ -31,8 +34,6 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
-import com.getbase.floatingactionbutton.FloatingActionButton;
-
import org.bouncycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
@@ -44,9 +45,6 @@ import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.ui.dialog.AdvancedAppSettingsDialogFragment;
import org.sufficientlysecure.keychain.util.Log;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
public class AppSettingsActivity extends BaseActivity {
private Uri mAppUri;
@@ -54,14 +52,6 @@ public class AppSettingsActivity extends BaseActivity {
private TextView mAppNameView;
private ImageView mAppIconView;
- private TextView mPackageName;
- private TextView mPackageSignature;
-
- private FloatingActionButton mStartFab;
-
- // deprecated API
- private AccountsListFragment mAccountsListFragment;
- private TextView mAccountsLabel;
// model
@@ -71,14 +61,10 @@ public class AppSettingsActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- mAccountsLabel = (TextView) findViewById(R.id.api_accounts_label);
mAppNameView = (TextView) findViewById(R.id.api_app_settings_app_name);
mAppIconView = (ImageView) findViewById(R.id.api_app_settings_app_icon);
- mPackageName = (TextView) findViewById(R.id.api_app_settings_package_name);
- mPackageSignature = (TextView) findViewById(R.id.api_app_settings_package_certificate);
- mStartFab = (FloatingActionButton) findViewById(R.id.fab);
- mStartFab.setOnClickListener(new View.OnClickListener() {
+ findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startApp();
@@ -99,10 +85,10 @@ public class AppSettingsActivity extends BaseActivity {
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
finish();
return;
- } else {
- Log.d(Constants.TAG, "uri: " + mAppUri);
- loadData(savedInstanceState, mAppUri);
}
+
+ Log.d(Constants.TAG, "uri: " + mAppUri);
+ loadData(savedInstanceState, mAppUri);
}
private void save() {
@@ -200,14 +186,12 @@ public class AppSettingsActivity extends BaseActivity {
mAppNameView.setText(appName);
mAppIconView.setImageDrawable(appIcon);
- Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build();
- Log.d(Constants.TAG, "accountsUri: " + accountsUri);
Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build();
Log.d(Constants.TAG, "allowedKeysUri: " + allowedKeysUri);
- startListFragments(savedInstanceState, accountsUri, allowedKeysUri);
+ startListFragments(savedInstanceState, allowedKeysUri);
}
- private void startListFragments(Bundle savedInstanceState, Uri accountsUri, Uri allowedKeysUri) {
+ private void startListFragments(Bundle savedInstanceState, Uri allowedKeysUri) {
// However, if we're being restored from a previous state,
// then we don't need to do anything and should return or else
// we could end up with overlapping fragments.
@@ -215,19 +199,6 @@ public class AppSettingsActivity extends BaseActivity {
return;
}
- // show accounts only if available (deprecated API)
- Cursor cursor = getContentResolver().query(accountsUri, null, null, null, null);
- if (cursor != null && cursor.moveToFirst()) try {
- mAccountsLabel.setVisibility(View.VISIBLE);
- mAccountsListFragment = AccountsListFragment.newInstance(accountsUri);
- // Create an instance of the fragments
- getSupportFragmentManager().beginTransaction()
- .replace(R.id.api_accounts_list_fragment, mAccountsListFragment)
- .commitAllowingStateLoss();
- } finally {
- cursor.close();
- }
-
// Create an instance of the fragments
mAllowedKeysFragment = AppSettingsAllowedKeysListFragment.newInstance(allowedKeysUri);
// Add the fragment to the 'fragment_container' FrameLayout
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java
index 22a03a7c5..7f64a21ef 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsAllowedKeysListFragment.java
@@ -107,7 +107,7 @@ public class AppSettingsAllowedKeysListFragment extends ListFragmentWorkaround i
// application this would come from a resource.
setEmptyText(getString(R.string.list_empty));
- Set checked = mApiDao.getAllKeyIdsForApp(mDataUri);
+ Set checked = mApiDao.getAllowedKeyIdsForApp(mDataUri);
mAdapter = new KeySelectableAdapter(getActivity(), null, 0, checked);
setListAdapter(mAdapter);
getListView().setOnItemClickListener(mAdapter);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteCreateAccountActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteCreateAccountActivity.java
deleted file mode 100644
index a4a0b242c..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteCreateAccountActivity.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2016 Dominik Schürmann
- *
- * 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 .
- */
-
-package org.sufficientlysecure.keychain.remote.ui;
-
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.TextView;
-
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.provider.ApiDataAccessObject;
-import org.sufficientlysecure.keychain.provider.KeychainContract;
-import org.sufficientlysecure.keychain.remote.AccountSettings;
-import org.sufficientlysecure.keychain.ui.base.BaseActivity;
-import org.sufficientlysecure.keychain.ui.util.Notify;
-
-public class RemoteCreateAccountActivity extends BaseActivity {
-
- public static final String EXTRA_ACC_NAME = "acc_name";
- public static final String EXTRA_PACKAGE_NAME = "package_name";
-
- public static final String EXTRA_DATA = "data";
-
- private AccountSettingsFragment mAccSettingsFragment;
-
- boolean mUpdateExistingAccount;
-
- @Override
- protected void initLayout() {
- setContentView(R.layout.api_remote_create_account);
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- final Bundle extras = getIntent().getExtras();
-
- final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
- final String accName = extras.getString(EXTRA_ACC_NAME);
-
- final ApiDataAccessObject apiDao = new ApiDataAccessObject(this);
-
- mAccSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById(
- R.id.api_account_settings_fragment);
-
- TextView text = (TextView) findViewById(R.id.api_remote_create_account_text);
-
- // update existing?
- Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(packageName, accName);
- AccountSettings settings = apiDao.getApiAccountSettings(uri);
- if (settings == null) {
- // create new account
- settings = new AccountSettings(accName);
- mUpdateExistingAccount = false;
-
- text.setText(R.string.api_create_account_text);
- } else {
- // update existing account
- mUpdateExistingAccount = true;
-
- text.setText(R.string.api_update_account_text);
- }
- mAccSettingsFragment.setAccSettings(settings);
-
- // Inflate a "Done"/"Cancel" custom action bar view
- setFullScreenDialogDoneClose(R.string.api_settings_save,
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // Save
-
- // user needs to select a key if it has explicitly requested (None is only allowed for new accounts)
- if (mUpdateExistingAccount && mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
- Notify.create(RemoteCreateAccountActivity.this, getString(R.string.api_register_error_select_key), Notify.Style.ERROR).show();
- } else {
- if (mUpdateExistingAccount) {
- Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);
- Uri accountUri = baseUri.buildUpon().appendEncodedPath(accName).build();
- apiDao.updateApiAccount(
- accountUri,
- mAccSettingsFragment.getAccSettings());
- } else {
- apiDao.insertApiAccount(
- KeychainContract.ApiAccounts.buildBaseUri(packageName),
- mAccSettingsFragment.getAccSettings());
- }
-
- // give data through for new service call
- Intent resultData = extras.getParcelable(EXTRA_DATA);
- RemoteCreateAccountActivity.this.setResult(RESULT_OK, resultData);
- RemoteCreateAccountActivity.this.finish();
- }
- }
- },
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // Cancel
- RemoteCreateAccountActivity.this.setResult(RESULT_CANCELED);
- RemoteCreateAccountActivity.this.finish();
- }
- });
-
- }
-
-}
diff --git a/OpenKeychain/src/main/res/layout/api_account_settings_activity.xml b/OpenKeychain/src/main/res/layout/api_account_settings_activity.xml
deleted file mode 100644
index d2fb291ea..000000000
--- a/OpenKeychain/src/main/res/layout/api_account_settings_activity.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/api_account_settings_fragment.xml b/OpenKeychain/src/main/res/layout/api_account_settings_fragment.xml
deleted file mode 100644
index d8d729fae..000000000
--- a/OpenKeychain/src/main/res/layout/api_account_settings_fragment.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/api_accounts_adapter_list_item.xml b/OpenKeychain/src/main/res/layout/api_accounts_adapter_list_item.xml
deleted file mode 100644
index 39d87ee25..000000000
--- a/OpenKeychain/src/main/res/layout/api_accounts_adapter_list_item.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml
index 5955fe8b5..3185fad1e 100644
--- a/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml
+++ b/OpenKeychain/src/main/res/layout/api_app_settings_activity.xml
@@ -77,20 +77,6 @@
android:padding="16dp"
android:orientation="vertical">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenKeychain/src/main/res/menu/api_account_settings.xml b/OpenKeychain/src/main/res/menu/api_account_settings.xml
deleted file mode 100644
index 713345ffc..000000000
--- a/OpenKeychain/src/main/res/menu/api_account_settings.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
\ No newline at end of file
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 77aa967a5..152b022e3 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -640,21 +640,14 @@
"Select key"
"Create new key"
"Save"
- "Account has been saved"
"Cancel"
"Revoke access"
"Start application"
- "Delete account"
"Package Name"
"SHA-256 of Package Certificate"
- "Accounts (old API)"
"Advanced"
"Allowed Keys"
"Settings"
- "Account key:"
- "No accounts attached to this app."
- "No key is configured for this account. Please select one of your existing keys or create a new one.\nApps can only decrypt/sign with the keys selected here!"
- "The key saved for this account has been deleted. Please select a different one!\nApps can only decrypt/sign with the keys selected here!"
"Allow access to OpenKeychain?"
"%s requests to use OpenKeychain as a crypto provider. You will still be asked for permission before the app can use any of your keys for decryption.\n\nYou can revoke access later in the 'Apps' screen."
"Allow access"
@@ -1465,8 +1458,6 @@
"Data processing successful"
"Skipping MIME parsing"
- "Account saved"
-
"Downloaded successfully!"
"Input file not found!"
"No valid keys found in file/clipboard!"
diff --git a/extern/openpgp-api-lib b/extern/openpgp-api-lib
index cbc5622b9..5aa2affb7 160000
--- a/extern/openpgp-api-lib
+++ b/extern/openpgp-api-lib
@@ -1 +1 @@
-Subproject commit cbc5622b95253b985c2207f493eff220a02d7258
+Subproject commit 5aa2affb752c066232bd7e7bb7c22739fa9f3526