combine thumbnail prefs to reduce nesting

This commit is contained in:
Eric House 2013-11-25 07:58:11 -08:00
parent 0b00f303bb
commit 42800851d3
6 changed files with 22 additions and 33 deletions

View file

@ -58,7 +58,6 @@
<string name="key_enable_sms">key_enable_sms</string> <string name="key_enable_sms">key_enable_sms</string>
<string name="key_keep_screenon">key_keep_screenon</string> <string name="key_keep_screenon">key_keep_screenon</string>
<string name="key_thumbsize">key_thumbsize3</string> <string name="key_thumbsize">key_thumbsize3</string>
<string name="key_thumb_enabled">key_thumb_disabled</string>
<string name="key_summary_field">key_summary_field</string> <string name="key_summary_field">key_summary_field</string>
<string name="key_default_loc">key_default_loc</string> <string name="key_default_loc">key_default_loc</string>

View file

@ -2166,13 +2166,11 @@
<string name="sel_gamesf">Games: %d</string> <string name="sel_gamesf">Games: %d</string>
<string name="sel_groupsf">Groups: %d</string> <string name="sel_groupsf">Groups: %d</string>
<string name="summary_thumbsize">Thumbnail size</string> <string name="summary_thumbsize">Thumbnail size</string>
<string name="thumb_off">Disabled</string>
<string name="sel_dictsf">Wordlists: %d</string> <string name="sel_dictsf">Wordlists: %d</string>
<string name="thumb_enabled">Show thumbnails</string> <!-- <string name="summary_thumb_enabled">Display snapshots of games</string> -->
<string name="summary_thumb_enabled">Display snapshots of games</string>
<string name="prefs_thumb">Thumbnails</string>
<string name="prefs_thumb_summary">Setting for game snapshots</string>
<string name="dropped_dupe">Invitation received but ignored: it <string name="dropped_dupe">Invitation received but ignored: it
has already been used to create a game.</string> has already been used to create a game.</string>
<string name="cur_menu_markerf">%1$s (yours)</string> <string name="cur_menu_markerf">%1$s (yours)</string>

View file

@ -110,14 +110,6 @@
<PreferenceScreen android:title="@string/prefs_appearance" <PreferenceScreen android:title="@string/prefs_appearance"
android:summary="@string/prefs_appearance_summary" android:summary="@string/prefs_appearance_summary"
> >
<PreferenceScreen android:title="@string/prefs_thumb"
android:summary="@string/prefs_thumb_summary"
>
<CheckBoxPreference android:key="@string/key_thumb_enabled"
android:title="@string/thumb_enabled"
android:summary="@string/summary_thumb_enabled"
android:defaultValue="true"
/>
<!-- " pct." below must match R.string.pct_suffix --> <!-- " pct." below must match R.string.pct_suffix -->
<org.eehouse.android.xw4.XWThumbListPreference <org.eehouse.android.xw4.XWThumbListPreference
@ -125,7 +117,6 @@
android:title="@string/summary_thumbsize" android:title="@string/summary_thumbsize"
android:defaultValue="30 pct." android:defaultValue="30 pct."
/> />
</PreferenceScreen>
<org.eehouse.android.xw4.XWSumListPreference <org.eehouse.android.xw4.XWSumListPreference
android:key="@string/key_summary_field" android:key="@string/key_summary_field"

View file

@ -45,7 +45,6 @@ public class PrefsActivity extends PreferenceActivity
private String m_smsToasting; private String m_smsToasting;
private String m_smsEnable; private String m_smsEnable;
private String m_downloadPath; private String m_downloadPath;
private String m_thumbEnabled;
private String m_thumbSize; private String m_thumbSize;
private String m_hideTitle; private String m_hideTitle;
@ -137,7 +136,6 @@ public class PrefsActivity extends PreferenceActivity
m_smsToasting = getString( R.string.key_show_sms ); m_smsToasting = getString( R.string.key_show_sms );
m_smsEnable = getString( R.string.key_enable_sms ); m_smsEnable = getString( R.string.key_enable_sms );
m_downloadPath = getString( R.string.key_download_path ); m_downloadPath = getString( R.string.key_download_path );
m_thumbEnabled = getString( R.string.key_thumb_enabled );
m_thumbSize = getString( R.string.key_thumbsize ); m_thumbSize = getString( R.string.key_thumbsize );
m_hideTitle = getString( R.string.key_hide_title ); m_hideTitle = getString( R.string.key_hide_title );
@ -202,8 +200,7 @@ public class PrefsActivity extends PreferenceActivity
} }
} }
DictUtils.invalDictList(); DictUtils.invalDictList();
} else if ( key.equals( m_thumbEnabled ) } else if ( key.equals( m_thumbSize ) ) {
|| key.equals( m_thumbSize ) ) {
DBUtils.clearThumbnails( this ); DBUtils.clearThumbnails( this );
} else if ( key.equals( m_hideTitle ) ) { } else if ( key.equals( m_hideTitle ) ) {
if ( sp.getBoolean( key, false ) && ABUtils.haveActionBar() ) { if ( sp.getBoolean( key, false ) && ABUtils.haveActionBar() ) {

View file

@ -344,13 +344,16 @@ public class XWPrefs {
public static boolean getThumbEnabled( Context context ) public static boolean getThumbEnabled( Context context )
{ {
return getPrefsBoolean( context, R.string.key_thumb_enabled, false ); return 0 < getThumbPct( context );
} }
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; int result;
if ( context.getString( R.string.thumb_off ).equals( pct ) ) {
result = 0;
} else {
try { try {
String suffix = context.getString( R.string.pct_suffix ); String suffix = context.getString( R.string.pct_suffix );
result = Integer.parseInt( pct.substring( 0, pct.length() result = Integer.parseInt( pct.substring( 0, pct.length()
@ -358,7 +361,7 @@ public class XWPrefs {
} catch (Exception ex ) { } catch (Exception ex ) {
result = 30; result = 30;
} }
DbgUtils.logf( "pct: %s => %d", pct, result ); }
return result; return result;
} }

View file

@ -37,8 +37,9 @@ public class XWThumbListPreference extends XWListPreference {
{ {
super.onAttachedToActivity(); super.onAttachedToActivity();
CharSequence[] newEntries = new CharSequence[6]; CharSequence[] newEntries = new CharSequence[7];
int indx = 0; int indx = 0;
newEntries[indx++] = m_context.getString( R.string.thumb_off );
String suffix = m_context.getString( R.string.pct_suffix ); 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%s", pct, suffix ); newEntries[indx++] = String.format( "%d%s", pct, suffix );