new separate set of three prefs for thumbnails, and make the first,

enable/disable, work.
This commit is contained in:
Eric House 2013-11-07 19:07:19 -08:00
parent fba7aee83a
commit 41df94af31
7 changed files with 56 additions and 26 deletions

View file

@ -58,6 +58,9 @@
<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_thumbsize2</string> <string name="key_thumbsize">key_thumbsize2</string>
<string name="key_thumb_disabled">key_thumb_disabled</string>
<string name="key_thumb_useactive">key_thumb_useactive</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>
@ -136,7 +139,6 @@
<string name="gamel_menu_storedb">Write DB to SD card</string> <string name="gamel_menu_storedb">Write DB to SD card</string>
<string name="gamel_menu_loaddb">Load DB from SD card</string> <string name="gamel_menu_loaddb">Load DB from SD card</string>
<string name="game_thumb_off">Off</string>
<string name="game_thumb_third">1/3</string> <string name="game_thumb_third">1/3</string>
<string name="game_thumb_quarter">1/4</string> <string name="game_thumb_quarter">1/4</string>
<string name="game_thumb_fifth">1/5</string> <string name="game_thumb_fifth">1/5</string>
@ -289,7 +291,6 @@
</string-array> </string-array>
<string-array name="game_thumb_values"> <string-array name="game_thumb_values">
<item>@string/game_thumb_off</item>
<item>@string/game_thumb_third</item> <item>@string/game_thumb_third</item>
<item>@string/game_thumb_quarter</item> <item>@string/game_thumb_quarter</item>
<item>@string/game_thumb_fifth</item> <item>@string/game_thumb_fifth</item>

View file

@ -1853,7 +1853,7 @@
<!-- --> <!-- -->
<string name="email_body_revf">(If relevant, please include the <string name="email_body_revf">(If relevant, please include the
version: \"%s\"; and make/model of your phone or version: \"%s\"; and make/model of your phone or
tablet.)"</string> tablet.)</string>
<string name="newgame_enable_bt">Turn Bluetooth on</string> <string name="newgame_enable_bt">Turn Bluetooth on</string>
@ -2154,8 +2154,17 @@
now clears any selection instead of exiting. Hit it again to exit now clears any selection instead of exiting. Hit it again to exit
the app.</string> the app.</string>
<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="sel_dictsf">Wordlists: %d"</string> <string name="sel_dictsf">Wordlists: %d</string>
<string name="thumb_disabled">Thumb disabled</string>
<string name="summary_thumb_disabled">Summayr thumb disbled</string>
<string name="thumb_useactive">thumb_useactive</string>
<string name="summary_thumb_useactive">summary_thumb_useactive</string>
<string name="prefs_thumb">Thumbnail prefs</string>
<string name="prefs_thumb_summary">prefs_thumb_summary</string>
</resources> </resources>

View file

@ -138,13 +138,29 @@
android:defaultValue="false" android:defaultValue="false"
/> />
<org.eehouse.android.xw4.XWListPreference <PreferenceScreen android:title="@string/prefs_thumb"
android:key="@string/key_thumbsize" android:summary="@string/prefs_thumb_summary"
android:title="@string/summary_thumbsize" >
android:entries="@array/game_thumb_values" <CheckBoxPreference android:key="@string/key_thumb_disabled"
android:entryValues="@array/game_thumb_values" android:title="@string/thumb_disabled"
android:defaultValue="@string/game_thumb_quarter" android:summary="@string/summary_thumb_disabled"
/> android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_thumb_useactive"
android:title="@string/thumb_useactive"
android:summary="@string/summary_thumb_useactive"
android:defaultValue="true"
/>
<org.eehouse.android.xw4.XWListPreference
android:key="@string/key_thumbsize"
android:title="@string/summary_thumbsize"
android:entries="@array/game_thumb_values"
android:entryValues="@array/game_thumb_values"
android:defaultValue="@string/game_thumb_quarter"
/>
</PreferenceScreen>
<PreferenceScreen android:title="@string/prefs_colors" <PreferenceScreen android:title="@string/prefs_colors"
android:summary="@string/prefs_colors_summary" android:summary="@string/prefs_colors_summary"

View file

@ -2059,8 +2059,9 @@ public class BoardActivity extends XWActivity
{ {
if ( GitVersion.THUMBNAIL_SUPPORTED ) { if ( GitVersion.THUMBNAIL_SUPPORTED ) {
Bitmap thumb = null; Bitmap thumb = null;
int scale = XWPrefs.getThumbScale( this ); if ( XWPrefs.getThumbEnabled( this ) ) {
if ( 0 < scale ) { int scale = XWPrefs.getThumbScale( this );
Assert.assertTrue( 0 < scale );
final int size = 15 * (9 + scale); final int size = 15 * (9 + scale);
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 ); thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );

View file

@ -443,7 +443,8 @@ public class DBUtils {
synchronized( s_dbHelper ) { synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase(); SQLiteDatabase db = s_dbHelper.getWritableDatabase();
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
String selection = String.format( ROW_ID_FMT, lock.getRowid() ); long rowid = lock.getRowid();
String selection = String.format( ROW_ID_FMT, rowid );
if ( null == thumb ) { if ( null == thumb ) {
DbgUtils.logf( "clearing thumbnail" ); DbgUtils.logf( "clearing thumbnail" );
@ -459,6 +460,8 @@ public class DBUtils {
Assert.assertTrue( result >= 0 ); Assert.assertTrue( result >= 0 );
db.close(); db.close();
notifyListeners( rowid, false );
} }
} }
} }

View file

@ -188,7 +188,9 @@ public class GameListItem extends LinearLayout
R.drawable.expander_ic_minimized); R.drawable.expander_ic_minimized);
m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE ); m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE );
if ( GitVersion.THUMBNAIL_SUPPORTED ) { if ( GitVersion.THUMBNAIL_SUPPORTED ) {
m_thumb.setVisibility( m_expanded ? View.VISIBLE : View.GONE ); int vis = m_expanded && XWPrefs.getThumbEnabled( m_context )
? View.VISIBLE : View.GONE;
m_thumb.setVisibility( vis );
} }
m_name.setBackgroundColor( android.R.color.transparent ); m_name.setBackgroundColor( android.R.color.transparent );
@ -299,12 +301,7 @@ public class GameListItem extends LinearLayout
if ( GitVersion.THUMBNAIL_SUPPORTED ) { if ( GitVersion.THUMBNAIL_SUPPORTED ) {
m_thumb = (ImageView)findViewById( R.id.thumbnail ); m_thumb = (ImageView)findViewById( R.id.thumbnail );
Bitmap bmp = summary.getThumbnail(); m_thumb.setImageBitmap( summary.getThumbnail() );
if ( null == bmp ) {
m_thumb.setVisibility( View.GONE );
} else {
m_thumb.setImageBitmap( bmp );
}
} }
tview = (TextView)findViewById( R.id.role ); tview = (TextView)findViewById( R.id.role );

View file

@ -328,13 +328,16 @@ public class XWPrefs {
return posns; return posns;
} }
public static boolean getThumbEnabled( Context context )
{
return !getPrefsBoolean( context, R.string.key_thumb_disabled, false );
}
public static int getThumbScale( Context context ) public static int getThumbScale( Context context )
{ {
String scale = getPrefsString( context, R.string.key_thumbsize ); String scale = getPrefsString( context, R.string.key_thumbsize );
int result = -1; int result = -1;
if ( context.getString(R.string.game_thumb_off).equals(scale) ) { if ( context.getString(R.string.game_thumb_third).equals(scale) ) {
result = 0;
} else if ( context.getString(R.string.game_thumb_third).equals(scale) ) {
result = 3; result = 3;
} else if ( context.getString(R.string.game_thumb_quarter).equals(scale) ) { } else if ( context.getString(R.string.game_thumb_quarter).equals(scale) ) {
result = 4; result = 4;