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

Commit 75e249f6 authored by Aaron Heuckroth's avatar Aaron Heuckroth
Browse files

Add rotation support to grid-based global actions menu.

Test: All automated tests should pass. Rotating the phone with the GAM displayed should result in both the container and icon views staying in the same physical position relative to the device.
Change-Id: Ia1ba6265fb954ea9908ddb618569ca018297c82d
parent d120e754
Loading
Loading
Loading
Loading
+80 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.globalactions.GlobalActionsGridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/global_actions_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:clipToPadding="false"
    android:theme="@style/qs_theme"
    android:gravity="top|right"
    android:clipChildren="false"
>

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:gravity="top|right"
        android:padding="0dp"
        android:orientation="vertical"
        android:layoutDirection="ltr"
        android:layout_marginRight="@dimen/global_actions_grid_container_bottom_margin"
    >
        <!-- Grid of action items -->
        <com.android.systemui.globalactions.ListGridLayout
            android:id="@android:id/list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layoutDirection="ltr"
            android:layout_marginTop="@dimen/global_actions_grid_side_margin"
            android:translationZ="@dimen/global_actions_translate"
            android:paddingLeft="@dimen/global_actions_grid_top_padding"
            android:paddingRight="@dimen/global_actions_grid_bottom_padding"
            android:paddingTop="@dimen/global_actions_grid_left_padding"
            android:paddingBottom="@dimen/global_actions_grid_right_padding"
            android:background="?android:attr/colorBackgroundFloating"
        >
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="ltr"
                android:orientation="horizontal"
            />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="ltr"
                android:orientation="horizontal"
            />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="ltr"
                android:orientation="horizontal"
            />
        </com.android.systemui.globalactions.ListGridLayout>

        <!-- For separated items-->
        <LinearLayout
            android:id="@+id/separated_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/global_actions_grid_side_margin"
            android:layout_marginBottom="@dimen/global_actions_grid_side_margin"
            android:paddingTop="@dimen/global_actions_grid_left_padding"
            android:paddingLeft="@dimen/global_actions_grid_top_padding"
            android:paddingBottom="@dimen/global_actions_grid_right_padding"
            android:paddingRight="@dimen/global_actions_grid_bottom_padding"
            android:orientation="horizontal"
            android:layoutDirection="ltr"
            android:background="?android:attr/colorBackgroundFloating"
            android:translationZ="@dimen/global_actions_translate"
        />

    </LinearLayout>

</com.android.systemui.globalactions.GlobalActionsGridLayout>
+82 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<com.android.systemui.globalactions.GlobalActionsGridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@id/global_actions_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:clipToPadding="false"
    android:theme="@style/qs_theme"
    android:gravity="top|left"
    android:clipChildren="false"
>

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:gravity="bottom|left"
        android:padding="0dp"
        android:orientation="vertical"
        android:layout_marginLeft="@dimen/global_actions_grid_container_bottom_margin"
    >
        <!-- For separated items-->
        <LinearLayout
            android:id="@+id/separated_button"
            android:layout_gravity="top|left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/global_actions_grid_side_margin"
            android:layout_marginBottom="@dimen/global_actions_grid_side_margin"
            android:paddingTop="@dimen/global_actions_grid_left_padding"
            android:paddingLeft="@dimen/global_actions_grid_top_padding"
            android:paddingBottom="@dimen/global_actions_grid_right_padding"
            android:paddingRight="@dimen/global_actions_grid_bottom_padding"
            android:orientation="horizontal"
            android:layoutDirection="rtl"
            android:background="?android:attr/colorBackgroundFloating"
            android:translationZ="@dimen/global_actions_translate"
        />

        <!-- Grid of action items -->
        <com.android.systemui.globalactions.ListGridLayout
            android:id="@android:id/list"
            android:layout_gravity="bottom|left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="@dimen/global_actions_grid_side_margin"
            android:translationZ="@dimen/global_actions_translate"
            android:paddingLeft="@dimen/global_actions_grid_top_padding"
            android:paddingRight="@dimen/global_actions_grid_bottom_padding"
            android:paddingTop="@dimen/global_actions_grid_left_padding"
            android:paddingBottom="@dimen/global_actions_grid_right_padding"
            android:background="?android:attr/colorBackgroundFloating"
        >
            <LinearLayout
                android:layout_gravity="bottom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="rtl"
                android:orientation="horizontal"
            />
            <LinearLayout
                android:layout_gravity="bottom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="rtl"
                android:orientation="horizontal"
            />
            <LinearLayout
                android:layout_gravity="bottom"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                android:layoutDirection="rtl"
                android:orientation="horizontal"
            />
        </com.android.systemui.globalactions.ListGridLayout>
    </LinearLayout>

</com.android.systemui.globalactions.GlobalActionsGridLayout>
+4 −13
Original line number Diff line number Diff line
@@ -12,10 +12,11 @@
>

    <LinearLayout
        android:layout_height="290dp"
        android:layout_width="412dp"
        android:gravity="bottom"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:gravity="bottom | right"
        android:padding="0dp"
        android:layoutDirection="ltr"
        android:layout_marginBottom="@dimen/global_actions_grid_container_bottom_margin"
    >
        <!-- For separated items-->
@@ -34,15 +35,11 @@
            android:translationZ="@dimen/global_actions_translate"
        />

        <Space android:layout_width="match_parent" android:layout_height="2dp"
               android:layout_weight="1" />

        <!-- Grid of action items -->
        <com.android.systemui.globalactions.ListGridLayout
            android:id="@android:id/list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="right"
            android:orientation="horizontal"
            android:layoutDirection="rtl"
            android:layout_marginRight="@dimen/global_actions_grid_side_margin"
@@ -56,25 +53,19 @@
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|right"
                android:visibility="gone"
                android:gravity="bottom"
                android:orientation="vertical"
            />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|right"
                android:visibility="gone"
                android:gravity="bottom"
                android:orientation="vertical"
            />
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|right"
                android:visibility="gone"
                android:gravity="bottom"
                android:orientation="vertical"
            />
        </com.android.systemui.globalactions.ListGridLayout>
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
        android:gravity="center"
        android:textSize="12sp"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:singleLine="true"
    />

    <TextView
@@ -57,5 +58,6 @@
        android:gravity="center"
        android:textColor="?android:attr/textColorTertiary"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:singleLine="true"
    />
</LinearLayout>
+4 −19
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Configuration;
import android.provider.Settings;
import android.util.AttributeSet;
import android.view.Gravity;
@@ -59,7 +58,6 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
    private int mEndPoint;
    private boolean mEdgeBleed;
    private boolean mRoundedDivider;
    private int mRotation = ROTATION_NONE;
    private boolean mRotatedBackground;
    private boolean mSwapOrientation = true;

@@ -89,7 +87,7 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
    }

    @Override
    public ViewGroup getParentView(boolean separated, int index) {
    public ViewGroup getParentView(boolean separated, int index, boolean reverse) {
        if (separated) {
            return getSeparatedView();
        } else {
@@ -174,7 +172,6 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
                mSeparatedView.setBackground(mSeparatedViewBackground);
                updateEdgeMargin(mEdgeBleed ? 0 : getEdgePadding());
                mOldHeight = mList.getMeasuredHeight();
                updateRotation();
            } else {
                return;
            }
@@ -188,25 +185,13 @@ public class HardwareUiLayout extends MultiListLayout implements Tunable {
        post(() -> updatePosition());
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        updateRotation();
    }

    public void setSwapOrientation(boolean swapOrientation) {
        mSwapOrientation = swapOrientation;
    }

    private void updateRotation() {
        int rotation = RotationUtils.getRotation(getContext());
        if (rotation != mRotation) {
            rotate(mRotation, rotation);
            mRotation = rotation;
        }
    }

    private void rotate(int from, int to) {
    @Override
    protected void rotate(int from, int to) {
        super.rotate(from, to);
        if (from != ROTATION_NONE && to != ROTATION_NONE) {
            // Rather than handling this confusing case, just do 2 rotations.
            rotate(from, ROTATION_NONE);
Loading