add setPrefsBoolean

This commit is contained in:
Andy2 2010-10-20 18:09:24 -07:00
parent 95f5c2e023
commit 8db6c7ad7f

View file

@ -170,7 +170,7 @@ public class CommonPrefs {
public static boolean getVolKeysZoom( Context context ) 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 ) public static int getDefaultBoardSize( Context context )
@ -233,26 +233,27 @@ public class CommonPrefs {
public static boolean getDefaultTimerEnabled( Context context ) 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 ) 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 ) 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 ) 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, public static boolean getPrefsBoolean( Context context, int keyID,
boolean defaultValue ) boolean defaultValue )
{ {
String key = context.getString( keyID ); String key = context.getString( keyID );
SharedPreferences sp = PreferenceManager SharedPreferences sp = PreferenceManager
@ -260,6 +261,17 @@ public class CommonPrefs {
return sp.getBoolean( key, defaultValue ); 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 ) private static String getString( Context context, int keyID )
{ {
String key = context.getString( keyID ); String key = context.getString( keyID );