1 /* 2 * Copyright (C) 2025 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 package com.android.launcher3.taskbar.growth 17 18 import android.content.Context 19 import com.android.launcher3.Utilities 20 import com.android.launcher3.taskbar.TaskbarActivityContext 21 import com.android.launcher3.taskbar.TaskbarControllers 22 import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController 23 import com.android.launcher3.util.DisplayController 24 import com.android.launcher3.views.ActivityContext 25 import java.io.PrintWriter 26 27 /** Controls nudge lifecycles. */ 28 class NudgeController(context: Context) : LoggableTaskbarController { 29 30 protected val activityContext: TaskbarActivityContext = ActivityContext.lookupContext(context) 31 32 private val isNudgeEnabled: Boolean 33 get() { 34 return !Utilities.isRunningInTestHarness() && 35 !activityContext.isPhoneMode && 36 !activityContext.isTinyTaskbar 37 } 38 39 private lateinit var controllers: TaskbarControllers 40 initnull41 fun init(controllers: TaskbarControllers) { 42 this.controllers = controllers 43 } 44 maybeShownull45 fun maybeShow(payload: NudgePayload) { 46 if (!isNudgeEnabled || !DisplayController.isTransientTaskbar(activityContext)) { 47 return 48 } 49 // TODO: b/398033012 - create and show nudge view based on the payload. 50 } 51 52 /** Closes the current [nudgeView]. */ hidenull53 fun hide() { 54 // TODO: b/398033012 - hide the nudge view. 55 } 56 dumpLogsnull57 override fun dumpLogs(prefix: String?, pw: PrintWriter?) { 58 pw?.println(prefix + "NudgeController:") 59 pw?.println("$prefix\tisNudgeEnabled=$isNudgeEnabled") 60 } 61 } 62