1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3.taskbar.customization 18 19 import com.android.launcher3.Flags.enableRecentsInTaskbar 20 import com.android.launcher3.config.FeatureFlags.enableTaskbarPinning 21 import com.android.launcher3.taskbar.TaskbarActivityContext 22 import com.android.launcher3.util.DisplayController 23 24 /** Evaluates all the features taskbar can have. */ 25 class TaskbarFeatureEvaluator 26 private constructor(private val taskbarActivityContext: TaskbarActivityContext) { 27 val hasAllApps = true 28 val hasAppIcons = true 29 val hasBubbles = false 30 val hasNavButtons = taskbarActivityContext.isThreeButtonNav 31 32 val isRecentsEnabled: Boolean 33 get() = enableRecentsInTaskbar() 34 35 val hasDivider: Boolean 36 get() = enableTaskbarPinning() || isRecentsEnabled 37 38 val isTransient: Boolean 39 get() = DisplayController.isTransientTaskbar(taskbarActivityContext) 40 41 val isLandscape: Boolean 42 get() = taskbarActivityContext.deviceProfile.isLandscape 43 44 val supportsPinningPopup: Boolean 45 get() = !hasNavButtons 46 onDestroynull47 fun onDestroy() { 48 taskbarFeatureEvaluator = null 49 } 50 51 companion object { 52 @Volatile private var taskbarFeatureEvaluator: TaskbarFeatureEvaluator? = null 53 54 @JvmStatic getInstancenull55 fun getInstance(taskbarActivityContext: TaskbarActivityContext): TaskbarFeatureEvaluator { 56 synchronized(this) { 57 if (taskbarFeatureEvaluator == null) { 58 taskbarFeatureEvaluator = TaskbarFeatureEvaluator(taskbarActivityContext) 59 } 60 return taskbarFeatureEvaluator!! 61 } 62 } 63 } 64 } 65