express thumb size as percent of screen with options, generated, in 5%

increments.
This commit is contained in:
Eric House 2013-11-21 06:27:09 -08:00
parent b874406b7b
commit 7be3a3bef8
5 changed files with 59 additions and 39 deletions

View file

@ -57,7 +57,7 @@
<string name="key_notify_vibrate">key_notify_vibrate</string>
<string name="key_enable_sms">key_enable_sms</string>
<string name="key_keep_screenon">key_keep_screenon</string>
<string name="key_thumbsize">key_thumbsize2</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>
@ -148,13 +148,6 @@
<string name="enable_dupes_title">Accept duplicate invites</string>
<string name="enable_dupes_summary">Accept invitations more than once</string>
<string name="game_thumb_half">1/2</string>
<string name="game_thumb_third">1/3</string>
<string name="game_thumb_quarter">1/4</string>
<string name="game_thumb_fifth">1/5</string>
<string name="game_thumb_sixth">1/6</string>
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->
<string-array name="board_sizes">
@ -301,12 +294,4 @@
<item>@string/confirm_sms_willpay</item>
</string-array>
<string-array name="game_thumb_values">
<item>@string/game_thumb_half</item>
<item>@string/game_thumb_third</item>
<item>@string/game_thumb_quarter</item>
<item>@string/game_thumb_fifth</item>
<item>@string/game_thumb_sixth</item>
</string-array>
</resources>

View file

@ -119,12 +119,10 @@
android:defaultValue="true"
/>
<org.eehouse.android.xw4.XWListPreference
<org.eehouse.android.xw4.XWThumbListPreference
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_third"
android:defaultValue="30"
/>
</PreferenceScreen>

View file

@ -324,8 +324,8 @@ public class GameUtils {
if ( BuildConstants.THUMBNAIL_SUPPORTED ) {
if ( XWPrefs.getThumbEnabled( activity ) ) {
int nCols = gi.boardSize;
int scale = XWPrefs.getThumbScale( activity );
Assert.assertTrue( 0 < scale );
int pct = XWPrefs.getThumbPct( activity );
Assert.assertTrue( 0 < pct );
if ( null == s_minScreen ) {
Display display =
@ -334,7 +334,7 @@ public class GameUtils {
int height = display.getHeight();
s_minScreen = new Integer( Math.min( width, height ) );
}
int dim = s_minScreen / scale;
int dim = s_minScreen * pct / 100;
int size = dim - (dim % nCols);
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );

View file

@ -347,24 +347,15 @@ public class XWPrefs {
return getPrefsBoolean( context, R.string.key_thumb_enabled, false );
}
public static int getThumbScale( Context context )
public static int getThumbPct( Context context )
{
String scale = getPrefsString( context, R.string.key_thumbsize );
int result = -1;
final int[][] data = {
{ R.string.game_thumb_half, 2 }
,{ R.string.game_thumb_third, 3 }
,{ R.string.game_thumb_quarter, 4 }
,{ R.string.game_thumb_fifth, 5 }
,{ R.string.game_thumb_sixth, 6 }
};
for ( int[] datum : data ) {
if ( context.getString(datum[0]).equals(scale) ) {
result = datum[1];
break;
}
String pct = getPrefsString( context, R.string.key_thumbsize );
int result = 30;
if ( null != pct && 2 <= pct.length() ) {
// result = Integer.parseInt( pct.substring( 0, pct.length() - 1 ) );
result = Integer.parseInt( pct );
}
DbgUtils.logf( "pct: %s => %d", pct, result );
return result;
}

View file

@ -0,0 +1,46 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/*
* Copyright 2010 - 2011 by Eric House (xwords@eehouse.org). All
* rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.eehouse.android.xw4;
import android.content.Context;
import android.util.AttributeSet;
public class XWThumbListPreference extends XWListPreference {
public XWThumbListPreference( Context context, AttributeSet attrs )
{
super( context, attrs );
}
// Why I exist: insert the rowid and gameid lines if debug is on
protected void onAttachedToActivity()
{
super.onAttachedToActivity();
CharSequence[] newEntries = new CharSequence[6];
int indx = 0;
for ( int pct = 20; pct <= 45; pct += 5 ) {
newEntries[indx++] = String.format( "%d", pct );
}
setEntries( newEntries );
setEntryValues( newEntries );
}
}