From b7247d259cc1a7007336f026b2115bad5f9a71fe Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 23 Jul 2012 22:42:38 -0700 Subject: [PATCH] add superclass for CommonPrefs that can hold stuff not related to jni/common code. --- .../src/org/eehouse/android/xw4/XWPrefs.java | 49 +++++++++++++++++++ .../eehouse/android/xw4/jni/CommonPrefs.java | 23 +-------- 2 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java new file mode 100644 index 000000000..b3e8c84df --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWPrefs.java @@ -0,0 +1,49 @@ +/* -*- compile-command: "cd ../../../../../../; ant debug install"; -*- */ +/* + * Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All + * rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package org.eehouse.android.xw4; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; + +public class XWPrefs { + + public static boolean getPrefsBoolean( Context context, int keyID, + boolean defaultValue ) + { + String key = context.getString( keyID ); + SharedPreferences sp = PreferenceManager + .getDefaultSharedPreferences( context ); + 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(); + } + +} \ No newline at end of file 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 c1c66bcb0..f0af5119e 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 @@ -29,11 +29,12 @@ import android.text.TextUtils; import java.util.ArrayList; import junit.framework.Assert; +import org.eehouse.android.xw4.XWPrefs; import org.eehouse.android.xw4.R; import org.eehouse.android.xw4.DictUtils; import org.eehouse.android.xw4.DbgUtils; -public class CommonPrefs { +public class CommonPrefs extends XWPrefs { public static final int COLOR_TILE_BACK = 0; public static final int COLOR_NOTILE = 1; public static final int COLOR_FOCUS = 2; @@ -377,26 +378,6 @@ public class CommonPrefs { return getPrefsStringArray( context, R.string.key_bt_addrs ); } - public static boolean getPrefsBoolean( Context context, int keyID, - boolean defaultValue ) - { - String key = context.getString( keyID ); - SharedPreferences sp = PreferenceManager - .getDefaultSharedPreferences( context ); - 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(); - } - public static String getPrefsString( Context context, int keyID ) { String key = context.getString( keyID );