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

Commit 2e8ca87c authored by Jagrut Desai's avatar Jagrut Desai
Browse files

Taskbar in Desktop Windowing Mode

Test: presubmit
Bug: 330146462
Flag: NONE
Change-Id: Ib33f90704c3010df6a52e2a1c420960b11dbd0d4
parent 5a8e719b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.statemanager.StatefulActivity;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.DisplayController;
import com.android.quickstep.GestureState;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.views.DesktopAppSelectView;
@@ -229,6 +230,7 @@ public class DesktopVisibilityController {
        for (DesktopVisibilityListener listener : mDesktopVisibilityListeners) {
            listener.onDesktopVisibilityChanged(areDesktopTasksVisible);
        }
        DisplayController.handleInfoChangeForDesktopMode(mLauncher);
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -301,7 +301,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
                createTaskbarRecentAppsController(),
                TaskbarEduTooltipController.newInstance(this),
                new KeyboardQuickSwitchController(),
                new TaskbarPinningController(this),
                new TaskbarPinningController(this, () ->
                        DisplayController.INSTANCE.get(this).getInfo().isInDesktopMode()),
                bubbleControllersOptional);

        mLauncherPrefs = LauncherPrefs.get(this);
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.launcher3.Flags.enableUnfoldStateAnimation;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
import static com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate;
import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY;
import static com.android.launcher3.util.DisplayController.CHANGE_DESKTOP_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.DisplayController.CHANGE_TASKBAR_PINNING;
import static com.android.launcher3.util.DisplayController.TASKBAR_NOT_DESTROYED_TAG;
@@ -142,7 +143,7 @@ public class TaskbarManager {
    private class RecreationListener implements DisplayController.DisplayInfoChangeListener {
        @Override
        public void onDisplayInfoChanged(Context context, DisplayController.Info info, int flags) {
            if ((flags & (CHANGE_DENSITY | CHANGE_NAVIGATION_MODE
            if ((flags & (CHANGE_DENSITY | CHANGE_NAVIGATION_MODE | CHANGE_DESKTOP_MODE
                    | CHANGE_TASKBAR_PINNING)) != 0) {
                recreateTaskbar();
            }
+26 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.core.animation.doOnEnd
import com.android.app.animation.Interpolators
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING
import com.android.launcher3.LauncherPrefs.Companion.TASKBAR_PINNING_IN_DESKTOP_MODE
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_CLOSE
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_DIVIDER_MENU_OPEN
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_PINNED
@@ -31,8 +32,10 @@ import com.android.launcher3.taskbar.TaskbarDividerPopupView.Companion.createAnd
import java.io.PrintWriter

/** Controls taskbar pinning through a popup view. */
class TaskbarPinningController(private val context: TaskbarActivityContext) :
    TaskbarControllers.LoggableTaskbarController {
class TaskbarPinningController(
    private val context: TaskbarActivityContext,
    private val isInDesktopModeProvider: () -> Boolean,
) : TaskbarControllers.LoggableTaskbarController {

    private lateinit var controllers: TaskbarControllers
    private lateinit var taskbarSharedState: TaskbarSharedState
@@ -54,14 +57,22 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
                if (!didPreferenceChange) {
                    return
                }
                val shouldPinTaskbar =
                    if (isInDesktopModeProvider()) {
                        !launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)
                    } else {
                        !launcherPrefs.get(TASKBAR_PINNING)
                    }

                val animateToValue =
                    if (!launcherPrefs.get(TASKBAR_PINNING)) {
                    if (shouldPinTaskbar) {
                        statsLogManager.logger().log(LAUNCHER_TASKBAR_PINNED)
                        PINNING_PERSISTENT
                    } else {
                        statsLogManager.logger().log(LAUNCHER_TASKBAR_UNPINNED)
                        PINNING_TRANSIENT
                    }

                taskbarSharedState.taskbarWasPinned = animateToValue == PINNING_TRANSIENT
                animateTaskbarPinning(animateToValue)
            }
@@ -123,13 +134,24 @@ class TaskbarPinningController(private val context: TaskbarActivityContext) :
    @VisibleForTesting
    fun recreateTaskbarAndUpdatePinningValue() {
        updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(false)
        if (isInDesktopModeProvider()) {
            launcherPrefs.put(
                TASKBAR_PINNING_IN_DESKTOP_MODE,
                !launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)
            )
        } else {
            launcherPrefs.put(TASKBAR_PINNING, !launcherPrefs.get(TASKBAR_PINNING))
        }
    }

    override fun dumpLogs(prefix: String, pw: PrintWriter) {
        pw.println(prefix + "TaskbarPinningController:")
        pw.println("$prefix\tisAnimatingTaskbarPinning=$isAnimatingTaskbarPinning")
        pw.println("$prefix\tTASKBAR_PINNING shared pref =" + launcherPrefs.get(TASKBAR_PINNING))
        pw.println(
            "$prefix\tTASKBAR_PINNING_IN_DESKTOP_MODE shared pref in desktop mode =" +
                launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)
        )
    }

    companion object {
+9 −0
Original line number Diff line number Diff line
@@ -26,9 +26,11 @@ import android.view.WindowManager;
import android.view.WindowMetrics;

import com.android.internal.policy.SystemBarUtils;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.util.window.CachedDisplayInfo;
import com.android.launcher3.util.window.WindowManagerProxy;
import com.android.quickstep.LauncherActivityInterface;

import java.util.List;
import java.util.Set;
@@ -48,6 +50,13 @@ public class SystemWindowManagerProxy extends WindowManagerProxy {
                .getMaxBounds();
    }

    @Override
    public boolean isInDesktopMode() {
        DesktopVisibilityController desktopController =
                LauncherActivityInterface.INSTANCE.getDesktopVisibilityController();
        return desktopController != null && desktopController.areDesktopTasksVisible();
    }

    @Override
    public int getRotation(Context displayInfoContext) {
        return displayInfoContext.getResources().getConfiguration().windowConfiguration
Loading