Loading k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +20 −8 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import java.util.Map; import android.app.Dialog; import android.app.FragmentTransaction; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; Loading Loading @@ -706,12 +708,21 @@ public class AccountSettings extends K9PreferenceActivity { mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) { mCryptoApp.addLegacyProvider("apg-placeholder", "APG", R.drawable.ic_apg_small); } mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String value = newValue.toString(); if ("apg-placeholder".equals(value)) { mCryptoApp.setValue(""); mCryptoKey.setOpenPgpProvider(""); showApgDeprecationDialog(); } else { mCryptoApp.setValue(value); mCryptoKey.setOpenPgpProvider(value); } return false; } }); Loading @@ -734,16 +745,17 @@ public class AccountSettings extends K9PreferenceActivity { mCryptoMenu.setEnabled(false); mCryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_installed); } if (mAccount.isCryptoAppDeprecatedApg()) { showApgDeprecationDialog(); mAccount.setCryptoApp(""); saveSettings(); } } private void showApgDeprecationDialog() { ApgDeprecationWarningDialog fragment = ApgDeprecationWarningDialog.newInstance(); fragment.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mCryptoApp.show(); } }); FragmentTransaction ta = getFragmentManager().beginTransaction(); ta.add(fragment, APG_DEPRECATION_DIALOG_TAG); ta.commitAllowingStateLoss(); Loading k9mail/src/main/java/com/fsck/k9/ui/dialog/ApgDeprecationWarningDialog.java +15 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import android.app.DialogFragment; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; Loading @@ -18,6 +19,8 @@ import com.fsck.k9.R; public class ApgDeprecationWarningDialog extends DialogFragment { private OnDismissListener onDismissListener; public static ApgDeprecationWarningDialog newInstance() { return new ApgDeprecationWarningDialog(); } Loading Loading @@ -54,4 +57,16 @@ public class ApgDeprecationWarningDialog extends DialogFragment { private void makeTextViewLinksClickable(TextView textView) { textView.setMovementMethod(LinkMovementMethod.getInstance()); } public void setOnDismissListener(OnDismissListener onDismissListener) { this.onDismissListener = onDismissListener; } @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); if (onDismissListener != null) { onDismissListener.onDismiss(dialog); } } } plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpAppPreference.java +38 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package org.openintents.openpgp.util; import java.util.ArrayList; import java.util.List; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; Loading @@ -25,9 +29,7 @@ import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.net.Uri; import android.preference.DialogPreference; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; Loading @@ -36,9 +38,6 @@ import android.widget.TextView; import org.openintents.openpgp.R; import java.util.ArrayList; import java.util.List; /** * Does not extend ListPreference, but is very similar to it! * http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/android/preference/ListPreference.java/?v=source Loading @@ -49,11 +48,12 @@ public class OpenPgpAppPreference extends DialogPreference { private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse( String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); private static final ArrayList<String> PROVIDER_BLACKLIST = new ArrayList<String>(); private static final String PACKAGE_NAME_APG = "org.thialfihar.android.apg"; private static final ArrayList<String> PROVIDER_BLACKLIST = new ArrayList<>(); static { // Unfortunately, the current released version of APG includes a broken version of the API PROVIDER_BLACKLIST.add("org.thialfihar.android.apg"); PROVIDER_BLACKLIST.add(PACKAGE_NAME_APG); } private ArrayList<OpenPgpProviderEntry> mLegacyList = new ArrayList<>(); Loading Loading @@ -81,6 +81,11 @@ public class OpenPgpAppPreference extends DialogPreference { mLegacyList.add(position, new OpenPgpProviderEntry(packageName, simpleName, icon)); } public void addLegacyProvider(String packageName, String simpleName, int iconRes) { Drawable icon = getContext().getResources().getDrawable(iconRes); mLegacyList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); } @Override protected void onPrepareDialogBuilder(Builder builder) { Loading Loading @@ -262,13 +267,13 @@ public class OpenPgpAppPreference extends DialogPreference { mList.addAll(mLegacyList); // search for OpenPGP providers... ArrayList<OpenPgpProviderEntry> providerList = new ArrayList<>(); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2); List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentServices(intent, 0); if (!resInfo.isEmpty()) { boolean hasNonBlacklistedChoices = false; for (ResolveInfo resolveInfo : resInfo) { if (resolveInfo.serviceInfo == null) if (resolveInfo.serviceInfo == null) { continue; } String packageName = resolveInfo.serviceInfo.packageName; String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getContext() Loading @@ -276,12 +281,12 @@ public class OpenPgpAppPreference extends DialogPreference { Drawable icon = resolveInfo.serviceInfo.loadIcon(getContext().getPackageManager()); if (!PROVIDER_BLACKLIST.contains(packageName)) { providerList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); } mList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); hasNonBlacklistedChoices = true; } } if (providerList.isEmpty()) { if (!hasNonBlacklistedChoices) { // add install links if provider list is empty resInfo = getContext().getPackageManager().queryIntentActivities (MARKET_INTENT, 0); Loading @@ -296,25 +301,26 @@ public class OpenPgpAppPreference extends DialogPreference { mList.add(new OpenPgpProviderEntry(OPENKEYCHAIN_PACKAGE, simpleName, icon, marketIntent)); } } else { // add provider mList.addAll(providerList); } } public void show() { showDialog(null); } private static class OpenPgpProviderEntry { private String packageName; private String simpleName; private Drawable icon; private Intent intent; public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon) { OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon) { this.packageName = packageName; this.simpleName = simpleName; this.icon = icon; } public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon, Intent intent) { OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon, Intent intent) { this(packageName, simpleName, icon); this.intent = intent; } Loading @@ -324,4 +330,11 @@ public class OpenPgpAppPreference extends DialogPreference { return simpleName; } } public static boolean isApgInstalled(Context context) { Intent intent = new Intent("org.openintents.openpgp.IOpenPgpService"); intent.setPackage(PACKAGE_NAME_APG); List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(intent, 0); return !resInfo.isEmpty(); } } Loading
k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +20 −8 Original line number Diff line number Diff line Loading @@ -10,6 +10,8 @@ import java.util.Map; import android.app.Dialog; import android.app.FragmentTransaction; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnDismissListener; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; Loading Loading @@ -706,12 +708,21 @@ public class AccountSettings extends K9PreferenceActivity { mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) { mCryptoApp.addLegacyProvider("apg-placeholder", "APG", R.drawable.ic_apg_small); } mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String value = newValue.toString(); if ("apg-placeholder".equals(value)) { mCryptoApp.setValue(""); mCryptoKey.setOpenPgpProvider(""); showApgDeprecationDialog(); } else { mCryptoApp.setValue(value); mCryptoKey.setOpenPgpProvider(value); } return false; } }); Loading @@ -734,16 +745,17 @@ public class AccountSettings extends K9PreferenceActivity { mCryptoMenu.setEnabled(false); mCryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_installed); } if (mAccount.isCryptoAppDeprecatedApg()) { showApgDeprecationDialog(); mAccount.setCryptoApp(""); saveSettings(); } } private void showApgDeprecationDialog() { ApgDeprecationWarningDialog fragment = ApgDeprecationWarningDialog.newInstance(); fragment.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mCryptoApp.show(); } }); FragmentTransaction ta = getFragmentManager().beginTransaction(); ta.add(fragment, APG_DEPRECATION_DIALOG_TAG); ta.commitAllowingStateLoss(); Loading
k9mail/src/main/java/com/fsck/k9/ui/dialog/ApgDeprecationWarningDialog.java +15 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ import android.app.DialogFragment; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.view.LayoutInflater; Loading @@ -18,6 +19,8 @@ import com.fsck.k9.R; public class ApgDeprecationWarningDialog extends DialogFragment { private OnDismissListener onDismissListener; public static ApgDeprecationWarningDialog newInstance() { return new ApgDeprecationWarningDialog(); } Loading Loading @@ -54,4 +57,16 @@ public class ApgDeprecationWarningDialog extends DialogFragment { private void makeTextViewLinksClickable(TextView textView) { textView.setMovementMethod(LinkMovementMethod.getInstance()); } public void setOnDismissListener(OnDismissListener onDismissListener) { this.onDismissListener = onDismissListener; } @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); if (onDismissListener != null) { onDismissListener.onDismiss(dialog); } } }
plugins/openpgp-api-lib/openpgp-api/src/main/java/org/openintents/openpgp/util/OpenPgpAppPreference.java +38 −25 Original line number Diff line number Diff line Loading @@ -16,6 +16,10 @@ package org.openintents.openpgp.util; import java.util.ArrayList; import java.util.List; import android.app.AlertDialog.Builder; import android.content.Context; import android.content.DialogInterface; Loading @@ -25,9 +29,7 @@ import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.net.Uri; import android.preference.DialogPreference; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; Loading @@ -36,9 +38,6 @@ import android.widget.TextView; import org.openintents.openpgp.R; import java.util.ArrayList; import java.util.List; /** * Does not extend ListPreference, but is very similar to it! * http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/android/preference/ListPreference.java/?v=source Loading @@ -49,11 +48,12 @@ public class OpenPgpAppPreference extends DialogPreference { private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse( String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); private static final ArrayList<String> PROVIDER_BLACKLIST = new ArrayList<String>(); private static final String PACKAGE_NAME_APG = "org.thialfihar.android.apg"; private static final ArrayList<String> PROVIDER_BLACKLIST = new ArrayList<>(); static { // Unfortunately, the current released version of APG includes a broken version of the API PROVIDER_BLACKLIST.add("org.thialfihar.android.apg"); PROVIDER_BLACKLIST.add(PACKAGE_NAME_APG); } private ArrayList<OpenPgpProviderEntry> mLegacyList = new ArrayList<>(); Loading Loading @@ -81,6 +81,11 @@ public class OpenPgpAppPreference extends DialogPreference { mLegacyList.add(position, new OpenPgpProviderEntry(packageName, simpleName, icon)); } public void addLegacyProvider(String packageName, String simpleName, int iconRes) { Drawable icon = getContext().getResources().getDrawable(iconRes); mLegacyList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); } @Override protected void onPrepareDialogBuilder(Builder builder) { Loading Loading @@ -262,13 +267,13 @@ public class OpenPgpAppPreference extends DialogPreference { mList.addAll(mLegacyList); // search for OpenPGP providers... ArrayList<OpenPgpProviderEntry> providerList = new ArrayList<>(); Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT_2); List<ResolveInfo> resInfo = getContext().getPackageManager().queryIntentServices(intent, 0); if (!resInfo.isEmpty()) { boolean hasNonBlacklistedChoices = false; for (ResolveInfo resolveInfo : resInfo) { if (resolveInfo.serviceInfo == null) if (resolveInfo.serviceInfo == null) { continue; } String packageName = resolveInfo.serviceInfo.packageName; String simpleName = String.valueOf(resolveInfo.serviceInfo.loadLabel(getContext() Loading @@ -276,12 +281,12 @@ public class OpenPgpAppPreference extends DialogPreference { Drawable icon = resolveInfo.serviceInfo.loadIcon(getContext().getPackageManager()); if (!PROVIDER_BLACKLIST.contains(packageName)) { providerList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); } mList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); hasNonBlacklistedChoices = true; } } if (providerList.isEmpty()) { if (!hasNonBlacklistedChoices) { // add install links if provider list is empty resInfo = getContext().getPackageManager().queryIntentActivities (MARKET_INTENT, 0); Loading @@ -296,25 +301,26 @@ public class OpenPgpAppPreference extends DialogPreference { mList.add(new OpenPgpProviderEntry(OPENKEYCHAIN_PACKAGE, simpleName, icon, marketIntent)); } } else { // add provider mList.addAll(providerList); } } public void show() { showDialog(null); } private static class OpenPgpProviderEntry { private String packageName; private String simpleName; private Drawable icon; private Intent intent; public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon) { OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon) { this.packageName = packageName; this.simpleName = simpleName; this.icon = icon; } public OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon, Intent intent) { OpenPgpProviderEntry(String packageName, String simpleName, Drawable icon, Intent intent) { this(packageName, simpleName, icon); this.intent = intent; } Loading @@ -324,4 +330,11 @@ public class OpenPgpAppPreference extends DialogPreference { return simpleName; } } public static boolean isApgInstalled(Context context) { Intent intent = new Intent("org.openintents.openpgp.IOpenPgpService"); intent.setPackage(PACKAGE_NAME_APG); List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(intent, 0); return !resInfo.isEmpty(); } }