aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API-Demo/src/org
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-13 10:25:01 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-13 10:25:01 +0200
commita4ae97628434b5b2e86e09b2718fda9559ea9c7f (patch)
tree23851fbec1377b137e11f69fee91dd804bab46f7 /OpenPGP-Keychain-API-Demo/src/org
parentca8f8e3ff7dd4742f65b541e4a8304433c093f87 (diff)
downloadopen-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.tar.gz
open-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.tar.bz2
open-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.zip
Fix intent for api, fix slection dialog in demo
Diffstat (limited to 'OpenPGP-Keychain-API-Demo/src/org')
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/BaseActivity.java2
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java98
2 files changed, 54 insertions, 46 deletions
diff --git a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/BaseActivity.java b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/BaseActivity.java
index e4fd8cd99..5b286f208 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/BaseActivity.java
+++ b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/BaseActivity.java
@@ -50,7 +50,7 @@ public class BaseActivity extends PreferenceActivity {
// find preferences
mIntentDemo = (Preference) findPreference("intent_demo");
mContentProviderDemo = (Preference) findPreference("content_provider_demo");
- mCryptoProvider = (Preference) findPreference("crypto_provider_demo");
+ mCryptoProvider = (Preference) findPreference("openpgp_provider_demo");
mAidlDemo = (Preference) findPreference("aidl_demo");
mAidlDemo2 = (Preference) findPreference("aidl_demo2");
diff --git a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
index 0780eed5a..2c2b86835 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
+++ b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
@@ -186,12 +186,12 @@ public class OpenPgpProviderActivity extends Activity {
}
}
- private static class OpenPGPProviderElement {
+ private static class OpenPgpProviderElement {
private String packageName;
private String simpleName;
private Drawable icon;
- public OpenPGPProviderElement(String packageName, String simpleName, Drawable icon) {
+ public OpenPgpProviderElement(String packageName, String simpleName, Drawable icon) {
this.packageName = packageName;
this.simpleName = simpleName;
this.icon = icon;
@@ -206,7 +206,7 @@ public class OpenPgpProviderActivity extends Activity {
private void selectCryptoProvider() {
Intent intent = new Intent(IOpenPgpService.class.getName());
- final ArrayList<OpenPGPProviderElement> providerList = new ArrayList<OpenPGPProviderElement>();
+ final ArrayList<OpenPgpProviderElement> providerList = new ArrayList<OpenPgpProviderElement>();
List<ResolveInfo> resInfo = getPackageManager().queryIntentServices(intent, 0);
if (!resInfo.isEmpty()) {
@@ -218,62 +218,70 @@ public class OpenPgpProviderActivity extends Activity {
String simpleName = String.valueOf(resolveInfo.serviceInfo
.loadLabel(getPackageManager()));
Drawable icon = resolveInfo.serviceInfo.loadIcon(getPackageManager());
- providerList.add(new OpenPGPProviderElement(packageName, simpleName, icon));
+ providerList.add(new OpenPgpProviderElement(packageName, simpleName, icon));
}
+ }
- AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle("Select OpenPGP Provider!");
- alert.setCancelable(false);
-
- if (!providerList.isEmpty()) {
+ AlertDialog.Builder alert = new AlertDialog.Builder(this);
+ alert.setTitle("Select OpenPGP Provider!");
+ alert.setCancelable(false);
- // Init ArrayAdapter with Crypto Providers
- ListAdapter adapter = new ArrayAdapter<OpenPGPProviderElement>(this,
- android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
- public View getView(int position, View convertView, ViewGroup parent) {
- // User super class to create the View
- View v = super.getView(position, convertView, parent);
- TextView tv = (TextView) v.findViewById(android.R.id.text1);
+ if (!providerList.isEmpty()) {
+ // add "disable OpenPGP provider"
+ providerList.add(0, new OpenPgpProviderElement(null, "Disable OpenPGP Provider", getResources()
+ .getDrawable(android.R.drawable.ic_menu_close_clear_cancel)));
- // Put the image on the TextView
- tv.setCompoundDrawablesWithIntrinsicBounds(providerList.get(position).icon,
- null, null, null);
+ // Init ArrayAdapter with OpenPGP Providers
+ ListAdapter adapter = new ArrayAdapter<OpenPgpProviderElement>(this,
+ android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
+ public View getView(int position, View convertView, ViewGroup parent) {
+ // User super class to create the View
+ View v = super.getView(position, convertView, parent);
+ TextView tv = (TextView) v.findViewById(android.R.id.text1);
- // Add margin between image and text (support various screen densities)
- int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
- tv.setCompoundDrawablePadding(dp5);
+ // Put the image on the TextView
+ tv.setCompoundDrawablesWithIntrinsicBounds(providerList.get(position).icon,
+ null, null, null);
- return v;
- }
- };
+ // Add margin between image and text (support various screen densities)
+ int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
+ tv.setCompoundDrawablePadding(dp5);
- alert.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
+ return v;
+ }
+ };
- public void onClick(DialogInterface dialog, int position) {
- String packageName = providerList.get(position).packageName;
+ alert.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
- // bind to service
- mCryptoServiceConnection = new OpenPgpServiceConnection(
- OpenPgpProviderActivity.this, packageName);
- mCryptoServiceConnection.bindToService();
+ public void onClick(DialogInterface dialog, int position) {
+ String packageName = providerList.get(position).packageName;
- dialog.dismiss();
+ if (packageName == null) {
+ dialog.cancel();
+ finish();
}
- });
- } else {
- alert.setMessage("No OpenPGP Provider installed!");
- }
-
- alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+
+ // bind to service
+ mCryptoServiceConnection = new OpenPgpServiceConnection(
+ OpenPgpProviderActivity.this, packageName);
+ mCryptoServiceConnection.bindToService();
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- finish();
+ dialog.dismiss();
}
});
-
- AlertDialog ad = alert.create();
- ad.show();
+ } else {
+ alert.setMessage("No OpenPGP Provider installed!");
}
+
+ alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ finish();
+ }
+ });
+
+ AlertDialog ad = alert.create();
+ ad.show();
}
}