1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Added new settings to GlobalSettings

This commit is contained in:
cketti 2011-10-17 04:52:33 +02:00
parent f08b1ef739
commit 75dc38a1c4

View File

@ -1,11 +1,14 @@
package com.fsck.k9.preferences;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import android.content.SharedPreferences;
import android.os.Environment;
import com.fsck.k9.FontSizes;
import com.fsck.k9.K9;
import com.fsck.k9.R;
@ -19,11 +22,15 @@ public class GlobalSettings {
Map<String, SettingsDescription> s = new LinkedHashMap<String, SettingsDescription>();
s.put("animations", new BooleanSetting(false));
s.put("attachmentdefaultpath",
new DirectorySetting(Environment.getExternalStorageDirectory().toString()));
s.put("backgroundOperations",
new EnumSetting(K9.BACKGROUND_OPS.class, K9.BACKGROUND_OPS.WHEN_CHECKED));
s.put("changeRegisteredNameColor", new BooleanSetting(false));
s.put("compactLayouts", new BooleanSetting(false));
s.put("confirmDelete", new BooleanSetting(false));
s.put("confirmMarkAllAsRead", new BooleanSetting(false));
s.put("confirmSpam", new BooleanSetting(false));
s.put("countSearchMessages", new BooleanSetting(false));
s.put("dateFormat", new DateFormatSetting(DateFormatter.DEFAULT_FORMAT));
s.put("enableDebugLogging", new BooleanSetting(false));
@ -56,6 +63,7 @@ public class GlobalSettings {
s.put("messageListTouchable", new BooleanSetting(false));
s.put("messageViewFixedWidthFont", new BooleanSetting(false));
s.put("messageViewReturnToList", new BooleanSetting(false));
s.put("messageViewShowNext", new BooleanSetting(false));
s.put("mobileOptimizedLayout", new BooleanSetting(false));
s.put("quietTimeEnabled", new BooleanSetting(false));
s.put("quietTimeEnds", new TimeSetting("7:00"));
@ -225,4 +233,24 @@ public class GlobalSettings {
return value;
}
}
/**
* A directory on the file system.
*/
public static class DirectorySetting extends SettingsDescription {
public DirectorySetting(String defaultValue) {
super(defaultValue);
}
@Override
public Object fromString(String value) throws InvalidSettingValueException {
try {
if (new File(value).isDirectory()) {
return value;
}
} catch (Exception e) { /* do nothing */ }
throw new InvalidSettingValueException();
}
}
}