Loading k9mail/src/main/java/com/fsck/k9/Account.java +1 −49 Original line number Diff line number Diff line Loading @@ -157,7 +157,6 @@ public class Account implements BaseAccount, StoreConfig { public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE; public static final boolean DEFAULT_SORT_ASCENDING = false; public static final String NO_OPENPGP_PROVIDER = ""; public static final long NO_OPENPGP_KEY = 0; private DeletePolicy mDeletePolicy = DeletePolicy.NEVER; Loading Loading @@ -220,10 +219,7 @@ public class Account implements BaseAccount, StoreConfig { private boolean mReplyAfterQuote; private boolean mStripSignature; private boolean mSyncRemoteDeletions; private String mCryptoApp; private boolean mCryptoAppIsDeprecatedApg; private long mCryptoKey; private boolean mCryptoSupportSignOnly; private boolean mMarkMessageAsReadOnView; private boolean mAlwaysShowCcBcc; private boolean mAllowRemoteSearch; Loading Loading @@ -318,9 +314,7 @@ public class Account implements BaseAccount, StoreConfig { mReplyAfterQuote = DEFAULT_REPLY_AFTER_QUOTE; mStripSignature = DEFAULT_STRIP_SIGNATURE; mSyncRemoteDeletions = true; mCryptoApp = NO_OPENPGP_PROVIDER; mCryptoKey = NO_OPENPGP_KEY; mCryptoSupportSignOnly = false; mAllowRemoteSearch = false; mRemoteSearchFullText = false; mRemoteSearchNumResults = DEFAULT_REMOTE_SEARCH_NUM_RESULTS; Loading Loading @@ -468,10 +462,7 @@ public class Account implements BaseAccount, StoreConfig { mIsSignatureBeforeQuotedText = storage.getBoolean(mUuid + ".signatureBeforeQuotedText", false); identities = loadIdentities(storage); String cryptoApp = storage.getString(mUuid + ".cryptoApp", NO_OPENPGP_PROVIDER); setCryptoApp(cryptoApp); mCryptoKey = storage.getLong(mUuid + ".cryptoKey", NO_OPENPGP_KEY); mCryptoSupportSignOnly = storage.getBoolean(mUuid + ".cryptoSupportSignOnly", false); mAllowRemoteSearch = storage.getBoolean(mUuid + ".allowRemoteSearch", false); mRemoteSearchFullText = storage.getBoolean(mUuid + ".remoteSearchFullText", false); mRemoteSearchNumResults = storage.getInt(mUuid + ".remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS); Loading Loading @@ -560,7 +551,7 @@ public class Account implements BaseAccount, StoreConfig { editor.remove(mUuid + ".showPicturesEnum"); editor.remove(mUuid + ".replyAfterQuote"); editor.remove(mUuid + ".stripSignature"); editor.remove(mUuid + ".cryptoApp"); editor.remove(mUuid + ".cryptoApp"); // this is no longer set, but cleans up legacy values editor.remove(mUuid + ".cryptoAutoSignature"); editor.remove(mUuid + ".cryptoAutoEncrypt"); editor.remove(mUuid + ".cryptoApp"); Loading Loading @@ -737,9 +728,7 @@ public class Account implements BaseAccount, StoreConfig { editor.putBoolean(mUuid + ".defaultQuotedTextShown", mDefaultQuotedTextShown); editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote); editor.putBoolean(mUuid + ".stripSignature", mStripSignature); editor.putString(mUuid + ".cryptoApp", mCryptoApp); editor.putLong(mUuid + ".cryptoKey", mCryptoKey); editor.putBoolean(mUuid + ".cryptoSupportSignOnly", mCryptoSupportSignOnly); editor.putBoolean(mUuid + ".allowRemoteSearch", mAllowRemoteSearch); editor.putBoolean(mUuid + ".remoteSearchFullText", mRemoteSearchFullText); editor.putInt(mUuid + ".remoteSearchNumResults", mRemoteSearchNumResults); Loading Loading @@ -1603,24 +1592,6 @@ public class Account implements BaseAccount, StoreConfig { mStripSignature = stripSignature; } public String getCryptoApp() { return mCryptoApp; } public void setCryptoApp(String cryptoApp) { boolean isApgCryptoProvider = "apg".equals(cryptoApp); if (cryptoApp == null || isApgCryptoProvider) { mCryptoAppIsDeprecatedApg = isApgCryptoProvider; mCryptoApp = NO_OPENPGP_PROVIDER; } else { mCryptoApp = cryptoApp; } } public boolean isCryptoAppDeprecatedApg() { return mCryptoAppIsDeprecatedApg; } public long getCryptoKey() { return mCryptoKey; } Loading @@ -1629,14 +1600,6 @@ public class Account implements BaseAccount, StoreConfig { mCryptoKey = keyId; } public boolean getCryptoSupportSignOnly() { return mCryptoSupportSignOnly; } public void setCryptoSupportSignOnly(boolean cryptoSupportSignOnly) { mCryptoSupportSignOnly = cryptoSupportSignOnly; } public boolean allowRemoteSearch() { return mAllowRemoteSearch; } Loading Loading @@ -1677,17 +1640,6 @@ public class Account implements BaseAccount, StoreConfig { lastSelectedFolderName = folderName; } public synchronized String getOpenPgpProvider() { if (!isOpenPgpProviderConfigured()) { return null; } return getCryptoApp(); } public synchronized boolean isOpenPgpProviderConfigured() { return !NO_OPENPGP_PROVIDER.equals(getCryptoApp()); } public synchronized NotificationSetting getNotificationSetting() { return mNotificationSetting; } Loading k9mail/src/main/java/com/fsck/k9/K9.java +30 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,9 @@ public class K9 extends Application { private static boolean mHideUserAgent = false; private static boolean mHideTimeZone = false; private static String sOpenPgpProvider = ""; private static boolean sOpenPgpSupportSignOnly = false; private static SortType mSortType; private static Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>(); Loading Loading @@ -311,6 +314,7 @@ public class K9 extends Application { public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000; public static final String NO_OPENPGP_PROVIDER = ""; public static class Intents { Loading Loading @@ -465,6 +469,9 @@ public class K9 extends Application { editor.putBoolean("hideUserAgent", mHideUserAgent); editor.putBoolean("hideTimeZone", mHideTimeZone); editor.putString("openPgpProvider", sOpenPgpProvider); editor.putBoolean("openPgpSupportSignOnly", sOpenPgpSupportSignOnly); editor.putString("language", language); editor.putInt("theme", theme.ordinal()); editor.putInt("messageViewTheme", messageViewTheme.ordinal()); Loading Loading @@ -683,6 +690,9 @@ public class K9 extends Application { mHideUserAgent = storage.getBoolean("hideUserAgent", false); mHideTimeZone = storage.getBoolean("hideTimeZone", false); sOpenPgpProvider = storage.getString("openPgpProvider", NO_OPENPGP_PROVIDER); sOpenPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false); mConfirmDelete = storage.getBoolean("confirmDelete", false); mConfirmDiscardMessage = storage.getBoolean("confirmDiscardMessage", true); mConfirmDeleteStarred = storage.getBoolean("confirmDeleteStarred", false); Loading Loading @@ -1228,6 +1238,26 @@ public class K9 extends Application { mHideTimeZone = state; } public static boolean isOpenPgpProviderConfigured() { return !NO_OPENPGP_PROVIDER.equals(sOpenPgpProvider); } public static String getOpenPgpProvider() { return sOpenPgpProvider; } public static void setOpenPgpProvider(String openPgpProvider) { sOpenPgpProvider = openPgpProvider; } public static boolean getOpenPgpSupportSignOnly() { return sOpenPgpSupportSignOnly; } public static void setOpenPgpSupportSignOnly(boolean supportSignOnly) { sOpenPgpSupportSignOnly = supportSignOnly; } public static String getAttachmentDefaultPath() { return mAttachmentDefaultPath; } Loading k9mail/src/main/java/com/fsck/k9/activity/MessageLoaderHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -202,7 +202,7 @@ public class MessageLoaderHelper { return; } if (account.isOpenPgpProviderConfigured()) { if (K9.isOpenPgpProviderConfigured()) { startOrResumeCryptoOperation(); return; } Loading Loading @@ -262,7 +262,7 @@ public class MessageLoaderHelper { if (retainCryptoHelperFragment.hasData()) { messageCryptoHelper = retainCryptoHelperFragment.getData(); } else { messageCryptoHelper = new MessageCryptoHelper(context, account.getOpenPgpProvider()); messageCryptoHelper = new MessageCryptoHelper(context); retainCryptoHelperFragment.setData(messageCryptoHelper); } messageCryptoHelper.asyncStartOrResumeProcessingMessage( Loading k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +18 −13 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.view.Menu; Loading Loading @@ -66,7 +67,7 @@ public class RecipientPresenter implements PermissionPingCallback { private final RecipientsChangedListener listener; private ReplyToParser replyToParser; private Account account; private String cryptoProvider; private String openPgpProvider; private Boolean hasContactPicker; private ComposeCryptoStatus cachedCryptoStatus; private PendingIntent pendingUserInteractionIntent; Loading Loading @@ -250,7 +251,7 @@ public class RecipientPresenter implements PermissionPingCallback { menu.findItem(R.id.openpgp_inline_enable).setVisible(isCryptoConfigured && !cryptoEnablePgpInline); menu.findItem(R.id.openpgp_inline_disable).setVisible(isCryptoConfigured && cryptoEnablePgpInline); boolean showSignOnly = isCryptoConfigured && account.getCryptoSupportSignOnly(); boolean showSignOnly = isCryptoConfigured && K9.getOpenPgpSupportSignOnly(); boolean isSignOnly = cachedCryptoStatus.isSignOnly(); menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly); Loading @@ -270,8 +271,8 @@ public class RecipientPresenter implements PermissionPingCallback { updateRecipientExpanderVisibility(); } String cryptoProvider = account.getOpenPgpProvider(); setCryptoProvider(cryptoProvider); // This does not strictly depend on the account, but this is as good a point to set this as any setupCryptoProvider(); } @SuppressWarnings("UnusedParameters") Loading Loading @@ -441,7 +442,7 @@ public class RecipientPresenter implements PermissionPingCallback { } private void addRecipientsFromAddresses(final RecipientType recipientType, final Address... addresses) { new RecipientLoader(context, cryptoProvider, addresses) { new RecipientLoader(context, openPgpProvider, addresses) { @Override public void deliverResult(List<Recipient> result) { Recipient[] recipientArray = result.toArray(new Recipient[result.size()]); Loading @@ -454,7 +455,7 @@ public class RecipientPresenter implements PermissionPingCallback { } private void addRecipientFromContactUri(final RecipientType recipientType, final Uri uri) { new RecipientLoader(context, cryptoProvider, uri, false) { new RecipientLoader(context, openPgpProvider, uri, false) { @Override public void deliverResult(List<Recipient> result) { // TODO handle multiple available mail addresses for a contact? Loading Loading @@ -609,10 +610,14 @@ public class RecipientPresenter implements PermissionPingCallback { } } private void setCryptoProvider(String cryptoProvider) { private void setupCryptoProvider() { String openPgpProvider = K9.getOpenPgpProvider(); if (TextUtils.isEmpty(openPgpProvider)) { openPgpProvider = null; } boolean providerIsBound = openPgpServiceConnection != null && openPgpServiceConnection.isBound(); boolean isSameProvider = cryptoProvider != null && cryptoProvider.equals(this.cryptoProvider); boolean isSameProvider = openPgpProvider != null && openPgpProvider.equals(this.openPgpProvider); if (isSameProvider && providerIsBound) { cryptoProviderBindOrCheckPermission(); return; Loading @@ -623,15 +628,15 @@ public class RecipientPresenter implements PermissionPingCallback { openPgpServiceConnection = null; } this.cryptoProvider = cryptoProvider; this.openPgpProvider = openPgpProvider; if (cryptoProvider == null) { if (openPgpProvider == null) { cryptoProviderState = CryptoProviderState.UNCONFIGURED; return; } cryptoProviderState = CryptoProviderState.UNINITIALIZED; openPgpServiceConnection = new OpenPgpServiceConnection(context, cryptoProvider, new OnBound() { openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() { @Override public void onBound(IOpenPgpService2 service) { cryptoProviderBindOrCheckPermission(); Loading @@ -644,7 +649,7 @@ public class RecipientPresenter implements PermissionPingCallback { }); cryptoProviderBindOrCheckPermission(); recipientMvpView.setCryptoProvider(cryptoProvider); recipientMvpView.setCryptoProvider(openPgpProvider); } private void cryptoProviderBindOrCheckPermission() { Loading Loading @@ -779,7 +784,7 @@ public class RecipientPresenter implements PermissionPingCallback { @VisibleForTesting void setOpenPgpServiceConnection(OpenPgpServiceConnection openPgpServiceConnection, String cryptoProvider) { this.openPgpServiceConnection = openPgpServiceConnection; this.cryptoProvider = cryptoProvider; this.openPgpProvider = cryptoProvider; } public enum CryptoProviderState { Loading k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +19 −52 Original line number Diff line number Diff line Loading @@ -9,8 +9,6 @@ import java.util.Map; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; Loading @@ -21,9 +19,11 @@ import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceScreen; import android.preference.RingtonePreference; import android.util.Log; import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.DeletePolicy; Loading @@ -48,10 +48,7 @@ import com.fsck.k9.mail.Store; import com.fsck.k9.mailstore.LocalFolder; import com.fsck.k9.mailstore.StorageManager; import com.fsck.k9.service.MailService; import com.fsck.k9.ui.dialog.ApgDeprecationWarningDialog; import org.openintents.openpgp.util.OpenPgpAppPreference; import org.openintents.openpgp.util.OpenPgpKeyPreference; import org.openintents.openpgp.util.OpenPgpUtils; public class AccountSettings extends K9PreferenceActivity { Loading @@ -59,7 +56,6 @@ public class AccountSettings extends K9PreferenceActivity { private static final int DIALOG_COLOR_PICKER_ACCOUNT = 1; private static final int DIALOG_COLOR_PICKER_LED = 2; private static final int DIALOG_APG_DEPRECATION_WARNING = 3; private static final int SELECT_AUTO_EXPAND_FOLDER = 1; Loading Loading @@ -116,9 +112,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_STRIP_SIGNATURE = "strip_signature"; private static final String PREFERENCE_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions"; private static final String PREFERENCE_CRYPTO = "crypto"; private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; private static final String PREFERENCE_CRYPTO_KEY = "crypto_key"; private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only"; private static final String PREFERENCE_CLOUD_SEARCH_ENABLED = "remote_search_enabled"; private static final String PREFERENCE_REMOTE_SEARCH_NUM_RESULTS = "account_remote_search_num_results"; private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text"; Loading @@ -131,7 +125,6 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_SPAM_FOLDER = "spam_folder"; private static final String PREFERENCE_TRASH_FOLDER = "trash_folder"; private static final String PREFERENCE_ALWAYS_SHOW_CC_BCC = "always_show_cc_bcc"; public static final String APG_PROVIDER_PLACEHOLDER = "apg-placeholder"; private Account mAccount; Loading Loading @@ -185,7 +178,6 @@ public class AccountSettings extends K9PreferenceActivity { private ListPreference mIdleRefreshPeriod; private ListPreference mMaxPushFolders; private boolean mHasCrypto = false; private OpenPgpAppPreference mCryptoApp; private OpenPgpKeyPreference mCryptoKey; private CheckBoxPreference mCryptoSupportSignOnly; Loading Loading @@ -701,34 +693,13 @@ public class AccountSettings extends K9PreferenceActivity { } }); mHasCrypto = OpenPgpUtils.isAvailable(this); mHasCrypto = K9.isOpenPgpProviderConfigured(); PreferenceScreen cryptoMenu = (PreferenceScreen) findPreference(PREFERENCE_CRYPTO); if (mHasCrypto) { mCryptoApp = (OpenPgpAppPreference) findPreference(PREFERENCE_CRYPTO_APP); mCryptoKey = (OpenPgpKeyPreference) findPreference(PREFERENCE_CRYPTO_KEY); mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) { mCryptoApp.addLegacyProvider(APG_PROVIDER_PLACEHOLDER, getString(R.string.apg), R.drawable.ic_apg_small); } mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String value = newValue.toString(); if (APG_PROVIDER_PLACEHOLDER.equals(value)) { mCryptoApp.setValue(""); mCryptoKey.setOpenPgpProvider(""); showDialog(DIALOG_APG_DEPRECATION_WARNING); } else { mCryptoApp.setValue(value); mCryptoKey.setOpenPgpProvider(value); } return false; } }); mCryptoKey.setValue(mAccount.getCryptoKey()); mCryptoKey.setOpenPgpProvider(mCryptoApp.getValue()); mCryptoKey.setOpenPgpProvider(K9.getOpenPgpProvider()); // TODO: other identities? mCryptoKey.setDefaultUserId(OpenPgpApiHelper.buildUserId(mAccount.getIdentity(0))); mCryptoKey.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { Loading @@ -739,11 +710,21 @@ public class AccountSettings extends K9PreferenceActivity { } }); mCryptoSupportSignOnly.setChecked(mAccount.getCryptoSupportSignOnly()); cryptoMenu.setOnPreferenceClickListener(null); } else { final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO); mCryptoMenu.setEnabled(false); mCryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_installed); cryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_configured); cryptoMenu.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Dialog dialog = ((PreferenceScreen) preference).getDialog(); if (dialog != null) { dialog.dismiss(); } Toast.makeText(AccountSettings.this, R.string.no_crypto_provider_see_global, Toast.LENGTH_SHORT).show(); return true; } }); } } Loading Loading @@ -806,13 +787,9 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setStripSignature(mStripSignature.isChecked()); mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue()); if (mHasCrypto) { mAccount.setCryptoApp(mCryptoApp.getValue()); mAccount.setCryptoKey(mCryptoKey.getValue()); mAccount.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked()); } else { mAccount.setCryptoApp(Account.NO_OPENPGP_PROVIDER); mAccount.setCryptoKey(Account.NO_OPENPGP_KEY); mAccount.setCryptoSupportSignOnly(false); } // In webdav account we use the exact folder name also for inbox, Loading Loading @@ -953,16 +930,6 @@ public class AccountSettings extends K9PreferenceActivity { break; } case DIALOG_APG_DEPRECATION_WARNING: { dialog = new ApgDeprecationWarningDialog(this); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mCryptoApp.show(); } }); break; } } return dialog; Loading Loading
k9mail/src/main/java/com/fsck/k9/Account.java +1 −49 Original line number Diff line number Diff line Loading @@ -157,7 +157,6 @@ public class Account implements BaseAccount, StoreConfig { public static final SortType DEFAULT_SORT_TYPE = SortType.SORT_DATE; public static final boolean DEFAULT_SORT_ASCENDING = false; public static final String NO_OPENPGP_PROVIDER = ""; public static final long NO_OPENPGP_KEY = 0; private DeletePolicy mDeletePolicy = DeletePolicy.NEVER; Loading Loading @@ -220,10 +219,7 @@ public class Account implements BaseAccount, StoreConfig { private boolean mReplyAfterQuote; private boolean mStripSignature; private boolean mSyncRemoteDeletions; private String mCryptoApp; private boolean mCryptoAppIsDeprecatedApg; private long mCryptoKey; private boolean mCryptoSupportSignOnly; private boolean mMarkMessageAsReadOnView; private boolean mAlwaysShowCcBcc; private boolean mAllowRemoteSearch; Loading Loading @@ -318,9 +314,7 @@ public class Account implements BaseAccount, StoreConfig { mReplyAfterQuote = DEFAULT_REPLY_AFTER_QUOTE; mStripSignature = DEFAULT_STRIP_SIGNATURE; mSyncRemoteDeletions = true; mCryptoApp = NO_OPENPGP_PROVIDER; mCryptoKey = NO_OPENPGP_KEY; mCryptoSupportSignOnly = false; mAllowRemoteSearch = false; mRemoteSearchFullText = false; mRemoteSearchNumResults = DEFAULT_REMOTE_SEARCH_NUM_RESULTS; Loading Loading @@ -468,10 +462,7 @@ public class Account implements BaseAccount, StoreConfig { mIsSignatureBeforeQuotedText = storage.getBoolean(mUuid + ".signatureBeforeQuotedText", false); identities = loadIdentities(storage); String cryptoApp = storage.getString(mUuid + ".cryptoApp", NO_OPENPGP_PROVIDER); setCryptoApp(cryptoApp); mCryptoKey = storage.getLong(mUuid + ".cryptoKey", NO_OPENPGP_KEY); mCryptoSupportSignOnly = storage.getBoolean(mUuid + ".cryptoSupportSignOnly", false); mAllowRemoteSearch = storage.getBoolean(mUuid + ".allowRemoteSearch", false); mRemoteSearchFullText = storage.getBoolean(mUuid + ".remoteSearchFullText", false); mRemoteSearchNumResults = storage.getInt(mUuid + ".remoteSearchNumResults", DEFAULT_REMOTE_SEARCH_NUM_RESULTS); Loading Loading @@ -560,7 +551,7 @@ public class Account implements BaseAccount, StoreConfig { editor.remove(mUuid + ".showPicturesEnum"); editor.remove(mUuid + ".replyAfterQuote"); editor.remove(mUuid + ".stripSignature"); editor.remove(mUuid + ".cryptoApp"); editor.remove(mUuid + ".cryptoApp"); // this is no longer set, but cleans up legacy values editor.remove(mUuid + ".cryptoAutoSignature"); editor.remove(mUuid + ".cryptoAutoEncrypt"); editor.remove(mUuid + ".cryptoApp"); Loading Loading @@ -737,9 +728,7 @@ public class Account implements BaseAccount, StoreConfig { editor.putBoolean(mUuid + ".defaultQuotedTextShown", mDefaultQuotedTextShown); editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote); editor.putBoolean(mUuid + ".stripSignature", mStripSignature); editor.putString(mUuid + ".cryptoApp", mCryptoApp); editor.putLong(mUuid + ".cryptoKey", mCryptoKey); editor.putBoolean(mUuid + ".cryptoSupportSignOnly", mCryptoSupportSignOnly); editor.putBoolean(mUuid + ".allowRemoteSearch", mAllowRemoteSearch); editor.putBoolean(mUuid + ".remoteSearchFullText", mRemoteSearchFullText); editor.putInt(mUuid + ".remoteSearchNumResults", mRemoteSearchNumResults); Loading Loading @@ -1603,24 +1592,6 @@ public class Account implements BaseAccount, StoreConfig { mStripSignature = stripSignature; } public String getCryptoApp() { return mCryptoApp; } public void setCryptoApp(String cryptoApp) { boolean isApgCryptoProvider = "apg".equals(cryptoApp); if (cryptoApp == null || isApgCryptoProvider) { mCryptoAppIsDeprecatedApg = isApgCryptoProvider; mCryptoApp = NO_OPENPGP_PROVIDER; } else { mCryptoApp = cryptoApp; } } public boolean isCryptoAppDeprecatedApg() { return mCryptoAppIsDeprecatedApg; } public long getCryptoKey() { return mCryptoKey; } Loading @@ -1629,14 +1600,6 @@ public class Account implements BaseAccount, StoreConfig { mCryptoKey = keyId; } public boolean getCryptoSupportSignOnly() { return mCryptoSupportSignOnly; } public void setCryptoSupportSignOnly(boolean cryptoSupportSignOnly) { mCryptoSupportSignOnly = cryptoSupportSignOnly; } public boolean allowRemoteSearch() { return mAllowRemoteSearch; } Loading Loading @@ -1677,17 +1640,6 @@ public class Account implements BaseAccount, StoreConfig { lastSelectedFolderName = folderName; } public synchronized String getOpenPgpProvider() { if (!isOpenPgpProviderConfigured()) { return null; } return getCryptoApp(); } public synchronized boolean isOpenPgpProviderConfigured() { return !NO_OPENPGP_PROVIDER.equals(getCryptoApp()); } public synchronized NotificationSetting getNotificationSetting() { return mNotificationSetting; } Loading
k9mail/src/main/java/com/fsck/k9/K9.java +30 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,9 @@ public class K9 extends Application { private static boolean mHideUserAgent = false; private static boolean mHideTimeZone = false; private static String sOpenPgpProvider = ""; private static boolean sOpenPgpSupportSignOnly = false; private static SortType mSortType; private static Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>(); Loading Loading @@ -311,6 +314,7 @@ public class K9 extends Application { public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 60000; public static final String NO_OPENPGP_PROVIDER = ""; public static class Intents { Loading Loading @@ -465,6 +469,9 @@ public class K9 extends Application { editor.putBoolean("hideUserAgent", mHideUserAgent); editor.putBoolean("hideTimeZone", mHideTimeZone); editor.putString("openPgpProvider", sOpenPgpProvider); editor.putBoolean("openPgpSupportSignOnly", sOpenPgpSupportSignOnly); editor.putString("language", language); editor.putInt("theme", theme.ordinal()); editor.putInt("messageViewTheme", messageViewTheme.ordinal()); Loading Loading @@ -683,6 +690,9 @@ public class K9 extends Application { mHideUserAgent = storage.getBoolean("hideUserAgent", false); mHideTimeZone = storage.getBoolean("hideTimeZone", false); sOpenPgpProvider = storage.getString("openPgpProvider", NO_OPENPGP_PROVIDER); sOpenPgpSupportSignOnly = storage.getBoolean("openPgpSupportSignOnly", false); mConfirmDelete = storage.getBoolean("confirmDelete", false); mConfirmDiscardMessage = storage.getBoolean("confirmDiscardMessage", true); mConfirmDeleteStarred = storage.getBoolean("confirmDeleteStarred", false); Loading Loading @@ -1228,6 +1238,26 @@ public class K9 extends Application { mHideTimeZone = state; } public static boolean isOpenPgpProviderConfigured() { return !NO_OPENPGP_PROVIDER.equals(sOpenPgpProvider); } public static String getOpenPgpProvider() { return sOpenPgpProvider; } public static void setOpenPgpProvider(String openPgpProvider) { sOpenPgpProvider = openPgpProvider; } public static boolean getOpenPgpSupportSignOnly() { return sOpenPgpSupportSignOnly; } public static void setOpenPgpSupportSignOnly(boolean supportSignOnly) { sOpenPgpSupportSignOnly = supportSignOnly; } public static String getAttachmentDefaultPath() { return mAttachmentDefaultPath; } Loading
k9mail/src/main/java/com/fsck/k9/activity/MessageLoaderHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -202,7 +202,7 @@ public class MessageLoaderHelper { return; } if (account.isOpenPgpProviderConfigured()) { if (K9.isOpenPgpProviderConfigured()) { startOrResumeCryptoOperation(); return; } Loading Loading @@ -262,7 +262,7 @@ public class MessageLoaderHelper { if (retainCryptoHelperFragment.hasData()) { messageCryptoHelper = retainCryptoHelperFragment.getData(); } else { messageCryptoHelper = new MessageCryptoHelper(context, account.getOpenPgpProvider()); messageCryptoHelper = new MessageCryptoHelper(context); retainCryptoHelperFragment.setData(messageCryptoHelper); } messageCryptoHelper.asyncStartOrResumeProcessingMessage( Loading
k9mail/src/main/java/com/fsck/k9/activity/compose/RecipientPresenter.java +18 −13 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.view.Menu; Loading Loading @@ -66,7 +67,7 @@ public class RecipientPresenter implements PermissionPingCallback { private final RecipientsChangedListener listener; private ReplyToParser replyToParser; private Account account; private String cryptoProvider; private String openPgpProvider; private Boolean hasContactPicker; private ComposeCryptoStatus cachedCryptoStatus; private PendingIntent pendingUserInteractionIntent; Loading Loading @@ -250,7 +251,7 @@ public class RecipientPresenter implements PermissionPingCallback { menu.findItem(R.id.openpgp_inline_enable).setVisible(isCryptoConfigured && !cryptoEnablePgpInline); menu.findItem(R.id.openpgp_inline_disable).setVisible(isCryptoConfigured && cryptoEnablePgpInline); boolean showSignOnly = isCryptoConfigured && account.getCryptoSupportSignOnly(); boolean showSignOnly = isCryptoConfigured && K9.getOpenPgpSupportSignOnly(); boolean isSignOnly = cachedCryptoStatus.isSignOnly(); menu.findItem(R.id.openpgp_sign_only).setVisible(showSignOnly && !isSignOnly); menu.findItem(R.id.openpgp_sign_only_disable).setVisible(showSignOnly && isSignOnly); Loading @@ -270,8 +271,8 @@ public class RecipientPresenter implements PermissionPingCallback { updateRecipientExpanderVisibility(); } String cryptoProvider = account.getOpenPgpProvider(); setCryptoProvider(cryptoProvider); // This does not strictly depend on the account, but this is as good a point to set this as any setupCryptoProvider(); } @SuppressWarnings("UnusedParameters") Loading Loading @@ -441,7 +442,7 @@ public class RecipientPresenter implements PermissionPingCallback { } private void addRecipientsFromAddresses(final RecipientType recipientType, final Address... addresses) { new RecipientLoader(context, cryptoProvider, addresses) { new RecipientLoader(context, openPgpProvider, addresses) { @Override public void deliverResult(List<Recipient> result) { Recipient[] recipientArray = result.toArray(new Recipient[result.size()]); Loading @@ -454,7 +455,7 @@ public class RecipientPresenter implements PermissionPingCallback { } private void addRecipientFromContactUri(final RecipientType recipientType, final Uri uri) { new RecipientLoader(context, cryptoProvider, uri, false) { new RecipientLoader(context, openPgpProvider, uri, false) { @Override public void deliverResult(List<Recipient> result) { // TODO handle multiple available mail addresses for a contact? Loading Loading @@ -609,10 +610,14 @@ public class RecipientPresenter implements PermissionPingCallback { } } private void setCryptoProvider(String cryptoProvider) { private void setupCryptoProvider() { String openPgpProvider = K9.getOpenPgpProvider(); if (TextUtils.isEmpty(openPgpProvider)) { openPgpProvider = null; } boolean providerIsBound = openPgpServiceConnection != null && openPgpServiceConnection.isBound(); boolean isSameProvider = cryptoProvider != null && cryptoProvider.equals(this.cryptoProvider); boolean isSameProvider = openPgpProvider != null && openPgpProvider.equals(this.openPgpProvider); if (isSameProvider && providerIsBound) { cryptoProviderBindOrCheckPermission(); return; Loading @@ -623,15 +628,15 @@ public class RecipientPresenter implements PermissionPingCallback { openPgpServiceConnection = null; } this.cryptoProvider = cryptoProvider; this.openPgpProvider = openPgpProvider; if (cryptoProvider == null) { if (openPgpProvider == null) { cryptoProviderState = CryptoProviderState.UNCONFIGURED; return; } cryptoProviderState = CryptoProviderState.UNINITIALIZED; openPgpServiceConnection = new OpenPgpServiceConnection(context, cryptoProvider, new OnBound() { openPgpServiceConnection = new OpenPgpServiceConnection(context, openPgpProvider, new OnBound() { @Override public void onBound(IOpenPgpService2 service) { cryptoProviderBindOrCheckPermission(); Loading @@ -644,7 +649,7 @@ public class RecipientPresenter implements PermissionPingCallback { }); cryptoProviderBindOrCheckPermission(); recipientMvpView.setCryptoProvider(cryptoProvider); recipientMvpView.setCryptoProvider(openPgpProvider); } private void cryptoProviderBindOrCheckPermission() { Loading Loading @@ -779,7 +784,7 @@ public class RecipientPresenter implements PermissionPingCallback { @VisibleForTesting void setOpenPgpServiceConnection(OpenPgpServiceConnection openPgpServiceConnection, String cryptoProvider) { this.openPgpServiceConnection = openPgpServiceConnection; this.cryptoProvider = cryptoProvider; this.openPgpProvider = cryptoProvider; } public enum CryptoProviderState { Loading
k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +19 −52 Original line number Diff line number Diff line Loading @@ -9,8 +9,6 @@ import java.util.Map; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; Loading @@ -21,9 +19,11 @@ import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceScreen; import android.preference.RingtonePreference; import android.util.Log; import android.widget.Toast; import com.fsck.k9.Account; import com.fsck.k9.Account.DeletePolicy; Loading @@ -48,10 +48,7 @@ import com.fsck.k9.mail.Store; import com.fsck.k9.mailstore.LocalFolder; import com.fsck.k9.mailstore.StorageManager; import com.fsck.k9.service.MailService; import com.fsck.k9.ui.dialog.ApgDeprecationWarningDialog; import org.openintents.openpgp.util.OpenPgpAppPreference; import org.openintents.openpgp.util.OpenPgpKeyPreference; import org.openintents.openpgp.util.OpenPgpUtils; public class AccountSettings extends K9PreferenceActivity { Loading @@ -59,7 +56,6 @@ public class AccountSettings extends K9PreferenceActivity { private static final int DIALOG_COLOR_PICKER_ACCOUNT = 1; private static final int DIALOG_COLOR_PICKER_LED = 2; private static final int DIALOG_APG_DEPRECATION_WARNING = 3; private static final int SELECT_AUTO_EXPAND_FOLDER = 1; Loading Loading @@ -116,9 +112,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_STRIP_SIGNATURE = "strip_signature"; private static final String PREFERENCE_SYNC_REMOTE_DELETIONS = "account_sync_remote_deletetions"; private static final String PREFERENCE_CRYPTO = "crypto"; private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; private static final String PREFERENCE_CRYPTO_KEY = "crypto_key"; private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only"; private static final String PREFERENCE_CLOUD_SEARCH_ENABLED = "remote_search_enabled"; private static final String PREFERENCE_REMOTE_SEARCH_NUM_RESULTS = "account_remote_search_num_results"; private static final String PREFERENCE_REMOTE_SEARCH_FULL_TEXT = "account_remote_search_full_text"; Loading @@ -131,7 +125,6 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_SPAM_FOLDER = "spam_folder"; private static final String PREFERENCE_TRASH_FOLDER = "trash_folder"; private static final String PREFERENCE_ALWAYS_SHOW_CC_BCC = "always_show_cc_bcc"; public static final String APG_PROVIDER_PLACEHOLDER = "apg-placeholder"; private Account mAccount; Loading Loading @@ -185,7 +178,6 @@ public class AccountSettings extends K9PreferenceActivity { private ListPreference mIdleRefreshPeriod; private ListPreference mMaxPushFolders; private boolean mHasCrypto = false; private OpenPgpAppPreference mCryptoApp; private OpenPgpKeyPreference mCryptoKey; private CheckBoxPreference mCryptoSupportSignOnly; Loading Loading @@ -701,34 +693,13 @@ public class AccountSettings extends K9PreferenceActivity { } }); mHasCrypto = OpenPgpUtils.isAvailable(this); mHasCrypto = K9.isOpenPgpProviderConfigured(); PreferenceScreen cryptoMenu = (PreferenceScreen) findPreference(PREFERENCE_CRYPTO); if (mHasCrypto) { mCryptoApp = (OpenPgpAppPreference) findPreference(PREFERENCE_CRYPTO_APP); mCryptoKey = (OpenPgpKeyPreference) findPreference(PREFERENCE_CRYPTO_KEY); mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY); mCryptoApp.setValue(String.valueOf(mAccount.getCryptoApp())); if (OpenPgpAppPreference.isApgInstalled(getApplicationContext())) { mCryptoApp.addLegacyProvider(APG_PROVIDER_PLACEHOLDER, getString(R.string.apg), R.drawable.ic_apg_small); } mCryptoApp.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { String value = newValue.toString(); if (APG_PROVIDER_PLACEHOLDER.equals(value)) { mCryptoApp.setValue(""); mCryptoKey.setOpenPgpProvider(""); showDialog(DIALOG_APG_DEPRECATION_WARNING); } else { mCryptoApp.setValue(value); mCryptoKey.setOpenPgpProvider(value); } return false; } }); mCryptoKey.setValue(mAccount.getCryptoKey()); mCryptoKey.setOpenPgpProvider(mCryptoApp.getValue()); mCryptoKey.setOpenPgpProvider(K9.getOpenPgpProvider()); // TODO: other identities? mCryptoKey.setDefaultUserId(OpenPgpApiHelper.buildUserId(mAccount.getIdentity(0))); mCryptoKey.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { Loading @@ -739,11 +710,21 @@ public class AccountSettings extends K9PreferenceActivity { } }); mCryptoSupportSignOnly.setChecked(mAccount.getCryptoSupportSignOnly()); cryptoMenu.setOnPreferenceClickListener(null); } else { final Preference mCryptoMenu = findPreference(PREFERENCE_CRYPTO); mCryptoMenu.setEnabled(false); mCryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_installed); cryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_configured); cryptoMenu.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Dialog dialog = ((PreferenceScreen) preference).getDialog(); if (dialog != null) { dialog.dismiss(); } Toast.makeText(AccountSettings.this, R.string.no_crypto_provider_see_global, Toast.LENGTH_SHORT).show(); return true; } }); } } Loading Loading @@ -806,13 +787,9 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setStripSignature(mStripSignature.isChecked()); mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue()); if (mHasCrypto) { mAccount.setCryptoApp(mCryptoApp.getValue()); mAccount.setCryptoKey(mCryptoKey.getValue()); mAccount.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked()); } else { mAccount.setCryptoApp(Account.NO_OPENPGP_PROVIDER); mAccount.setCryptoKey(Account.NO_OPENPGP_KEY); mAccount.setCryptoSupportSignOnly(false); } // In webdav account we use the exact folder name also for inbox, Loading Loading @@ -953,16 +930,6 @@ public class AccountSettings extends K9PreferenceActivity { break; } case DIALOG_APG_DEPRECATION_WARNING: { dialog = new ApgDeprecationWarningDialog(this); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mCryptoApp.show(); } }); break; } } return dialog; Loading