From 669d442509c2b6d38f5a1ba9ccfed8d5d22bf21b Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Mon, 27 Dec 2010 12:50:17 -0800 Subject: Add theme flags to resize background the same way we resize icons so everything is the same size diff --git a/src/net/hoopajoo/android/SoftKeys/Generator.java b/src/net/hoopajoo/android/SoftKeys/Generator.java index f851e3d..42bd57e 100644 --- a/src/net/hoopajoo/android/SoftKeys/Generator.java +++ b/src/net/hoopajoo/android/SoftKeys/Generator.java @@ -64,6 +64,10 @@ public class Generator { ); if( d != null ) { + // resize? + if( theme.getBoolean( new String[] { prefix + "_resize_background", "resize_background" } ) ) { + d = resizeImage( d, iconSize, iconSize ); + } container.setBackgroundDrawable( d ); } @@ -130,6 +134,14 @@ public class Generator { ); if( d != null ) { + if( theme.getBoolean( new String[] { + prefix + "_resize_button_background_" + name, + prefix + "_resize_button_background", + "resize_button_background_" + name, + "resize_button_background" } ) ) { + d = resizeImage( d, iconSize, iconSize ); + } + b.setBackgroundDrawable( d ); } @@ -171,7 +183,12 @@ public class Generator { Matrix matrix = new Matrix(); matrix.postScale( scaleWidth, scaleHeight); - return new BitmapDrawable( Bitmap.createBitmap(b, 0, 0, width, height, matrix, true) ); + BitmapDrawable ret = new BitmapDrawable( Bitmap.createBitmap(b, 0, 0, width, height, matrix, true) ); + // copy tile mode + if( d instanceof BitmapDrawable ) { + ret.setTileModeXY( ( (BitmapDrawable)d ).getTileModeX(), ( (BitmapDrawable)d ).getTileModeY() ); + } + return ret; } } \ No newline at end of file diff --git a/src/net/hoopajoo/android/SoftKeys/Theme.java b/src/net/hoopajoo/android/SoftKeys/Theme.java index 9a886c7..310fd31 100644 --- a/src/net/hoopajoo/android/SoftKeys/Theme.java +++ b/src/net/hoopajoo/android/SoftKeys/Theme.java @@ -69,6 +69,32 @@ public class Theme { return( null ); } + // these check theme config flags + public boolean getBoolean( String[] name ) { + return getBoolean( name, false ); + } + + public boolean getBoolean( String[] name, boolean def ) { + String flag = getString( name ); + if( flag != null ) { + // t/true is true, everything else is false + if( flag.startsWith( "t" ) ) { + return( true ); + } + return( false ); + } + + return( def ); + } + + public String getString( String[] name ) { + IdPack i = getId( name, "string" ); + if( i != null ) { + return i.R.getString( i.id ); + } + return( null ); + } + // For use mostly with the notification bar, allowing custom themes to include // new icons primarily, but since it's a layout they can do more than that public RemoteViews getRemoteViews( String[] name ) { -- cgit v0.10.2