add debug-only context menu giving conn-via config and invites for GamesList games.

This commit is contained in:
Eric House 2016-01-16 12:08:36 -08:00
parent 84fe06e029
commit 3ca47cdd82
7 changed files with 350 additions and 305 deletions

File diff suppressed because it is too large Load diff

View file

@ -31,4 +31,9 @@
<item android:id="@+id/games_game_deselect"
android:title="@string/list_item_deselect"
/>
<!-- Debug only -->
<item android:id="@+id/games_game_invites"
android:title="@string/board_menu_game_showInvites"
/>
</menu>

View file

@ -2043,6 +2043,9 @@
<!-- -->
<string name="connstat_net_fmt">Network status for game connected via
%1$s:</string>
<!-- First line of debug-only Invites list dialog -->
<string name="invites_net_fmt">Invitations sent for game connected via
%1$s:</string>
<!-- -->
<string name="connstat_succ">successful</string>
<!-- -->

View file

@ -1766,6 +1766,9 @@
<!-- -->
<string name="connstat_net_fmt">Krowten sutats rof emag detcennoc aiv
%1$s:</string>
<!-- First line of debug-only Invites list dialog -->
<string name="invites_net_fmt">Snoitativni tnes rof emag detcennoc aiv
%1$s:</string>
<!-- -->
<string name="connstat_succ">lufsseccus</string>
<!-- -->

View file

@ -1766,6 +1766,9 @@
<!-- -->
<string name="connstat_net_fmt">NETWORK STATUS FOR GAME CONNECTED VIA
%1$s:</string>
<!-- First line of debug-only Invites list dialog -->
<string name="invites_net_fmt">INVITATIONS SENT FOR GAME CONNECTED VIA
%1$s:</string>
<!-- -->
<string name="connstat_succ">SUCCESSFUL</string>
<!-- -->

View file

@ -102,6 +102,12 @@ public class GameListItem extends LinearLayout
} );
}
public GameSummary getSummary()
{
Assert.assertNotNull( m_summary );
return m_summary;
}
private void init( Handler handler, long rowid, int fieldID,
SelectableItem cb )
{

View file

@ -60,14 +60,15 @@ import junit.framework.Assert;
import org.eehouse.android.xw4.DBUtils.GameChangeType;
import org.eehouse.android.xw4.DBUtils.GameGroupInfo;
import org.eehouse.android.xw4.DBUtils.SentInvitesInfo;
import org.eehouse.android.xw4.DlgDelegate.Action;
import org.eehouse.android.xw4.DlgDelegate.ActionPair;
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
import org.eehouse.android.xw4.jni.*;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
import org.eehouse.android.xw4.loc.LocUtils;
import org.eehouse.android.xw4.DwnldDelegate.DownloadFinishedListener;
import org.eehouse.android.xw4.DwnldDelegate.OnGotLcDictListener;
public class GamesListDelegate extends ListDelegateBase
implements OnItemLongClickListener,
@ -1517,21 +1518,22 @@ public class GamesListDelegate extends ListDelegateBase
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
{
boolean enable;
super.onCreateContextMenu( menu, view, menuInfo );
int id = 0;
boolean selected = false;
long gameRowID = 0;
GameListItem item = null;
AdapterView.AdapterContextMenuInfo info
= (AdapterView.AdapterContextMenuInfo)menuInfo;
View targetView = info.targetView;
DbgUtils.logf( "onCreateContextMenu(t=%s)",
targetView.getClass().getName() );
if ( targetView instanceof GameListItem ) {
item = (GameListItem)targetView;
id = R.menu.games_list_game_menu;
gameRowID = ((GameListItem)targetView).getRowID();
selected = m_selGames.contains( gameRowID );
selected = m_selGames.contains( item.getRowID() );
} else if ( targetView instanceof GameListGroup ) {
id = R.menu.games_list_group_menu;
@ -1548,12 +1550,16 @@ public class GamesListDelegate extends ListDelegateBase
? R.id.games_game_select : R.id.games_game_deselect;
Utils.setItemVisible( menu, hideId, false );
if ( 0 != gameRowID ) {
boolean enable = BoardDelegate.rematchSupported( m_activity,
gameRowID );
if ( null != item ) {
enable = BoardDelegate.rematchSupported( m_activity,
item.getRowID() );
Utils.setItemVisible( menu, R.id.games_game_rematch, enable );
enable = BuildConfig.DEBUG && item.getSummary().isMultiGame();
Utils.setItemVisible( menu, R.id.games_game_invites, enable );
}
}
}
public boolean onContextItemSelected( MenuItem item )
@ -1714,6 +1720,21 @@ public class GamesListDelegate extends ListDelegateBase
m_rowid = selRowIDs[0];
showDialog( DlgID.RENAME_GAME );
break;
// DEBUG only
case R.id.games_game_invites:
msg = DBUtils.getSummary( m_activity, selRowIDs[0] )
.conTypes.toString( m_activity );
msg = getString( R.string.invites_net_fmt, msg );
SentInvitesInfo info = DBUtils.getInvitesFor( m_activity,
selRowIDs[0] );
if ( null != info ) {
msg += "\n\n" + info.getAsText( m_activity );
}
showOKOnlyDialog( msg );
break;
default:
handled = false;
}