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

Commit ee002b9c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8534619 from e73c3075 to tm-release

Change-Id: Iab8621d6073f63106cbd0ea8648629e406c289a8
parents 5016e295 e73c3075
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.ALL_APPS_PAGE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.MINUS_ONE_PAGE_PROGRESS_INDEX;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.WIDGETS_PAGE_PROGRESS_INDEX;
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
@@ -229,6 +232,28 @@ public abstract class BaseQuickstepLauncher extends Launcher {
    public void onScrollChanged(float progress) {
        super.onScrollChanged(progress);
        mDepthController.onOverlayScrollChanged(progress);
        onTaskbarInAppDisplayProgressUpdate(progress, MINUS_ONE_PAGE_PROGRESS_INDEX);
    }

    @Override
    public void onAllAppsTransition(float progress) {
        super.onAllAppsTransition(progress);
        onTaskbarInAppDisplayProgressUpdate(progress, ALL_APPS_PAGE_PROGRESS_INDEX);
    }

    @Override
    public void onWidgetsTransition(float progress) {
        super.onWidgetsTransition(progress);
        onTaskbarInAppDisplayProgressUpdate(progress, WIDGETS_PAGE_PROGRESS_INDEX);
    }

    private void onTaskbarInAppDisplayProgressUpdate(float progress, int flag) {
        if (mTaskbarManager == null
                || mTaskbarManager.getCurrentActivityContext() == null
                || mTaskbarUIController == null) {
            return;
        }
        mTaskbarUIController.onTaskbarInAppDisplayProgressUpdate(progress, flag);
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ public interface QuickstepSystemShortcut {

            RecentsView recentsView = mTarget.getOverviewPanel();
            recentsView.initiateSplitSelect(
                    new SplitSelectSource(view, new BitmapDrawable(bitmap), intent, mPosition));
                    new SplitSelectSource(mOriginalView, new BitmapDrawable(bitmap), intent,
                            mPosition));
        }
    }

+6 −0
Original line number Diff line number Diff line
@@ -39,4 +39,10 @@ public class DesktopTaskbarUIController extends TaskbarUIController {
    protected void onDestroy() {
        mLauncher.getHotseat().setIconsAlpha(1f);
    }

    @Override
    /** Disable taskbar stashing in desktop environment. */
    public boolean supportsVisualStashing() {
        return false;
    }
}
+97 −13
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.animation.Animator;
import android.annotation.ColorInt;
import android.os.RemoteException;
import android.util.Log;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.TaskTransitionSpec;
import android.view.WindowManagerGlobal;
@@ -43,6 +44,7 @@ import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Stream;
@@ -54,10 +56,22 @@ public class LauncherTaskbarUIController extends TaskbarUIController {

    private static final String TAG = "TaskbarUIController";

    public static final int MINUS_ONE_PAGE_PROGRESS_INDEX = 0;
    public static final int ALL_APPS_PAGE_PROGRESS_INDEX = 1;
    public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
    public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;

    private final SparseArray<Float> mTaskbarInAppDisplayProgress = new SparseArray<>(4);

    private final BaseQuickstepLauncher mLauncher;

    private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
            this::onStashedInAppChanged;
            dp -> {
                onStashedInAppChanged(dp);
                if (mControllers != null && mControllers.taskbarViewController != null) {
                    mControllers.taskbarViewController.onRotationChanged(dp);
                }
            };

    // Initialized in init.
    private AnimatedFloat mTaskbarOverrideBackgroundAlpha;
@@ -65,15 +79,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
    private final TaskbarLauncherStateController
            mTaskbarLauncherStateController = new TaskbarLauncherStateController();

    private final DeviceProfile.OnDeviceProfileChangeListener mProfileChangeListener =
            new DeviceProfile.OnDeviceProfileChangeListener() {
                @Override
                public void onDeviceProfileChanged(DeviceProfile dp) {
                    mControllers.taskbarViewController.onRotationChanged(
                            mLauncher.getDeviceProfile());
                }
            };

    public LauncherTaskbarUIController(BaseQuickstepLauncher launcher) {
        mLauncher = launcher;
    }
@@ -93,7 +98,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController {

        onStashedInAppChanged(mLauncher.getDeviceProfile());
        mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
        mLauncher.addOnDeviceProfileChangeListener(mProfileChangeListener);
    }

    @Override
@@ -102,9 +106,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        onLauncherResumedOrPaused(false);
        mTaskbarLauncherStateController.onDestroy();

        mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
        mLauncher.setTaskbarUIController(null);
        mLauncher.removeOnDeviceProfileChangeListener(mProfileChangeListener);
        mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
        updateTaskTransitionSpec(true);
    }

@@ -271,4 +274,85 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
        // gesture ends, start drawing taskbar's background again since launcher might stop drawing.
        forceHideBackground(inProgress);
    }

    /**
     * Animates Taskbar elements during a transition to a Launcher state that should use in-app
     * layouts.
     *
     * @param progress [0, 1]
     *                 0 => use home layout
     *                 1 => use in-app layout
     */
    public void onTaskbarInAppDisplayProgressUpdate(float progress, int progressIndex) {
        if (mControllers == null) {
            // This method can be called before init() is called.
            return;
        }
        mTaskbarInAppDisplayProgress.put(progressIndex, progress);
        if (!mControllers.taskbarStashController.isInApp()
                && !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
            // Only animate the nav buttons while home and not animating home, otherwise let
            // the TaskbarViewController handle it.
            mControllers.navbarButtonsViewController
                    .getTaskbarNavButtonTranslationYForInAppDisplay()
                    .updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
                            * getInAppDisplayProgress());
        }
    }

    /** Returns true iff any in-app display progress > 0. */
    public boolean shouldUseInAppLayout() {
        return getInAppDisplayProgress() > 0;
    }

    private float getInAppDisplayProgress(int index) {
        if (!mTaskbarInAppDisplayProgress.contains(index)) {
            mTaskbarInAppDisplayProgress.put(index, 0f);
        }
        return mTaskbarInAppDisplayProgress.get(index);
    }

    private float getInAppDisplayProgress() {
        return Stream.of(
                getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX),
                getInAppDisplayProgress(ALL_APPS_PAGE_PROGRESS_INDEX),
                getInAppDisplayProgress(WIDGETS_PAGE_PROGRESS_INDEX),
                getInAppDisplayProgress(SYSUI_SURFACE_PROGRESS_INDEX))
                .max(Float::compareTo)
                .get();
    }

    @Override
    public void dumpLogs(String prefix, PrintWriter pw) {
        super.dumpLogs(prefix, pw);

        pw.println(String.format(
                "%s\tmTaskbarOverrideBackgroundAlpha=%.2f",
                prefix,
                mTaskbarOverrideBackgroundAlpha.value));

        pw.println(String.format("%s\tTaskbar in-app display progress:", prefix));
        if (mControllers == null) {
            pw.println(String.format("%s\t\tMissing mControllers", prefix));
        } else {
            pw.println(String.format(
                    "%s\t\tprogress at MINUS_ONE_PAGE_PROGRESS_INDEX=%.2f",
                    prefix,
                    getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX)));
            pw.println(String.format(
                    "%s\t\tprogress at ALL_APPS_PAGE_PROGRESS_INDEX=%.2f",
                    prefix,
                    getInAppDisplayProgress(ALL_APPS_PAGE_PROGRESS_INDEX)));
            pw.println(String.format(
                    "%s\t\tprogress at WIDGETS_PAGE_PROGRESS_INDEX=%.2f",
                    prefix,
                    getInAppDisplayProgress(WIDGETS_PAGE_PROGRESS_INDEX)));
            pw.println(String.format(
                    "%s\t\tprogress at SYSUI_SURFACE_PROGRESS_INDEX=%.2f",
                    prefix,
                    getInAppDisplayProgress(SYSUI_SURFACE_PROGRESS_INDEX)));
        }

        mTaskbarLauncherStateController.dumpLogs(prefix + "\t", pw);
    }
}
+32 −10
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar;

import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.SYSUI_SURFACE_PROGRESS_INDEX;
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;
@@ -126,11 +127,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
    private final AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    // Only applies to mTaskbarNavButtonTranslationY
    private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat(
    private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
            this::updateNavButtonTranslationY);
    // Used for System UI state updates that should translate the nav button for in-app display.
    private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat(
            this::updateNavButtonInAppDisplayProgressForSysui);
    private final AnimatedFloat mTaskbarNavButtonDarkIntensity = new AnimatedFloat(
            this::updateNavButtonDarkIntensity);
    private final AnimatedFloat mNavButtonDarkIntensityMultiplier = new AnimatedFloat(
@@ -173,7 +176,6 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    public void init(TaskbarControllers controllers) {
        mControllers = controllers;
        mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;
        mNavButtonTranslationYMultiplier.value = 1;

        boolean isThreeButtonNav = mContext.isThreeButtonNav();
        mIsImeRenderingNavButtons =
@@ -205,9 +207,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        // Make sure to remove nav bar buttons translation when notification shade is expanded or
        // IME is showing (add separate translation for IME).
        int flagsToRemoveTranslation = FLAG_NOTIFICATION_SHADE_EXPANDED | FLAG_IME_VISIBLE;
        mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier,
        mPropertyHolders.add(new StatePropertyHolder(mNavButtonInAppDisplayProgressForSysui,
                flags -> (flags & flagsToRemoveTranslation) != 0, AnimatedFloat.VALUE,
                0, 1));
                1, 0));
        // Center nav buttons in new height for IME.
        float transForIme = (mContext.getDeviceProfile().taskbarSize
                - mControllers.taskbarInsetsController.getTaskbarHeightForIme()) / 2f;
@@ -526,6 +528,11 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        return mTaskbarNavButtonTranslationY;
    }

    /** Use to set the translationY for the all nav+contextual buttons when in Launcher */
    public AnimatedFloat getTaskbarNavButtonTranslationYForInAppDisplay() {
        return mTaskbarNavButtonTranslationYForInAppDisplay;
    }

    /** Use to set the dark intensity for the all nav+contextual buttons */
    public AnimatedFloat getTaskbarNavButtonDarkIntensity() {
        return mTaskbarNavButtonDarkIntensity;
@@ -554,11 +561,26 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        }
    }

    private void updateNavButtonInAppDisplayProgressForSysui() {
        TaskbarUIController uiController = mControllers.uiController;
        if (uiController instanceof LauncherTaskbarUIController) {
            ((LauncherTaskbarUIController) uiController).onTaskbarInAppDisplayProgressUpdate(
                    mNavButtonInAppDisplayProgressForSysui.value, SYSUI_SURFACE_PROGRESS_INDEX);
        }
    }

    private void updateNavButtonTranslationY() {
        float normalTranslationY = mTaskbarNavButtonTranslationY.value
                * mNavButtonTranslationYMultiplier.value;
        float otherTranslationY = mTaskbarNavButtonTranslationYForIme.value;
        mNavButtonsView.setTranslationY(normalTranslationY + otherTranslationY);
        final float normalTranslationY = mTaskbarNavButtonTranslationY.value;
        final float imeAdjustmentTranslationY = mTaskbarNavButtonTranslationYForIme.value;
        TaskbarUIController uiController = mControllers.uiController;
        final float inAppDisplayAdjustmentTranslationY =
                (uiController instanceof LauncherTaskbarUIController
                        && ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout())
                        ? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0;

        mNavButtonsView.setTranslationY(normalTranslationY
                + imeAdjustmentTranslationY
                + inAppDisplayAdjustmentTranslationY);
    }

    private void updateNavButtonDarkIntensity() {
Loading