From 8db6c7ad7f421a39f586f340c2a49dc10dc6e951 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Wed, 20 Oct 2010 18:09:24 -0700 Subject: [PATCH] add setPrefsBoolean --- .../eehouse/android/xw4/jni/CommonPrefs.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java index f22686f19..b77adbb52 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java @@ -170,7 +170,7 @@ public class CommonPrefs { public static boolean getVolKeysZoom( Context context ) { - return getBoolean( context, R.string.key_ringer_zoom, false ); + return getPrefsBoolean( context, R.string.key_ringer_zoom, false ); } public static int getDefaultBoardSize( Context context ) @@ -233,26 +233,27 @@ public class CommonPrefs { public static boolean getDefaultTimerEnabled( Context context ) { - return getBoolean( context, R.string.key_default_timerenabled, false ); + return getPrefsBoolean( context, R.string.key_default_timerenabled, + false ); } public static boolean getHideTitleBar( Context context ) { - return getBoolean( context, R.string.key_hide_title, true ); + return getPrefsBoolean( context, R.string.key_hide_title, true ); } public static boolean getClickLaunches( Context context ) { - return getBoolean( context, R.string.key_click_launches, false ); + return getPrefsBoolean( context, R.string.key_click_launches, false ); } public static boolean getShowBonusSumms( Context context ) { - return getBoolean( context, R.string.key_show_bonussum, false ); + return getPrefsBoolean( context, R.string.key_show_bonussum, false ); } - private static boolean getBoolean( Context context, int keyID, - boolean defaultValue ) + public static boolean getPrefsBoolean( Context context, int keyID, + boolean defaultValue ) { String key = context.getString( keyID ); SharedPreferences sp = PreferenceManager @@ -260,6 +261,17 @@ public class CommonPrefs { return sp.getBoolean( key, defaultValue ); } + public static void setPrefsBoolean( Context context, int keyID, + boolean newValue ) + { + SharedPreferences sp = PreferenceManager + .getDefaultSharedPreferences( context ); + SharedPreferences.Editor editor = sp.edit(); + String key = context.getString( keyID ); + editor.putBoolean( key, newValue ); + editor.commit(); + } + private static String getString( Context context, int keyID ) { String key = context.getString( keyID );