add gameid as option for what's shown in summary (debug only)

This commit is contained in:
Eric House 2013-11-18 07:25:40 -08:00
parent 6d06197c45
commit d7239323bc
4 changed files with 30 additions and 11 deletions

View file

@ -119,6 +119,7 @@
<string name="invite_prefix">/and/</string>
<string name="invite_mime">application/x-xwordsinvite</string>
<string name="game_summary_field_rowid">rowid</string>
<string name="game_summary_field_gameid">gameid</string>
<!--string name="invite_mime">text/plain</string-->
<string name="dict_url">http://eehouse.org/and_wordlists</string>

View file

@ -443,11 +443,12 @@ public class GameListAdapter implements ExpandableListAdapter {
private int fieldToID( String fieldName )
{
int[] ids = {
R.string.game_summary_field_empty
,R.string.game_summary_field_language
,R.string.game_summary_field_opponents
,R.string.game_summary_field_state
,R.string.game_summary_field_rowid
R.string.game_summary_field_empty,
R.string.game_summary_field_language,
R.string.game_summary_field_opponents,
R.string.game_summary_field_state,
R.string.game_summary_field_rowid,
R.string.game_summary_field_gameid,
};
int result = -1;
for ( int id : ids ) {

View file

@ -211,6 +211,9 @@ public class GameListItem extends LinearLayout
switch ( m_fieldID ) {
case R.string.game_summary_field_empty:
break;
case R.string.game_summary_field_gameid:
value = String.format( "%d", m_summary.gameID );
break;
case R.string.game_summary_field_rowid:
value = String.format( "%d", m_rowid );
break;

View file

@ -25,12 +25,17 @@ import android.util.AttributeSet;
public class XWSumListPreference extends XWListPreference {
private static final int[] s_ADDROWS = {
R.string.game_summary_field_rowid,
R.string.game_summary_field_gameid,
};
public XWSumListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
}
// Why I exist: insert the rowid line if debug is on
// Why I exist: insert the rowid and gameid lines if debug is on
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
@ -38,14 +43,23 @@ public class XWSumListPreference extends XWListPreference {
if ( BuildConstants.IS_DEBUG_BUILD ||
XWPrefs.getDebugEnabled( m_context ) ) {
CharSequence[] entries = getEntries();
String lastRow
= m_context.getString( R.string.game_summary_field_rowid );
if ( !entries[entries.length - 1].equals( lastRow ) ) {
CharSequence lastRow = entries[entries.length - 1];
boolean done = false;
String[] addRows = new String[s_ADDROWS.length];
for ( int ii = 0; !done && ii < s_ADDROWS.length; ++ii ) {
String addRow = m_context.getString( s_ADDROWS[ii] );
done = lastRow.equals( addRow );
addRows[ii] = addRow;
}
if ( !done ) {
CharSequence[] newEntries =
new CharSequence[1 + entries.length];
new CharSequence[entries.length + addRows.length];
System.arraycopy( entries, 0, newEntries, 0,
entries.length );
newEntries[entries.length] = lastRow;
System.arraycopy( addRows, 0, newEntries, entries.length,
addRows.length );
setEntries( newEntries );
setEntryValues( newEntries );