diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-13 10:25:01 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2013-09-13 10:25:01 +0200 |
commit | a4ae97628434b5b2e86e09b2718fda9559ea9c7f (patch) | |
tree | 23851fbec1377b137e11f69fee91dd804bab46f7 | |
parent | ca8f8e3ff7dd4742f65b541e4a8304433c093f87 (diff) | |
download | open-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.tar.gz open-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.tar.bz2 open-keychain-a4ae97628434b5b2e86e09b2718fda9559ea9c7f.zip |
Fix intent for api, fix slection dialog in demo
4 files changed, 60 insertions, 52 deletions
diff --git a/OpenPGP-Keychain-API-Demo/res/xml/base_preference.xml b/OpenPGP-Keychain-API-Demo/res/xml/base_preference.xml index f2645b509..f36c5f5a9 100644 --- a/OpenPGP-Keychain-API-Demo/res/xml/base_preference.xml +++ b/OpenPGP-Keychain-API-Demo/res/xml/base_preference.xml @@ -11,10 +11,10 @@ <!-- android:key="aidl_demo2" --> <!-- android:title="AIDL Demo (ACCESS_KEYS permission)" /> --> <!-- </PreferenceCategory> --> - <PreferenceCategory android:title="Crypto Provider" > + <PreferenceCategory android:title="OpenPGP Provider" > <Preference - android:key="crypto_provider_demo" - android:title="Crypto Provider" /> + android:key="openpgp_provider_demo" + android:title="OpenPGP Provider" /> </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file 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(); } } diff --git a/OpenPGP-Keychain/AndroidManifest.xml b/OpenPGP-Keychain/AndroidManifest.xml index efa92e760..fc9e020b8 100644 --- a/OpenPGP-Keychain/AndroidManifest.xml +++ b/OpenPGP-Keychain/AndroidManifest.xml @@ -380,7 +380,7 @@ <!-- android:permission="org.sufficientlysecure.keychain.permission.ACCESS_API" /> --> - <!-- OpenPGP Remote Service API internal --> + <!-- OpenPGP API internal classes (not exported) --> <activity android:name="org.sufficientlysecure.keychain.openpgp_api.OpenPgpServiceActivity" @@ -399,7 +399,7 @@ android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:exported="false" /> - <!-- OpenPGP Remote Service API --> + <!-- OpenPGP API --> <service android:name="org.sufficientlysecure.keychain.openpgp_api.OpenPgpService" @@ -407,7 +407,7 @@ android:exported="true" android:process=":openpgp_api" > <intent-filter> - <action android:name="org.openintents.crypto.ICryptoService" /> + <action android:name="org.openintents.openpgp.IOpenPgpService" /> </intent-filter> <meta-data |