mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
beginning of rematch menu: enabled correctly, but not yet handled
This commit is contained in:
parent
5886394fd7
commit
ddc9c5f920
5 changed files with 94 additions and 49 deletions
|
@ -163,33 +163,34 @@ public final class R {
|
||||||
public static final int game_locked_check=0x7f0a0028;
|
public static final int game_locked_check=0x7f0a0028;
|
||||||
public static final int game_name=0x7f0a0046;
|
public static final int game_name=0x7f0a0046;
|
||||||
public static final int gamel_menu_checkmoves=0x7f0a0092;
|
public static final int gamel_menu_checkmoves=0x7f0a0092;
|
||||||
public static final int games_game_config=0x7f0a00b0;
|
public static final int games_game_config=0x7f0a00aa;
|
||||||
public static final int games_game_copy=0x7f0a00b5;
|
public static final int games_game_copy=0x7f0a00af;
|
||||||
public static final int games_game_delete=0x7f0a00af;
|
public static final int games_game_delete=0x7f0a00a8;
|
||||||
public static final int games_game_deselect=0x7f0a00ae;
|
public static final int games_game_deselect=0x7f0a00b1;
|
||||||
public static final int games_game_move=0x7f0a00b1;
|
public static final int games_game_move=0x7f0a00ab;
|
||||||
public static final int games_game_new_from=0x7f0a00b3;
|
public static final int games_game_new_from=0x7f0a00ad;
|
||||||
public static final int games_game_rename=0x7f0a00b4;
|
public static final int games_game_rematch=0x7f0a00a9;
|
||||||
public static final int games_game_reset=0x7f0a00b2;
|
public static final int games_game_rename=0x7f0a00ae;
|
||||||
public static final int games_game_select=0x7f0a00ad;
|
public static final int games_game_reset=0x7f0a00ac;
|
||||||
public static final int games_group_default=0x7f0a00ab;
|
public static final int games_game_select=0x7f0a00b0;
|
||||||
public static final int games_group_delete=0x7f0a00aa;
|
public static final int games_group_default=0x7f0a00b5;
|
||||||
public static final int games_group_movedown=0x7f0a00a9;
|
public static final int games_group_delete=0x7f0a00b4;
|
||||||
public static final int games_group_moveup=0x7f0a00a8;
|
public static final int games_group_movedown=0x7f0a00b3;
|
||||||
public static final int games_group_rename=0x7f0a00ac;
|
public static final int games_group_moveup=0x7f0a00b2;
|
||||||
public static final int games_menu_about=0x7f0a00bd;
|
public static final int games_group_rename=0x7f0a00b6;
|
||||||
public static final int games_menu_checkmoves=0x7f0a00bf;
|
public static final int games_menu_about=0x7f0a00be;
|
||||||
public static final int games_menu_checkupdates=0x7f0a00c0;
|
public static final int games_menu_checkmoves=0x7f0a00c0;
|
||||||
public static final int games_menu_dicts=0x7f0a00bb;
|
public static final int games_menu_checkupdates=0x7f0a00c1;
|
||||||
public static final int games_menu_email=0x7f0a00bc;
|
public static final int games_menu_dicts=0x7f0a00bc;
|
||||||
public static final int games_menu_loaddb=0x7f0a00c2;
|
public static final int games_menu_email=0x7f0a00bd;
|
||||||
public static final int games_menu_newgame_net=0x7f0a00b7;
|
public static final int games_menu_loaddb=0x7f0a00c3;
|
||||||
public static final int games_menu_newgame_solo=0x7f0a00b6;
|
public static final int games_menu_newgame_net=0x7f0a00b8;
|
||||||
public static final int games_menu_newgroup=0x7f0a00b8;
|
public static final int games_menu_newgame_solo=0x7f0a00b7;
|
||||||
public static final int games_menu_prefs=0x7f0a00b9;
|
public static final int games_menu_newgroup=0x7f0a00b9;
|
||||||
public static final int games_menu_rateme=0x7f0a00ba;
|
public static final int games_menu_prefs=0x7f0a00ba;
|
||||||
public static final int games_menu_resend=0x7f0a00be;
|
public static final int games_menu_rateme=0x7f0a00bb;
|
||||||
public static final int games_menu_storedb=0x7f0a00c1;
|
public static final int games_menu_resend=0x7f0a00bf;
|
||||||
|
public static final int games_menu_storedb=0x7f0a00c2;
|
||||||
public static final int games_menu_study=0x7f0a0091;
|
public static final int games_menu_study=0x7f0a0091;
|
||||||
public static final int group_done=0x7f0a0084;
|
public static final int group_done=0x7f0a0084;
|
||||||
public static final int group_exchange=0x7f0a0096;
|
public static final int group_exchange=0x7f0a0096;
|
||||||
|
@ -205,10 +206,10 @@ public final class R {
|
||||||
public static final int label=0x7f0a0025;
|
public static final int label=0x7f0a0025;
|
||||||
public static final int lang_separator=0x7f0a002b;
|
public static final int lang_separator=0x7f0a002b;
|
||||||
public static final int lang_spinner=0x7f0a002c;
|
public static final int lang_spinner=0x7f0a002c;
|
||||||
public static final int loc_item_check=0x7f0a00c4;
|
public static final int loc_item_check=0x7f0a00c5;
|
||||||
public static final int loc_item_clear=0x7f0a00c3;
|
public static final int loc_item_clear=0x7f0a00c4;
|
||||||
public static final int loc_item_copy_bless=0x7f0a00c6;
|
public static final int loc_item_copy_bless=0x7f0a00c7;
|
||||||
public static final int loc_item_copy_eng=0x7f0a00c5;
|
public static final int loc_item_copy_eng=0x7f0a00c6;
|
||||||
public static final int loc_search_button=0x7f0a005e;
|
public static final int loc_search_button=0x7f0a005e;
|
||||||
public static final int loc_search_field=0x7f0a005d;
|
public static final int loc_search_field=0x7f0a005d;
|
||||||
public static final int local_label=0x7f0a0059;
|
public static final int local_label=0x7f0a0059;
|
||||||
|
@ -256,11 +257,11 @@ public final class R {
|
||||||
public static final int seek_red=0x7f0a0014;
|
public static final int seek_red=0x7f0a0014;
|
||||||
public static final int show_remote=0x7f0a001e;
|
public static final int show_remote=0x7f0a001e;
|
||||||
public static final int shuffle_button=0x7f0a007d;
|
public static final int shuffle_button=0x7f0a007d;
|
||||||
public static final int slmenu_clear_sel=0x7f0a00cb;
|
public static final int slmenu_clear_sel=0x7f0a00cc;
|
||||||
public static final int slmenu_copy_sel=0x7f0a00ca;
|
public static final int slmenu_copy_sel=0x7f0a00cb;
|
||||||
public static final int slmenu_deselect_all=0x7f0a00c9;
|
public static final int slmenu_deselect_all=0x7f0a00ca;
|
||||||
public static final int slmenu_lookup_sel=0x7f0a00c7;
|
public static final int slmenu_lookup_sel=0x7f0a00c8;
|
||||||
public static final int slmenu_select_all=0x7f0a00c8;
|
public static final int slmenu_select_all=0x7f0a00c9;
|
||||||
public static final int smart_robot=0x7f0a0040;
|
public static final int smart_robot=0x7f0a0040;
|
||||||
public static final int state=0x7f0a004d;
|
public static final int state=0x7f0a004d;
|
||||||
public static final int summary=0x7f0a0060;
|
public static final int summary=0x7f0a0060;
|
||||||
|
@ -335,8 +336,8 @@ public final class R {
|
||||||
public static final int chat_menu=0x7f090001;
|
public static final int chat_menu=0x7f090001;
|
||||||
public static final int dicts_menu=0x7f090002;
|
public static final int dicts_menu=0x7f090002;
|
||||||
public static final int empty=0x7f090003;
|
public static final int empty=0x7f090003;
|
||||||
public static final int games_list_group_menu=0x7f090004;
|
public static final int games_list_game_menu=0x7f090004;
|
||||||
public static final int games_list_item_menu=0x7f090005;
|
public static final int games_list_group_menu=0x7f090005;
|
||||||
public static final int games_list_menu=0x7f090006;
|
public static final int games_list_menu=0x7f090006;
|
||||||
public static final int loc_item_menu=0x7f090007;
|
public static final int loc_item_menu=0x7f090007;
|
||||||
public static final int studylist=0x7f090008;
|
public static final int studylist=0x7f090008;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
<item android:id="@+id/games_game_delete"
|
<item android:id="@+id/games_game_delete"
|
||||||
android:title="@string/list_item_delete"
|
android:title="@string/list_item_delete"
|
||||||
/>
|
/>
|
||||||
|
<item android:id="@+id/games_game_rematch"
|
||||||
|
android:title="@string/button_rematch"
|
||||||
|
/>
|
||||||
<item android:id="@+id/games_game_config"
|
<item android:id="@+id/games_game_config"
|
||||||
android:title="@string/list_item_config"
|
android:title="@string/list_item_config"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -57,6 +57,9 @@
|
||||||
android:icon="@drawable/content_discard__gen"
|
android:icon="@drawable/content_discard__gen"
|
||||||
android:showAsAction="ifRoom"
|
android:showAsAction="ifRoom"
|
||||||
/>
|
/>
|
||||||
|
<item android:id="@+id/games_game_rematch"
|
||||||
|
android:title="@string/button_rematch"
|
||||||
|
/>
|
||||||
<item android:id="@+id/games_game_config"
|
<item android:id="@+id/games_game_config"
|
||||||
android:title="@string/list_item_config"
|
android:title="@string/list_item_config"
|
||||||
android:icon="@drawable/content_edit"
|
android:icon="@drawable/content_edit"
|
||||||
|
|
|
@ -23,8 +23,9 @@ package org.eehouse.android.xw4;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface.OnCancelListener;
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -2529,24 +2530,40 @@ public class BoardDelegate extends DelegateBase
|
||||||
|
|
||||||
// For now, supported if standalone or either BT or SMS used for transport
|
// For now, supported if standalone or either BT or SMS used for transport
|
||||||
private boolean rematchSupported( boolean showMulti )
|
private boolean rematchSupported( boolean showMulti )
|
||||||
|
{
|
||||||
|
return rematchSupported( showMulti ? m_activity : null,
|
||||||
|
m_summary );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean rematchSupported( GameSummary summary )
|
||||||
|
{
|
||||||
|
return rematchSupported( null, summary );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean rematchSupported( Context context,
|
||||||
|
GameSummary summary )
|
||||||
{
|
{
|
||||||
boolean supported = false;
|
boolean supported = false;
|
||||||
if ( XWApp.REMATCH_SUPPORTED ) {
|
if ( XWApp.REMATCH_SUPPORTED ) {
|
||||||
// standalone games are easy to rematch
|
// standalone games are easy to rematch
|
||||||
supported = m_gi.serverRole == DeviceRole.SERVER_STANDALONE;
|
supported = summary.serverRole == DeviceRole.SERVER_STANDALONE;
|
||||||
|
|
||||||
if ( !supported )
|
if ( !supported ) {
|
||||||
if ( 2 == m_gi.nPlayers ) {
|
if ( 2 == summary.nPlayers ) {
|
||||||
supported = m_connTypes.contains( CommsConnType.COMMS_CONN_BT )
|
if ( !summary.anyMissing() ) {
|
||||||
|| m_connTypes.contains( CommsConnType.COMMS_CONN_SMS )
|
CommsConnTypeSet connTypes = summary.conTypes;
|
||||||
|| m_connTypes.contains( CommsConnType.COMMS_CONN_RELAY );
|
supported = connTypes.contains( CommsConnType.COMMS_CONN_BT )
|
||||||
} else if ( showMulti ) {
|
|| connTypes.contains( CommsConnType.COMMS_CONN_SMS )
|
||||||
|
|| connTypes.contains( CommsConnType.COMMS_CONN_RELAY );
|
||||||
|
}
|
||||||
|
} else if ( null != context ) {
|
||||||
// show the button if people haven't dismissed the hint yet
|
// show the button if people haven't dismissed the hint yet
|
||||||
supported = ! XWPrefs
|
supported = ! XWPrefs
|
||||||
.getPrefsBoolean( m_activity,
|
.getPrefsBoolean( context,
|
||||||
R.string.key_na_rematch_two_only,
|
R.string.key_na_rematch_two_only,
|
||||||
false );
|
false );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return supported;
|
return supported;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1355,6 +1355,15 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
.contains( XWPrefs.getDefaultNewGameGroup( m_activity ) );
|
.contains( XWPrefs.getDefaultNewGameGroup( m_activity ) );
|
||||||
Utils.setItemVisible( menu, R.id.games_group_default, enable );
|
Utils.setItemVisible( menu, R.id.games_group_default, enable );
|
||||||
|
|
||||||
|
// Rematch supported if there's one game selected
|
||||||
|
enable = 1 == nGamesSelected;
|
||||||
|
if ( enable ) {
|
||||||
|
GameSummary summary = DBUtils.getSummary( m_activity,
|
||||||
|
getSelRowIDs()[0] );
|
||||||
|
enable = BoardDelegate.rematchSupported( summary );
|
||||||
|
}
|
||||||
|
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
|
||||||
|
|
||||||
// Move up/down enabled for groups if not the top-most or bottommost
|
// Move up/down enabled for groups if not the top-most or bottommost
|
||||||
// selected
|
// selected
|
||||||
enable = 1 == nGroupsSelected;
|
enable = 1 == nGroupsSelected;
|
||||||
|
@ -1507,6 +1516,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
|
long gameRowID = 0;
|
||||||
AdapterView.AdapterContextMenuInfo info
|
AdapterView.AdapterContextMenuInfo info
|
||||||
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
= (AdapterView.AdapterContextMenuInfo)menuInfo;
|
||||||
View targetView = info.targetView;
|
View targetView = info.targetView;
|
||||||
|
@ -1515,8 +1525,8 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
if ( targetView instanceof GameListItem ) {
|
if ( targetView instanceof GameListItem ) {
|
||||||
id = R.menu.games_list_game_menu;
|
id = R.menu.games_list_game_menu;
|
||||||
|
|
||||||
long rowID = ((GameListItem)targetView).getRowID();
|
gameRowID = ((GameListItem)targetView).getRowID();
|
||||||
selected = m_selGames.contains( rowID );
|
selected = m_selGames.contains( gameRowID );
|
||||||
} else if ( targetView instanceof GameListGroup ) {
|
} else if ( targetView instanceof GameListGroup ) {
|
||||||
id = R.menu.games_list_group_menu;
|
id = R.menu.games_list_group_menu;
|
||||||
|
|
||||||
|
@ -1532,6 +1542,12 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
int hideId = selected
|
int hideId = selected
|
||||||
? R.id.games_game_select : R.id.games_game_deselect;
|
? R.id.games_game_select : R.id.games_game_deselect;
|
||||||
Utils.setItemVisible( menu, hideId, false );
|
Utils.setItemVisible( menu, hideId, false );
|
||||||
|
|
||||||
|
if ( 0 != gameRowID ) {
|
||||||
|
GameSummary summary = DBUtils.getSummary(m_activity, gameRowID);
|
||||||
|
boolean enable = BoardDelegate.rematchSupported( summary );
|
||||||
|
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,6 +1651,11 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
Action.DELETE_GAMES, selRowIDs );
|
Action.DELETE_GAMES, selRowIDs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.games_game_rematch:
|
||||||
|
Assert.assertTrue( 1 == selRowIDs.length );
|
||||||
|
Utils.notImpl( m_activity );
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.games_game_config:
|
case R.id.games_game_config:
|
||||||
GameUtils.doConfig( m_activity, selRowIDs[0], GameConfigActivity.class );
|
GameUtils.doConfig( m_activity, selRowIDs[0], GameConfigActivity.class );
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue