mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
add superclass for CommonPrefs that can hold stuff not related to
jni/common code.
This commit is contained in:
parent
381f30b6d2
commit
b7247d259c
2 changed files with 51 additions and 21 deletions
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -29,11 +29,12 @@ import android.text.TextUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.XWPrefs;
|
||||||
import org.eehouse.android.xw4.R;
|
import org.eehouse.android.xw4.R;
|
||||||
import org.eehouse.android.xw4.DictUtils;
|
import org.eehouse.android.xw4.DictUtils;
|
||||||
import org.eehouse.android.xw4.DbgUtils;
|
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_TILE_BACK = 0;
|
||||||
public static final int COLOR_NOTILE = 1;
|
public static final int COLOR_NOTILE = 1;
|
||||||
public static final int COLOR_FOCUS = 2;
|
public static final int COLOR_FOCUS = 2;
|
||||||
|
@ -377,26 +378,6 @@ public class CommonPrefs {
|
||||||
return getPrefsStringArray( context, R.string.key_bt_addrs );
|
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 )
|
public static String getPrefsString( Context context, int keyID )
|
||||||
{
|
{
|
||||||
String key = context.getString( keyID );
|
String key = context.getString( keyID );
|
||||||
|
|
Loading…
Reference in a new issue