1 /* 2 * Copyright (C) 2022 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.systemui.temporarydisplay.chipbar 18 19 import android.os.VibrationEffect 20 import android.view.View 21 import androidx.annotation.ColorRes 22 import com.android.systemui.R 23 import com.android.systemui.common.shared.model.Text 24 import com.android.systemui.common.shared.model.TintedIcon 25 import com.android.systemui.temporarydisplay.TemporaryViewInfo 26 import com.android.systemui.temporarydisplay.ViewPriority 27 28 /** 29 * A container for all the state needed to display a chipbar via [ChipbarCoordinator]. 30 * 31 * @property startIcon the icon to display at the start of the chipbar (on the left in LTR locales; 32 * on the right in RTL locales). 33 * @property text the text to display. 34 * @property endItem an optional end item to display at the end of the chipbar (on the right in LTR 35 * locales; on the left in RTL locales). 36 * @property vibrationEffect an optional vibration effect when the chipbar is displayed 37 * @property allowSwipeToDismiss true if users are allowed to swipe up to dismiss this chipbar. 38 */ 39 data class ChipbarInfo( 40 val startIcon: TintedIcon, 41 val text: Text, 42 val endItem: ChipbarEndItem?, 43 val vibrationEffect: VibrationEffect? = null, 44 val allowSwipeToDismiss: Boolean = false, 45 override val windowTitle: String, 46 override val wakeReason: String, 47 override val timeoutMs: Int, 48 override val id: String, 49 override val priority: ViewPriority, 50 ) : TemporaryViewInfo() { 51 companion object { 52 @ColorRes val DEFAULT_ICON_TINT = R.color.chipbar_text_and_icon_color 53 } 54 } 55 56 /** The possible items to display at the end of the chipbar. */ 57 sealed class ChipbarEndItem { 58 /** A loading icon should be displayed. */ 59 object Loading : ChipbarEndItem() 60 61 /** An error icon should be displayed. */ 62 object Error : ChipbarEndItem() 63 64 /** 65 * A button with the provided [text] and [onClickListener] functionality should be displayed. 66 */ 67 data class Button(val text: Text, val onClickListener: View.OnClickListener) : ChipbarEndItem() 68 69 // TODO(b/245610654): Add support for a generic icon. 70 } 71