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

Commit f19d2726 authored by Aaron Heuckroth's avatar Aaron Heuckroth
Browse files

Move grid-based Global Actions to power button when not using panel.

Use a pixel-value instead of a dp-value for defining location of the power button to ensure the menu appears in the correct place at different display sizes.
Improve separated list logic to avoid showing an empty separated list.
Switch ListGridLayout priority to minimize rows instead of columns.

Test: Automated tests pass. GA menu appears next to button when the panel is disabled (feature flag), and snaps to the bottom of the screen when the panel is enabled.
Change-Id: Ic0246dc4a2af7679e65c71ae8d9db758aeb9a3a8

Fixes: 127740041
parent 06c06b29
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,8 @@
    android:orientation="horizontal"
    android:orientation="horizontal"
    android:clipToPadding="false"
    android:clipToPadding="false"
    android:theme="@style/qs_theme"
    android:theme="@style/qs_theme"
    android:gravity="top|right"
    android:paddingLeft="@dimen/global_actions_top_padding"
    android:gravity="top|left"
    android:clipChildren="false"
    android:clipChildren="false"
>
>
    <LinearLayout
    <LinearLayout
+2 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,8 @@
    android:orientation="horizontal"
    android:orientation="horizontal"
    android:clipToPadding="false"
    android:clipToPadding="false"
    android:theme="@style/qs_theme"
    android:theme="@style/qs_theme"
    android:gravity="top|left"
    android:gravity="top|right"
    android:paddingRight="@dimen/global_actions_top_padding"
    android:clipChildren="false"
    android:clipChildren="false"
>
>
    <LinearLayout
    <LinearLayout
+2 −1
Original line number Original line Diff line number Diff line
@@ -6,8 +6,9 @@
    android:layout_height="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:orientation="horizontal"
    android:clipToPadding="false"
    android:clipToPadding="false"
    android:paddingTop="@dimen/global_actions_top_padding"
    android:theme="@style/qs_theme"
    android:theme="@style/qs_theme"
    android:gravity="bottom|center"
    android:gravity="top|center"
    android:clipChildren="false"
    android:clipChildren="false"
>
>
    <LinearLayout
    <LinearLayout
+3 −1
Original line number Original line Diff line number Diff line
@@ -865,10 +865,12 @@


    <!-- Global actions power menu -->
    <!-- Global actions power menu -->
    <dimen name="global_actions_panel_width">120dp</dimen>
    <dimen name="global_actions_panel_width">120dp</dimen>
    <dimen name="global_actions_top_padding">120dp</dimen>
    <dimen name="global_actions_padding">12dp</dimen>
    <dimen name="global_actions_padding">12dp</dimen>
    <dimen name="global_actions_translate">9dp</dimen>
    <dimen name="global_actions_translate">9dp</dimen>


    <!-- Distance from the top of screen in pixels, to position the power menu near the button. -->
    <dimen name="global_actions_top_padding">330px</dimen>

    <!-- Global actions grid layout -->
    <!-- Global actions grid layout -->
    <dimen name="global_actions_grid_side_margin">4dp</dimen>
    <dimen name="global_actions_grid_side_margin">4dp</dimen>


+11 −9
Original line number Original line Diff line number Diff line
@@ -215,7 +215,7 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
        } else {
        } else {
            rotateLeft();
            rotateLeft();
        }
        }
        if (mSeparated) {
        if (mAdapter.hasSeparatedItems()) {
            if (from == ROTATION_SEASCAPE || to == ROTATION_SEASCAPE) {
            if (from == ROTATION_SEASCAPE || to == ROTATION_SEASCAPE) {
                // Separated view has top margin, so seascape separated view need special rotation,
                // Separated view has top margin, so seascape separated view need special rotation,
                // not a full left or right rotation.
                // not a full left or right rotation.
@@ -257,10 +257,10 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {


    @Override
    @Override
    public void onUpdateList() {
    public void onUpdateList() {
        removeAllItems();
        super.onUpdateList();
        ArrayList<GlobalActionsDialog.Action> separatedActions =
        ArrayList<GlobalActionsDialog.Action> separatedActions =
                mAdapter.getSeparatedItems(mSeparated);
                mAdapter.getSeparatedItems();
        ArrayList<GlobalActionsDialog.Action> listActions = mAdapter.getListItems(mSeparated);
        ArrayList<GlobalActionsDialog.Action> listActions = mAdapter.getListItems();


        for (int i = 0; i < mAdapter.getCount(); i++) {
        for (int i = 0; i < mAdapter.getCount(); i++) {
            Object action = mAdapter.getItem(i);
            Object action = mAdapter.getItem(i);
@@ -461,8 +461,9 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
        if (mList == null) return;
        if (mList == null) return;
        // If got separated button, setRotatedBackground to false,
        // If got separated button, setRotatedBackground to false,
        // all items won't get white background.
        // all items won't get white background.
        mListBackground.setRotatedBackground(mSeparated);
        boolean separated = mAdapter.hasSeparatedItems();
        mSeparatedViewBackground.setRotatedBackground(mSeparated);
        mListBackground.setRotatedBackground(separated);
        mSeparatedViewBackground.setRotatedBackground(separated);
        if (mDivision != null && mDivision.getVisibility() == VISIBLE) {
        if (mDivision != null && mDivision.getVisibility() == VISIBLE) {
            int index = mRotatedBackground ? 0 : 1;
            int index = mRotatedBackground ? 0 : 1;
            mDivision.getLocationOnScreen(mTmp2);
            mDivision.getLocationOnScreen(mTmp2);
@@ -508,26 +509,27 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
        int screenHeight;
        int screenHeight;
        int totalHeight;
        int totalHeight;
        int targetGravity;
        int targetGravity;
        boolean separated = mAdapter.hasSeparatedItems();
        MarginLayoutParams params = (MarginLayoutParams) mSeparatedView.getLayoutParams();
        MarginLayoutParams params = (MarginLayoutParams) mSeparatedView.getLayoutParams();
        switch (RotationUtils.getRotation(getContext())) {
        switch (RotationUtils.getRotation(getContext())) {
            case RotationUtils.ROTATION_LANDSCAPE:
            case RotationUtils.ROTATION_LANDSCAPE:
                defaultTopPadding = getPaddingLeft();
                defaultTopPadding = getPaddingLeft();
                viewsTotalHeight = mList.getMeasuredWidth() + mSeparatedView.getMeasuredWidth();
                viewsTotalHeight = mList.getMeasuredWidth() + mSeparatedView.getMeasuredWidth();
                separatedViewTopMargin = mSeparated ? params.leftMargin : 0;
                separatedViewTopMargin = separated ? params.leftMargin : 0;
                screenHeight = getMeasuredWidth();
                screenHeight = getMeasuredWidth();
                targetGravity = Gravity.CENTER_HORIZONTAL|Gravity.TOP;
                targetGravity = Gravity.CENTER_HORIZONTAL|Gravity.TOP;
                break;
                break;
            case RotationUtils.ROTATION_SEASCAPE:
            case RotationUtils.ROTATION_SEASCAPE:
                defaultTopPadding = getPaddingRight();
                defaultTopPadding = getPaddingRight();
                viewsTotalHeight = mList.getMeasuredWidth() + mSeparatedView.getMeasuredWidth();
                viewsTotalHeight = mList.getMeasuredWidth() + mSeparatedView.getMeasuredWidth();
                separatedViewTopMargin = mSeparated ? params.leftMargin : 0;
                separatedViewTopMargin = separated ? params.leftMargin : 0;
                screenHeight = getMeasuredWidth();
                screenHeight = getMeasuredWidth();
                targetGravity = Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM;
                targetGravity = Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM;
                break;
                break;
            default: // Portrait
            default: // Portrait
                defaultTopPadding = getPaddingTop();
                defaultTopPadding = getPaddingTop();
                viewsTotalHeight = mList.getMeasuredHeight() + mSeparatedView.getMeasuredHeight();
                viewsTotalHeight = mList.getMeasuredHeight() + mSeparatedView.getMeasuredHeight();
                separatedViewTopMargin = mSeparated ? params.topMargin : 0;
                separatedViewTopMargin = separated ? params.topMargin : 0;
                screenHeight = getMeasuredHeight();
                screenHeight = getMeasuredHeight();
                targetGravity = Gravity.CENTER_VERTICAL|Gravity.RIGHT;
                targetGravity = Gravity.CENTER_VERTICAL|Gravity.RIGHT;
                break;
                break;
Loading