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

Commit c9174e17 authored by Jagrut Desai's avatar Jagrut Desai Committed by Android (Google) Code Review
Browse files

Merge "Add support for different container and space calculation logic." into main

parents 9fb11f4d 84151055
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -112,6 +112,8 @@ import com.android.launcher3.taskbar.bubbles.BubbleDragController;
import com.android.launcher3.taskbar.bubbles.BubblePinController;
import com.android.launcher3.taskbar.bubbles.BubbleStashController;
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController;
import com.android.launcher3.taskbar.customization.TaskbarFeatureEvaluator;
import com.android.launcher3.taskbar.customization.TaskbarSpecsEvaluator;
import com.android.launcher3.taskbar.navbutton.NearestTouchFrame;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
import com.android.launcher3.testing.TestLogging;
@@ -205,6 +207,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {

    private final LauncherPrefs mLauncherPrefs;

    private final TaskbarFeatureEvaluator mTaskbarFeatureEvaluator;

    private final TaskbarSpecsEvaluator mTaskbarSpecsEvaluator;

    public TaskbarActivityContext(Context windowContext,
            @Nullable Context navigationBarPanelContext, DeviceProfile launcherDp,
            TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
@@ -215,6 +221,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        applyDeviceProfile(launcherDp);
        final Resources resources = getResources();

        mTaskbarFeatureEvaluator = TaskbarFeatureEvaluator.getInstance(this);
        mTaskbarSpecsEvaluator = new TaskbarSpecsEvaluator(
                this,
                mTaskbarFeatureEvaluator,
                mDeviceProfile.inv.numRows,
                mDeviceProfile.inv.numColumns);

        mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, resources, false);
        mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
                () -> getPackageManager().isSafeMode());
@@ -1649,6 +1662,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        return mControllers.taskbarStashController.isInStashedLauncherState();
    }

    public TaskbarFeatureEvaluator getTaskbarFeatureEvaluator() {
        return mTaskbarFeatureEvaluator;
    }

    public TaskbarSpecsEvaluator getTaskbarSpecsEvaluator() {
        return mTaskbarSpecsEvaluator;
    }

    protected void dumpLogs(String prefix, PrintWriter pw) {
        pw.println(prefix + "TaskbarActivityContext:");

+7 −9
Original line number Diff line number Diff line
@@ -13,15 +13,13 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.taskbar.customization

/** Enums for all feature container that taskbar supports. */
enum class TaskbarContainer {
    ALL_APPS,
    DIVIDER,
    APP_ICONS,
    RECENTS,
    NAV_BUTTONS,
    BUBBLES,
import androidx.annotation.Dimension

/**
 * Interface to be implemented by all taskbar container to expose [spaceNeeded] for each container.
 */
interface TaskbarContainer {
    @get:Dimension(unit = Dimension.DP) val spaceNeeded: Int
}
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.launcher3.taskbar.customization

/** Enums for all feature container that taskbar supports. */
enum class TaskbarContainers {
    ALL_APPS,
    DIVIDER,
    APP_ICONS,
    RECENTS,
    NAV_BUTTONS,
    BUBBLES,
}
+22 −6
Original line number Diff line number Diff line
@@ -16,27 +16,43 @@

package com.android.launcher3.taskbar.customization

import com.android.launcher3.Flags.enableRecentsInTaskbar
import com.android.launcher3.config.FeatureFlags.enableTaskbarPinning
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.launcher3.taskbar.TaskbarControllers
import com.android.launcher3.util.DisplayController

/** Evaluates all the features taskbar can have. */
class TaskbarFeatureEvaluator(
class TaskbarFeatureEvaluator
private constructor(
    private val taskbarActivityContext: TaskbarActivityContext,
    private val taskbarControllers: TaskbarControllers,
) {

    companion object {
        @Volatile private lateinit var taskbarFeatureEvaluator: TaskbarFeatureEvaluator

        @JvmStatic
        fun getInstance(
            taskbarActivityContext: TaskbarActivityContext,
        ): TaskbarFeatureEvaluator {
            synchronized(this) {
                if (!::taskbarFeatureEvaluator.isInitialized) {
                    taskbarFeatureEvaluator = TaskbarFeatureEvaluator(taskbarActivityContext)
                }
                return taskbarFeatureEvaluator
            }
        }
    }

    val hasAllApps = true
    val hasAppIcons = true
    val hasBubbles = false
    val hasNavButtons = taskbarActivityContext.isThreeButtonNav

    val hasRecents: Boolean
        get() = taskbarControllers.taskbarRecentAppsController.shownTasks.isNotEmpty()
    val isRecentsEnabled: Boolean
        get() = enableRecentsInTaskbar()

    val hasDivider: Boolean
        get() = enableTaskbarPinning() || hasRecents
        get() = enableTaskbarPinning() || isRecentsEnabled

    val isTransient: Boolean
        get() = DisplayController.isTransientTaskbar(taskbarActivityContext)
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,13 @@ object TaskbarIconSpecs {
    val defaultPersistentIconSize = iconSize40dp
    val defaultTransientIconSize = iconSize44dp

    val minimumIconSize = iconSize40dp

    val defaultPersistentIconMargin = TaskbarIconMarginSize(6)
    val defaultTransientIconMargin = TaskbarIconMarginSize(12)

    val minimumTaskbarIconTouchSize = TaskbarIconSize(48)

    val transientTaskbarIconSizeByGridSize =
        mapOf(
            TransientTaskbarIconSizeKey(6, 5, false) to iconSize52dp,
Loading