From d7239323bc02c082bb88742df2b9b88b6321b941 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 18 Nov 2013 07:25:40 -0800 Subject: [PATCH] add gameid as option for what's shown in summary (debug only) --- .../XWords4/res/values/common_rsrc.xml | 1 + .../eehouse/android/xw4/GameListAdapter.java | 11 ++++---- .../org/eehouse/android/xw4/GameListItem.java | 3 +++ .../android/xw4/XWSumListPreference.java | 26 ++++++++++++++----- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 92435ae75..4f4a8f98f 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -119,6 +119,7 @@ /and/ application/x-xwordsinvite rowid + gameid http://eehouse.org/and_wordlists diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java index 15f91c5c8..4b675d619 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -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 ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java index 163ca3f67..4b136b6f4 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java @@ -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; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java index b744af7c9..e6964e799 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWSumListPreference.java @@ -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 );