aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 18:11:14 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-02-15 18:11:14 +0100
commita659e97a645a7874b1712d9ad4e1a7493629ed9b (patch)
treea92badd8bea5b07e55cef3700452ac4ce8d315b4 /OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents
parent9f7f4fd27a02c02b15df613710433dfc35ad8e17 (diff)
downloadopen-keychain-a659e97a645a7874b1712d9ad4e1a7493629ed9b.tar.gz
open-keychain-a659e97a645a7874b1712d9ad4e1a7493629ed9b.tar.bz2
open-keychain-a659e97a645a7874b1712d9ad4e1a7493629ed9b.zip
list preference: load provider list on open of dialog not on create of preference to reload when keychain has been installed
Diffstat (limited to 'OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents')
-rw-r--r--OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java48
1 files changed, 26 insertions, 22 deletions
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java
index 4917b6993..987c8c8fc 100644
--- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java
@@ -36,31 +36,11 @@ import java.util.List;
import org.sufficientlysecure.keychain.api.R;
public class OpenPgpListPreference extends DialogPreference {
- ArrayList<OpenPgpProviderEntry> mProviderList = new ArrayList<OpenPgpProviderEntry>();
+ private ArrayList<OpenPgpProviderEntry> mProviderList = new ArrayList<OpenPgpProviderEntry>();
private String mSelectedPackage;
public OpenPgpListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
-
- Intent intent = new Intent(OpenPgpConstants.SERVICE_INTENT);
- List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(intent, 0);
- if (!resInfo.isEmpty()) {
- for (ResolveInfo resolveInfo : resInfo) {
- if (resolveInfo.serviceInfo == null)
- continue;
-
- String packageName = resolveInfo.serviceInfo.packageName;
- String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(context
- .getPackageManager()));
- Drawable icon = resolveInfo.serviceInfo.loadIcon(context.getPackageManager());
-
- mProviderList.add(new OpenPgpProviderEntry(packageName, simpleName, icon));
- }
- }
-
- // add "none"
- mProviderList.add(0, new OpenPgpProviderEntry("", context.getString(R.string.openpgp_list_preference_none),
- context.getResources().getDrawable(R.drawable.ic_action_cancel_launchersize)));
}
public OpenPgpListPreference(Context context) {
@@ -68,7 +48,7 @@ public class OpenPgpListPreference extends DialogPreference {
}
/**
- * Can be used to add "no selection"
+ * Public method to add new entries for legacy applications
*
* @param packageName
* @param simpleName
@@ -80,6 +60,30 @@ public class OpenPgpListPreference extends DialogPreference {
@Override
protected void onPrepareDialogBuilder(Builder builder) {
+
+ // get providers
+ mProviderList.clear();
+ Intent intent = new Intent(OpenPgpConstants.SERVICE_INTENT);
+ List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentServices(intent, 0);
+ if (!resInfo.isEmpty()) {
+ for (ResolveInfo resolveInfo : resInfo) {
+ if (resolveInfo.serviceInfo == null)
+ continue;
+
+ String packageName = resolveInfo.serviceInfo.packageName;
+ String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getContext()
+ .getPackageManager()));
+ Drawable icon = resolveInfo.serviceInfo.loadIcon(getContext().getPackageManager());
+
+ mProviderList.add(new OpenPgpProviderEntry(packageName, simpleName, icon));
+ }
+ }
+
+ // add "none"-entry
+ mProviderList.add(0, new OpenPgpProviderEntry("",
+ getContext().getString(R.string.openpgp_list_preference_none),
+ getContext().getResources().getDrawable(R.drawable.ic_action_cancel_launchersize)));
+
// Init ArrayAdapter with OpenPGP Providers
ListAdapter adapter = new ArrayAdapter<OpenPgpProviderEntry>(getContext(),
android.R.layout.select_dialog_singlechoice, android.R.id.text1, mProviderList) {