diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java
index 97c74cbd1..f17fbf51d 100644
--- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java
+++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GamesListDelegate.java
@@ -387,14 +387,10 @@ public class GamesListDelegate extends ListDelegateBase
}
}
- boolean setField( String newField )
+ boolean setField( int newID )
{
boolean changed = false;
- int newID = fieldToID( newField );
- if ( -1 == newID ) {
- Log.d( TAG, "setField(): unable to match fieldName %s",
- newField );
- } else if ( m_fieldID != newID ) {
+ if ( 0 != newID && m_fieldID != newID ) {
m_fieldID = newID;
// return true so caller will do onContentChanged.
// There's no other way to signal GameListItem instances
@@ -548,29 +544,6 @@ public class GamesListDelegate extends ListDelegateBase
}
return result;
}
-
- 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_gameid,
- R.string.game_summary_field_npackets,
- R.string.title_addrs_pref,
- R.string.game_summary_field_created,
- };
- int result = ids[0]; // need a default in case set changes
- for ( int id : ids ) {
- if ( LocUtils.getString( m_activity, id ).equals( fieldName )){
- result = id;
- break;
- }
- }
- return result;
- }
} // class GameListAdapter
private static final int[] DEBUG_ITEMS = {
@@ -2738,7 +2711,7 @@ public class GamesListDelegate extends ListDelegateBase
private void updateField()
{
- String newField = CommonPrefs.getSummaryField( m_activity );
+ int newField = CommonPrefs.getSummaryFieldId( m_activity );
if ( m_adapter.setField( newField ) ) {
// The adapter should be able to decide whether full
// content change is required. PENDING
diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWSumListPreference.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWSumListPreference.java
index 84467c534..8b9169a4f 100644
--- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWSumListPreference.java
+++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/XWSumListPreference.java
@@ -1,6 +1,6 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/*
- * Copyright 2010 - 2016 by Eric House (xwords@eehouse.org). All rights
+ * Copyright 2010 - 2022 by Eric House (xwords@eehouse.org). All rights
* reserved.
*
* This program is free software; you can redistribute it and/or modify it
@@ -27,7 +27,14 @@ import org.eehouse.android.xw4.loc.LocUtils;
public class XWSumListPreference extends XWListPreference {
- private static final int[] s_ADDROWS = {
+ private static int[] _s_game_summary_values = {
+ R.string.game_summary_field_empty,
+ R.string.game_summary_field_language,
+ R.string.game_summary_field_opponents,
+ R.string.game_summary_field_state,
+ };
+
+ private static int[] _s_game_summary_values_dbg = {
R.string.game_summary_field_npackets,
R.string.game_summary_field_rowid,
R.string.game_summary_field_gameid,
@@ -35,6 +42,30 @@ public class XWSumListPreference extends XWListPreference {
R.string.game_summary_field_created,
};
+ private static int[] s_game_summary_values = null;
+ public static int[] getFieldIDs( Context context )
+ {
+ if ( null == s_game_summary_values ) {
+ int len = _s_game_summary_values.length;
+ boolean addDbg = BuildConfig.NON_RELEASE
+ || XWPrefs.getDebugEnabled( context );
+ if ( addDbg ) {
+ len += _s_game_summary_values_dbg.length;
+ }
+ s_game_summary_values = new int[len];
+ int ii = 0;
+ for ( int id : _s_game_summary_values ) {
+ s_game_summary_values[ii++] = id;
+ }
+ if ( addDbg ) {
+ for ( int id : _s_game_summary_values_dbg ) {
+ s_game_summary_values[ii++] = id;
+ }
+ }
+ }
+ return s_game_summary_values;
+ }
+
public XWSumListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
@@ -46,36 +77,13 @@ public class XWSumListPreference extends XWListPreference {
{
super.onAttached();
- CharSequence[] entries = getEntries();
- CharSequence[] newEntries = LocUtils.xlateStrings( m_context, entries );
- if ( ! newEntries.equals( entries ) ) {
- setEntries( newEntries );
- setEntryValues( newEntries );
+ int[] ids = getFieldIDs( m_context );
+ CharSequence[] rows = new String[ids.length];
+ for ( int ii = 0; ii < ids.length; ++ii ) {
+ rows[ii] = LocUtils.getString( m_context, ids[ii] );
}
- if ( BuildConfig.DEBUG || XWPrefs.getDebugEnabled( m_context ) ) {
- entries = getEntries();
- 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 = LocUtils.getString( m_context, s_ADDROWS[ii] );
- done = lastRow.equals( addRow );
- addRows[ii] = addRow;
- }
-
- if ( !done ) {
- newEntries = new CharSequence[entries.length + addRows.length];
- System.arraycopy( entries, 0, newEntries, 0,
- entries.length );
- System.arraycopy( addRows, 0, newEntries, entries.length,
- addRows.length );
- setEntries( newEntries );
-
- setEntryValues( newEntries );
- }
- }
+ setEntries( rows );
+ setEntryValues( rows );
}
-
}
diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommonPrefs.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommonPrefs.java
index 6a8c127a9..7126e4ccf 100644
--- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommonPrefs.java
+++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/CommonPrefs.java
@@ -1,6 +1,6 @@
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
/*
- * Copyright 2009 - 2011 by Eric House (xwords@eehouse.org). All
+ * Copyright 2009 - 2022 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -35,6 +35,7 @@ import org.eehouse.android.xw4.NetUtils;
import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils;
import org.eehouse.android.xw4.XWPrefs;
+import org.eehouse.android.xw4.XWSumListPreference;
import org.eehouse.android.xw4.loc.LocUtils;
public class CommonPrefs extends XWPrefs {
@@ -339,6 +340,20 @@ public class CommonPrefs extends XWPrefs {
return getPrefsString( context, R.string.key_summary_field );
}
+ public static int getSummaryFieldId( Context context )
+ {
+ int result = 0;
+ String str = getSummaryField( context );
+ int[] ids = XWSumListPreference.getFieldIDs( context );
+ for ( int id : ids ) {
+ if ( LocUtils.getString( context, id ).equals( str )){
+ result = id;
+ break;
+ }
+ }
+ return result;
+ }
+
public enum ColorTheme {
LIGHT(R.array.color_ids_light),
DARK(R.array.color_ids_dark);
diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml
index 66ede19f3..ad82dd366 100644
--- a/xwords4/android/app/src/main/res/values/common_rsrc.xml
+++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml
@@ -313,13 +313,6 @@
- http://www.google.com/search?nl=%1$s\u0026q=%2$s
-
- - @string/game_summary_field_empty
- - @string/game_summary_field_language
- - @string/game_summary_field_opponents
- - @string/game_summary_field_state
-
-
- @string/confirm_sms_leave
- @string/confirm_sms_unlimited
diff --git a/xwords4/android/app/src/main/res/xml/prefs_appear.xml b/xwords4/android/app/src/main/res/xml/prefs_appear.xml
index dfc654697..8da38c5d0 100644
--- a/xwords4/android/app/src/main/res/xml/prefs_appear.xml
+++ b/xwords4/android/app/src/main/res/xml/prefs_appear.xml
@@ -13,11 +13,10 @@
android:defaultValue="30"
/>
+