clean up more warnings (no semantic changes)
This commit is contained in:
parent
cad7da10d6
commit
045fd63760
6 changed files with 91 additions and 95 deletions
|
@ -1,6 +1,7 @@
|
|||
|
||||
package com.fsck.k9;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,13 +34,12 @@ import com.fsck.k9.controller.MessagingListener;
|
|||
import com.fsck.k9.mail.Address;
|
||||
import com.fsck.k9.mail.K9MailLib;
|
||||
import com.fsck.k9.mail.Message;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import com.fsck.k9.mail.internet.BinaryTempFileBody;
|
||||
import com.fsck.k9.mail.ssl.LocalKeyStore;
|
||||
import com.fsck.k9.mailstore.LocalStore;
|
||||
import com.fsck.k9.preferences.Storage;
|
||||
import com.fsck.k9.preferences.StorageEditor;
|
||||
import com.fsck.k9.provider.UnreadWidgetProvider;
|
||||
import com.fsck.k9.mail.ssl.LocalKeyStore;
|
||||
import com.fsck.k9.service.BootReceiver;
|
||||
import com.fsck.k9.service.MailService;
|
||||
import com.fsck.k9.service.ShutdownReceiver;
|
||||
|
|
|
@ -32,12 +32,11 @@ import com.fsck.k9.preferences.Settings.StringSetting;
|
|||
import com.fsck.k9.preferences.Settings.V;
|
||||
|
||||
public class AccountSettings {
|
||||
public static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
public static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
private static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
|
||||
static {
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s =
|
||||
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* When adding new settings here, be sure to increment {@link Settings.VERSION}
|
||||
|
@ -85,16 +84,16 @@ public class AccountSettings {
|
|||
R.array.account_setup_expunge_policy_values))
|
||||
));
|
||||
s.put("folderDisplayMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
||||
new V(1, new EnumSetting<>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
||||
));
|
||||
s.put("folderPushMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
|
||||
new V(1, new EnumSetting<>(FolderMode.class, FolderMode.FIRST_CLASS))
|
||||
));
|
||||
s.put("folderSyncMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
|
||||
new V(1, new EnumSetting<>(FolderMode.class, FolderMode.FIRST_CLASS))
|
||||
));
|
||||
s.put("folderTargetMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
||||
new V(1, new EnumSetting<>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
||||
));
|
||||
s.put("goToUnreadMessageSearch", Settings.versions(
|
||||
new V(1, new BooleanSetting(false))
|
||||
|
@ -129,7 +128,7 @@ public class AccountSettings {
|
|||
R.array.account_settings_message_age_values))
|
||||
));
|
||||
s.put("messageFormat", Settings.versions(
|
||||
new V(1, new EnumSetting<MessageFormat>(
|
||||
new V(1, new EnumSetting<>(
|
||||
MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
|
||||
));
|
||||
s.put("messageFormatAuto", Settings.versions(
|
||||
|
@ -145,7 +144,7 @@ public class AccountSettings {
|
|||
new V(1, new BooleanSetting(false))
|
||||
));
|
||||
s.put("folderNotifyNewMailMode", Settings.versions(
|
||||
new V(34, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.ALL))
|
||||
new V(34, new EnumSetting<>(FolderMode.class, FolderMode.ALL))
|
||||
));
|
||||
s.put("notifySelfNewMail", Settings.versions(
|
||||
new V(1, new BooleanSetting(true))
|
||||
|
@ -157,8 +156,7 @@ public class AccountSettings {
|
|||
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
|
||||
));
|
||||
s.put("quoteStyle", Settings.versions(
|
||||
new V(1, new EnumSetting<QuoteStyle>(
|
||||
QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
|
||||
new V(1, new EnumSetting<>(QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
|
||||
));
|
||||
s.put("replyAfterQuote", Settings.versions(
|
||||
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
|
||||
|
@ -170,21 +168,19 @@ public class AccountSettings {
|
|||
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
|
||||
));
|
||||
s.put("searchableFolders", Settings.versions(
|
||||
new V(1, new EnumSetting<Searchable>(
|
||||
Searchable.class, Searchable.ALL))
|
||||
new V(1, new EnumSetting<>(Searchable.class, Searchable.ALL))
|
||||
));
|
||||
s.put("sentFolderName", Settings.versions(
|
||||
new V(1, new StringSetting("Sent"))
|
||||
));
|
||||
s.put("sortTypeEnum", Settings.versions(
|
||||
new V(9, new EnumSetting<SortType>(SortType.class, Account.DEFAULT_SORT_TYPE))
|
||||
new V(9, new EnumSetting<>(SortType.class, Account.DEFAULT_SORT_TYPE))
|
||||
));
|
||||
s.put("sortAscending", Settings.versions(
|
||||
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
||||
));
|
||||
s.put("showPicturesEnum", Settings.versions(
|
||||
new V(1, new EnumSetting<ShowPictures>(
|
||||
ShowPictures.class, ShowPictures.NEVER))
|
||||
new V(1, new EnumSetting<>(ShowPictures.class, ShowPictures.NEVER))
|
||||
));
|
||||
s.put("signatureBeforeQuotedText", Settings.versions(
|
||||
new V(1, new BooleanSetting(false))
|
||||
|
@ -240,11 +236,12 @@ public class AccountSettings {
|
|||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<Integer, SettingsUpgrader>();
|
||||
// noinspection MismatchedQueryAndUpdateOfCollection, this map intentionally left blank
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<>();
|
||||
UPGRADERS = Collections.unmodifiableMap(u);
|
||||
}
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
boolean useDefaultValues) {
|
||||
return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
|
||||
}
|
||||
|
@ -257,8 +254,8 @@ public class AccountSettings {
|
|||
return Settings.convert(settings, SETTINGS);
|
||||
}
|
||||
|
||||
public static Map<String, String> getAccountSettings(Storage storage, String uuid) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
static Map<String, String> getAccountSettings(Storage storage, String uuid) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String prefix = uuid + ".";
|
||||
for (String key : SETTINGS.keySet()) {
|
||||
String value = storage.getString(prefix + key, null);
|
||||
|
@ -277,10 +274,10 @@ public class AccountSettings {
|
|||
* integer strings.
|
||||
* </p>
|
||||
*/
|
||||
public static class IntegerResourceSetting extends PseudoEnumSetting<Integer> {
|
||||
private static class IntegerResourceSetting extends PseudoEnumSetting<Integer> {
|
||||
private final Map<Integer, String> mMapping;
|
||||
|
||||
public IntegerResourceSetting(int defaultValue, int resId) {
|
||||
IntegerResourceSetting(int defaultValue, int resId) {
|
||||
super(defaultValue);
|
||||
|
||||
Map<Integer, String> mapping = new HashMap<>();
|
||||
|
@ -314,13 +311,13 @@ public class AccountSettings {
|
|||
* Basically a {@link PseudoEnumSetting} that is initialized from a resource array.
|
||||
* </p>
|
||||
*/
|
||||
public static class StringResourceSetting extends PseudoEnumSetting<String> {
|
||||
private static class StringResourceSetting extends PseudoEnumSetting<String> {
|
||||
private final Map<String, String> mMapping;
|
||||
|
||||
public StringResourceSetting(String defaultValue, int resId) {
|
||||
StringResourceSetting(String defaultValue, int resId) {
|
||||
super(defaultValue);
|
||||
|
||||
Map<String, String> mapping = new HashMap<String, String>();
|
||||
Map<String, String> mapping = new HashMap<>();
|
||||
String[] values = K9.app.getResources().getStringArray(resId);
|
||||
for (String value : values) {
|
||||
mapping.put(value, value);
|
||||
|
@ -345,8 +342,8 @@ public class AccountSettings {
|
|||
/**
|
||||
* The notification ringtone setting.
|
||||
*/
|
||||
public static class RingtoneSetting extends SettingsDescription<String> {
|
||||
public RingtoneSetting(String defaultValue) {
|
||||
private static class RingtoneSetting extends SettingsDescription<String> {
|
||||
RingtoneSetting(String defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
|
@ -360,8 +357,8 @@ public class AccountSettings {
|
|||
/**
|
||||
* The storage provider setting.
|
||||
*/
|
||||
public static class StorageProviderSetting extends SettingsDescription<String> {
|
||||
public StorageProviderSetting() {
|
||||
private static class StorageProviderSetting extends SettingsDescription<String> {
|
||||
StorageProviderSetting() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
|
@ -381,10 +378,10 @@ public class AccountSettings {
|
|||
}
|
||||
}
|
||||
|
||||
public static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
|
||||
private static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
|
||||
private Map<Integer, String> mMapping;
|
||||
|
||||
public DeletePolicySetting(DeletePolicy defaultValue) {
|
||||
DeletePolicySetting(DeletePolicy defaultValue) {
|
||||
super(defaultValue.setting);
|
||||
Map<Integer, String> mapping = new HashMap<>();
|
||||
mapping.put(DeletePolicy.NEVER.setting, "NEVER");
|
||||
|
|
|
@ -10,13 +10,12 @@ import java.util.TreeMap;
|
|||
import com.fsck.k9.mail.Folder.FolderClass;
|
||||
import com.fsck.k9.preferences.Settings.*;
|
||||
|
||||
public class FolderSettings {
|
||||
public static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
public static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
class FolderSettings {
|
||||
static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
private static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
|
||||
static {
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s =
|
||||
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* When adding new settings here, be sure to increment {@link Settings.VERSION}
|
||||
|
@ -24,16 +23,16 @@ public class FolderSettings {
|
|||
*/
|
||||
|
||||
s.put("displayMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.NO_CLASS))
|
||||
new V(1, new EnumSetting<>(FolderClass.class, FolderClass.NO_CLASS))
|
||||
));
|
||||
s.put("notifyMode", Settings.versions(
|
||||
new V(34, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.INHERITED))
|
||||
new V(34, new EnumSetting<>(FolderClass.class, FolderClass.INHERITED))
|
||||
));
|
||||
s.put("syncMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.INHERITED))
|
||||
new V(1, new EnumSetting<>(FolderClass.class, FolderClass.INHERITED))
|
||||
));
|
||||
s.put("pushMode", Settings.versions(
|
||||
new V(1, new EnumSetting<FolderClass>(FolderClass.class, FolderClass.INHERITED))
|
||||
new V(1, new EnumSetting<>(FolderClass.class, FolderClass.INHERITED))
|
||||
));
|
||||
s.put("inTopGroup", Settings.versions(
|
||||
new V(1, new BooleanSetting(false))
|
||||
|
@ -44,11 +43,12 @@ public class FolderSettings {
|
|||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<Integer, SettingsUpgrader>();
|
||||
// noinspection MismatchedQueryAndUpdateOfCollection, this map intentionally left blank
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<>();
|
||||
UPGRADERS = Collections.unmodifiableMap(u);
|
||||
}
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
boolean useDefaultValues) {
|
||||
return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ public class FolderSettings {
|
|||
return Settings.convert(settings, SETTINGS);
|
||||
}
|
||||
|
||||
public static Map<String, String> getFolderSettings(Storage storage, String uuid,
|
||||
static Map<String, String> getFolderSettings(Storage storage, String uuid,
|
||||
String folderName) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String prefix = uuid + "." + folderName + ".";
|
||||
for (String key : SETTINGS.keySet()) {
|
||||
String value = storage.getString(prefix + key, null);
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.fsck.k9.preferences;
|
|||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -37,12 +36,11 @@ import com.fsck.k9.preferences.Settings.WebFontSizeSetting;
|
|||
import static com.fsck.k9.K9.LockScreenNotificationVisibility;
|
||||
|
||||
public class GlobalSettings {
|
||||
public static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
public static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
private static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
|
||||
static {
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s =
|
||||
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* When adding new settings here, be sure to increment {@link Settings.VERSION}
|
||||
|
@ -58,7 +56,7 @@ public class GlobalSettings {
|
|||
Environment.DIRECTORY_DOWNLOADS)))
|
||||
));
|
||||
s.put("backgroundOperations", Settings.versions(
|
||||
new V(1, new EnumSetting<K9.BACKGROUND_OPS>(
|
||||
new V(1, new EnumSetting<>(
|
||||
K9.BACKGROUND_OPS.class, K9.BACKGROUND_OPS.WHEN_CHECKED_AUTO_SYNC))
|
||||
));
|
||||
s.put("changeRegisteredNameColor", Settings.versions(
|
||||
|
@ -191,7 +189,7 @@ public class GlobalSettings {
|
|||
new V(1, new BooleanSetting(true))
|
||||
));
|
||||
s.put("sortTypeEnum", Settings.versions(
|
||||
new V(10, new EnumSetting<SortType>(SortType.class, Account.DEFAULT_SORT_TYPE))
|
||||
new V(10, new EnumSetting<>(SortType.class, Account.DEFAULT_SORT_TYPE))
|
||||
));
|
||||
s.put("sortAscending", Settings.versions(
|
||||
new V(10, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
||||
|
@ -216,7 +214,7 @@ public class GlobalSettings {
|
|||
new V(22, new BooleanSetting(false))
|
||||
));
|
||||
s.put("notificationHideSubject", Settings.versions(
|
||||
new V(12, new EnumSetting<NotificationHideSubject>(
|
||||
new V(12, new EnumSetting<>(
|
||||
NotificationHideSubject.class, NotificationHideSubject.NEVER))
|
||||
));
|
||||
s.put("useBackgroundAsUnreadIndicator", Settings.versions(
|
||||
|
@ -226,7 +224,7 @@ public class GlobalSettings {
|
|||
new V(20, new BooleanSetting(true))
|
||||
));
|
||||
s.put("splitViewMode", Settings.versions(
|
||||
new V(23, new EnumSetting<SplitViewMode>(SplitViewMode.class, SplitViewMode.NEVER))
|
||||
new V(23, new EnumSetting<>(SplitViewMode.class, SplitViewMode.NEVER))
|
||||
));
|
||||
s.put("messageComposeTheme", Settings.versions(
|
||||
new V(24, new SubThemeSetting(K9.Theme.USE_GLOBAL))
|
||||
|
@ -268,7 +266,7 @@ public class GlobalSettings {
|
|||
new V(32, new BooleanSetting(false))
|
||||
));
|
||||
s.put("lockScreenNotificationVisibility", Settings.versions(
|
||||
new V(37, new EnumSetting<LockScreenNotificationVisibility>(LockScreenNotificationVisibility.class,
|
||||
new V(37, new EnumSetting<>(LockScreenNotificationVisibility.class,
|
||||
LockScreenNotificationVisibility.MESSAGE_COUNT))
|
||||
));
|
||||
s.put("confirmDeleteFromNotification", Settings.versions(
|
||||
|
@ -278,7 +276,7 @@ public class GlobalSettings {
|
|||
new V(38, new BooleanSetting(false))
|
||||
));
|
||||
s.put("notificationQuickDelete", Settings.versions(
|
||||
new V(38, new EnumSetting<NotificationQuickDelete>(NotificationQuickDelete.class,
|
||||
new V(38, new EnumSetting<>(NotificationQuickDelete.class,
|
||||
NotificationQuickDelete.NEVER))
|
||||
));
|
||||
s.put("notificationDuringQuietTimeEnabled", Settings.versions(
|
||||
|
@ -293,7 +291,7 @@ public class GlobalSettings {
|
|||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<Integer, SettingsUpgrader>();
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<>();
|
||||
u.put(12, new SettingsUpgraderV12());
|
||||
u.put(24, new SettingsUpgraderV24());
|
||||
u.put(31, new SettingsUpgraderV31());
|
||||
|
@ -301,7 +299,7 @@ public class GlobalSettings {
|
|||
UPGRADERS = Collections.unmodifiableMap(u);
|
||||
}
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String, String> importedSettings) {
|
||||
static Map<String, Object> validate(int version, Map<String, String> importedSettings) {
|
||||
return Settings.validate(version, SETTINGS, importedSettings, false);
|
||||
}
|
||||
|
||||
|
@ -313,8 +311,8 @@ public class GlobalSettings {
|
|||
return Settings.convert(settings, SETTINGS);
|
||||
}
|
||||
|
||||
public static Map<String, String> getGlobalSettings(Storage storage) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
static Map<String, String> getGlobalSettings(Storage storage) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
for (String key : SETTINGS.keySet()) {
|
||||
String value = storage.getString(key, null);
|
||||
if (value != null) {
|
||||
|
@ -329,19 +327,19 @@ public class GlobalSettings {
|
|||
*
|
||||
* Map the 'keyguardPrivacy' value to the new NotificationHideSubject enum.
|
||||
*/
|
||||
public static class SettingsUpgraderV12 implements SettingsUpgrader {
|
||||
private static class SettingsUpgraderV12 implements SettingsUpgrader {
|
||||
|
||||
@Override
|
||||
public Set<String> upgrade(Map<String, Object> settings) {
|
||||
Boolean keyguardPrivacy = (Boolean) settings.get("keyguardPrivacy");
|
||||
if (keyguardPrivacy != null && keyguardPrivacy.booleanValue()) {
|
||||
if (keyguardPrivacy != null && keyguardPrivacy) {
|
||||
// current setting: only show subject when unlocked
|
||||
settings.put("notificationHideSubject", NotificationHideSubject.WHEN_LOCKED);
|
||||
} else {
|
||||
// always show subject [old default]
|
||||
settings.put("notificationHideSubject", NotificationHideSubject.NEVER);
|
||||
}
|
||||
return new HashSet<String>(Arrays.asList("keyguardPrivacy"));
|
||||
return new HashSet<>(Collections.singletonList("keyguardPrivacy"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +351,7 @@ public class GlobalSettings {
|
|||
* the same value as <em>theme</em>.
|
||||
* </p>
|
||||
*/
|
||||
public static class SettingsUpgraderV24 implements SettingsUpgrader {
|
||||
private static class SettingsUpgraderV24 implements SettingsUpgrader {
|
||||
|
||||
@Override
|
||||
public Set<String> upgrade(Map<String, Object> settings) {
|
||||
|
@ -379,13 +377,13 @@ public class GlobalSettings {
|
|||
|
||||
@Override
|
||||
public Set<String> upgrade(Map<String, Object> settings) {
|
||||
int oldSize = ((Integer) settings.get("fontSizeMessageViewContent")).intValue();
|
||||
int oldSize = (Integer) settings.get("fontSizeMessageViewContent");
|
||||
|
||||
int newSize = convertFromOldSize(oldSize);
|
||||
|
||||
settings.put("fontSizeMessageViewContentPercent", newSize);
|
||||
|
||||
return new HashSet<String>(Arrays.asList("fontSizeMessageViewContent"));
|
||||
return new HashSet<>(Collections.singletonList("fontSizeMessageViewContent"));
|
||||
}
|
||||
|
||||
public static int convertFromOldSize(int oldSize) {
|
||||
|
@ -418,13 +416,13 @@ public class GlobalSettings {
|
|||
* {@code res/values/arrays.xml}.
|
||||
* </p>
|
||||
*/
|
||||
public static class LanguageSetting extends PseudoEnumSetting<String> {
|
||||
private static class LanguageSetting extends PseudoEnumSetting<String> {
|
||||
private final Map<String, String> mMapping;
|
||||
|
||||
public LanguageSetting() {
|
||||
LanguageSetting() {
|
||||
super("");
|
||||
|
||||
Map<String, String> mapping = new HashMap<String, String>();
|
||||
Map<String, String> mapping = new HashMap<>();
|
||||
String[] values = K9.app.getResources().getStringArray(R.array.settings_language_values);
|
||||
for (String value : values) {
|
||||
if (value.length() == 0) {
|
||||
|
@ -454,11 +452,11 @@ public class GlobalSettings {
|
|||
/**
|
||||
* The theme setting.
|
||||
*/
|
||||
public static class ThemeSetting extends SettingsDescription<K9.Theme> {
|
||||
static class ThemeSetting extends SettingsDescription<K9.Theme> {
|
||||
private static final String THEME_LIGHT = "light";
|
||||
private static final String THEME_DARK = "dark";
|
||||
|
||||
public ThemeSetting(K9.Theme defaultValue) {
|
||||
ThemeSetting(K9.Theme defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
|
@ -512,10 +510,10 @@ public class GlobalSettings {
|
|||
/**
|
||||
* The message view theme setting.
|
||||
*/
|
||||
public static class SubThemeSetting extends ThemeSetting {
|
||||
private static class SubThemeSetting extends ThemeSetting {
|
||||
private static final String THEME_USE_GLOBAL = "use_global";
|
||||
|
||||
public SubThemeSetting(Theme defaultValue) {
|
||||
SubThemeSetting(Theme defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
|
@ -555,8 +553,8 @@ public class GlobalSettings {
|
|||
/**
|
||||
* A time setting.
|
||||
*/
|
||||
public static class TimeSetting extends SettingsDescription<String> {
|
||||
public TimeSetting(String defaultValue) {
|
||||
private static class TimeSetting extends SettingsDescription<String> {
|
||||
TimeSetting(String defaultValue) {
|
||||
super(defaultValue);
|
||||
}
|
||||
|
||||
|
@ -572,8 +570,8 @@ public class GlobalSettings {
|
|||
/**
|
||||
* A directory on the file system.
|
||||
*/
|
||||
public static class DirectorySetting extends SettingsDescription<String> {
|
||||
public DirectorySetting(File defaultPath) {
|
||||
private static class DirectorySetting extends SettingsDescription<String> {
|
||||
DirectorySetting(File defaultPath) {
|
||||
super(defaultPath.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ import com.fsck.k9.K9;
|
|||
import com.fsck.k9.R;
|
||||
import com.fsck.k9.preferences.Settings.*;
|
||||
|
||||
public class IdentitySettings {
|
||||
public static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
public static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
class IdentitySettings {
|
||||
static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
||||
private static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
||||
|
||||
static {
|
||||
Map<String, TreeMap<Integer, SettingsDescription>> s =
|
||||
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
|
||||
new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* When adding new settings here, be sure to increment {@link Settings.VERSION}
|
||||
|
@ -37,11 +37,12 @@ public class IdentitySettings {
|
|||
|
||||
SETTINGS = Collections.unmodifiableMap(s);
|
||||
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<Integer, SettingsUpgrader>();
|
||||
// noinspection MismatchedQueryAndUpdateOfCollection, this map intentionally left blank
|
||||
Map<Integer, SettingsUpgrader> u = new HashMap<>();
|
||||
UPGRADERS = Collections.unmodifiableMap(u);
|
||||
}
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
||||
boolean useDefaultValues) {
|
||||
return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
|
||||
}
|
||||
|
@ -54,9 +55,9 @@ public class IdentitySettings {
|
|||
return Settings.convert(settings, SETTINGS);
|
||||
}
|
||||
|
||||
public static Map<String, String> getIdentitySettings(Storage storage, String uuid,
|
||||
static Map<String, String> getIdentitySettings(Storage storage, String uuid,
|
||||
int identityIndex) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String prefix = uuid + ".";
|
||||
String suffix = "." + Integer.toString(identityIndex);
|
||||
for (String key : SETTINGS.keySet()) {
|
||||
|
@ -69,15 +70,15 @@ public class IdentitySettings {
|
|||
}
|
||||
|
||||
|
||||
public static boolean isEmailAddressValid(String email) {
|
||||
static boolean isEmailAddressValid(String email) {
|
||||
return new EmailAddressValidator().isValidAddressOnly(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* The message signature setting.
|
||||
*/
|
||||
public static class SignatureSetting extends SettingsDescription<String> {
|
||||
public SignatureSetting() {
|
||||
private static class SignatureSetting extends SettingsDescription<String> {
|
||||
SignatureSetting() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
|
@ -95,10 +96,10 @@ public class IdentitySettings {
|
|||
/**
|
||||
* An optional email address setting.
|
||||
*/
|
||||
public static class OptionalEmailAddressSetting extends SettingsDescription<String> {
|
||||
private static class OptionalEmailAddressSetting extends SettingsDescription<String> {
|
||||
private EmailAddressValidator mValidator;
|
||||
|
||||
public OptionalEmailAddressSetting() {
|
||||
OptionalEmailAddressSetting() {
|
||||
super(null);
|
||||
mValidator = new EmailAddressValidator();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.fsck.k9.preferences;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
@ -225,8 +226,7 @@ public class Settings {
|
|||
* @return A {@code TreeMap} using the version number as key, the {@code SettingsDescription}
|
||||
* as value.
|
||||
*/
|
||||
static TreeMap<Integer, SettingsDescription> versions(
|
||||
V... versionDescriptions) {
|
||||
static TreeMap<Integer, SettingsDescription> versions(V... versionDescriptions) {
|
||||
TreeMap<Integer, SettingsDescription> map = new TreeMap<>();
|
||||
for (V v : versionDescriptions) {
|
||||
map.put(v.version, v.description);
|
||||
|
|
Loading…
Reference in a new issue