1 /* 2 * Copyright (C) 2021 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.statusbar.notification.row.wrapper 18 19 import android.content.Context 20 import android.view.View 21 import com.android.internal.widget.CachingIconView 22 import com.android.internal.widget.CallLayout 23 import com.android.systemui.res.R 24 import com.android.systemui.statusbar.notification.NotificationFadeAware 25 import com.android.systemui.statusbar.notification.NotificationUtils 26 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow 27 28 /** 29 * Wraps a notification containing a call template 30 */ 31 class NotificationCallTemplateViewWrapper constructor( 32 ctx: Context, 33 view: View, 34 row: ExpandableNotificationRow 35 ) : NotificationTemplateViewWrapper(ctx, view, row) { 36 37 private val minHeightWithActions: Int = 38 NotificationUtils.getFontScaledHeight(ctx, R.dimen.notification_max_height) 39 private val callLayout: CallLayout = view as CallLayout 40 41 private lateinit var conversationIconContainer: View 42 private lateinit var conversationIconView: CachingIconView 43 private lateinit var conversationBadgeBg: View 44 private lateinit var expandBtn: View 45 private lateinit var appName: View 46 private lateinit var conversationTitleView: View 47 resolveViewsnull48 private fun resolveViews() { 49 with(callLayout) { 50 conversationIconContainer = 51 requireViewById(com.android.internal.R.id.conversation_icon_container) 52 conversationIconView = requireViewById(com.android.internal.R.id.conversation_icon) 53 conversationBadgeBg = 54 requireViewById(com.android.internal.R.id.conversation_icon_badge_bg) 55 expandBtn = requireViewById(com.android.internal.R.id.expand_button) 56 appName = requireViewById(com.android.internal.R.id.app_name_text) 57 conversationTitleView = requireViewById(com.android.internal.R.id.conversation_text) 58 } 59 } 60 onContentUpdatednull61 override fun onContentUpdated(row: ExpandableNotificationRow) { 62 // Reinspect the notification. Before the super call, because the super call also updates 63 // the transformation types and we need to have our values set by then. 64 resolveViews() 65 super.onContentUpdated(row) 66 } 67 updateTransformedTypesnull68 override fun updateTransformedTypes() { 69 // This also clears the existing types 70 super.updateTransformedTypes() 71 addTransformedViews( 72 appName, 73 conversationTitleView 74 ) 75 addViewsTransformingToSimilar( 76 conversationIconView, 77 conversationBadgeBg, 78 expandBtn 79 ) 80 } 81 disallowSingleClicknull82 override fun disallowSingleClick(x: Float, y: Float): Boolean { 83 val isOnExpandButton = expandBtn.visibility == View.VISIBLE && 84 isOnView(expandBtn, x, y) 85 return isOnExpandButton || super.disallowSingleClick(x, y) 86 } 87 getMinLayoutHeightnull88 override fun getMinLayoutHeight(): Int = minHeightWithActions 89 90 /** 91 * Apply the faded state as a layer type change to the face pile view which needs to have 92 * overlapping contents render precisely. 93 */ 94 override fun setNotificationFaded(faded: Boolean) { 95 // Do not call super 96 NotificationFadeAware.setLayerTypeForFaded(expandBtn, faded) 97 NotificationFadeAware.setLayerTypeForFaded(conversationIconContainer, faded) 98 } 99 } 100