mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
add new-game/default prefs for phonies and timer_enabled
This commit is contained in:
parent
ec57cbcf1b
commit
28d9d4559d
6 changed files with 67 additions and 15 deletions
|
@ -28,6 +28,9 @@
|
|||
<string name="key_board_size">key_board_size</string>
|
||||
<string name="key_initial_game_minutes">key_initial_game_minutes</string>
|
||||
<string name="key_default_dict">key_default_dict</string>
|
||||
<string name="key_default_phonies">key_default_phonies</string>
|
||||
<string name="key_default_timerenabled">key_default_timerenabled</string>
|
||||
|
||||
<!-- other -->
|
||||
<string name="default_host">eehouse.org</string>
|
||||
<string name="dict_url">http://eehouse.org/and_dicts</string>
|
||||
|
|
|
@ -232,7 +232,9 @@
|
|||
<string name="prefs_defaults_summary">Default settings for new
|
||||
games</string>
|
||||
<string name="default_dict">Game dictionary</string>
|
||||
<string name="default_phonies">Handle phonies</string>
|
||||
<string name="board_size">Initial board size</string>
|
||||
<string name="default_timerenabled">Use game timer</string>
|
||||
|
||||
<string name="manage_dicts">Choose</string>
|
||||
|
||||
|
|
|
@ -6,17 +6,30 @@
|
|||
<PreferenceScreen android:title="@string/prefs_defaults"
|
||||
android:summary="@string/prefs_defaults_summary"
|
||||
>
|
||||
<EditTextPreference android:key="@string/key_initial_game_minutes"
|
||||
android:title="@string/initial_game_minutes"
|
||||
android:defaultValue="25"
|
||||
android:numeric="decimal"
|
||||
/>
|
||||
|
||||
<org.eehouse.android.xw4.DictListPreference
|
||||
android:key="@string/key_default_dict"
|
||||
android:title="@string/default_dict"
|
||||
/>
|
||||
|
||||
<ListPreference android:key="@string/key_default_phonies"
|
||||
android:title="@string/default_phonies"
|
||||
android:entries="@array/phony_names"
|
||||
android:entryValues="@array/phony_names"
|
||||
android:defaultValue="0"
|
||||
/>
|
||||
|
||||
<CheckBoxPreference android:key="@string/key_default_timerenabled"
|
||||
android:title="@string/use_timer"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
|
||||
<EditTextPreference android:key="@string/key_initial_game_minutes"
|
||||
android:title="@string/initial_game_minutes"
|
||||
android:defaultValue="25"
|
||||
android:numeric="decimal"
|
||||
/>
|
||||
|
||||
<ListPreference android:key="@string/key_board_size"
|
||||
android:title="@string/board_size"
|
||||
android:entries="@array/board_sizes"
|
||||
|
|
|
@ -46,6 +46,7 @@ public class PrefsActivity extends PreferenceActivity
|
|||
R.string.key_board_size,
|
||||
R.string.key_initial_game_minutes,
|
||||
R.string.key_default_dict,
|
||||
R.string.key_default_phonies,
|
||||
};
|
||||
|
||||
SharedPreferences sp
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.graphics.Paint;
|
||||
import android.content.res.Resources;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.Utils;
|
||||
|
@ -157,10 +158,7 @@ public class CommonPrefs {
|
|||
|
||||
public static boolean getVolKeysZoom( Context context )
|
||||
{
|
||||
String key = context.getString( R.string.key_ringer_zoom );
|
||||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences( context );
|
||||
return sp.getBoolean( key, false );
|
||||
return getBoolean( context, R.string.key_ringer_zoom, false );
|
||||
}
|
||||
|
||||
public static int getDefaultBoardSize( Context context )
|
||||
|
@ -178,7 +176,6 @@ public class CommonPrefs {
|
|||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences( context );
|
||||
String value = sp.getString( key, "25" );
|
||||
Utils.logf( "value for key_initial_game_minutes: %s", value );
|
||||
return Integer.parseInt( value );
|
||||
}
|
||||
|
||||
|
@ -194,4 +191,40 @@ public class CommonPrefs {
|
|||
return value;
|
||||
}
|
||||
|
||||
public static CurGameInfo.XWPhoniesChoice
|
||||
getDefaultPhonies( Context context )
|
||||
{
|
||||
String key = context.getString( R.string.key_default_phonies );
|
||||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences( context );
|
||||
String value = sp.getString( key, "" );
|
||||
|
||||
CurGameInfo.XWPhoniesChoice result =
|
||||
CurGameInfo.XWPhoniesChoice.PHONIES_IGNORE;
|
||||
Resources res = context.getResources();
|
||||
String[] names = res.getStringArray( R.array.phony_names );
|
||||
for ( int ii = 0; ii < names.length; ++ii ) {
|
||||
String name = names[ii];
|
||||
if ( name.equals( value ) ) {
|
||||
result = CurGameInfo.XWPhoniesChoice.values()[ii];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean getDefaultTimerEnabled( Context context )
|
||||
{
|
||||
return getBoolean( context, R.string.key_default_timerenabled, false );
|
||||
}
|
||||
|
||||
private static boolean getBoolean( Context context, int keyID,
|
||||
boolean defaultValue )
|
||||
{
|
||||
String key = context.getString( keyID );
|
||||
SharedPreferences sp = PreferenceManager
|
||||
.getDefaultSharedPreferences( context );
|
||||
return sp.getBoolean( key, defaultValue );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ public class CurGameInfo {
|
|||
public DeviceRole serverRole;
|
||||
|
||||
public boolean hintsNotAllowed;
|
||||
public boolean timerEnabled;
|
||||
public boolean allowPickTiles;
|
||||
public boolean allowHintRect;
|
||||
public boolean timerEnabled;
|
||||
public boolean allowPickTiles;
|
||||
public boolean allowHintRect;
|
||||
public int robotSmartness;
|
||||
public XWPhoniesChoice phoniesAction;
|
||||
public boolean confirmBTConnect; /* only used for BT */
|
||||
|
@ -64,8 +64,8 @@ public class CurGameInfo {
|
|||
serverRole = DeviceRole.SERVER_STANDALONE;
|
||||
dictName = CommonPrefs.getDefaultDict( context );
|
||||
hintsNotAllowed = false;
|
||||
phoniesAction = XWPhoniesChoice.PHONIES_IGNORE;
|
||||
timerEnabled = false;
|
||||
phoniesAction = CommonPrefs.getDefaultPhonies( context );
|
||||
timerEnabled = CommonPrefs.getDefaultTimerEnabled( context );
|
||||
allowPickTiles = false;
|
||||
allowHintRect = false;
|
||||
robotSmartness = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue