aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-05 00:02:48 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-05 00:02:48 +0200
commit9a737c7318e20a56a7d7a2efd8602fb0bec05101 (patch)
tree1e5b794d551f7382e2a31520f0505a954101b73a /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api
parentfcec7e830c11fa0bda903ea9913fa2e41fa4d2e2 (diff)
downloadopen-keychain-9a737c7318e20a56a7d7a2efd8602fb0bec05101.tar.gz
open-keychain-9a737c7318e20a56a7d7a2efd8602fb0bec05101.tar.bz2
open-keychain-9a737c7318e20a56a7d7a2efd8602fb0bec05101.zip
rename crypto consumers to api apps
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java60
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java3
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsAdapter.java4
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java12
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java36
5 files changed, 81 insertions, 34 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
index 765cb8e2b..3046dd0d2 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsActivity.java
@@ -6,6 +6,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.util.Log;
import android.content.ContentUris;
+import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -13,6 +14,8 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
@@ -20,22 +23,24 @@ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
public class AppSettingsActivity extends SherlockFragmentActivity {
-
private PackageManager pm;
+ // model
+ Uri appUri;
long id;
-
String packageName;
long keyId;
boolean asciiArmor;
- // derived
+ // model, derived
String appName;
// view
TextView selectedKey;
Button selectKeyButton;
CheckBox asciiArmorCheckBox;
+ Button saveButton;
+ Button revokeButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -48,9 +53,26 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
selectedKey = (TextView) findViewById(R.id.api_app_settings_selected_key);
selectKeyButton = (Button) findViewById(R.id.api_app_settings_select_key_button);
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();
- Uri appUri = intent.getData();
+ appUri = intent.getData();
if (appUri == null) {
Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!");
finish();
@@ -67,7 +89,7 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
if (cur.moveToFirst()) {
do {
packageName = cur.getString(cur
- .getColumnIndex(KeychainContract.CryptoConsumers.PACKAGE_NAME));
+ .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME));
// get application name
try {
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
@@ -76,15 +98,35 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
} catch (final NameNotFoundException e) {
appName = getString(R.string.api_unknown_app);
}
-// asciiArmor = (cur.getInt(cur
-// .getColumnIndex(KeychainContract.CryptoConsumers.ASCII_ARMOR)) == 1);
- // display values
-// asciiArmorCheckBox.setChecked(asciiArmor);
+ try {
+ 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());
}
+ }
+
+ 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();
}
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java
index 98cf5abd5..ec983dc06 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/AppSettingsFragment.java
@@ -60,9 +60,11 @@ public class AppSettingsFragment extends Fragment {
if (advancedSettingsContainer.getVisibility() == View.VISIBLE) {
advancedSettingsContainer.startAnimation(invisibleAnimation);
advancedSettingsContainer.setVisibility(View.INVISIBLE);
+ advancedSettingsButton.setText(R.string.api_settings_show_advanced);
} else {
advancedSettingsContainer.startAnimation(visibleAnimation);
advancedSettingsContainer.setVisibility(View.VISIBLE);
+ advancedSettingsButton.setText(R.string.api_settings_hide_advanced);
}
}
});
@@ -72,7 +74,6 @@ public class AppSettingsFragment extends Fragment {
@Override
public void onClick(View v) {
selectSecretKey();
-
}
});
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsAdapter.java
index dcc0b973d..71a819ec2 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsAdapter.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsAdapter.java
@@ -17,7 +17,7 @@
package org.sufficientlysecure.keychain.remote_api;
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.pm.ApplicationInfo;
@@ -47,7 +47,7 @@ public class RegisteredAppsAdapter extends CursorAdapter {
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
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) {
text2.setText(packageName);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java
index bd879a1b6..5ab210d5f 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/RegisteredAppsListFragment.java
@@ -2,7 +2,7 @@ package org.sufficientlysecure.keychain.remote_api;
import org.sufficientlysecure.keychain.R;
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;
@@ -38,7 +38,7 @@ public class RegisteredAppsListFragment extends SherlockListFragment implements
// edit app settings
Intent intent = new Intent(getActivity(), AppSettingsActivity.class);
intent.setData(ContentUris.withAppendedId(
- KeychainContract.CryptoConsumers.CONTENT_URI, id));
+ KeychainContract.ApiApps.CONTENT_URI, id));
startActivity(intent);
}
});
@@ -60,20 +60,20 @@ public class RegisteredAppsListFragment extends SherlockListFragment implements
}
// These are the Contacts rows that we will retrieve.
- static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { CryptoConsumers._ID,
- CryptoConsumers.PACKAGE_NAME };
+ static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { ApiApps._ID,
+ ApiApps.PACKAGE_NAME };
public Loader<Cursor> 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.
// First, pick the base URI to use depending on whether we are
// currently filtering.
- Uri baseUri = CryptoConsumers.CONTENT_URI;
+ Uri baseUri = ApiApps.CONTENT_URI;
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
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) {
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
index 5849fb80d..703093f0a 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
@@ -134,22 +134,26 @@ public class ServiceActivity extends SherlockFragmentActivity {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
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);
-
- // 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);
- }
-
- Button allowButton = (Button) findViewById(R.id.register_crypto_consumer_allow);
- Button disallowButton = (Button) findViewById(R.id.register_crypto_consumer_disallow);
+
+ //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);
+ // }
+
+ Button allowButton = (Button) findViewById(R.id.api_register_allow);
+ Button disallowButton = (Button) findViewById(R.id.api_register_disallow);
allowButton.setOnClickListener(new OnClickListener() {