Merge branch 'android_branch' into toolbar

Conflicts:
	xwords4/android/XWords4/AndroidManifest.xml
	xwords4/android/XWords4/res/values/strings.xml
	xwords4/android/XWords4/res/xml/xwprefs.xml
	xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConstants.java
This commit is contained in:
Andy2 2010-07-04 13:28:47 -07:00
commit b163b45abe
9 changed files with 233 additions and 191 deletions

View file

@ -21,8 +21,8 @@
to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4"
android:versionCode="4"
android:versionName="4.4 beta 10"
android:versionCode="5"
android:versionName="4.4 beta 11"
>
<uses-permission android:name="android.permission.INTERNET" />

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:id="@+id/list_item_open" -->
<!-- android:title="@string/list_item_open" -->
<!-- /> -->
<item android:id="@+id/list_item_play"
android:title="@string/list_item_play"
/>
<item android:id="@+id/list_item_config"
android:title="@string/list_item_config"
/>

View file

@ -11,6 +11,7 @@
<string name="key_sort_tiles">key_sort_tiles</string>
<string name="key_hide_values">key_hide_values</string>
<string name="key_ringer_zoom">key_ringer_zoom</string>
<string name="key_click_launches">key_click_launches</string>
<string name="key_hide_title">key_hide_title</string>
<string name="key_player0">key_clr_player0</string>
<string name="key_player1">key_clr_player1</string>

View file

@ -19,6 +19,7 @@
<string name="menu_insert">Add game</string>
<string name="button_new_game">Add game</string>
<string name="list_item_play">Play game</string>
<string name="list_item_config">Game settings</string>
<string name="list_item_hide">Hide</string>
<string name="list_item_delete">Delete</string>
@ -197,6 +198,9 @@
are added</string>
<string name="ringer_zoom">Volume keys zoom</string>
<string name="ringer_zoom_summary">Zoom board using volume keys</string>
<string name="click_launches">Tap to play</string>
<string name="click_launches_summary">Tapping on game in games
list opens it rather than dropping a menu</string>
<string name="hide_title">Hide titlebar</string>
<string name="hide_title_summary">Hiding the game name lets the
board be slightly larger</string>
@ -238,6 +242,12 @@
<string name="prefs_defaults">New game defaults</string>
<string name="prefs_defaults_summary">Default settings for new
games</string>
<string name="prefs_appearance">Appearance</string>
<string name="prefs_appearance_summary">Settings controlling
appearance</string>
<string name="prefs_behavior">Behavior</string>
<string name="prefs_behavior_summary">Settings controlling app behavior</string>
<string name="default_dict">Game dictionary</string>
<string name="default_phonies">Handle phonies</string>
<string name="board_size">Board size</string>

View file

@ -3,79 +3,60 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
>
<PreferenceScreen android:title="@string/prefs_defaults"
android:summary="@string/prefs_defaults_summary"
>
<PreferenceScreen android:title="@string/prefs_defaults"
android:summary="@string/prefs_defaults_summary"
>
<org.eehouse.android.xw4.DictListPreference
android:key="@string/key_default_dict"
android:title="@string/default_dict"
/>
<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="@string/phonies_warn"
/>
<ListPreference android:key="@string/key_default_phonies"
android:title="@string/default_phonies"
android:entries="@array/phony_names"
android:entryValues="@array/phony_names"
android:defaultValue="@string/phonies_warn"
/>
<CheckBoxPreference android:key="@string/key_default_timerenabled"
android:title="@string/use_timer"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_default_timerenabled"
android:title="@string/use_timer"
android:defaultValue="false"
/>
<EditTextPreference android:key="@string/key_initial_player_minutes"
android:title="@string/initial_player_minutes"
android:defaultValue="25"
android:numeric="decimal"
/>
<EditTextPreference android:key="@string/key_initial_player_minutes"
android:title="@string/initial_player_minutes"
android:defaultValue="25"
android:numeric="decimal"
/>
<ListPreference android:key="@string/key_board_size"
android:title="@string/board_size"
android:entries="@array/board_sizes"
android:entryValues="@array/board_sizes"
android:defaultValue="15x15"
/>
<ListPreference android:key="@string/key_board_size"
android:title="@string/board_size"
android:entries="@array/board_sizes"
android:entryValues="@array/board_sizes"
android:defaultValue="15x15"
/>
</PreferenceScreen>
<CheckBoxPreference android:key="@string/key_color_tiles"
android:title="@string/color_tiles"
android:summary="@string/color_tiles_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_explain_robot"
android:title="@string/explain_robot"
android:summary="@string/explain_robot_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_skip_confirm"
android:title="@string/skip_confirm_turn"
android:summary="@string/skip_confirm_turn_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_sort_tiles"
android:title="@string/title_sort_tiles"
android:summary="@string/summary_sort_tiles"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_ringer_zoom"
android:title="@string/ringer_zoom"
android:summary="@string/ringer_zoom_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_hide_title"
android:title="@string/hide_title"
android:summary="@string/hide_title_summary"
android:defaultValue="true"
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/prefs_appearance"
android:summary="@string/prefs_appearance_summary"
>
<CheckBoxPreference android:key="@string/key_color_tiles"
android:title="@string/color_tiles"
android:summary="@string/color_tiles_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_hide_title"
android:title="@string/hide_title"
android:summary="@string/hide_title_summary"
android:defaultValue="true"
/>
<PreferenceScreen android:title="@string/prefs_colors"
android:summary="@string/prefs_colors_summary"
>
@ -136,31 +117,63 @@
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/advanced"
android:summary="@string/advanced_summary"
>
<EditTextPreference android:key="@string/key_relay_host"
android:title="@string/relay_host"
android:defaultValue="@string/default_host"
/>
<EditTextPreference android:key="@string/key_relay_port"
android:title="@string/relay_port"
android:defaultValue="10999"
android:numeric="decimal"
/>
<!-- <EditTextPreference android:key="@string/key_sms_port" -->
<!-- android:title="@string/sms_port" -->
<!-- android:defaultValue="5432" -->
<!-- android:numeric="decimal" -->
<!-- /> -->
<EditTextPreference android:key="@string/key_dict_host"
android:title="@string/dict_host"
android:defaultValue="@string/dict_url"
/>
</PreferenceScreen>
<EditTextPreference android:title="@string/git_rev_title"
android:summary="@string/git_rev_gen"
android:enabled="false"
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/prefs_behavior"
android:summary="@string/prefs_behavior_summary"
>
<CheckBoxPreference android:key="@string/key_explain_robot"
android:title="@string/explain_robot"
android:summary="@string/explain_robot_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_skip_confirm"
android:title="@string/skip_confirm_turn"
android:summary="@string/skip_confirm_turn_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_sort_tiles"
android:title="@string/title_sort_tiles"
android:summary="@string/summary_sort_tiles"
android:defaultValue="true"
/>
<CheckBoxPreference android:key="@string/key_ringer_zoom"
android:title="@string/ringer_zoom"
android:summary="@string/ringer_zoom_summary"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_click_launches"
android:title="@string/click_launches"
android:summary="@string/click_launches_summary"
android:defaultValue="false"
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/advanced"
android:summary="@string/advanced_summary"
>
<EditTextPreference android:key="@string/key_relay_host"
android:title="@string/relay_host"
android:defaultValue="@string/default_host"
/>
<EditTextPreference android:key="@string/key_relay_port"
android:title="@string/relay_port"
android:defaultValue="10999"
android:numeric="decimal"
/>
<!-- <EditTextPreference android:key="@string/key_sms_port" -->
<!-- android:title="@string/sms_port" -->
<!-- android:defaultValue="5432" -->
<!-- android:numeric="decimal" -->
<!-- /> -->
<EditTextPreference android:key="@string/key_dict_host"
android:title="@string/dict_host"
android:defaultValue="@string/dict_url"
/>
<EditTextPreference android:title="@string/git_rev_title"
android:summary="@string/git_rev_gen"
android:enabled="false"
/>
</PreferenceScreen>
</PreferenceScreen>

View file

@ -60,14 +60,16 @@ public class DBUtils {
String scoresStr =
cursor.getString( cursor.getColumnIndex(DBHelper.SCORES));
StringTokenizer st = new StringTokenizer( scoresStr );
int[] scores = new int[st.countTokens()];
for ( int ii = 0; ii < scores.length; ++ii ) {
Assert.assertTrue( st.hasMoreTokens() );
String token = st.nextToken();
scores[ii] = Integer.parseInt( token );
if ( null != scoresStr ) {
StringTokenizer st = new StringTokenizer( scoresStr );
int[] scores = new int[st.countTokens()];
for ( int ii = 0; ii < scores.length; ++ii ) {
Assert.assertTrue( st.hasMoreTokens() );
String token = st.nextToken();
scores[ii] = Integer.parseInt( token );
}
summary.scores = scores;
}
summary.scores = scores;
int col = cursor.getColumnIndex( DBHelper.CONTYPE );
if ( col >= 0 ) {
@ -103,11 +105,13 @@ public class DBUtils {
values.put( DBHelper.NUM_MOVES, summary.nMoves );
values.put( DBHelper.GAME_OVER, summary.gameOver );
StringBuffer sb = new StringBuffer();
for ( int score : summary.scores ) {
sb.append( String.format( "%d ", score ) );
if ( null != summary.scores ) {
StringBuffer sb = new StringBuffer();
for ( int score : summary.scores ) {
sb.append( String.format( "%d ", score ) );
}
values.put( DBHelper.SCORES, sb.toString() );
}
values.put( DBHelper.SCORES, sb.toString() );
if ( null != summary.conType ) {
values.put( DBHelper.CONTYPE, summary.conType.ordinal() );

View file

@ -42,7 +42,7 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*;
public class GamesList extends ListActivity implements View.OnClickListener {
public class GamesList extends ListActivity {
private static final int WARN_NODICT = Utils.DIALOG_LAST + 1;
private static final int CONFIRM_DELETE_ALL = Utils.DIALOG_LAST + 2;
@ -117,7 +117,13 @@ public class GamesList extends ListActivity implements View.OnClickListener {
registerForContextMenu( getListView() );
Button newGameB = (Button)findViewById(R.id.new_game);
newGameB.setOnClickListener( this );
newGameB.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick( View v ) {
saveNew( new CurGameInfo( GamesList.this ) );
onContentChanged();
}
} );
m_adapter = new GameListAdapter( this );
setListAdapter( m_adapter );
@ -145,10 +151,6 @@ public class GamesList extends ListActivity implements View.OnClickListener {
@Override
public boolean onContextItemSelected( MenuItem item )
{
boolean handled = true;
byte[] stream;
String invalPath = null;
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
@ -157,65 +159,7 @@ public class GamesList extends ListActivity implements View.OnClickListener {
return false;
}
String path = GameUtils.gamesList( this )[info.position];
int id = item.getItemId();
if ( R.id.list_item_delete == id ) {
GameUtils.deleteGame( this, path );
invalPath = path;
} else {
String[] missingName = new String[1];
boolean hasDict = GameUtils.gameDictHere( this, path, missingName );
if ( !hasDict ) {
m_missingDict = missingName[0];
showDialog( WARN_NODICT );
} else {
switch ( id ) {
case R.id.list_item_config:
doConfig( path );
invalPath = path;
break;
case R.id.list_item_reset:
GameUtils.resetGame( this, path, path );
invalPath = path;
break;
case R.id.list_item_new_from:
String newName = GameUtils.resetGame( this, path );
invalPath = newName;
break;
case R.id.list_item_copy:
stream = GameUtils.savedGame( this, path );
newName = GameUtils.saveGame( this, stream );
DBUtils.saveSummary( newName, DBUtils.getSummary( this, path ) );
break;
// These require some notion of predictable sort order.
// Maybe put off until I'm using a db?
// case R.id.list_item_hide:
// case R.id.list_item_move_up:
// case R.id.list_item_move_down:
// case R.id.list_item_move_to_top:
// case R.id.list_item_move_to_bottom:
// Utils.notImpl( this );
// break;
default:
handled = false;
break;
}
}
}
if ( null != invalPath ) {
m_adapter.inval( invalPath );
}
if ( handled ) {
onContentChanged();
}
return handled;
return handleMenuItem( item.getItemId(), info.position );
} // onContextItemSelected
public boolean onCreateOptionsMenu( Menu menu )
@ -262,29 +206,94 @@ public class GamesList extends ListActivity implements View.OnClickListener {
return handled;
}
public void onClick( View v ) {
saveNew( new CurGameInfo( this ) );
onContentChanged();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
protected void onListItemClick( ListView l, View v, int position, long id )
{
String[] missingDict = new String[1];
if ( ! GameUtils.gameDictHere( this, position, missingDict ) ) {
m_missingDict = missingDict[0];
showDialog( WARN_NODICT );
super.onListItemClick( l, v, position, id );
if ( CommonPrefs.getClickLaunches( this ) ) {
handleMenuItem( R.id.list_item_play, position );
} else {
String path = GameUtils.gamesList(this)[position];
File file = new File( path );
Uri uri = Uri.fromFile( file );
Intent intent = new Intent( Intent.ACTION_EDIT, uri,
this, BoardActivity.class );
startActivity( intent );
m_invalPath = path;
v.showContextMenu();
}
}
private boolean handleMenuItem( int menuID, int position )
{
boolean handled = true;
byte[] stream;
String invalPath = null;
String path = GameUtils.gamesList( this )[position];
if ( R.id.list_item_delete == menuID ) {
GameUtils.deleteGame( this, path );
invalPath = path;
} else {
String[] missingName = new String[1];
boolean hasDict = GameUtils.gameDictHere( this, path, missingName );
if ( !hasDict ) {
m_missingDict = missingName[0];
showDialog( WARN_NODICT );
} else {
switch ( menuID ) {
case R.id.list_item_play:
File file = new File( path );
Uri uri = Uri.fromFile( file );
Intent intent = new Intent( Intent.ACTION_EDIT, uri,
this, BoardActivity.class );
startActivity( intent );
m_invalPath = path;
break;
case R.id.list_item_config:
doConfig( path );
invalPath = path;
break;
case R.id.list_item_reset:
GameUtils.resetGame( this, path, path );
invalPath = path;
break;
case R.id.list_item_new_from:
String newName = GameUtils.resetGame( this, path );
invalPath = newName;
break;
case R.id.list_item_copy:
stream = GameUtils.savedGame( this, path );
newName = GameUtils.saveGame( this, stream );
DBUtils.saveSummary( newName,
DBUtils.getSummary( this, path ) );
break;
// These require some notion of predictable sort order.
// Maybe put off until I'm using a db?
// case R.id.list_item_hide:
// case R.id.list_item_move_up:
// case R.id.list_item_move_down:
// case R.id.list_item_move_to_top:
// case R.id.list_item_move_to_bottom:
// Utils.notImpl( this );
// break;
default:
handled = false;
break;
}
}
}
if ( null != invalPath ) {
m_adapter.inval( invalPath );
}
if ( handled ) {
onContentChanged();
}
return handled;
} // handleMenuItem
private void doConfig( String path )
{
Uri uri = Uri.fromFile( new File(path) );

View file

@ -23,5 +23,5 @@ package org.eehouse.android.xw4;
public interface XWConstants {
public static final String GAME_EXTN = ".xwg";
public static final String DICT_EXTN = ".xwd";
public static final String VERSION_STR = "4.4 beta 10";
public static final String VERSION_STR = "4.4 beta 11";
}

View file

@ -217,6 +217,11 @@ public class CommonPrefs {
return getBoolean( context, R.string.key_hide_title, true );
}
public static boolean getClickLaunches( Context context )
{
return getBoolean( context, R.string.key_click_launches, false );
}
private static boolean getBoolean( Context context, int keyID,
boolean defaultValue )
{