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

Commit 89fa4e35 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Make sure touch only goes to the nearest button when it makes sense" into main

parents c7d7418c 419140ae
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BA
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HOME;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_SPACE;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_SMALL_SCREEN;
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
@@ -79,6 +80,7 @@ import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Space;

import androidx.annotation.Nullable;

@@ -207,6 +209,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            this::onComputeInsetsForSeparateWindow;
    private final RecentsHitboxExtender mHitboxExtender = new RecentsHitboxExtender();
    private ImageView mRecentsButton;
    private Space mSpace;

    public NavbarButtonsViewController(TaskbarActivityContext context,
            @Nullable Context navigationBarPanelContext, NearestTouchFrame navButtonsView) {
@@ -432,6 +435,11 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        mPropertyHolders.add(new StatePropertyHolder(mA11yButton,
                flags -> (flags & FLAG_A11Y_VISIBLE) != 0
                        && (flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0));

        mSpace = new Space(mNavButtonsView.getContext());
        mSpace.setOnClickListener(view -> navButtonController.onButtonClick(BUTTON_SPACE, view));
        mSpace.setOnLongClickListener(view ->
                navButtonController.onButtonLongClick(BUTTON_SPACE, view));
    }

    private void parseSystemUiFlags(int sysUiStateFlags) {
@@ -760,7 +768,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                    NavButtonLayoutFactory.Companion.getUiLayoutter(
                            dp, mNavButtonsView, mImeSwitcherButton,
                            mControllers.rotationButtonController.getRotationButton(),
                            mA11yButton, res, isInKidsMode, isInSetup, isThreeButtonNav,
                            mA11yButton, mSpace, res, isInKidsMode, isInSetup, isThreeButtonNav,
                            mContext.isPhoneMode(), mWindowManagerProxy.getRotation(mContext));
            navButtonLayoutter.layoutButtons(mContext, isA11yButtonPersistent());
            updateButtonsBackground();
+7 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
    static final int BUTTON_A11Y = BUTTON_IME_SWITCH << 1;
    static final int BUTTON_QUICK_SETTINGS = BUTTON_A11Y << 1;
    static final int BUTTON_NOTIFICATIONS = BUTTON_QUICK_SETTINGS << 1;
    static final int BUTTON_SPACE = BUTTON_NOTIFICATIONS << 1;

    private static final int SCREEN_UNPIN_COMBO = BUTTON_BACK | BUTTON_RECENTS;
    private int mLongPressedButtons = 0;
@@ -123,6 +124,9 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
    }

    public void onButtonClick(@TaskbarButton int buttonType, View view) {
        if (buttonType == BUTTON_SPACE) {
            return;
        }
        // Provide the same haptic feedback that the system offers for virtual keys.
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        switch (buttonType) {
@@ -156,6 +160,9 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
    }

    public boolean onButtonLongClick(@TaskbarButton int buttonType, View view) {
        if (buttonType == BUTTON_SPACE) {
            return false;
        }
        // Provide the same haptic feedback that the system offers for virtual keys.
        view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
        switch (buttonType) {
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
@@ -46,7 +47,8 @@ abstract class AbstractNavButtonLayoutter(
        protected val startContextualContainer: ViewGroup,
        protected val imeSwitcher: ImageView?,
        protected val rotationButton: RotationButton?,
        protected val a11yButton: ImageView?
        protected val a11yButton: ImageView?,
        protected val space: Space
) : NavButtonLayoutter {
    protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
    protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
+5 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import com.android.launcher3.R
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
@@ -37,7 +38,8 @@ class KidsNavLayoutter(
        startContextualContainer: ViewGroup,
        imeSwitcher: ImageView?,
        rotationButton: RotationButton?,
        a11yButton: ImageView?
        a11yButton: ImageView?,
        space: Space,
) :
    AbstractNavButtonLayoutter(
            resources,
@@ -46,7 +48,8 @@ class KidsNavLayoutter(
            startContextualContainer,
            imeSwitcher,
            rotationButton,
            a11yButton
            a11yButton,
            space
    ) {

    override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
+16 −7
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import com.android.launcher3.DeviceProfile
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
@@ -60,6 +61,7 @@ class NavButtonLayoutFactory {
                imeSwitcher: ImageView?,
                rotationButton: RotationButton?,
                a11yButton: ImageView?,
                space: Space,
                resources: Resources,
                isKidsMode: Boolean,
                isInSetup: Boolean,
@@ -86,7 +88,8 @@ class NavButtonLayoutFactory {
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                                a11yButton,
                                space
                        )
                    } else if (surfaceRotation == ROTATION_90) {
                        navButtonsView.setIsVertical(true)
@@ -97,7 +100,8 @@ class NavButtonLayoutFactory {
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                                a11yButton,
                                space
                        )
                    } else {
                        navButtonsView.setIsVertical(true)
@@ -108,7 +112,8 @@ class NavButtonLayoutFactory {
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                                a11yButton,
                                space
                        )
                    }
                }
@@ -120,7 +125,8 @@ class NavButtonLayoutFactory {
                            startContextualContainer,
                            imeSwitcher,
                            rotationButton,
                            a11yButton
                            a11yButton,
                            space
                    )
                }
                deviceProfile.isTaskbarPresent -> {
@@ -133,7 +139,8 @@ class NavButtonLayoutFactory {
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                                    a11yButton,
                                    space
                            )
                        }
                        isKidsMode -> {
@@ -144,7 +151,8 @@ class NavButtonLayoutFactory {
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                                    a11yButton,
                                    space
                            )
                        }
                        else ->
@@ -155,7 +163,8 @@ class NavButtonLayoutFactory {
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                                    a11yButton,
                                    space
                            )
                    }
                }
Loading