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

Commit 0288d2e8 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Move floating rotation button handling to Launcher

Moves handling of floating rotation button when navigation
bar is not created to the launcher. This button was not
showing when taskbar is visible as it was initialized in
navigation bar (which is not created for large screens).

Bug: 200103245
Test: rotate phone when autorotate disabled on inner screen
Test: showing rotate suggestion when gesture nav enabled/disabled
Change-Id: I13dd555bcd811f1524be7ab9ad51b2b012b3b749
parent e6a04336
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@
    <color name="taskbar_stashed_handle_light_color">#EBffffff</color>
    <color name="taskbar_stashed_handle_dark_color">#99000000</color>

    <color name="rotation_button_light_color">#FFF</color>
    <color name="rotation_button_dark_color">#99000000</color>

    <!-- Gesture navigation tutorial -->
    <color name="gesture_tutorial_back_arrow_color">#FFFFFFFF</color>

+3 −0
Original line number Diff line number Diff line
@@ -208,6 +208,9 @@
    <!-- Button text shown on a button on the tutorial skip dialog to exit the tutorial. [CHAR LIMIT=14] -->
    <string name="gesture_tutorial_action_button_label_skip">Skip</string>

    <!-- Accessibility label for the rotation suggestion button -->
    <string name="accessibility_rotate_button">Rotate screen</string>

    <!-- ******* Taskbar Edu ******* -->
    <!-- Accessibility text spoken when the taskbar education panel appears [CHAR_LIMIT=NONE] -->
    <string name="taskbar_edu_opened">Taskbar education appeared</string>
+2 −1
Original line number Diff line number Diff line
@@ -345,7 +345,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
     * @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
     */
    public boolean isEventOverAnyTaskbarItem(MotionEvent ev) {
        return mControllers.taskbarViewController.isEventOverAnyItem(ev);
        return mControllers.taskbarViewController.isEventOverAnyItem(ev)
                || mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
    }

    public boolean isDraggingItem() {
+43 −6
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.launcher3.taskbar;

import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y_LONG_CLICK;
@@ -38,6 +40,7 @@ import android.animation.ObjectAnimator;
import android.annotation.DrawableRes;
import android.annotation.IdRes;
import android.annotation.LayoutRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.graphics.Region;
@@ -45,6 +48,7 @@ import android.graphics.Region.Op;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.util.Property;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnHoverListener;
@@ -57,11 +61,12 @@ import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AlphaUpdateListener;
import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarButton;
import com.android.launcher3.taskbar.contextual.RotationButton;
import com.android.launcher3.taskbar.contextual.RotationButtonController;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.launcher3.util.Themes;
import com.android.quickstep.AnimatedFloat;
import com.android.systemui.shared.rotation.FloatingRotationButton;
import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;

import java.util.ArrayList;
import java.util.function.IntPredicate;
@@ -103,12 +108,16 @@ public class NavbarButtonsViewController {
            this::updateNavButtonTranslationY);
    private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    private final RotationButtonListener mRotationButtonListener = new RotationButtonListener();

    private final Rect mFloatingRotationButtonBounds = new Rect();

    // Initialized in init.
    private TaskbarControllers mControllers;
    private View mA11yButton;
    private int mSysuiStateFlags;
    private View mBackButton;
    private FloatingRotationButton mFloatingRotationButton;

    public NavbarButtonsViewController(TaskbarActivityContext context, FrameLayout navButtonsView) {
        mContext = context;
@@ -198,9 +207,13 @@ public class NavbarButtonsViewController {
                    addButton(mEndContextualContainer, R.id.rotate_suggestion,
                            R.layout.taskbar_contextual_button));
            rotationButton.hide();
            mControllers.rotationButtonController.setRotationButton(rotationButton);
            mControllers.rotationButtonController.setRotationButton(rotationButton, null);
        } else {
            mControllers.rotationButtonController.setRotationButton(new RotationButton() {});
            mFloatingRotationButton = new FloatingRotationButton(mContext,
                    R.string.accessibility_rotate_button);
            mControllers.rotationButtonController.setRotationButton(mFloatingRotationButton,
                    mRotationButtonListener);

            View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
                    mStartContextualContainer, mControllers.navButtonController, R.id.back);
            imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90);
@@ -405,8 +418,28 @@ public class NavbarButtonsViewController {
        return buttonView;
    }

    public boolean isEventOverAnyItem(MotionEvent ev) {
        return mFloatingRotationButtonBounds.contains((int) ev.getX(), (int) ev.getY());
    }

    public void onDestroy() {
        mPropertyHolders.clear();
        mControllers.rotationButtonController.unregisterListeners();
        if (mFloatingRotationButton != null) {
            mFloatingRotationButton.hide();
        }
    }

    private class RotationButtonListener implements RotationButton.RotationButtonUpdatesCallback {
        @Override
        public void onVisibilityChanged(boolean isVisible) {
            if (isVisible) {
                mFloatingRotationButton.getCurrentView()
                        .getBoundsOnScreen(mFloatingRotationButtonBounds);
            } else {
                mFloatingRotationButtonBounds.setEmpty();
            }
        }
    }

    private class RotationButtonImpl implements RotationButton {
@@ -424,6 +457,8 @@ public class NavbarButtonsViewController {
            mImageDrawable = (AnimatedVectorDrawable) mButton.getContext()
                    .getDrawable(rotationButtonController.getIconResId());
            mButton.setImageDrawable(mImageDrawable);
            mButton.setContentDescription(mButton.getResources()
                    .getString(R.string.accessibility_rotate_button));
            mImageDrawable.setCallback(mButton);
        }

@@ -433,17 +468,19 @@ public class NavbarButtonsViewController {
        }

        @Override
        public void show() {
        public boolean show() {
            mButton.setVisibility(View.VISIBLE);
            mState |= FLAG_ROTATION_BUTTON_VISIBLE;
            applyState();
            return true;
        }

        @Override
        public void hide() {
        public boolean hide() {
            mButton.setVisibility(View.GONE);
            mState &= ~FLAG_ROTATION_BUTTON_VISIBLE;
            applyState();
            return true;
        }

        @Override
+9 −3
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.taskbar.contextual.RotationButtonController;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.SettingsCache;
@@ -71,6 +70,7 @@ import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.rotation.RotationButtonController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
@@ -147,8 +147,14 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                new TaskbarDragController(this),
                buttonController,
                new NavbarButtonsViewController(this, navButtonsView),
                new RotationButtonController(this, R.color.popup_color_primary_light,
                        R.color.popup_color_primary_light),
                new RotationButtonController(this,
                        c.getColor(R.color.rotation_button_light_color),
                        c.getColor(R.color.rotation_button_dark_color),
                        R.drawable.ic_sysbar_rotate_button_ccw_start_0,
                        R.drawable.ic_sysbar_rotate_button_ccw_start_90,
                        R.drawable.ic_sysbar_rotate_button_cw_start_0,
                        R.drawable.ic_sysbar_rotate_button_cw_start_90,
                        () -> getDisplay().getRotation()),
                new TaskbarDragLayerController(this, mDragLayer),
                new TaskbarViewController(this, taskbarView),
                new TaskbarScrimViewController(this, taskbarScrimView),
Loading