mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
add menuitem to main games list view that brings up view of all
installed dicts. Currently allows to delete them. Later should allow invoking a browser like DawgShow.
This commit is contained in:
parent
626a7e4a32
commit
7fadce15ef
9 changed files with 157 additions and 18 deletions
|
@ -51,6 +51,11 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="DictsActivity"
|
||||||
|
android:label="@string/title_dicts_list"
|
||||||
|
>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity android:name="GameConfig"
|
<activity android:name="GameConfig"
|
||||||
android:theme="@android:style/Theme.Light"
|
android:theme="@android:style/Theme.Light"
|
||||||
android:label="@string/title_game"
|
android:label="@string/title_game"
|
||||||
|
|
|
@ -7,9 +7,16 @@
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
android:paddingRight="8dp">
|
android:paddingRight="8dp">
|
||||||
|
|
||||||
<WebView android:id="@+id/dict_web_view"
|
<ListView android:id="@id/android:list"
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawSelectorOnTop="false"/>
|
||||||
|
|
||||||
|
<Button android:id="@+id/download"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/download_dicts"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
10
xwords4/android/XWords4/res/menu/dicts_item_menu.xml
Normal file
10
xwords4/android/XWords4/res/menu/dicts_item_menu.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/dicts_item_delete"
|
||||||
|
android:title="@string/dicts_item_delete"
|
||||||
|
/>
|
||||||
|
<item android:id="@+id/dicts_item_details"
|
||||||
|
android:title="@string/dicts_item_details"
|
||||||
|
/>
|
||||||
|
</menu>
|
|
@ -10,6 +10,9 @@
|
||||||
<item android:id="@+id/gamel_menu_prefs"
|
<item android:id="@+id/gamel_menu_prefs"
|
||||||
android:title="@string/gamel_menu_prefs"
|
android:title="@string/gamel_menu_prefs"
|
||||||
/>
|
/>
|
||||||
|
<item android:id="@+id/gamel_menu_dicts"
|
||||||
|
android:title="@string/gamel_menu_dicts"
|
||||||
|
/>
|
||||||
<item android:id="@+id/gamel_menu_about"
|
<item android:id="@+id/gamel_menu_about"
|
||||||
android:title="@string/board_menu_file_about"
|
android:title="@string/board_menu_file_about"
|
||||||
android:alphabeticShortcut="A"
|
android:alphabeticShortcut="A"
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
<string name="title_create">Create game</string>
|
<string name="title_create">Create game</string>
|
||||||
<string name="title_edit">Edit game</string>
|
<string name="title_edit">Edit game</string>
|
||||||
<string name="title_games_list">Crosswords</string>
|
<string name="title_games_list">Crosswords</string>
|
||||||
|
<string name="title_dicts_list">Crosswords dictionaries</string>
|
||||||
<string name="title_game">Game</string>
|
<string name="title_game">Game</string>
|
||||||
<string name="title_edit_title">Game name:</string>
|
<string name="title_edit_title">Game name:</string>
|
||||||
|
|
||||||
|
@ -151,6 +152,8 @@
|
||||||
|
|
||||||
<string name="list_item_up">Up one</string>
|
<string name="list_item_up">Up one</string>
|
||||||
<string name="list_item_down">Down one</string>
|
<string name="list_item_down">Down one</string>
|
||||||
|
<string name="dicts_item_delete">Delete dictionary</string>
|
||||||
|
<string name="dicts_item_details">Details</string>
|
||||||
|
|
||||||
<string name="dict_label">Dictionary</string>
|
<string name="dict_label">Dictionary</string>
|
||||||
<string name="role_label">Role</string>
|
<string name="role_label">Role</string>
|
||||||
|
@ -187,6 +190,7 @@
|
||||||
<string name="phonies_warn">Warn</string>
|
<string name="phonies_warn">Warn</string>
|
||||||
<string name="phonies_disallow">Disallow</string>
|
<string name="phonies_disallow">Disallow</string>
|
||||||
<string name="gamel_menu_prefs">Preferences</string>
|
<string name="gamel_menu_prefs">Preferences</string>
|
||||||
|
<string name="gamel_menu_dicts">Dictionaries</string>
|
||||||
|
|
||||||
<string name="room_label">Room</string>
|
<string name="room_label">Room</string>
|
||||||
<string name="hostname_label">Hostname</string>
|
<string name="hostname_label">Hostname</string>
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
|
||||||
|
|
||||||
|
package org.eehouse.android.xw4;
|
||||||
|
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ContextMenu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
public class DictsActivity extends ListActivity
|
||||||
|
implements View.OnClickListener {
|
||||||
|
String[] m_dicts;
|
||||||
|
|
||||||
|
private class DictListAdapter extends XWListAdapter {
|
||||||
|
Context m_context;
|
||||||
|
|
||||||
|
public DictListAdapter( Context context ) {
|
||||||
|
super( context, m_dicts.length );
|
||||||
|
m_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getItem( int position) { return m_dicts[position]; }
|
||||||
|
public View getView( final int position, View convertView,
|
||||||
|
ViewGroup parent ) {
|
||||||
|
LayoutInflater factory = LayoutInflater.from( DictsActivity.this );
|
||||||
|
final XWListItem view
|
||||||
|
= (XWListItem)factory.inflate( R.layout.list_item, null );
|
||||||
|
view.setPosition( position );
|
||||||
|
view.setText( m_dicts[position] );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate( savedInstanceState );
|
||||||
|
|
||||||
|
setContentView( R.layout.dict_browse );
|
||||||
|
registerForContextMenu( getListView() );
|
||||||
|
|
||||||
|
Button download = (Button)findViewById( R.id.download );
|
||||||
|
download.setOnClickListener( this );
|
||||||
|
|
||||||
|
mkListAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
mkListAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick( View v ) {
|
||||||
|
startActivity( Utils.mkDownloadActivity( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateContextMenu( ContextMenu menu, View view,
|
||||||
|
ContextMenuInfo menuInfo ) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate( R.menu.dicts_item_menu, menu );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextItemSelected( MenuItem item )
|
||||||
|
{
|
||||||
|
boolean handled = false;
|
||||||
|
AdapterView.AdapterContextMenuInfo info;
|
||||||
|
try {
|
||||||
|
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
Utils.logf( "bad menuInfo:" + e.toString() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = item.getItemId();
|
||||||
|
switch( id ) {
|
||||||
|
case R.id.dicts_item_delete:
|
||||||
|
deleteFile( m_dicts[info.position] );
|
||||||
|
mkListAdapter();
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
case R.id.dicts_item_details:
|
||||||
|
Utils.notImpl( this );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mkListAdapter()
|
||||||
|
{
|
||||||
|
m_dicts = Utils.dictList( this );
|
||||||
|
setListAdapter( new DictListAdapter( this ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -440,7 +440,7 @@ public class GameConfig extends Activity implements View.OnClickListener {
|
||||||
ContextMenuInfo menuInfo ) {
|
ContextMenuInfo menuInfo ) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate( R.menu.players_list_item_menu, menu );
|
inflater.inflate( R.menu.players_list_item_menu, menu );
|
||||||
m_whichPlayer = ((PlayerView)view).getPosition();
|
m_whichPlayer = ((XWListItem)view).getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -568,8 +568,8 @@ public class GameConfig extends Activity implements View.OnClickListener {
|
||||||
m_playerLayout.addView( divider );
|
m_playerLayout.addView( divider );
|
||||||
}
|
}
|
||||||
|
|
||||||
final PlayerView view
|
final XWListItem view
|
||||||
= (PlayerView)factory.inflate( R.layout.player_view, null );
|
= (XWListItem)factory.inflate( R.layout.list_item, null );
|
||||||
view.setPosition( ii );
|
view.setPosition( ii );
|
||||||
view.setText( names[ii] );
|
view.setText( names[ii] );
|
||||||
view.setGravity( Gravity.CENTER );
|
view.setGravity( Gravity.CENTER );
|
||||||
|
@ -578,7 +578,7 @@ public class GameConfig extends Activity implements View.OnClickListener {
|
||||||
view.setOnClickListener( new View.OnClickListener() {
|
view.setOnClickListener( new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View view ) {
|
public void onClick( View view ) {
|
||||||
m_whichPlayer = ((PlayerView)view).getPosition();
|
m_whichPlayer = ((XWListItem)view).getPosition();
|
||||||
showDialog( PLAYER_EDIT );
|
showDialog( PLAYER_EDIT );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -209,6 +209,7 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
public boolean onOptionsItemSelected( MenuItem item )
|
public boolean onOptionsItemSelected( MenuItem item )
|
||||||
{
|
{
|
||||||
boolean handled = true;
|
boolean handled = true;
|
||||||
|
Intent intent;
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.gamel_menu_delete_all:
|
case R.id.gamel_menu_delete_all:
|
||||||
|
@ -224,8 +225,13 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.gamel_menu_dicts:
|
||||||
|
intent = new Intent( this, DictsActivity.class );
|
||||||
|
startActivity( intent );
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.gamel_menu_prefs:
|
case R.id.gamel_menu_prefs:
|
||||||
Intent intent = new Intent( this, PrefsActivity.class );
|
intent = new Intent( this, PrefsActivity.class );
|
||||||
startActivity( intent );
|
startActivity( intent );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -249,17 +255,14 @@ public class GamesList extends ListActivity implements View.OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id)
|
||||||
doOpen( position );
|
{
|
||||||
}
|
|
||||||
|
|
||||||
private void doOpen( int indx ) {
|
|
||||||
String[] missingDict = new String[1];
|
String[] missingDict = new String[1];
|
||||||
if ( ! Utils.gameDictHere( this, indx, missingDict ) ) {
|
if ( ! Utils.gameDictHere( this, position, missingDict ) ) {
|
||||||
m_missingDict = missingDict[0];
|
m_missingDict = missingDict[0];
|
||||||
showDialog( WARN_NODICT );
|
showDialog( WARN_NODICT );
|
||||||
} else {
|
} else {
|
||||||
String path = Utils.gamesList(this)[indx];
|
String path = Utils.gamesList(this)[position];
|
||||||
File file = new File( path );
|
File file = new File( path );
|
||||||
Uri uri = Uri.fromFile( file );
|
Uri uri = Uri.fromFile( file );
|
||||||
Intent intent = new Intent( Intent.ACTION_EDIT, uri,
|
Intent intent = new Intent( Intent.ACTION_EDIT, uri,
|
||||||
|
|
Loading…
Reference in a new issue