diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2010-12-28 00:48:12 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2010-12-28 00:48:12 (GMT) |
commit | 6f84379257c7c95b35427a64c4aa5e09f619fea4 (patch) | |
tree | ebd8b25912e4cef402d2078891048c1470a7345d /src | |
parent | bf52c9978704a78ca04f21da1a71255f64f67986 (diff) | |
download | SoftKeys-6f84379257c7c95b35427a64c4aa5e09f619fea4.zip SoftKeys-6f84379257c7c95b35427a64c4aa5e09f619fea4.tar.gz SoftKeys-6f84379257c7c95b35427a64c4aa5e09f619fea4.tar.bz2 |
Correctly handle hiding background for button_container views created from
xml that have been nested inside another viewgroup
Diffstat (limited to 'src')
-rw-r--r-- | src/net/hoopajoo/android/SoftKeys/SoftKeysService.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java index 0de7e42..faa2a14 100644 --- a/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java +++ b/src/net/hoopajoo/android/SoftKeys/SoftKeysService.java @@ -258,7 +258,8 @@ public class SoftKeysService extends Service { // insert the container ViewGroup container = (ViewGroup)Generator.createButtonContainer( this, 0, buttonMult, "service", (ViewGroup)mView.findViewById( R.id.main_view ) ); - container.removeView( container.findViewById( R.id.settings ) ); // no settings in service + // container may not be button_container for a custom xml view + ((LinearLayout)mView.findViewById( R.id.button_container )).removeView( container.findViewById( R.id.settings ) ); // no settings in service // arrange buttons Keys.applyButtons( settings, mView, c, longpress, touch, true ); @@ -270,8 +271,7 @@ public class SoftKeysService extends Service { if( settings.getBoolean( "service_no_background", false ) ) { // make button container transparent - ((LinearLayout)mView.findViewById( R.id.button_container )).setBackgroundResource( 0 ); - ((LinearLayout)mView.findViewById( R.id.button_container )).setPadding( 0, 0, 0, 0 ); + recursivelyBlank( container ); } // Put together the popper @@ -437,4 +437,21 @@ public class SoftKeysService extends Service { // need to create an animation controller since its empty by default and the animation doesn't work ((ViewGroup)v).setLayoutAnimation( new LayoutAnimationController( alpha, 0 ) ); } + + private void recursivelyBlank( View v ) { + // we walk this view and children and keep removing backgrounds and padding until we hit + if( v instanceof ImageButton ) { + return; + } + + v.setBackgroundColor( 0 ); + v.setPadding( 0, 0, 0, 0 ); + + if( v instanceof ViewGroup ) { + ViewGroup g = (ViewGroup)v; + for( int i = 0; i < g.getChildCount(); i++ ) { + recursivelyBlank( g.getChildAt( i ) ); + } + } + } } |