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

Commit 72864a13 authored by Vinit Nayak's avatar Vinit Nayak Committed by Automerger Merge Worker
Browse files

Merge "Show 3 button nav on phone in Taskbar (1/2)" into tm-qpr-dev am: 89be3a4c

parents 67e9b7fb 89be3a4c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@

    <!--  Taskbar 3 button spacing  -->
    <dimen name="taskbar_button_space_inbetween">24dp</dimen>
    <dimen name="taskbar_button_space_inbetween_phone">40dp</dimen>
    <dimen name="taskbar_button_margin_5_5">26dp</dimen>
    <dimen name="taskbar_button_margin_6_5">75dp</dimen>
    <dimen name="taskbar_button_margin_4_5">47dp</dimen>
+75 −12
Original line number Diff line number Diff line
@@ -15,15 +15,20 @@
 */
package com.android.launcher3.taskbar;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.SYSUI_SURFACE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.TaskbarManager.isPhoneButtonNavMode;
import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_BACK;
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.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_SMALL_SCREEN;
import static com.android.launcher3.taskbar.Utilities.appendFlag;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
@@ -109,6 +114,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    private static final int FLAG_NOTIFICATION_SHADE_EXPANDED = 1 << 10;
    private static final int FLAG_SCREEN_PINNING_ACTIVE = 1 << 11;
    private static final int FLAG_VOICE_INTERACTION_WINDOW_SHOWING = 1 << 12;
    private static final int FLAG_SMALL_SCREEN = 1 << 13;

    private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons";

@@ -122,7 +128,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private final TaskbarActivityContext mContext;
    private final FrameLayout mNavButtonsView;
    private final ViewGroup mNavButtonContainer;
    private final LinearLayout mNavButtonContainer;
    // Used for IME+A11Y buttons
    private final ViewGroup mEndContextualContainer;
    private final ViewGroup mStartContextualContainer;
@@ -180,9 +186,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
     */
    public void init(TaskbarControllers controllers) {
        mControllers = controllers;
        mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;

        boolean isThreeButtonNav = mContext.isThreeButtonNav();
        DeviceProfile deviceProfile = mContext.getDeviceProfile();
        Resources resources = mContext.getResources();
        mNavButtonsView.getLayoutParams().height = !isPhoneMode(deviceProfile) ?
                deviceProfile.taskbarSize :
                resources.getDimensionPixelSize(R.dimen.taskbar_size);

        mIsImeRenderingNavButtons =
                InputMethodService.canImeRenderGesturalNavButtons() && mContext.imeDrawsImeNavBar();
        if (!mIsImeRenderingNavButtons) {
@@ -201,6 +211,11 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0
                        && (flags & FLAG_SCREEN_PINNING_ACTIVE) == 0));

        mPropertyHolders.add(new StatePropertyHolder(
                mControllers.taskbarViewController.getTaskbarIconAlpha()
                        .getProperty(ALPHA_INDEX_SMALL_SCREEN),
                flags -> (flags & FLAG_SMALL_SCREEN) == 0));

        mPropertyHolders.add(new StatePropertyHolder(mControllers.taskbarDragLayerController
                .getKeyguardBgTaskbar(), flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0));

@@ -231,7 +246,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            initButtons(mNavButtonContainer, mEndContextualContainer,
                    mControllers.navButtonController);
            updateButtonLayoutSpacing();

            updateStateForFlag(FLAG_SMALL_SCREEN, isPhoneButtonNavMode(mContext));
            if (isInSetup) {
                // Since setup wizard only has back button enabled, it looks strange to be
                // end-aligned, so start-align instead.
@@ -244,18 +259,18 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

                // TODO(b/210906568) Dark intensity is currently not propagated during setup, so set
                //  it based on dark theme for now.
                int mode = mContext.getResources().getConfiguration().uiMode
                int mode = resources.getConfiguration().uiMode
                        & Configuration.UI_MODE_NIGHT_MASK;
                boolean isDarkTheme = mode == Configuration.UI_MODE_NIGHT_YES;
                mTaskbarNavButtonDarkIntensity.updateValue(isDarkTheme ? 0 : 1);
            } else if (isInKidsMode) {
                int iconSize = mContext.getResources().getDimensionPixelSize(
                int iconSize = resources.getDimensionPixelSize(
                        R.dimen.taskbar_icon_size_kids);
                int buttonWidth = mContext.getResources().getDimensionPixelSize(
                int buttonWidth = resources.getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_width_kids);
                int buttonHeight = mContext.getResources().getDimensionPixelSize(
                int buttonHeight = resources.getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_height_kids);
                int buttonRadius = mContext.getResources().getDimensionPixelSize(
                int buttonRadius = resources.getDimensionPixelSize(
                        R.dimen.taskbar_nav_buttons_corner_radius_kids);
                int paddingleft = (buttonWidth - iconSize) / 2;
                int paddingRight = paddingleft;
@@ -277,7 +292,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                        buttonWidth,
                        buttonHeight
                );
                int homeButtonLeftMargin = mContext.getResources().getDimensionPixelSize(
                int homeButtonLeftMargin = resources.getDimensionPixelSize(
                        R.dimen.taskbar_home_button_left_margin_kids);
                homeLayoutparams.setMargins(homeButtonLeftMargin, 0, 0, 0);
                mHomeButton.setLayoutParams(homeLayoutparams);
@@ -287,7 +302,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                        buttonWidth,
                        buttonHeight
                );
                int backButtonLeftMargin = mContext.getResources().getDimensionPixelSize(
                int backButtonLeftMargin = resources.getDimensionPixelSize(
                        R.dimen.taskbar_back_button_left_margin_kids);
                backLayoutParams.setMargins(backButtonLeftMargin, 0, 0, 0);
                mBackButton.setLayoutParams(backLayoutParams);
@@ -342,7 +357,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            if (!mIsImeRenderingNavButtons) {
                View imeDownButton = addButton(R.drawable.ic_sysbar_back, BUTTON_BACK,
                        mStartContextualContainer, mControllers.navButtonController, R.id.back);
                imeDownButton.setRotation(Utilities.isRtl(mContext.getResources()) ? 90 : -90);
                imeDownButton.setRotation(Utilities.isRtl(resources) ? 90 : -90);
                // Only show when IME is visible.
                mPropertyHolders.add(new StatePropertyHolder(imeDownButton,
                        flags -> (flags & FLAG_IME_VISIBLE) != 0));
@@ -614,6 +629,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    }

    private void updateNavButtonTranslationY() {
        if (isPhoneButtonNavMode(mContext)) {
            return;
        }
        final float normalTranslationY = mTaskbarNavButtonTranslationY.value;
        final float imeAdjustmentTranslationY = mTaskbarNavButtonTranslationYForIme.value;
        TaskbarUIController uiController = mControllers.uiController;
@@ -683,12 +701,22 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        if (!mContext.isThreeButtonNav() || mContext.isNavBarKidsModeActive()) {
            return;
        }

        if (isPhoneButtonNavMode(mContext)) {
            updatePhoneButtonSpacing();
            return;
        }

        DeviceProfile dp = mContext.getDeviceProfile();
        Resources res = mContext.getResources();

        // Add spacing after the end of the last nav button
        FrameLayout.LayoutParams navButtonParams =
                (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
        navButtonParams.gravity = Gravity.END;
        navButtonParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
        navButtonParams.height = MATCH_PARENT;

        int navMarginEnd = (int) res.getDimension(dp.inv.inlineNavButtonsEndSpacing);
        int contextualWidth = mEndContextualContainer.getWidth();
        // If contextual buttons are showing, we check if the end margin is enough for the
@@ -706,6 +734,39 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
            View navButton = mNavButtonContainer.getChildAt(i);
            LinearLayout.LayoutParams buttonLayoutParams =
                    (LinearLayout.LayoutParams) navButton.getLayoutParams();
            buttonLayoutParams.weight = 0;
            if (i == 0) {
                buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
            } else if (i == mNavButtonContainer.getChildCount() - 1) {
                buttonLayoutParams.setMarginStart(spaceInBetween / 2);
            } else {
                buttonLayoutParams.setMarginStart(spaceInBetween / 2);
                buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
            }
        }
    }

    /** Uniformly spaces out the 3 button nav for smaller phone screens */
    private void updatePhoneButtonSpacing() {
        DeviceProfile dp = mContext.getDeviceProfile();
        Resources res = mContext.getResources();

        // TODO: Polish pending, this is just to make it usable
        FrameLayout.LayoutParams navContainerParams =
                (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams();
        int endStartMargins = res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size);
        navContainerParams.gravity = Gravity.CENTER;
        navContainerParams.setMarginEnd(endStartMargins);
        navContainerParams.setMarginStart(endStartMargins);
        mNavButtonContainer.setLayoutParams(navContainerParams);

        // Add the spaces in between the nav buttons
        int spaceInBetween = res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween_phone);
        for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) {
            View navButton = mNavButtonContainer.getChildAt(i);
            LinearLayout.LayoutParams buttonLayoutParams =
                    (LinearLayout.LayoutParams) navButton.getLayoutParams();
            buttonLayoutParams.weight = 1;
            if (i == 0) {
                buttonLayoutParams.setMarginEnd(spaceInBetween / 2);
            } else if (i == mNavButtonContainer.getChildCount() - 1) {
@@ -725,6 +786,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        }

        moveNavButtonsBackToTaskbarWindow();
        mNavButtonContainer.removeAllViews();
        mAllButtons.clear();
    }

    /**
+7 −5
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@
 */
package com.android.launcher3.taskbar;

import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -96,7 +94,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        mControllers = controllers;
        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
        Resources resources = mActivity.getResources();
        if (isPhoneMode(mActivity.getDeviceProfile())) {
        if (isPhoneGestureNavMode(mActivity.getDeviceProfile())) {
            mStashedHandleView.getLayoutParams().height =
                    resources.getDimensionPixelSize(R.dimen.taskbar_size);
            mStashedHandleWidth =
@@ -108,7 +106,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        }

        mTaskbarStashedHandleAlpha.getProperty(ALPHA_INDEX_STASHED).setValue(
                isPhoneMode(deviceProfile) ? 1 : 0);
                isPhoneGestureNavMode(deviceProfile) ? 1 : 0);
        mTaskbarStashedHandleHintScale.updateValue(1f);

        final int stashedTaskbarHeight = mControllers.taskbarStashController.getStashedHeight();
@@ -136,7 +134,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
            view.setPivotY(stashedCenterY);
        });
        initRegionSampler();
        if (isPhoneMode(deviceProfile)) {
        if (isPhoneGestureNavMode(deviceProfile)) {
            onIsStashedChanged(true);
        }
    }
@@ -164,6 +162,10 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        mRegionSamplingHelper = null;
    }

    private boolean isPhoneGestureNavMode(DeviceProfile deviceProfile) {
        return TaskbarManager.isPhoneMode(deviceProfile) && !mActivity.isThreeButtonNav();
    }

    public MultiValueAlpha getStashedHandleAlpha() {
        return mTaskbarStashedHandleAlpha;
    }
+7 −3
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
    // The size we should return to when we call setTaskbarWindowFullscreen(false)
    private int mLastRequestedNonFullscreenHeight;

    private final NavigationMode mNavMode;
    private NavigationMode mNavMode;
    private final boolean mImeDrawsImeNavBar;
    private final ViewCache mViewCache = new ViewCache();

@@ -235,7 +235,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
    }

    /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
    public void updateDeviceProfile(DeviceProfile dp) {
    public void updateDeviceProfile(DeviceProfile dp, NavigationMode navMode) {
        mNavMode = navMode;
        mControllers.taskbarAllAppsController.updateDeviceProfile(dp);
        mDeviceProfile = dp.copy(this);
        updateIconSize(getResources());
@@ -608,7 +609,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
     */
    public int getDefaultTaskbarWindowHeight() {
        if (FLAG_HIDE_NAVBAR_WINDOW && mDeviceProfile.isPhone) {
            return getResources().getDimensionPixelSize(R.dimen.taskbar_stashed_size);
            Resources resources = getResources();
            return isThreeButtonNav() ?
                    resources.getDimensionPixelSize(R.dimen.taskbar_size) :
                    resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
        }
        return mDeviceProfile.taskbarSize + Math.max(getLeftCornerRadius(), getRightCornerRadius());
    }
+10 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
import android.content.res.Resources;
import android.graphics.Rect;

import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.AnimatedFloat;
@@ -173,7 +174,15 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa
         * Returns how tall the background should be drawn at the bottom of the screen.
         */
        public int getTaskbarBackgroundHeight() {
            return mActivity.getDeviceProfile().taskbarSize;
            DeviceProfile deviceProfile = mActivity.getDeviceProfile();
            if (TaskbarManager.isPhoneMode(deviceProfile)) {
                Resources resources = mActivity.getResources();
                return mActivity.isThreeButtonNav() ?
                        resources.getDimensionPixelSize(R.dimen.taskbar_size) :
                        resources.getDimensionPixelSize(R.dimen.taskbar_stashed_size);
            } else {
                return deviceProfile.taskbarSize;
            }
        }

        /**
Loading