• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 /** Evaluates all the features taskbar can have. */
24 class TaskbarFeatureEvaluator
25 private constructor(private val taskbarActivityContext: TaskbarActivityContext) {
26     val hasAllApps = true
27     val hasAppIcons = true
28     val hasBubbles = false
29     val hasNavButtons = taskbarActivityContext.isThreeButtonNav
30 
31     val isRecentsEnabled: Boolean
32         get() = enableRecentsInTaskbar()
33 
34     val hasDivider: Boolean
35         get() = enableTaskbarPinning() || isRecentsEnabled
36 
37     val isTransient: Boolean
38         get() = taskbarActivityContext.isTransientTaskbar
39 
40     val isLandscape: Boolean
41         get() = taskbarActivityContext.deviceProfile.isLandscape
42 
43     val supportsPinningPopup: Boolean
44         get() = !hasNavButtons
45 
onDestroynull46     fun onDestroy() {
47         taskbarFeatureEvaluator = null
48     }
49 
50     companion object {
51         @Volatile private var taskbarFeatureEvaluator: TaskbarFeatureEvaluator? = null
52 
53         @JvmStatic
getInstancenull54         fun getInstance(taskbarActivityContext: TaskbarActivityContext): TaskbarFeatureEvaluator {
55             synchronized(this) {
56                 if (taskbarFeatureEvaluator == null) {
57                     taskbarFeatureEvaluator = TaskbarFeatureEvaluator(taskbarActivityContext)
58                 }
59                 return taskbarFeatureEvaluator!!
60             }
61         }
62     }
63 }
64