From 6f84379257c7c95b35427a64c4aa5e09f619fea4 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Mon, 27 Dec 2010 16:48:12 -0800 Subject: Correctly handle hiding background for button_container views created from xml that have been nested inside another viewgroup 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 ) ); + } + } + } } -- cgit v0.10.2