use "pct." to indicate what thumb scale choices mean. '%' triggers a

known crasher in Android.
This commit is contained in:
Eric House 2013-11-21 06:44:19 -08:00
parent 7be3a3bef8
commit 75d9752024
4 changed files with 15 additions and 6 deletions

View file

@ -2192,4 +2192,6 @@
means that any time a board that\'s missing a player is open, you means that any time a board that\'s missing a player is open, you
can tap a nearby person\'s device to invite him/her to can tap a nearby person\'s device to invite him/her to
play if he/she is also using NFC.</string> play if he/she is also using NFC.</string>
<string name="pct_suffix">\u0020pct.</string>
</resources> </resources>

View file

@ -119,10 +119,11 @@
android:defaultValue="true" android:defaultValue="true"
/> />
<!-- " pct." below must match R.string.pct_suffix -->
<org.eehouse.android.xw4.XWThumbListPreference <org.eehouse.android.xw4.XWThumbListPreference
android:key="@string/key_thumbsize" android:key="@string/key_thumbsize"
android:title="@string/summary_thumbsize" android:title="@string/summary_thumbsize"
android:defaultValue="30" android:defaultValue="30 pct."
/> />
</PreferenceScreen> </PreferenceScreen>

View file

@ -350,10 +350,13 @@ public class XWPrefs {
public static int getThumbPct( Context context ) public static int getThumbPct( Context context )
{ {
String pct = getPrefsString( context, R.string.key_thumbsize ); String pct = getPrefsString( context, R.string.key_thumbsize );
int result = 30; int result;
if ( null != pct && 2 <= pct.length() ) { try {
// result = Integer.parseInt( pct.substring( 0, pct.length() - 1 ) ); String suffix = context.getString( R.string.pct_suffix );
result = Integer.parseInt( pct ); result = Integer.parseInt( pct.substring( 0, pct.length()
- suffix.length() ) );
} catch (Exception ex ) {
result = 30;
} }
DbgUtils.logf( "pct: %s => %d", pct, result ); DbgUtils.logf( "pct: %s => %d", pct, result );
return result; return result;

View file

@ -24,10 +24,12 @@ import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
public class XWThumbListPreference extends XWListPreference { public class XWThumbListPreference extends XWListPreference {
private Context m_context;
public XWThumbListPreference( Context context, AttributeSet attrs ) public XWThumbListPreference( Context context, AttributeSet attrs )
{ {
super( context, attrs ); super( context, attrs );
m_context = context;
} }
// Why I exist: insert the rowid and gameid lines if debug is on // Why I exist: insert the rowid and gameid lines if debug is on
@ -37,8 +39,9 @@ public class XWThumbListPreference extends XWListPreference {
CharSequence[] newEntries = new CharSequence[6]; CharSequence[] newEntries = new CharSequence[6];
int indx = 0; int indx = 0;
String suffix = m_context.getString( R.string.pct_suffix );
for ( int pct = 20; pct <= 45; pct += 5 ) { for ( int pct = 20; pct <= 45; pct += 5 ) {
newEntries[indx++] = String.format( "%d", pct ); newEntries[indx++] = String.format( "%d%s", pct, suffix );
} }
setEntries( newEntries ); setEntries( newEntries );
setEntryValues( newEntries ); setEntryValues( newEntries );