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 package com.android.systemui.statusbar.notification 17 18 import android.content.Intent 19 import android.provider.Settings.ACTION_AUTOMATIC_ZEN_RULE_SETTINGS 20 import android.provider.Settings.ACTION_NOTIFICATION_HISTORY 21 import android.provider.Settings.ACTION_NOTIFICATION_SETTINGS 22 import android.provider.Settings.ACTION_ZEN_MODE_SETTINGS 23 import android.provider.Settings.EXTRA_AUTOMATIC_ZEN_RULE_ID 24 import android.view.View 25 import com.android.systemui.statusbar.notification.collection.NotificationEntry 26 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow 27 28 /** 29 * Component responsible for handling actions on a notification which cause activites to start. 30 * (e.g. clicking on a notification, tapping on the settings icon in the notification guts) 31 */ 32 interface NotificationActivityStarter { 33 34 /** Called when the user clicks on the notification bubble icon. */ onNotificationBubbleIconClickednull35 fun onNotificationBubbleIconClicked(entry: NotificationEntry) 36 37 /** Called when the user clicks on the surface of a notification. */ 38 fun onNotificationClicked(entry: NotificationEntry, row: ExpandableNotificationRow) 39 40 /** Called when the user clicks on a button in the notification guts which fires an intent. */ 41 fun startNotificationGutsIntent(intent: Intent, appUid: Int, row: ExpandableNotificationRow) 42 43 /** 44 * Called when the user clicks "Manage" or "History" in the Shade. Prefer using 45 * [startSettingsIntent] instead. 46 */ 47 fun startHistoryIntent(view: View?, showHistory: Boolean) 48 49 /** 50 * Called to open a settings intent from a launchable view (such as the "Manage" or "History" 51 * button in the shade, or the "No notifications" text). 52 * 53 * @param view the view to perform the launch animation from (must extend [LaunchableView]) 54 * @param intentInfo information about the (settings) intent to be launched 55 */ 56 fun startSettingsIntent(view: View, intentInfo: SettingsIntent) 57 58 /** Called when the user succeed to drop notification to proper target view. */ 59 fun onDragSuccess(entry: NotificationEntry) 60 61 val isCollapsingToShowActivityOverLockscreen: Boolean 62 get() = false 63 64 /** 65 * Information about a settings intent to be launched. 66 * 67 * If the [targetIntent] is T and [backStack] is [A, B, C], the stack will look like 68 * [A, B, C, T]. 69 */ 70 data class SettingsIntent( 71 var targetIntent: Intent, 72 var backStack: List<Intent> = emptyList(), 73 var cujType: Int? = null, 74 ) { 75 // Utility factory methods for known intents 76 companion object { 77 fun forNotificationSettings(cujType: Int? = null) = 78 SettingsIntent( 79 targetIntent = Intent(ACTION_NOTIFICATION_SETTINGS), 80 cujType = cujType, 81 ) 82 83 fun forNotificationHistory(cujType: Int? = null) = 84 SettingsIntent( 85 targetIntent = Intent(ACTION_NOTIFICATION_HISTORY), 86 backStack = listOf(Intent(ACTION_NOTIFICATION_SETTINGS)), 87 cujType = cujType, 88 ) 89 90 fun forModesSettings(cujType: Int? = null) = 91 SettingsIntent(targetIntent = Intent(ACTION_ZEN_MODE_SETTINGS), cujType = cujType) 92 93 fun forModeSettings(modeId: String, cujType: Int? = null) = 94 SettingsIntent( 95 targetIntent = 96 Intent(ACTION_AUTOMATIC_ZEN_RULE_SETTINGS) 97 .putExtra(EXTRA_AUTOMATIC_ZEN_RULE_ID, modeId), 98 backStack = listOf(Intent(ACTION_ZEN_MODE_SETTINGS)), 99 cujType = cujType, 100 ) 101 } 102 } 103 } 104