Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c02ae245 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

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
parent ec2df26d
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -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))