add "play game" item to context menu, and invoke that menu on item

click.  This fixes problem with users apparently not knowing about
long-tap and context menu and so not knowing they can configure a
game.  Unfortunately I can't figure out how to disable long-tap
also bringing up the context menu.  Yet another preference might be the fix.
This commit is contained in:
Andy2 2010-07-02 07:04:37 -07:00
parent 9b3463c8e0
commit e22479ba03
3 changed files with 19 additions and 17 deletions

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

@ -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>

View file

@ -177,6 +177,15 @@ public class GamesList extends ListActivity {
showDialog( WARN_NODICT );
} else {
switch ( id ) {
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;
@ -269,21 +278,13 @@ public class GamesList extends ListActivity {
}
@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 );
} 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;
}
// Might want a preference that, when set, just opens game
// instead of bringing up the list. But that shouldn't be the
// default: new users don't know about long-taps.
super.onListItemClick( l, v, position, id );
v.showContextMenu();
}
private void doConfig( String path )