diff --git a/xwords4/android/XWords4/AndroidManifest.xml b/xwords4/android/XWords4/AndroidManifest.xml index 37610d8dd..4e5cf6157 100644 --- a/xwords4/android/XWords4/AndroidManifest.xml +++ b/xwords4/android/XWords4/AndroidManifest.xml @@ -21,8 +21,8 @@ to come from a domain that you own or have control over. --> diff --git a/xwords4/android/XWords4/res/menu/games_list_item_menu.xml b/xwords4/android/XWords4/res/menu/games_list_item_menu.xml index 6261d9588..874575d1a 100644 --- a/xwords4/android/XWords4/res/menu/games_list_item_menu.xml +++ b/xwords4/android/XWords4/res/menu/games_list_item_menu.xml @@ -1,9 +1,9 @@ - - - + diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 95e4c4e0d..a017f839e 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -11,6 +11,7 @@ key_sort_tiles key_hide_values key_ringer_zoom + key_click_launches key_hide_title key_clr_player0 key_clr_player1 diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 4c137e535..5e486c195 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -19,6 +19,7 @@ Add game Add game + Play game Game settings Hide Delete @@ -197,6 +198,9 @@ are added Volume keys zoom Zoom board using volume keys + Tap to play + Tapping on game in games + list opens it rather than dropping a menu Hide titlebar Hiding the game name lets the board be slightly larger @@ -238,6 +242,12 @@ New game defaults Default settings for new games + Appearance + Settings controlling + appearance + Behavior + Settings controlling app behavior + Game dictionary Handle phonies Board size diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml index 7b4315d7f..a598413a5 100644 --- a/xwords4/android/XWords4/res/xml/xwprefs.xml +++ b/xwords4/android/XWords4/res/xml/xwprefs.xml @@ -3,79 +3,60 @@ - + - + - + - + - + - + - - - - - - - - - - + + + + + @@ -136,31 +117,63 @@ /> - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java index 0a1bef83e..a74bbc825 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBUtils.java @@ -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() ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index e58c3c070..dcf41a157 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -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) ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConstants.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConstants.java index 0394abf1b..b873fa6ec 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConstants.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConstants.java @@ -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"; } 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 e00406b7f..1c8195c54 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 @@ -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 ) {