From 8f8911c7d1d9616657d061c3fd0589f835cf8070 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 23 Oct 2013 20:26:19 -0700 Subject: [PATCH] add feature controlled by "debug features" preference, to add rowids to the list of game properties that can be part of the game's summary display. --- .../android/XWords4/res/values/common_rsrc.xml | 1 + .../org/eehouse/android/xw4/GameListAdapter.java | 1 + .../org/eehouse/android/xw4/GameListItem.java | 3 +++ .../eehouse/android/xw4/XWListPreference.java | 16 ++++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 983cbb3a0..ed105a95d 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -113,6 +113,7 @@ eehouse.org /and/ application/x-xwordsinvite + rowid 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 3401492cf..b70bde5f9 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListAdapter.java @@ -462,6 +462,7 @@ public class GameListAdapter implements ExpandableListAdapter { ,R.string.game_summary_field_language ,R.string.game_summary_field_opponents ,R.string.game_summary_field_state + ,R.string.game_summary_field_rowid }; 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 79f6df793..1cf8c3257 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameListItem.java @@ -201,6 +201,9 @@ public class GameListItem extends LinearLayout switch ( m_fieldID ) { case R.string.game_summary_field_empty: break; + case R.string.game_summary_field_rowid: + value = String.format( "%d", m_rowid ); + break; case R.string.game_summary_field_language: value = DictLangCache.getLangName( m_context, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java index 9a3754e87..34c4f940c 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListPreference.java @@ -27,16 +27,32 @@ import android.util.AttributeSet; import junit.framework.Assert; public class XWListPreference extends ListPreference { + private Context m_context; public XWListPreference( Context context, AttributeSet attrs ) { super( context, attrs ); + m_context = context; } protected void onAttachedToActivity() { super.onAttachedToActivity(); setSummary( getPersistedString( "" ) ); + + if ( 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[] newEntries = new CharSequence[1 + entries.length]; + System.arraycopy( entries, 0, newEntries, 0, entries.length ); + newEntries[entries.length] = lastRow; + setEntries( newEntries ); + + setEntryValues( newEntries ); + } + } } protected boolean persistString( String value )