mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
rename crypto consumers to api apps
This commit is contained in:
parent
fcec7e830c
commit
9a737c7318
@ -14,14 +14,13 @@
|
|||||||
tools:layout="@layout/api_app_settings_fragment" />
|
tools:layout="@layout/api_app_settings_fragment" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/register_crypto_consumer_register_layout"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingBottom="3dip" >
|
android:paddingBottom="3dip" >
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/register_crypto_consumer_question"
|
android:id="@+id/api_register_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TODO: use string"
|
android:text="TODO: use string"
|
||||||
@ -34,14 +33,14 @@
|
|||||||
android:paddingBottom="3dip" >
|
android:paddingBottom="3dip" >
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/register_crypto_consumer_disallow"
|
android:id="@+id/api_register_disallow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/api_register_disallow" />
|
android:text="@string/api_register_disallow" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/register_crypto_consumer_allow"
|
android:id="@+id/api_register_allow"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -14,21 +14,20 @@
|
|||||||
tools:layout="@layout/api_app_settings_fragment" />
|
tools:layout="@layout/api_app_settings_fragment" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/register_crypto_consumer_edit_layout"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingBottom="3dip" >
|
android:paddingBottom="3dip" >
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/register_crypto_consumer_disallow"
|
android:id="@+id/api_app_settings_revoke"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/api_settings_revoke" />
|
android:text="@string/api_settings_revoke" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/register_crypto_consumer_allow"
|
android:id="@+id/api_app_settings_save"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -53,7 +53,7 @@ public class KeychainContract {
|
|||||||
String RANK = "rank";
|
String RANK = "rank";
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CryptoConsumersColumns {
|
interface ApiAppsColumns {
|
||||||
String PACKAGE_NAME = "package_name";
|
String PACKAGE_NAME = "package_name";
|
||||||
String PRIVATE_KEY_ID = "private_key_id"; // not a database id
|
String PRIVATE_KEY_ID = "private_key_id"; // not a database id
|
||||||
String ASCII_ARMOR = "ascii_armor";
|
String ASCII_ARMOR = "ascii_armor";
|
||||||
@ -87,7 +87,7 @@ public class KeychainContract {
|
|||||||
public static final String PATH_USER_IDS = "user_ids";
|
public static final String PATH_USER_IDS = "user_ids";
|
||||||
public static final String PATH_KEYS = "keys";
|
public static final String PATH_KEYS = "keys";
|
||||||
|
|
||||||
public static final String BASE_CRYPTO_CONSUMERS = "crypto_consumers";
|
public static final String BASE_API_APPS = "api_apps";
|
||||||
public static final String PATH_BY_PACKAGE_NAME = "package_name";
|
public static final String PATH_BY_PACKAGE_NAME = "package_name";
|
||||||
|
|
||||||
public static class KeyRings implements KeyRingsColumns, BaseColumns {
|
public static class KeyRings implements KeyRingsColumns, BaseColumns {
|
||||||
@ -219,15 +219,15 @@ public class KeychainContract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CryptoConsumers implements CryptoConsumersColumns, BaseColumns {
|
public static class ApiApps implements ApiAppsColumns, BaseColumns {
|
||||||
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
|
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
|
||||||
.appendPath(BASE_CRYPTO_CONSUMERS).build();
|
.appendPath(BASE_API_APPS).build();
|
||||||
|
|
||||||
/** Use if multiple items get returned */
|
/** Use if multiple items get returned */
|
||||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.crypto_consumers";
|
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_apps";
|
||||||
|
|
||||||
/** Use if a single item is returned */
|
/** Use if a single item is returned */
|
||||||
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.crypto_consumers";
|
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_apps";
|
||||||
|
|
||||||
public static Uri buildIdUri(String rowId) {
|
public static Uri buildIdUri(String rowId) {
|
||||||
return CONTENT_URI.buildUpon().appendPath(rowId).build();
|
return CONTENT_URI.buildUpon().appendPath(rowId).build();
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package org.sufficientlysecure.keychain.provider;
|
package org.sufficientlysecure.keychain.provider;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumersColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns;
|
||||||
@ -37,7 +37,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
String KEY_RINGS = "key_rings";
|
String KEY_RINGS = "key_rings";
|
||||||
String KEYS = "keys";
|
String KEYS = "keys";
|
||||||
String USER_IDS = "user_ids";
|
String USER_IDS = "user_ids";
|
||||||
String CRYPTO_CONSUMERS = "crypto_consumers";
|
String API_APPS = "api_apps";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS
|
private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS
|
||||||
@ -64,14 +64,14 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
+ UserIdsColumns.KEY_RING_ROW_ID + ") REFERENCES " + Tables.KEY_RINGS + "("
|
+ UserIdsColumns.KEY_RING_ROW_ID + ") REFERENCES " + Tables.KEY_RINGS + "("
|
||||||
+ BaseColumns._ID + ") ON DELETE CASCADE)";
|
+ BaseColumns._ID + ") ON DELETE CASCADE)";
|
||||||
|
|
||||||
private static final String CREATE_CRYPTO_CONSUMERS = "CREATE TABLE IF NOT EXISTS "
|
private static final String CREATE_API_APPS = "CREATE TABLE IF NOT EXISTS "
|
||||||
+ Tables.CRYPTO_CONSUMERS + " (" + BaseColumns._ID
|
+ Tables.API_APPS + " (" + BaseColumns._ID
|
||||||
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + CryptoConsumersColumns.PACKAGE_NAME
|
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + ApiAppsColumns.PACKAGE_NAME
|
||||||
+ " TEXT UNIQUE, " + CryptoConsumersColumns.PRIVATE_KEY_ID + " INT64, "
|
+ " TEXT UNIQUE, " + ApiAppsColumns.PRIVATE_KEY_ID + " INT64, "
|
||||||
+ CryptoConsumersColumns.ASCII_ARMOR + " INTEGER, "
|
+ ApiAppsColumns.ASCII_ARMOR + " INTEGER, "
|
||||||
+ CryptoConsumersColumns.ENCRYPTION_ALGORITHM + " INTEGER, "
|
+ ApiAppsColumns.ENCRYPTION_ALGORITHM + " INTEGER, "
|
||||||
+ CryptoConsumersColumns.HASH_ALORITHM + " INTEGER, "
|
+ ApiAppsColumns.HASH_ALORITHM + " INTEGER, "
|
||||||
+ CryptoConsumersColumns.COMPRESSION + " INTEGER)";
|
+ ApiAppsColumns.COMPRESSION + " INTEGER)";
|
||||||
|
|
||||||
KeychainDatabase(Context context) {
|
KeychainDatabase(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
@ -84,7 +84,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
db.execSQL(CREATE_KEY_RINGS);
|
db.execSQL(CREATE_KEY_RINGS);
|
||||||
db.execSQL(CREATE_KEYS);
|
db.execSQL(CREATE_KEYS);
|
||||||
db.execSQL(CREATE_USER_IDS);
|
db.execSQL(CREATE_USER_IDS);
|
||||||
db.execSQL(CREATE_CRYPTO_CONSUMERS);
|
db.execSQL(CREATE_API_APPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -112,7 +112,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
|||||||
+ " = 1 WHERE " + KeysColumns.IS_MASTER_KEY + "= 1;");
|
+ " = 1 WHERE " + KeysColumns.IS_MASTER_KEY + "= 1;");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
db.execSQL(CREATE_CRYPTO_CONSUMERS);
|
db.execSQL(CREATE_API_APPS);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -21,7 +21,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes;
|
||||||
@ -228,10 +228,10 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
/**
|
/**
|
||||||
* Crypto Consumers
|
* Crypto Consumers
|
||||||
*/
|
*/
|
||||||
matcher.addURI(authority, KeychainContract.BASE_CRYPTO_CONSUMERS, CRYPTO_CONSUMERS);
|
matcher.addURI(authority, KeychainContract.BASE_API_APPS, CRYPTO_CONSUMERS);
|
||||||
matcher.addURI(authority, KeychainContract.BASE_CRYPTO_CONSUMERS + "/#",
|
matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/#",
|
||||||
CRYPTO_CONSUMERS_BY_ROW_ID);
|
CRYPTO_CONSUMERS_BY_ROW_ID);
|
||||||
matcher.addURI(authority, KeychainContract.BASE_CRYPTO_CONSUMERS + "/"
|
matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/"
|
||||||
+ KeychainContract.PATH_BY_PACKAGE_NAME + "/*", CRYPTO_CONSUMERS_BY_PACKAGE_NAME);
|
+ KeychainContract.PATH_BY_PACKAGE_NAME + "/*", CRYPTO_CONSUMERS_BY_PACKAGE_NAME);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,11 +294,11 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
return UserIds.CONTENT_ITEM_TYPE;
|
return UserIds.CONTENT_ITEM_TYPE;
|
||||||
|
|
||||||
case CRYPTO_CONSUMERS:
|
case CRYPTO_CONSUMERS:
|
||||||
return CryptoConsumers.CONTENT_TYPE;
|
return ApiApps.CONTENT_TYPE;
|
||||||
|
|
||||||
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
||||||
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
||||||
return CryptoConsumers.CONTENT_ITEM_TYPE;
|
return ApiApps.CONTENT_ITEM_TYPE;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unknown uri: " + uri);
|
throw new UnsupportedOperationException("Unknown uri: " + uri);
|
||||||
@ -609,19 +609,19 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CRYPTO_CONSUMERS:
|
case CRYPTO_CONSUMERS:
|
||||||
qb.setTables(Tables.CRYPTO_CONSUMERS);
|
qb.setTables(Tables.API_APPS);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
||||||
qb.setTables(Tables.CRYPTO_CONSUMERS);
|
qb.setTables(Tables.API_APPS);
|
||||||
|
|
||||||
qb.appendWhere(BaseColumns._ID + " = ");
|
qb.appendWhere(BaseColumns._ID + " = ");
|
||||||
qb.appendWhereEscapeString(uri.getLastPathSegment());
|
qb.appendWhereEscapeString(uri.getLastPathSegment());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
||||||
qb.setTables(Tables.CRYPTO_CONSUMERS);
|
qb.setTables(Tables.API_APPS);
|
||||||
qb.appendWhere(CryptoConsumers.PACKAGE_NAME + " = ");
|
qb.appendWhere(ApiApps.PACKAGE_NAME + " = ");
|
||||||
qb.appendWhereEscapeString(uri.getPathSegments().get(2));
|
qb.appendWhereEscapeString(uri.getPathSegments().get(2));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -712,8 +712,8 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case CRYPTO_CONSUMERS:
|
case CRYPTO_CONSUMERS:
|
||||||
rowId = db.insertOrThrow(Tables.CRYPTO_CONSUMERS, null, values);
|
rowId = db.insertOrThrow(Tables.API_APPS, null, values);
|
||||||
rowUri = CryptoConsumers.buildIdUri(Long.toString(rowId));
|
rowUri = ApiApps.buildIdUri(Long.toString(rowId));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -773,7 +773,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
break;
|
break;
|
||||||
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
||||||
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
||||||
count = db.delete(Tables.CRYPTO_CONSUMERS,
|
count = db.delete(Tables.API_APPS,
|
||||||
buildDefaultCryptoConsumersSelection(uri, selection), selectionArgs);
|
buildDefaultCryptoConsumersSelection(uri, selection), selectionArgs);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -838,7 +838,7 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
break;
|
break;
|
||||||
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
case CRYPTO_CONSUMERS_BY_ROW_ID:
|
||||||
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
case CRYPTO_CONSUMERS_BY_PACKAGE_NAME:
|
||||||
count = db.update(Tables.CRYPTO_CONSUMERS, values,
|
count = db.update(Tables.API_APPS, values,
|
||||||
buildDefaultCryptoConsumersSelection(uri, selection), selectionArgs);
|
buildDefaultCryptoConsumersSelection(uri, selection), selectionArgs);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -31,7 +31,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.helper.PgpConversionHelper;
|
import org.sufficientlysecure.keychain.helper.PgpConversionHelper;
|
||||||
import org.sufficientlysecure.keychain.helper.PgpHelper;
|
import org.sufficientlysecure.keychain.helper.PgpHelper;
|
||||||
import org.sufficientlysecure.keychain.helper.PgpMain;
|
import org.sufficientlysecure.keychain.helper.PgpMain;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
@ -719,12 +719,12 @@ public class ProviderHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> getCryptoConsumers(Context context) {
|
public static ArrayList<String> getCryptoConsumers(Context context) {
|
||||||
Cursor cursor = context.getContentResolver().query(CryptoConsumers.CONTENT_URI, null, null,
|
Cursor cursor = context.getContentResolver().query(ApiApps.CONTENT_URI, null, null,
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
ArrayList<String> packageNames = new ArrayList<String>();
|
ArrayList<String> packageNames = new ArrayList<String>();
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
int packageNameCol = cursor.getColumnIndex(CryptoConsumers.PACKAGE_NAME);
|
int packageNameCol = cursor.getColumnIndex(ApiApps.PACKAGE_NAME);
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
packageNames.add(cursor.getString(packageNameCol));
|
packageNames.add(cursor.getString(packageNameCol));
|
||||||
@ -741,7 +741,7 @@ public class ProviderHelper {
|
|||||||
|
|
||||||
public static void addCryptoConsumer(Context context, String packageName) {
|
public static void addCryptoConsumer(Context context, String packageName) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(CryptoConsumers.PACKAGE_NAME, packageName);
|
values.put(ApiApps.PACKAGE_NAME, packageName);
|
||||||
context.getContentResolver().insert(CryptoConsumers.CONTENT_URI, values);
|
context.getContentResolver().insert(ApiApps.CONTENT_URI, values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@ -13,6 +14,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -20,22 +23,24 @@ import android.widget.TextView;
|
|||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
|
||||||
public class AppSettingsActivity extends SherlockFragmentActivity {
|
public class AppSettingsActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
private PackageManager pm;
|
private PackageManager pm;
|
||||||
|
|
||||||
|
// model
|
||||||
|
Uri appUri;
|
||||||
long id;
|
long id;
|
||||||
|
|
||||||
String packageName;
|
String packageName;
|
||||||
long keyId;
|
long keyId;
|
||||||
boolean asciiArmor;
|
boolean asciiArmor;
|
||||||
|
|
||||||
// derived
|
// model, derived
|
||||||
String appName;
|
String appName;
|
||||||
|
|
||||||
// view
|
// view
|
||||||
TextView selectedKey;
|
TextView selectedKey;
|
||||||
Button selectKeyButton;
|
Button selectKeyButton;
|
||||||
CheckBox asciiArmorCheckBox;
|
CheckBox asciiArmorCheckBox;
|
||||||
|
Button saveButton;
|
||||||
|
Button revokeButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -48,9 +53,26 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
|||||||
selectedKey = (TextView) findViewById(R.id.api_app_settings_selected_key);
|
selectedKey = (TextView) findViewById(R.id.api_app_settings_selected_key);
|
||||||
selectKeyButton = (Button) findViewById(R.id.api_app_settings_select_key_button);
|
selectKeyButton = (Button) findViewById(R.id.api_app_settings_select_key_button);
|
||||||
asciiArmorCheckBox = (CheckBox) findViewById(R.id.api_app_ascii_armor);
|
asciiArmorCheckBox = (CheckBox) findViewById(R.id.api_app_ascii_armor);
|
||||||
|
revokeButton = (Button) findViewById(R.id.api_app_settings_revoke);
|
||||||
|
saveButton = (Button) findViewById(R.id.api_app_settings_save);
|
||||||
|
|
||||||
|
revokeButton.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
revokeAccess();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveButton.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Uri appUri = intent.getData();
|
appUri = intent.getData();
|
||||||
if (appUri == null) {
|
if (appUri == null) {
|
||||||
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
|
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
|
||||||
finish();
|
finish();
|
||||||
@ -67,7 +89,7 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
|||||||
if (cur.moveToFirst()) {
|
if (cur.moveToFirst()) {
|
||||||
do {
|
do {
|
||||||
packageName = cur.getString(cur
|
packageName = cur.getString(cur
|
||||||
.getColumnIndex(KeychainContract.CryptoConsumers.PACKAGE_NAME));
|
.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME));
|
||||||
// get application name
|
// get application name
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
||||||
@ -76,15 +98,35 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
|||||||
} catch (final NameNotFoundException e) {
|
} catch (final NameNotFoundException e) {
|
||||||
appName = getString(R.string.api_unknown_app);
|
appName = getString(R.string.api_unknown_app);
|
||||||
}
|
}
|
||||||
// asciiArmor = (cur.getInt(cur
|
|
||||||
// .getColumnIndex(KeychainContract.CryptoConsumers.ASCII_ARMOR)) == 1);
|
|
||||||
|
|
||||||
// display values
|
try {
|
||||||
// asciiArmorCheckBox.setChecked(asciiArmor);
|
asciiArmor = (cur.getInt(cur
|
||||||
|
.getColumnIndexOrThrow(KeychainContract.ApiApps.ASCII_ARMOR)) == 1);
|
||||||
|
|
||||||
|
// display values
|
||||||
|
asciiArmorCheckBox.setChecked(asciiArmor);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.e(Constants.TAG, "AppSettingsActivity", e);
|
||||||
|
}
|
||||||
|
|
||||||
} while (cur.moveToNext());
|
} while (cur.moveToNext());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revokeAccess() {
|
||||||
|
Uri calUri = ContentUris.withAppendedId(appUri, id);
|
||||||
|
getContentResolver().delete(calUri, null, null);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
final ContentValues cv = new ContentValues();
|
||||||
|
cv.put(KeychainContract.ApiApps.PACKAGE_NAME, packageName);
|
||||||
|
cv.put(KeychainContract.ApiApps.ASCII_ARMOR, asciiArmor);
|
||||||
|
// TODO: other parameter
|
||||||
|
getContentResolver().update(appUri, cv, null, null);
|
||||||
|
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,11 @@ public class AppSettingsFragment extends Fragment {
|
|||||||
if (advancedSettingsContainer.getVisibility() == View.VISIBLE) {
|
if (advancedSettingsContainer.getVisibility() == View.VISIBLE) {
|
||||||
advancedSettingsContainer.startAnimation(invisibleAnimation);
|
advancedSettingsContainer.startAnimation(invisibleAnimation);
|
||||||
advancedSettingsContainer.setVisibility(View.INVISIBLE);
|
advancedSettingsContainer.setVisibility(View.INVISIBLE);
|
||||||
|
advancedSettingsButton.setText(R.string.api_settings_show_advanced);
|
||||||
} else {
|
} else {
|
||||||
advancedSettingsContainer.startAnimation(visibleAnimation);
|
advancedSettingsContainer.startAnimation(visibleAnimation);
|
||||||
advancedSettingsContainer.setVisibility(View.VISIBLE);
|
advancedSettingsContainer.setVisibility(View.VISIBLE);
|
||||||
|
advancedSettingsButton.setText(R.string.api_settings_hide_advanced);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -72,7 +74,6 @@ public class AppSettingsFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
selectSecretKey();
|
selectSecretKey();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
package org.sufficientlysecure.keychain.remote_api;
|
package org.sufficientlysecure.keychain.remote_api;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
@ -47,7 +47,7 @@ public class RegisteredAppsAdapter extends CursorAdapter {
|
|||||||
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||||
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
||||||
|
|
||||||
String packageName = cursor.getString(cursor.getColumnIndex(CryptoConsumers.PACKAGE_NAME));
|
String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME));
|
||||||
if (packageName != null) {
|
if (packageName != null) {
|
||||||
text2.setText(packageName);
|
text2.setText(packageName);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package org.sufficientlysecure.keychain.remote_api;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockListFragment;
|
import com.actionbarsherlock.app.SherlockListFragment;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class RegisteredAppsListFragment extends SherlockListFragment implements
|
|||||||
// edit app settings
|
// edit app settings
|
||||||
Intent intent = new Intent(getActivity(), AppSettingsActivity.class);
|
Intent intent = new Intent(getActivity(), AppSettingsActivity.class);
|
||||||
intent.setData(ContentUris.withAppendedId(
|
intent.setData(ContentUris.withAppendedId(
|
||||||
KeychainContract.CryptoConsumers.CONTENT_URI, id));
|
KeychainContract.ApiApps.CONTENT_URI, id));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -60,20 +60,20 @@ public class RegisteredAppsListFragment extends SherlockListFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
// These are the Contacts rows that we will retrieve.
|
// These are the Contacts rows that we will retrieve.
|
||||||
static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { CryptoConsumers._ID,
|
static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { ApiApps._ID,
|
||||||
CryptoConsumers.PACKAGE_NAME };
|
ApiApps.PACKAGE_NAME };
|
||||||
|
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
// This is called when a new Loader needs to be created. This
|
// 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.
|
// sample only has one Loader, so we don't care about the ID.
|
||||||
// First, pick the base URI to use depending on whether we are
|
// First, pick the base URI to use depending on whether we are
|
||||||
// currently filtering.
|
// currently filtering.
|
||||||
Uri baseUri = CryptoConsumers.CONTENT_URI;
|
Uri baseUri = ApiApps.CONTENT_URI;
|
||||||
|
|
||||||
// Now create and return a CursorLoader that will take care of
|
// Now create and return a CursorLoader that will take care of
|
||||||
// creating a Cursor for the data being displayed.
|
// creating a Cursor for the data being displayed.
|
||||||
return new CursorLoader(getActivity(), baseUri, CONSUMERS_SUMMARY_PROJECTION, null, null,
|
return new CursorLoader(getActivity(), baseUri, CONSUMERS_SUMMARY_PROJECTION, null, null,
|
||||||
CryptoConsumers.PACKAGE_NAME + " COLLATE LOCALIZED ASC");
|
ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
|
@ -134,22 +134,26 @@ public class ServiceActivity extends SherlockFragmentActivity {
|
|||||||
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
|
||||||
|
|
||||||
setContentView(R.layout.api_app_settings_activity);
|
setContentView(R.layout.api_app_settings_activity);
|
||||||
LinearLayout layoutRegister = (LinearLayout) findViewById(R.id.register_crypto_consumer_register_layout);
|
|
||||||
LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.register_crypto_consumer_edit_layout);
|
//TODO: handle if app is already registered
|
||||||
|
// LinearLayout layoutRegister = (LinearLayout)
|
||||||
|
// findViewById(R.id.register_crypto_consumer_register_layout);
|
||||||
|
// LinearLayout layoutEdit = (LinearLayout)
|
||||||
|
// findViewById(R.id.register_crypto_consumer_edit_layout);
|
||||||
|
//
|
||||||
|
// // if already registered show edit buttons
|
||||||
|
// ArrayList<String> allowedPkgs = ProviderHelper.getCryptoConsumers(this);
|
||||||
|
// if (allowedPkgs.contains(packageName)) {
|
||||||
|
// Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName);
|
||||||
|
// layoutRegister.setVisibility(View.GONE);
|
||||||
|
// layoutEdit.setVisibility(View.VISIBLE);
|
||||||
|
// } else {
|
||||||
|
// layoutRegister.setVisibility(View.VISIBLE);
|
||||||
|
// layoutEdit.setVisibility(View.GONE);
|
||||||
|
// }
|
||||||
|
|
||||||
// if already registered show edit buttons
|
Button allowButton = (Button) findViewById(R.id.api_register_allow);
|
||||||
ArrayList<String> allowedPkgs = ProviderHelper.getCryptoConsumers(this);
|
Button disallowButton = (Button) findViewById(R.id.api_register_disallow);
|
||||||
if (allowedPkgs.contains(packageName)) {
|
|
||||||
Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName);
|
|
||||||
layoutRegister.setVisibility(View.GONE);
|
|
||||||
layoutEdit.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
layoutRegister.setVisibility(View.VISIBLE);
|
|
||||||
layoutEdit.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Button allowButton = (Button) findViewById(R.id.register_crypto_consumer_allow);
|
|
||||||
Button disallowButton = (Button) findViewById(R.id.register_crypto_consumer_disallow);
|
|
||||||
|
|
||||||
allowButton.setOnClickListener(new OnClickListener() {
|
allowButton.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user