mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +01:00
add system menu to games list with "delete all" item; implement roughly
This commit is contained in:
parent
35dd738c26
commit
9761596e6e
4 changed files with 35 additions and 25 deletions
6
xwords4/android/XWords4/res/menu/games_list_menu.xml
Normal file
6
xwords4/android/XWords4/res/menu/games_list_menu.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/gamel_menu_delete_all"
|
||||
android:title="@string/gamel_menu_delete_all" />
|
||||
</menu>
|
|
@ -71,4 +71,6 @@
|
|||
<string name="board_menu_file_new">New game</string>
|
||||
<string name="board_menu_file_prefs">Preferences</string>
|
||||
<string name="board_menu_file_about">About Crosswords</string>
|
||||
|
||||
<string name="gamel_menu_delete_all">Delete all</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
||||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
|
@ -37,30 +37,7 @@ public class GameListAdapter implements ListAdapter {
|
|||
|
||||
public Object getItem( int position ) {
|
||||
TextView view = new TextView(m_context);
|
||||
|
||||
try {
|
||||
FileInputStream in = m_context.openFileInput( m_files[position] );
|
||||
|
||||
InputStreamReader reader = new InputStreamReader( in );
|
||||
try {
|
||||
int len = in.available();
|
||||
CharBuffer buf = CharBuffer.allocate(len);
|
||||
reader.read( buf.array(), 0, len );
|
||||
reader.close();
|
||||
view.setText( buf );
|
||||
} catch ( java.io.IOException ex ) {
|
||||
Utils.logf( "got IOException: " + ex.toString() );
|
||||
}
|
||||
|
||||
try {
|
||||
in.close();
|
||||
} catch ( java.io.IOException ex ) {
|
||||
Utils.logf( "got IOException: " + ex.toString() );
|
||||
}
|
||||
} catch ( java.io.FileNotFoundException ex ) {
|
||||
Utils.logf( "got FileNotFoundException: " + ex.toString() );
|
||||
}
|
||||
|
||||
view.setText( "one game" );
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
|
@ -233,6 +234,30 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
|||
return handled;
|
||||
}
|
||||
|
||||
public boolean onCreateOptionsMenu( Menu menu )
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate( R.menu.games_list_menu, menu );
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected( MenuItem item )
|
||||
{
|
||||
boolean handled = true;
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.gamel_menu_delete_all:
|
||||
for( String file : fileList() ) {
|
||||
deleteFile( file );
|
||||
}
|
||||
m_adapter = new GameListAdapter( this );
|
||||
setListAdapter( m_adapter );
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
public void onClick( View v ) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName( "org.eehouse.android.xw4",
|
||||
|
|
Loading…
Reference in a new issue