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

Commit 0e2ca773 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Also factor the floating rotation button into the active touch region"

parents ab928b02 3e64e959
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.policy.KeyButtonDrawable;
import com.android.systemui.statusbar.policy.KeyButtonView;

import java.util.function.Consumer;

/** Containing logic for the rotation button on the physical left bottom corner of the screen. */
public class FloatingRotationButton implements RotationButton {

@@ -45,6 +47,7 @@ public class FloatingRotationButton implements RotationButton {
    private boolean mCanShow = true;

    private RotationButtonController mRotationButtonController;
    private Consumer<Boolean> mVisibilityChangedCallback;

    FloatingRotationButton(Context context) {
        mContext = context;
@@ -66,6 +69,11 @@ public class FloatingRotationButton implements RotationButton {
                mRotationButtonController.getDarkIconColor());
    }

    @Override
    public void setVisibilityChangedCallback(Consumer<Boolean> visibilityChangedCallback) {
        mVisibilityChangedCallback = visibilityChangedCallback;
    }

    @Override
    public View getCurrentView() {
        return mKeyButtonView;
@@ -105,6 +113,16 @@ public class FloatingRotationButton implements RotationButton {
            mKeyButtonDrawable.resetAnimation();
            mKeyButtonDrawable.startAnimation();
        }
        mKeyButtonView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5,
                    int i6, int i7) {
                if (mIsShowing && mVisibilityChangedCallback != null) {
                    mVisibilityChangedCallback.accept(true);
                }
                mKeyButtonView.removeOnLayoutChangeListener(this);
            }
        });
        return true;
    }

@@ -115,6 +133,9 @@ public class FloatingRotationButton implements RotationButton {
        }
        mWindowManager.removeViewImmediate(mKeyButtonView);
        mIsShowing = false;
        if (mVisibilityChangedCallback != null) {
            mVisibilityChangedCallback.accept(false);
        }
        return true;
    }

+1 −11
Original line number Diff line number Diff line
@@ -354,15 +354,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
                }
            };

    private final ContextButtonListener mRotationButtonListener = (button, visible) -> {
        if (visible) {
            // If the button will actually become visible and the navbar is about to hide,
            // tell the statusbar to keep it around for longer
            mAutoHideController.touchAutoHide();
            mNavigationBarView.notifyActiveTouchRegions();
        }
    };

    private final Runnable mAutoDim = () -> getBarTransitions().setAutoDim(true);

    private final ContentObserver mAssistContentObserver = new ContentObserver(
@@ -550,8 +541,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback

        // Currently there is no accelerometer sensor on non-default display.
        if (mIsOnDefaultDisplay) {
            mNavigationBarView.getRotateSuggestionButton().setListener(mRotationButtonListener);

            final RotationButtonController rotationButtonController =
                    mNavigationBarView.getRotationButtonController();
            rotationButtonController.addRotationCallback(mRotationWatcher);
@@ -1355,6 +1344,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
        if (mAutoHideController != null) {
            mAutoHideController.setNavigationBar(mAutoHideUiElement);
        }
        mNavigationBarView.setAutoHideController(autoHideController);
    }

    private boolean isTransientShown() {
+26 −2
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ public class NavigationBarView extends FrameLayout implements
    private boolean mDeadZoneConsuming = false;
    private final NavigationBarTransitions mBarTransitions;
    private final OverviewProxyService mOverviewProxyService;
    private AutoHideController mAutoHideController;

    // performs manual animation in sync with layout transitions
    private final NavTransitionListener mTransitionListener = new NavTransitionListener();
@@ -276,6 +277,15 @@ public class NavigationBarView extends FrameLayout implements
        info.touchableRegion.setEmpty();
    };

    private final Consumer<Boolean> mRotationButtonListener = (visible) -> {
        if (visible) {
            // If the button will actually become visible and the navbar is about to hide,
            // tell the statusbar to keep it around for longer
            mAutoHideController.touchAutoHide();
        }
        notifyActiveTouchRegions();
    };

    public NavigationBarView(Context context, AttributeSet attrs) {
        super(context, attrs);

@@ -313,7 +323,8 @@ public class NavigationBarView extends FrameLayout implements
        mFloatingRotationButton = new FloatingRotationButton(context);
        mRotationButtonController = new RotationButtonController(mLightContext,
                mLightIconColor, mDarkIconColor,
                isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton);
                isGesturalMode ? mFloatingRotationButton : rotateSuggestionButton,
                mRotationButtonListener);

        mConfiguration = new Configuration();
        mTmpLastConfiguration = new Configuration();
@@ -361,6 +372,10 @@ public class NavigationBarView extends FrameLayout implements
                });
    }

    public void setAutoHideController(AutoHideController autoHideController) {
        mAutoHideController = autoHideController;
    }

    public NavigationBarTransitions getBarTransitions() {
        return mBarTransitions;
    }
@@ -939,7 +954,15 @@ public class NavigationBarView extends FrameLayout implements
        updateButtonLocation(getBackButton());
        updateButtonLocation(getHomeButton());
        updateButtonLocation(getRecentsButton());
        updateButtonLocation(getImeSwitchButton());
        updateButtonLocation(getAccessibilityButton());
        if (mFloatingRotationButton.isVisible()) {
            View floatingRotationView = mFloatingRotationButton.getCurrentView();
            floatingRotationView.getBoundsOnScreen(mTmpBounds);
            mActiveRegion.op(mTmpBounds, Op.UNION);
        } else {
            updateButtonLocation(getRotateSuggestionButton());
        }
        mOverviewProxyService.onActiveNavBarRegionChanges(mActiveRegion);
    }

@@ -1211,6 +1234,7 @@ public class NavigationBarView extends FrameLayout implements
        dumpButton(pw, "rcnt", getRecentsButton());
        dumpButton(pw, "rota", getRotateSuggestionButton());
        dumpButton(pw, "a11y", getAccessibilityButton());
        dumpButton(pw, "ime", getImeSwitchButton());

        pw.println("    }");
        pw.println("    mScreenOn: " + mScreenOn);
+3 −0
Original line number Diff line number Diff line
@@ -20,9 +20,12 @@ import android.view.View;

import com.android.systemui.statusbar.policy.KeyButtonDrawable;

import java.util.function.Consumer;

/** Interface of a rotation button that interacts {@link RotationButtonController}. */
interface RotationButton {
    void setRotationButtonController(RotationButtonController rotationButtonController);
    void setVisibilityChangedCallback(Consumer<Boolean> visibilityChangedCallback);
    View getCurrentView();
    boolean show();
    boolean hide();
+3 −1
Original line number Diff line number Diff line
@@ -124,7 +124,8 @@ public class RotationButtonController {
    }

    RotationButtonController(Context context, @ColorInt int lightIconColor,
            @ColorInt int darkIconColor, RotationButton rotationButton) {
            @ColorInt int darkIconColor, RotationButton rotationButton,
            Consumer<Boolean> visibilityChangedCallback) {
        mContext = context;
        mLightIconColor = lightIconColor;
        mDarkIconColor = darkIconColor;
@@ -139,6 +140,7 @@ public class RotationButtonController {
        mTaskStackListener = new TaskStackListenerImpl();
        mRotationButton.setOnClickListener(this::onRotateSuggestionClick);
        mRotationButton.setOnHoverListener(this::onRotateSuggestionHover);
        mRotationButton.setVisibilityChangedCallback(visibilityChangedCallback);
    }

    void registerListeners() {
Loading