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.systemui.statusbar.notification.row.wrapper
18 
19 import android.content.Context
20 import android.view.View
21 import android.view.ViewGroup
22 import com.android.internal.R
23 import com.android.internal.widget.CachingIconView
24 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
25 
26 /** Wraps a notification containing a messaging or conversation template */
27 class NotificationCompactMessagingTemplateViewWrapper
28 constructor(ctx: Context, view: View, row: ExpandableNotificationRow) :
29     NotificationCompactHeadsUpTemplateViewWrapper(ctx, view, row) {
30 
31     private val compactMessagingView: ViewGroup = requireNotNull(view as? ViewGroup)
32 
33     private var conversationIconView: CachingIconView? = null
34     private var expandBtn: View? = null
35     private var titleView: View? = null
36     private var headerTextSecondary: View? = null
37     private var subText: View? = null
38     private var facePileTop: View? = null
39     private var facePileBottom: View? = null
40     private var facePileBottomBg: View? = null
onContentUpdatednull41     override fun onContentUpdated(row: ExpandableNotificationRow?) {
42         resolveViews()
43         super.onContentUpdated(row)
44     }
45 
resolveViewsnull46     private fun resolveViews() {
47         conversationIconView = compactMessagingView.requireViewById(R.id.conversation_icon)
48         titleView = compactMessagingView.findViewById(R.id.title)
49         headerTextSecondary = compactMessagingView.findViewById(R.id.header_text_secondary)
50         subText = compactMessagingView.findViewById(R.id.header_text)
51         facePileTop = compactMessagingView.findViewById(R.id.conversation_face_pile_top)
52         facePileBottom = compactMessagingView.findViewById(R.id.conversation_face_pile_bottom)
53         facePileBottomBg =
54             compactMessagingView.findViewById(R.id.conversation_face_pile_bottom_background)
55 
56         expandBtn = compactMessagingView.requireViewById(R.id.expand_button)
57     }
58 
updateTransformedTypesnull59     override fun updateTransformedTypes() {
60         super.updateTransformedTypes()
61 
62         addViewsTransformingToSimilar(
63             conversationIconView,
64             titleView,
65             headerTextSecondary,
66             subText,
67             facePileTop,
68             facePileBottom,
69             facePileBottomBg,
70             expandBtn,
71         )
72     }
73 }
74