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

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

Snap for 11211173 from d48279bf to 24Q1-release

Change-Id: Ib0f855c521d9356b3b003c4945bfd1ef71ebcd59
parents 24ddc4ec d48279bf
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -183,6 +184,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {

    private DeviceProfile mPersistentTaskbarDeviceProfile;

    private final LauncherPrefs mLauncherPrefs;

    public TaskbarActivityContext(Context windowContext,
            @Nullable Context navigationBarPanelContext, DeviceProfile launcherDp,
            TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
@@ -294,6 +297,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                new KeyboardQuickSwitchController(),
                new TaskbarPinningController(this),
                bubbleControllersOptional);

        mLauncherPrefs = LauncherPrefs.get(this);
    }

    /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
@@ -411,6 +416,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                getDeviceProfile().toSmallString());
    }

    @NonNull
    public LauncherPrefs getLauncherPrefs() {
        return mLauncherPrefs;
    }

    /**
     * Returns the View bounds of transient taskbar.
     */
+50 −31
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@
package com.android.launcher3.taskbar

import android.animation.AnimatorSet
import android.annotation.SuppressLint
import android.view.View
import androidx.annotation.VisibleForTesting
import androidx.core.animation.doOnEnd
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
@@ -31,29 +33,23 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :

    private lateinit var controllers: TaskbarControllers
    private lateinit var taskbarSharedState: TaskbarSharedState
    private val launcherPrefs = LauncherPrefs.get(context)
    private lateinit var launcherPrefs: LauncherPrefs
    private val statsLogManager = context.statsLogManager
    private var isAnimatingTaskbarPinning = false
    @VisibleForTesting var isAnimatingTaskbarPinning = false
    @VisibleForTesting lateinit var onCloseCallback: (preferenceChanged: Boolean) -> Unit

    @SuppressLint("VisibleForTests")
    fun init(taskbarControllers: TaskbarControllers, sharedState: TaskbarSharedState) {
        controllers = taskbarControllers
        taskbarSharedState = sharedState
    }

    fun showPinningView(view: View) {
        context.isTaskbarWindowFullscreen = true

        view.post {
            val popupView = createAndPopulate(view, context)
            popupView.requestFocus()

            popupView.onCloseCallback =
                callback@{ didPreferenceChange ->
        launcherPrefs = context.launcherPrefs
        onCloseCallback =
            fun(didPreferenceChange: Boolean) {
                statsLogManager.logger().log(LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE)
                context.dragLayer.post { context.onPopupVisibilityChanged(false) }

                if (!didPreferenceChange) {
                        return@callback
                    return
                }
                val animateToValue =
                    if (!launcherPrefs.get(TASKBAR_PINNING)) {
@@ -64,13 +60,41 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
                taskbarSharedState.taskbarWasPinned = animateToValue == PINNING_TRANSIENT
                animateTaskbarPinning(animateToValue)
            }
    }

    fun showPinningView(view: View) {
        context.isTaskbarWindowFullscreen = true
        view.post {
            val popupView = getPopupView(view)
            popupView.requestFocus()
            popupView.onCloseCallback = onCloseCallback
            context.onPopupVisibilityChanged(true)
            popupView.show()
            statsLogManager.logger().log(LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN)
        }
    }

    private fun animateTaskbarPinning(animateToValue: Float) {
    @VisibleForTesting
    fun getPopupView(view: View): TaskbarDividerPopupView<*> {
        return createAndPopulate(view, context)
    }

    @VisibleForTesting
    fun animateTaskbarPinning(animateToValue: Float) {
        val taskbarViewController = controllers.taskbarViewController
        val animatorSet =
            getAnimatorSetForTaskbarPinningAnimation(animateToValue).apply {
                doOnEnd { recreateTaskbarAndUpdatePinningValue() }
                duration = PINNING_ANIMATION_DURATION
            }
        controllers.taskbarOverlayController.hideWindow()
        updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(true)
        taskbarViewController.animateAwayNotificationDotsDuringTaskbarPinningAnimation()
        animatorSet.start()
    }

    @VisibleForTesting
    fun getAnimatorSetForTaskbarPinningAnimation(animateToValue: Float): AnimatorSet {
        val animatorSet = AnimatorSet()
        val taskbarViewController = controllers.taskbarViewController
        val dragLayerController = controllers.taskbarDragLayerController
@@ -82,13 +106,7 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
            taskbarViewController.taskbarIconTranslationXForPinning.animateToValue(animateToValue)
        )

        controllers.taskbarOverlayController.hideWindow()

        animatorSet.doOnEnd { recreateTaskbarAndUpdatePinningValue() }
        animatorSet.duration = PINNING_ANIMATION_DURATION
        updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(true)
        taskbarViewController.animateAwayNotificationDotsDuringTaskbarPinningAnimation()
        animatorSet.start()
        return animatorSet
    }

    private fun updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(isAnimating: Boolean) {
@@ -96,7 +114,8 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
        context.dragLayer.setAnimatingTaskbarPinning(isAnimating)
    }

    private fun recreateTaskbarAndUpdatePinningValue() {
    @VisibleForTesting
    fun recreateTaskbarAndUpdatePinningValue() {
        updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(false)
        launcherPrefs.put(TASKBAR_PINNING, !launcherPrefs.get(TASKBAR_PINNING))
    }
+10 −2
Original line number Diff line number Diff line
@@ -73,9 +73,17 @@ public class TaskbarSharedState {
    };

    // Allows us to shift translation logic when doing taskbar pinning animation.
    public Boolean startTaskbarVariantIsTransient = true;
    public boolean startTaskbarVariantIsTransient = true;

    // To track if taskbar was pinned using taskbar pinning feature at the time of recreate,
    // so we can unstash transient taskbar when we un-pinning taskbar.
    public Boolean taskbarWasPinned = false;
    private boolean mTaskbarWasPinned = false;

    public boolean getTaskbarWasPinned() {
        return mTaskbarWasPinned;
    }

    public void setTaskbarWasPinned(boolean taskbarWasPinned) {
        mTaskbarWasPinned = taskbarWasPinned;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivity);
        boolean isInSetup = !mActivity.isUserSetupComplete() || setupUIVisible;
        updateStateForFlag(FLAG_STASHED_IN_APP_AUTO,
                isTransientTaskbar && !mTaskbarSharedState.taskbarWasPinned);
                isTransientTaskbar && !mTaskbarSharedState.getTaskbarWasPinned());
        updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup);
        updateStateForFlag(FLAG_IN_SETUP, isInSetup);
        updateStateForFlag(FLAG_STASHED_SMALL_SCREEN, isPhoneMode()
@@ -316,7 +316,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
        // us that we're paused until a bit later. This avoids flickering upon recreating taskbar.
        updateStateForFlag(FLAG_IN_APP, true);
        applyState(/* duration = */ 0);
        if (mTaskbarSharedState.taskbarWasPinned) {
        if (mTaskbarSharedState.getTaskbarWasPinned()) {
            tryStartTaskbarTimeout();
        }
        notifyStashChange(/* visible */ false, /* stashed */ isStashedInApp());
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView<TaskbarOverla
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mNoIntercept = !mAppsView.shouldContainerScroll(ev)
                    || getTopOpenViewWithType(
                            mActivityContext, TYPE_ACCESSIBLE & ~TYPE_TASKBAR_OVERLAYS) != null;
                            mActivityContext, TYPE_TOUCH_CONTROLLER_NO_INTERCEPT) != null;
        }
        return super.onControllerInterceptTouchEvent(ev);
    }
Loading