2011-04-20 15:37:48 -04:00
|
|
|
package com.fsck.k9.preferences;
|
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
import java.util.Collections;
|
2011-06-06 13:44:01 -04:00
|
|
|
import java.util.HashMap;
|
2011-04-20 15:37:48 -04:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
2011-12-10 22:57:47 -05:00
|
|
|
import java.util.Set;
|
2011-12-10 23:16:22 -05:00
|
|
|
import java.util.TreeMap;
|
|
|
|
|
2011-06-06 13:44:01 -04:00
|
|
|
import android.content.SharedPreferences;
|
2011-04-20 15:37:48 -04:00
|
|
|
import com.fsck.k9.Account;
|
2015-02-15 02:37:52 -05:00
|
|
|
import com.fsck.k9.Account.DeletePolicy;
|
|
|
|
import com.fsck.k9.Account.Expunge;
|
|
|
|
import com.fsck.k9.Account.FolderMode;
|
|
|
|
import com.fsck.k9.Account.MessageFormat;
|
|
|
|
import com.fsck.k9.Account.QuoteStyle;
|
|
|
|
import com.fsck.k9.Account.Searchable;
|
|
|
|
import com.fsck.k9.Account.ShowPictures;
|
2012-04-08 22:29:08 -04:00
|
|
|
import com.fsck.k9.Account.SortType;
|
2011-04-20 15:37:48 -04:00
|
|
|
import com.fsck.k9.K9;
|
|
|
|
import com.fsck.k9.R;
|
2014-12-14 10:28:42 -05:00
|
|
|
import com.fsck.k9.mailstore.StorageManager;
|
2011-04-20 15:37:48 -04:00
|
|
|
import com.fsck.k9.preferences.Settings.*;
|
|
|
|
|
|
|
|
public class AccountSettings {
|
2011-12-10 23:16:22 -05:00
|
|
|
public static final Map<String, TreeMap<Integer, SettingsDescription>> SETTINGS;
|
2011-12-10 22:57:47 -05:00
|
|
|
public static final Map<Integer, SettingsUpgrader> UPGRADERS;
|
2011-04-20 15:37:48 -04:00
|
|
|
|
|
|
|
static {
|
2011-12-10 23:16:22 -05:00
|
|
|
Map<String, TreeMap<Integer, SettingsDescription>> s =
|
|
|
|
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2012-04-08 18:27:39 -04:00
|
|
|
/**
|
|
|
|
* When adding new settings here, be sure to increment {@link Settings.VERSION}
|
|
|
|
* and use that for whatever you add here.
|
|
|
|
*/
|
|
|
|
|
2012-05-16 17:03:40 -04:00
|
|
|
s.put("alwaysBcc", Settings.versions(
|
|
|
|
new V(11, new StringSetting(""))
|
|
|
|
));
|
2012-08-09 21:38:10 -04:00
|
|
|
s.put("alwaysShowCcBcc", Settings.versions(
|
|
|
|
new V(13, new BooleanSetting(false))
|
|
|
|
));
|
2011-12-10 23:16:22 -05:00
|
|
|
s.put("archiveFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("Archive"))
|
|
|
|
));
|
|
|
|
s.put("autoExpandFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("INBOX"))
|
|
|
|
));
|
|
|
|
s.put("automaticCheckIntervalMinutes", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(-1,
|
|
|
|
R.array.account_settings_check_frequency_values))
|
|
|
|
));
|
|
|
|
s.put("chipColor", Settings.versions(
|
|
|
|
new V(1, new ColorSetting(0xFF0000FF))
|
|
|
|
));
|
|
|
|
s.put("cryptoApp", Settings.versions(
|
2014-09-18 13:45:25 -04:00
|
|
|
new V(1, new StringSetting("apg")),
|
|
|
|
new V(36, new StringSetting(Account.NO_OPENPGP_PROVIDER))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("defaultQuotedTextShown", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(Account.DEFAULT_QUOTED_TEXT_SHOWN))
|
|
|
|
));
|
|
|
|
s.put("deletePolicy", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new DeletePolicySetting(DeletePolicy.NEVER))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("displayCount", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(K9.DEFAULT_VISIBLE_LIMIT,
|
|
|
|
R.array.account_settings_display_count_values))
|
|
|
|
));
|
|
|
|
s.put("draftsFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("Drafts"))
|
|
|
|
));
|
|
|
|
s.put("expungePolicy", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new StringResourceSetting(Expunge.EXPUNGE_IMMEDIATELY.name(),
|
2011-12-10 23:16:22 -05:00
|
|
|
R.array.account_setup_expunge_policy_values))
|
|
|
|
));
|
|
|
|
s.put("folderDisplayMode", Settings.versions(
|
2013-02-04 05:18:49 -05:00
|
|
|
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("folderPushMode", Settings.versions(
|
2013-02-04 05:18:49 -05:00
|
|
|
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("folderSyncMode", Settings.versions(
|
2013-02-04 05:18:49 -05:00
|
|
|
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.FIRST_CLASS))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("folderTargetMode", Settings.versions(
|
2013-02-04 05:18:49 -05:00
|
|
|
new V(1, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.NOT_SECOND_CLASS))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("goToUnreadMessageSearch", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
|
|
|
s.put("idleRefreshMinutes", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(24, R.array.idle_refresh_period_values))
|
|
|
|
));
|
|
|
|
s.put("inboxFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("INBOX"))
|
|
|
|
));
|
|
|
|
s.put("led", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("ledColor", Settings.versions(
|
|
|
|
new V(1, new ColorSetting(0xFF0000FF))
|
|
|
|
));
|
|
|
|
s.put("localStorageProvider", Settings.versions(
|
|
|
|
new V(1, new StorageProviderSetting())
|
|
|
|
));
|
2012-03-18 23:44:41 -04:00
|
|
|
s.put("markMessageAsReadOnView", Settings.versions(
|
|
|
|
new V(7, new BooleanSetting(true))
|
|
|
|
));
|
2011-12-10 23:16:22 -05:00
|
|
|
s.put("maxPushFolders", Settings.versions(
|
|
|
|
new V(1, new IntegerRangeSetting(0, 100, 10))
|
|
|
|
));
|
|
|
|
s.put("maximumAutoDownloadMessageSize", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(32768,
|
|
|
|
R.array.account_settings_autodownload_message_size_values))
|
|
|
|
));
|
|
|
|
s.put("maximumPolledMessageAge", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(-1,
|
|
|
|
R.array.account_settings_message_age_values))
|
|
|
|
));
|
|
|
|
s.put("messageFormat", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new EnumSetting<MessageFormat>(
|
|
|
|
MessageFormat.class, Account.DEFAULT_MESSAGE_FORMAT))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("messageFormatAuto", Settings.versions(
|
2011-12-10 23:03:53 -05:00
|
|
|
new V(2, new BooleanSetting(Account.DEFAULT_MESSAGE_FORMAT_AUTO))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("messageReadReceipt", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(Account.DEFAULT_MESSAGE_READ_RECEIPT))
|
|
|
|
));
|
|
|
|
s.put("notifyMailCheck", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
|
|
|
s.put("notifyNewMail", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
2014-08-06 05:04:07 -04:00
|
|
|
s.put("folderNotifyNewMailMode", Settings.versions(
|
2014-09-04 17:00:29 -04:00
|
|
|
new V(34, new EnumSetting<FolderMode>(FolderMode.class, FolderMode.ALL))
|
2014-08-06 05:04:07 -04:00
|
|
|
));
|
2011-12-10 23:16:22 -05:00
|
|
|
s.put("notifySelfNewMail", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("pushPollOnConnect", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("quotePrefix", Settings.versions(
|
|
|
|
new V(1, new StringSetting(Account.DEFAULT_QUOTE_PREFIX))
|
|
|
|
));
|
|
|
|
s.put("quoteStyle", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new EnumSetting<QuoteStyle>(
|
|
|
|
QuoteStyle.class, Account.DEFAULT_QUOTE_STYLE))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("replyAfterQuote", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(Account.DEFAULT_REPLY_AFTER_QUOTE))
|
|
|
|
));
|
|
|
|
s.put("ring", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("ringtone", Settings.versions(
|
|
|
|
new V(1, new RingtoneSetting("content://settings/system/notification_sound"))
|
|
|
|
));
|
|
|
|
s.put("searchableFolders", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new EnumSetting<Searchable>(
|
|
|
|
Searchable.class, Searchable.ALL))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("sentFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("Sent"))
|
|
|
|
));
|
2012-02-26 04:26:46 -05:00
|
|
|
s.put("sortTypeEnum", Settings.versions(
|
2013-02-04 05:18:49 -05:00
|
|
|
new V(9, new EnumSetting<SortType>(SortType.class, Account.DEFAULT_SORT_TYPE))
|
2012-02-26 04:26:46 -05:00
|
|
|
));
|
|
|
|
s.put("sortAscending", Settings.versions(
|
2012-04-08 17:13:55 -04:00
|
|
|
new V(9, new BooleanSetting(Account.DEFAULT_SORT_ASCENDING))
|
2012-02-26 04:26:46 -05:00
|
|
|
));
|
2011-12-10 23:16:22 -05:00
|
|
|
s.put("showPicturesEnum", Settings.versions(
|
2015-02-15 02:37:52 -05:00
|
|
|
new V(1, new EnumSetting<ShowPictures>(
|
|
|
|
ShowPictures.class, ShowPictures.NEVER))
|
2011-12-10 23:16:22 -05:00
|
|
|
));
|
|
|
|
s.put("signatureBeforeQuotedText", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
|
|
|
s.put("spamFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("Spam"))
|
|
|
|
));
|
2011-12-10 23:03:53 -05:00
|
|
|
s.put("stripSignature", Settings.versions(
|
|
|
|
new V(2, new BooleanSetting(Account.DEFAULT_STRIP_SIGNATURE))
|
|
|
|
));
|
2011-12-10 23:16:22 -05:00
|
|
|
s.put("subscribedFoldersOnly", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
|
|
|
s.put("syncRemoteDeletions", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("trashFolderName", Settings.versions(
|
|
|
|
new V(1, new StringSetting("Trash"))
|
|
|
|
));
|
|
|
|
s.put("useCompression.MOBILE", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("useCompression.OTHER", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("useCompression.WIFI", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(true))
|
|
|
|
));
|
|
|
|
s.put("vibrate", Settings.versions(
|
|
|
|
new V(1, new BooleanSetting(false))
|
|
|
|
));
|
|
|
|
s.put("vibratePattern", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(0,
|
|
|
|
R.array.account_settings_vibrate_pattern_values))
|
|
|
|
));
|
|
|
|
s.put("vibrateTimes", Settings.versions(
|
|
|
|
new V(1, new IntegerResourceSetting(5,
|
|
|
|
R.array.account_settings_vibrate_times_label))
|
|
|
|
));
|
2012-09-18 23:04:48 -04:00
|
|
|
s.put("allowRemoteSearch", Settings.versions(
|
2012-09-29 10:48:49 -04:00
|
|
|
new V(18, new BooleanSetting(true))
|
2012-09-18 23:04:48 -04:00
|
|
|
));
|
|
|
|
s.put("remoteSearchNumResults", Settings.versions(
|
2012-09-25 18:50:47 -04:00
|
|
|
new V(18, new IntegerResourceSetting(Account.DEFAULT_REMOTE_SEARCH_NUM_RESULTS,
|
2012-09-18 23:04:48 -04:00
|
|
|
R.array.account_settings_remote_search_num_results_values))
|
|
|
|
));
|
|
|
|
s.put("remoteSearchFullText", Settings.versions(
|
2012-09-25 18:50:47 -04:00
|
|
|
new V(18, new BooleanSetting(false))
|
2012-09-18 23:04:48 -04:00
|
|
|
));
|
2011-10-07 15:20:12 -04:00
|
|
|
|
|
|
|
SETTINGS = Collections.unmodifiableMap(s);
|
2011-12-10 22:57:47 -05:00
|
|
|
|
|
|
|
Map<Integer, SettingsUpgrader> u = new HashMap<Integer, SettingsUpgrader>();
|
|
|
|
UPGRADERS = Collections.unmodifiableMap(u);
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
|
2011-12-11 00:02:31 -05:00
|
|
|
public static Map<String, Object> validate(int version, Map<String, String> importedSettings,
|
2011-05-01 22:06:22 -04:00
|
|
|
boolean useDefaultValues) {
|
2011-12-10 23:16:22 -05:00
|
|
|
return Settings.validate(version, SETTINGS, importedSettings, useDefaultValues);
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
|
2011-12-11 00:02:31 -05:00
|
|
|
public static Set<String> upgrade(int version, Map<String, Object> validatedSettings) {
|
2011-12-10 22:57:47 -05:00
|
|
|
return Settings.upgrade(version, UPGRADERS, SETTINGS, validatedSettings);
|
|
|
|
}
|
|
|
|
|
2011-12-11 00:02:31 -05:00
|
|
|
public static Map<String, String> convert(Map<String, Object> settings) {
|
|
|
|
return Settings.convert(settings, SETTINGS);
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:44:01 -04:00
|
|
|
public static Map<String, String> getAccountSettings(SharedPreferences storage, String uuid) {
|
|
|
|
Map<String, String> result = new HashMap<String, String>();
|
|
|
|
String prefix = uuid + ".";
|
|
|
|
for (String key : SETTINGS.keySet()) {
|
|
|
|
String value = storage.getString(prefix + key, null);
|
|
|
|
if (value != null) {
|
|
|
|
result.put(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
/**
|
|
|
|
* An integer resource setting.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* Basically a {@link PseudoEnumSetting} that is initialized from a resource array containing
|
|
|
|
* integer strings.
|
|
|
|
* </p>
|
|
|
|
*/
|
|
|
|
public static class IntegerResourceSetting extends PseudoEnumSetting<Integer> {
|
|
|
|
private final Map<Integer, String> mMapping;
|
|
|
|
|
|
|
|
public IntegerResourceSetting(int defaultValue, int resId) {
|
|
|
|
super(defaultValue);
|
|
|
|
|
|
|
|
Map<Integer, String> mapping = new HashMap<Integer, String>();
|
|
|
|
String[] values = K9.app.getResources().getStringArray(resId);
|
|
|
|
for (String value : values) {
|
|
|
|
int intValue = Integer.parseInt(value);
|
|
|
|
mapping.put(intValue, value);
|
|
|
|
}
|
|
|
|
mMapping = Collections.unmodifiableMap(mapping);
|
|
|
|
}
|
2011-06-06 13:44:01 -04:00
|
|
|
|
2011-04-20 15:37:48 -04:00
|
|
|
@Override
|
2011-10-07 14:29:03 -04:00
|
|
|
protected Map<Integer, String> getMapping() {
|
|
|
|
return mMapping;
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-07 14:29:03 -04:00
|
|
|
public Object fromString(String value) throws InvalidSettingValueException {
|
|
|
|
try {
|
|
|
|
return Integer.parseInt(value);
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
throw new InvalidSettingValueException();
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
/**
|
|
|
|
* A string resource setting.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* Basically a {@link PseudoEnumSetting} that is initialized from a resource array.
|
|
|
|
* </p>
|
|
|
|
*/
|
|
|
|
public static class StringResourceSetting extends PseudoEnumSetting<String> {
|
|
|
|
private final Map<String, String> mMapping;
|
|
|
|
|
|
|
|
public StringResourceSetting(String defaultValue, int resId) {
|
|
|
|
super(defaultValue);
|
|
|
|
|
|
|
|
Map<String, String> mapping = new HashMap<String, String>();
|
|
|
|
String[] values = K9.app.getResources().getStringArray(resId);
|
|
|
|
for (String value : values) {
|
|
|
|
mapping.put(value, value);
|
|
|
|
}
|
|
|
|
mMapping = Collections.unmodifiableMap(mapping);
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-07 14:29:03 -04:00
|
|
|
protected Map<String, String> getMapping() {
|
|
|
|
return mMapping;
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
@Override
|
|
|
|
public Object fromString(String value) throws InvalidSettingValueException {
|
|
|
|
if (!mMapping.containsKey(value)) {
|
|
|
|
throw new InvalidSettingValueException();
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
/**
|
|
|
|
* The notification ringtone setting.
|
|
|
|
*/
|
|
|
|
public static class RingtoneSetting extends SettingsDescription {
|
|
|
|
public RingtoneSetting(String defaultValue) {
|
|
|
|
super(defaultValue);
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
@Override
|
|
|
|
public Object fromString(String value) {
|
|
|
|
//TODO: add validation
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
/**
|
|
|
|
* The storage provider setting.
|
|
|
|
*/
|
|
|
|
public static class StorageProviderSetting extends SettingsDescription {
|
|
|
|
public StorageProviderSetting() {
|
|
|
|
super(null);
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
@Override
|
|
|
|
public Object getDefaultValue() {
|
|
|
|
return StorageManager.getInstance(K9.app).getDefaultProviderId();
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-07 14:29:03 -04:00
|
|
|
public Object fromString(String value) {
|
|
|
|
StorageManager storageManager = StorageManager.getInstance(K9.app);
|
|
|
|
Map<String, String> providers = storageManager.getAvailableProviders();
|
|
|
|
if (providers.containsKey(value)) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
throw new RuntimeException("Validation failed");
|
|
|
|
}
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
public static class DeletePolicySetting extends PseudoEnumSetting<Integer> {
|
|
|
|
private Map<Integer, String> mMapping;
|
|
|
|
|
2015-02-15 02:37:52 -05:00
|
|
|
public DeletePolicySetting(DeletePolicy defaultValue) {
|
2011-10-07 14:29:03 -04:00
|
|
|
super(defaultValue);
|
|
|
|
Map<Integer, String> mapping = new HashMap<Integer, String>();
|
2015-02-15 02:37:52 -05:00
|
|
|
mapping.put(DeletePolicy.NEVER.setting, "NEVER");
|
|
|
|
mapping.put(DeletePolicy.ON_DELETE.setting, "DELETE");
|
|
|
|
mapping.put(DeletePolicy.MARK_AS_READ.setting, "MARK_AS_READ");
|
2011-10-07 14:29:03 -04:00
|
|
|
mMapping = Collections.unmodifiableMap(mapping);
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
@Override
|
|
|
|
protected Map<Integer, String> getMapping() {
|
|
|
|
return mMapping;
|
|
|
|
}
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
@Override
|
|
|
|
public Object fromString(String value) throws InvalidSettingValueException {
|
|
|
|
try {
|
|
|
|
Integer deletePolicy = Integer.parseInt(value);
|
|
|
|
if (mMapping.containsKey(deletePolicy)) {
|
|
|
|
return deletePolicy;
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
2011-10-07 14:29:03 -04:00
|
|
|
} catch (NumberFormatException e) { /* do nothing */ }
|
2011-04-20 15:37:48 -04:00
|
|
|
|
2011-10-07 14:29:03 -04:00
|
|
|
throw new InvalidSettingValueException();
|
2011-04-20 15:37:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|