From c02ae2457a11e4631f4593480c4905424d024018 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Sun, 29 Jul 2012 23:55:17 +0200 Subject: Fix 5761: Power widget bar widens if >6 toggle buttons enabled If more that 6 button widgets are enabled in the power widget, and hide scrollbar is active, the space of the scrollbars is not recovered This change make 2 modifications: - Recreate the button layout, when a EXPANDED_HIDE_SCROLLBAR is received, instead of only update the scrollview. This remove the scrollview if it is not needed. - Move the setPadding of the buttonLayout to updateScrollbar to determine the correct botton padding Change-Id: Ib8f149d9d220391ea0606da2252df4ace8cd7611 --- .../systemui/statusbar/powerwidget/PowerWidget.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerWidget.java b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerWidget.java index 5f8f91f..1fc48d9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerWidget.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/powerwidget/PowerWidget.java @@ -272,11 +272,6 @@ public class PowerWidget extends FrameLayout { mScrollView.setFadingEdgeLength(mContext.getResources().getDisplayMetrics().widthPixels / LAYOUT_SCROLL_BUTTON_THRESHOLD); mScrollView.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); mScrollView.setOverScrollMode(View.OVER_SCROLL_NEVER); - // set the padding on the linear layout to the size of our scrollbar, so we don't have them overlap - mButtonLayout.setPadding(mButtonLayout.getPaddingLeft(), - mButtonLayout.getPaddingTop(), - mButtonLayout.getPaddingRight(), - mScrollView.getVerticalScrollbarWidth()); mScrollView.addView(mButtonLayout, WIDGET_LAYOUT_PARAMS); updateScrollbar(); addView(mScrollView, WIDGET_LAYOUT_PARAMS); @@ -370,6 +365,15 @@ public class PowerWidget extends FrameLayout { boolean hideScrollBar = Settings.System.getInt(mContext.getContentResolver(), Settings.System.EXPANDED_HIDE_SCROLLBAR, 0) == 1; mScrollView.setHorizontalScrollBarEnabled(!hideScrollBar); + + // set the padding on the linear layout to the size of our scrollbar, + // so we don't have them overlap + // need to be here for make use of EXPANDED_HIDE_SCROLLBAR, expanding or collapsing + // the space used by the scrollbar + if (mButtonLayout != null) { + mButtonLayout.setPadding(0, 0, 0, + !hideScrollBar ? mScrollView.getVerticalScrollbarWidth() : 0); + } } private void updateHapticFeedbackSetting() { @@ -486,7 +490,8 @@ public class PowerWidget extends FrameLayout { updateVisibility(); // now check for scrollbar hiding } else if(uri.equals(Settings.System.getUriFor(Settings.System.EXPANDED_HIDE_SCROLLBAR))) { - updateScrollbar(); + // Needed to remove scrollview to gain the space of the scrollable area + recreateButtonLayout(); } if (uri.equals(Settings.System.getUriFor(Settings.System.HAPTIC_FEEDBACK_ENABLED)) -- cgit v1.1