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

Commit 30808036 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Using AnimatedFloat for maintaing TaskbarInAppDisplayProgress instead...

Merge "Using AnimatedFloat for maintaing TaskbarInAppDisplayProgress instead of a float array" into tm-qpr-dev
parents ff569730 00e3c1ac
Loading
Loading
Loading
Loading
+20 −45
Original line number Original line Diff line number Diff line
@@ -26,7 +26,6 @@ import android.animation.AnimatorSet;
import android.annotation.ColorInt;
import android.annotation.ColorInt;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.Log;
import android.util.Log;
import android.util.SparseArray;
import android.view.TaskTransitionSpec;
import android.view.TaskTransitionSpec;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerGlobal;


@@ -45,13 +44,13 @@ import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.RecentsView;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.Set;
import java.util.Set;
import java.util.stream.Stream;


/**
/**
 * A data source which integrates with a Launcher instance
 * A data source which integrates with a Launcher instance
@@ -65,7 +64,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
    public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
    public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
    public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;
    public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;


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

    private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat();
    private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp =
            new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress,
                    AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max);


    private final QuickstepLauncher mLauncher;
    private final QuickstepLauncher mLauncher;


@@ -305,11 +309,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
     *                 1 => use in-app layout
     *                 1 => use in-app layout
     */
     */
    public void onTaskbarInAppDisplayProgressUpdate(float progress, int progressIndex) {
    public void onTaskbarInAppDisplayProgressUpdate(float progress, int progressIndex) {
        mTaskbarInAppDisplayProgressMultiProp.get(progressIndex).setValue(progress);
        if (mControllers == null) {
        if (mControllers == null) {
            // This method can be called before init() is called.
            // This method can be called before init() is called.
            return;
            return;
        }
        }
        mTaskbarInAppDisplayProgress.put(progressIndex, progress);
        if (mControllers.uiController.isIconAlignedWithHotseat()
        if (mControllers.uiController.isIconAlignedWithHotseat()
                && !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
                && !mTaskbarLauncherStateController.isAnimatingToLauncher()) {
            // Only animate the nav buttons while home and not animating home, otherwise let
            // Only animate the nav buttons while home and not animating home, otherwise let
@@ -317,30 +321,13 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
            mControllers.navbarButtonsViewController
            mControllers.navbarButtonsViewController
                    .getTaskbarNavButtonTranslationYForInAppDisplay()
                    .getTaskbarNavButtonTranslationYForInAppDisplay()
                    .updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
                    .updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY()
                            * getInAppDisplayProgress());
                            * mTaskbarInAppDisplayProgress.value);
        }
        }
    }
    }


    /** Returns true iff any in-app display progress > 0. */
    /** Returns true iff any in-app display progress > 0. */
    public boolean shouldUseInAppLayout() {
    public boolean shouldUseInAppLayout() {
        return getInAppDisplayProgress() > 0;
        return mTaskbarInAppDisplayProgress.value > 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
    @Override
@@ -358,7 +345,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
    @Override
    @Override
    public boolean isHotseatIconOnTopWhenAligned() {
    public boolean isHotseatIconOnTopWhenAligned() {
        return mTaskbarLauncherStateController.isInHotseatOnTopStates()
        return mTaskbarLauncherStateController.isInHotseatOnTopStates()
                && getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX) == 0;
                && mTaskbarInAppDisplayProgressMultiProp.get(MINUS_ONE_PAGE_PROGRESS_INDEX)
                    .getValue() == 0;
    }
    }


    @Override
    @Override
@@ -369,28 +357,15 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
                "%s\tmTaskbarOverrideBackgroundAlpha=%.2f",
                "%s\tmTaskbarOverrideBackgroundAlpha=%.2f",
                prefix,
                prefix,
                mTaskbarOverrideBackgroundAlpha.value));
                mTaskbarOverrideBackgroundAlpha.value));

        pw.println(String.format("%s\tTaskbar in-app display progress:", prefix));
        pw.println(String.format("%s\tTaskbar in-app display progress:", prefix));
        if (mControllers == null) {
        mTaskbarInAppDisplayProgressMultiProp.dump(
            pw.println(String.format("%s\t\tMissing mControllers", prefix));
                prefix + "\t",
        } else {
                pw,
            pw.println(String.format(
                "mTaskbarInAppDisplayProgressMultiProp",
                    "%s\t\tprogress at MINUS_ONE_PAGE_PROGRESS_INDEX=%.2f",
                "MINUS_ONE_PAGE_PROGRESS_INDEX",
                    prefix,
                "ALL_APPS_PAGE_PROGRESS_INDEX",
                    getInAppDisplayProgress(MINUS_ONE_PAGE_PROGRESS_INDEX)));
                "WIDGETS_PAGE_PROGRESS_INDEX",
            pw.println(String.format(
                "SYSUI_SURFACE_PROGRESS_INDEX");
                    "%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);
        mTaskbarLauncherStateController.dumpLogs(prefix + "\t", pw);
    }
    }