2323import android .support .annotation .IntDef ;
2424import android .support .annotation .IntRange ;
2525import android .support .annotation .NonNull ;
26- import android .support .annotation .StyleableRes ;
26+ import android .support .annotation .StyleRes ;
2727import android .text .TextUtils ;
2828
2929import com .duy .ide .editor .editor .R ;
4545public class Preferences implements SharedPreferences .OnSharedPreferenceChangeListener {
4646 public static final String KEY_FONT_SIZE = "pref_font_size" ;
4747 public static final String KEY_CURSOR_WIDTH = "pref_cursor_width" ;
48- public static final String KEY_TOUCH_TO_ADJUST_TEXT_SIZE = "pref_touch_to_adjust_text_size" ;
4948 public static final String KEY_WORD_WRAP = "pref_word_wrap" ;
5049 public static final String KEY_SHOW_LINE_NUMBER = "pref_show_linenumber" ;
5150 public static final String KEY_SHOW_WHITESPACE = "pref_show_whitespace" ;
5251 public static final String KEY_AUTO_INDENT = "pref_auto_indent" ;
53- public static final String KEY_INSERT_SPACE_FOR_TAB = "pref_insert_space_for_tab" ;
5452 public static final String KEY_TAB_SIZE = "pref_tab_size" ;
5553 public static final String KEY_SYMBOL = "pref_symbol" ;
5654 public static final String KEY_AUTO_CAPITALIZE = "pref_auto_capitalize" ;
57- public static final String KEY_HIGHLIGHT_FILE_SIZE_LIMIT = "pref_highlight_file_size_limit" ;
58- public static final String KEY_REMEMBER_LAST_OPENED_FILES = "pref_remember_last_opened_files" ;
5955 public static final String KEY_SCREEN_ORIENTATION = "pref_screen_orientation" ;
6056 public static final String KEY_KEEP_SCREEN_ON = "pref_keep_screen_on" ;
61- public static final String KEY_TOOLBAR_ICONS = "pref_toolbar_icons" ;
62- public static final String KEY_PREF_AUTO_CHECK_UPDATES = "pref_auto_check_updates" ;
63- public static final String KEY_LAST_OPEN_PATH = "last_open_path" ;
6457 public static final String KEY_READ_ONLY = "readonly_mode" ;
65- public static final String KEY_SHOW_HIDDEN_FILES = "show_hidden_files" ;
66- public static final String KEY_FILE_SORT_TYPE = "show_file_sort" ;
67- public static final String KEY_FULL_SCREEN = "fullscreen_mode" ;
68- public static final String KEY_LAST_TAB = "last_tab" ;
69-
7058 public static final int DEF_MIN_FONT_SIZE = 9 ;
7159 public static final int DEF_MAX_FONT_SIZE = 32 ;
72-
7360 public static final int SCREEN_ORIENTATION_AUTO = 0 ;
7461 public static final int SCREEN_ORIENTATION_LANDSCAPE = 1 ;
7562 public static final int SCREEN_ORIENTATION_PORTRAIT = 2 ;
7663 public static final String VALUE_SYMBOL = TextUtils .join ("\n " , new String []{"{" , "}" , "<" , ">"
7764 , "," , ";" , "'" , "\" " , "(" , ")" , "/" , "\\ " , "%" , "[" , "]" , "|" , "#" , "=" , "$" , ":"
7865 , "&" , "?" , "!" , "@" , "^" , "+" , "*" , "-" , "_" , "`" , "\\ t" , "\\ n" });
7966
80- public static final int [] THEMES = new int []{R .style .LightTheme , R .style .DarkTheme };
81-
67+ private static final int [] THEMES = new int []{R .style .LightTheme , R .style .DarkTheme };
68+ private static final String KEY_TOUCH_TO_ADJUST_TEXT_SIZE = "pref_touch_to_adjust_text_size" ;
69+ private static final String KEY_INSERT_SPACE_FOR_TAB = "pref_insert_space_for_tab" ;
70+ private static final String KEY_HIGHLIGHT_FILE_SIZE_LIMIT = "pref_highlight_file_size_limit" ;
71+ private static final String KEY_REMEMBER_LAST_OPENED_FILES = "pref_remember_last_opened_files" ;
72+ private static final String KEY_TOOLBAR_ICONS = "pref_toolbar_icons" ;
73+ private static final String KEY_PREF_AUTO_CHECK_UPDATES = "pref_auto_check_updates" ;
74+ private static final String KEY_LAST_OPEN_PATH = "last_open_path" ;
75+ private static final String KEY_SHOW_HIDDEN_FILES = "show_hidden_files" ;
76+ private static final String KEY_FILE_SORT_TYPE = "show_file_sort" ;
77+ private static final String KEY_FULL_SCREEN = "fullscreen_mode" ;
78+ private static final String KEY_LAST_TAB = "last_tab" ;
8279 private static final Object mContent = new Object ();
8380 private static Preferences instance ;
8481
@@ -212,16 +209,6 @@ public boolean isShowWhiteSpace() {
212209 return (boolean ) map .get (KEY_SHOW_WHITESPACE );
213210 }
214211
215- public int getTheme () {
216- return getInt (context .getString (R .string .pref_app_theme ), 0 );
217- }
218-
219- /**
220- * theme index of {@link #THEMES}
221- */
222- public void setTheme (int theme ) {
223- preferences .edit ().putInt (context .getString (R .string .pref_app_theme ), theme ).apply ();
224- }
225212
226213 public int getHighlightSizeLimit () {
227214 return 1024 * (int ) map .get (KEY_HIGHLIGHT_FILE_SIZE_LIMIT );
@@ -332,7 +319,7 @@ public boolean isAutoCapitalize() {
332319
333320
334321 public boolean isOpenLastFiles () {
335- return ( boolean ) map . get ( KEY_REMEMBER_LAST_OPENED_FILES );
322+ return getBoolean ( context . getString ( R . string . pref_remember_last_opened_files ), true );
336323 }
337324
338325 public int getTabSize () {
@@ -408,7 +395,7 @@ public void setEditorTheme(String fileName) {
408395 preferences .edit ().putString (context .getString (R .string .pref_theme_editor_theme ), fileName ).apply ();
409396 }
410397
411- @ StyleableRes
398+ @ StyleRes
412399 public int getAppTheme () {
413400 int index = getInt (context .getString (R .string .pref_app_theme ), 0 );
414401 return THEMES [index ];
@@ -423,7 +410,7 @@ public void setTerminalTheme(int index) {
423410 }
424411
425412 public boolean isUseLightTheme () {
426- return getTheme () == 0 ;
413+ return getAppTheme () == THEMES [ 0 ] ;
427414 }
428415
429416 @ IntDef ({SCREEN_ORIENTATION_AUTO , SCREEN_ORIENTATION_LANDSCAPE , SCREEN_ORIENTATION_PORTRAIT })
0 commit comments