move sign-only support settings to global

This commit is contained in:
Vincent Breitmoser 2017-01-20 16:33:05 +01:00
parent 46046f8926
commit 6e982690d2
11 changed files with 42 additions and 32 deletions

View file

@ -220,7 +220,6 @@ public class Account implements BaseAccount, StoreConfig {
private boolean mStripSignature;
private boolean mSyncRemoteDeletions;
private long mCryptoKey;
private boolean mCryptoSupportSignOnly;
private boolean mMarkMessageAsReadOnView;
private boolean mAlwaysShowCcBcc;
private boolean mAllowRemoteSearch;
@ -316,7 +315,6 @@ public class Account implements BaseAccount, StoreConfig {
mStripSignature = DEFAULT_STRIP_SIGNATURE;
mSyncRemoteDeletions = true;
mCryptoKey = NO_OPENPGP_KEY;
mCryptoSupportSignOnly = false;
mAllowRemoteSearch = false;
mRemoteSearchFullText = false;
mRemoteSearchNumResults = DEFAULT_REMOTE_SEARCH_NUM_RESULTS;
@ -465,7 +463,6 @@ public class Account implements BaseAccount, StoreConfig {
identities = loadIdentities(storage);
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);
@ -732,7 +729,6 @@ public class Account implements BaseAccount, StoreConfig {
editor.putBoolean(mUuid + ".replyAfterQuote", mReplyAfterQuote);
editor.putBoolean(mUuid + ".stripSignature", mStripSignature);
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);
@ -1604,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;
}

View file

@ -243,6 +243,7 @@ public class K9 extends Application {
private static boolean mHideTimeZone = false;
private static String sCryptoProvider = "";
private static boolean sCryptoSupportSignOnly = false;
private static SortType mSortType;
private static Map<SortType, Boolean> mSortAscending = new HashMap<SortType, Boolean>();
@ -469,6 +470,7 @@ public class K9 extends Application {
editor.putBoolean("hideTimeZone", mHideTimeZone);
editor.putString("cryptoProvider", sCryptoProvider);
editor.putBoolean("cryptoSupportSignOnly", sCryptoSupportSignOnly);
editor.putString("language", language);
editor.putInt("theme", theme.ordinal());
@ -689,6 +691,7 @@ public class K9 extends Application {
mHideTimeZone = storage.getBoolean("hideTimeZone", false);
sCryptoProvider = storage.getString("cryptoProvider", NO_CRYPTO_PROVIDER);
sCryptoSupportSignOnly = storage.getBoolean("cryptoSupportSignOnly", false);
mConfirmDelete = storage.getBoolean("confirmDelete", false);
mConfirmDiscardMessage = storage.getBoolean("confirmDiscardMessage", true);
@ -1247,6 +1250,14 @@ public class K9 extends Application {
sCryptoProvider = cryptoProvider;
}
public static boolean getCryptoSupportSignOnly() {
return sCryptoSupportSignOnly;
}
public static void setCryptoSupportSignOnly(boolean supportSignOnly) {
sCryptoSupportSignOnly = supportSignOnly;
}
public static String getAttachmentDefaultPath() {
return mAttachmentDefaultPath;
}

View file

@ -251,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.getCryptoSupportSignOnly();
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);

View file

@ -113,7 +113,6 @@ public class AccountSettings extends K9PreferenceActivity {
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_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";
@ -698,7 +697,6 @@ public class AccountSettings extends K9PreferenceActivity {
PreferenceScreen cryptoMenu = (PreferenceScreen) findPreference(PREFERENCE_CRYPTO);
if (mHasCrypto) {
mCryptoKey = (OpenPgpKeyPreference) findPreference(PREFERENCE_CRYPTO_KEY);
mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY);
mCryptoKey.setValue(mAccount.getCryptoKey());
mCryptoKey.setOpenPgpProvider(K9.getCryptoProvider());
@ -712,7 +710,6 @@ public class AccountSettings extends K9PreferenceActivity {
}
});
mCryptoSupportSignOnly.setChecked(mAccount.getCryptoSupportSignOnly());
cryptoMenu.setOnPreferenceClickListener(null);
} else {
cryptoMenu.setSummary(R.string.account_settings_no_openpgp_provider_configured);
@ -791,10 +788,8 @@ public class AccountSettings extends K9PreferenceActivity {
mAccount.setLocalStorageProviderId(mLocalStorageProvider.getValue());
if (mHasCrypto) {
mAccount.setCryptoKey(mCryptoKey.getValue());
mAccount.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked());
} else {
mAccount.setCryptoKey(Account.NO_OPENPGP_KEY);
mAccount.setCryptoSupportSignOnly(false);
}
// In webdav account we use the exact folder name also for inbox,

View file

@ -94,6 +94,7 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone";
private static final String PREFERENCE_CRYPTO_APP = "crypto_app";
private static final String PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY = "crypto_support_sign_only";
private static final String PREFERENCE_AUTOFIT_WIDTH = "messageview_autofit_width";
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
@ -155,6 +156,7 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxListPreference mVisibleRefileActions;
private OpenPgpAppPreference mCryptoProvider;
private CheckBoxPreference mCryptoSupportSignOnly;
private CheckBoxPreference mQuietTimeEnabled;
private CheckBoxPreference mDisableNotificationDuringQuietTime;
@ -401,6 +403,9 @@ public class Prefs extends K9PreferenceActivity {
}
});
mCryptoSupportSignOnly = (CheckBoxPreference) findPreference(PREFERENCE_CRYPTO_SUPPORT_SIGN_ONLY);
mCryptoSupportSignOnly.setChecked(K9.getCryptoSupportSignOnly());
mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH);
mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath());
mAttachmentPathPreference
@ -557,6 +562,7 @@ public class Prefs extends K9PreferenceActivity {
K9.setHideTimeZone(mHideTimeZone.isChecked());
K9.setCryptoProvider(mCryptoProvider.getValue());
K9.setCryptoSupportSignOnly(mCryptoSupportSignOnly.isChecked());
StorageEditor editor = storage.edit();
K9.save(editor);

View file

@ -293,6 +293,9 @@ public class GlobalSettings {
s.put("cryptoProvider", Settings.versions(
new V(46, new StringSetting(K9.NO_CRYPTO_PROVIDER))
));
s.put("cryptoSupportSignOnly", Settings.versions(
new V(47, new BooleanSetting(false))
));
SETTINGS = Collections.unmodifiableMap(s);

View file

@ -36,7 +36,7 @@ public class Settings {
*
* @see SettingsExporter
*/
public static final int VERSION = 46;
public static final int VERSION = 47;
static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
Map<String, String> importedSettings, boolean useDefaultValues) {

View file

@ -59,7 +59,7 @@ public class MessageCryptoPresenter implements OnCryptoClickListener {
return false;
}
boolean suppressSignOnlyMessages = !account.getCryptoSupportSignOnly();
boolean suppressSignOnlyMessages = !K9.getCryptoSupportSignOnly();
if (suppressSignOnlyMessages && displayStatus.isUnencryptedSigned()) {
return false;
}

View file

@ -19,6 +19,7 @@ import android.widget.TextView;
import com.fsck.k9.Account;
import com.fsck.k9.Account.ShowPictures;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.mail.Address;
@ -114,7 +115,7 @@ public class MessageTopView extends LinearLayout {
containerView, false);
containerView.addView(view);
boolean hideUnsignedTextDivider = !account.getCryptoSupportSignOnly();
boolean hideUnsignedTextDivider = !K9.getCryptoSupportSignOnly();
view.displayMessageViewContainer(messageViewInfo, new OnRenderingFinishedListener() {
@Override
public void onLoadFinished() {

View file

@ -479,13 +479,6 @@
android:key="crypto_key"
android:title="@string/account_settings_crypto_key" />
<CheckBoxPreference
android:persistent="false"
android:key="crypto_support_sign_only"
android:title="@string/account_settings_crypto_support_sign_only"
/>
</PreferenceScreen>
</PreferenceScreen>

View file

@ -409,8 +409,21 @@
</PreferenceScreen>
<org.openintents.openpgp.util.OpenPgpAppPreference
android:persistent="false"
android:key="crypto_app"
android:title="@string/account_settings_crypto_app" />
<PreferenceScreen
android:title="Cryptography"
android:key="crypto">
<org.openintents.openpgp.util.OpenPgpAppPreference
android:persistent="false"
android:key="crypto_app"
android:title="@string/account_settings_crypto_app" />
<CheckBoxPreference
android:persistent="false"
android:key="crypto_support_sign_only"
android:title="@string/account_settings_crypto_support_sign_only"
/>
</PreferenceScreen>
</PreferenceScreen>