From 4237e8277a717a467051d645f72af6e3f55af0e5 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 31 Mar 2020 17:22:28 -0700 Subject: [PATCH 1/2] Reintroduced app ops for conversation notifications Previously app ops weren't showing in conversation notifications Also made sure that they show in case the app name is long. Additionally this fixes the coloring of the sender name. Fixes: 150905003 Test: atest SystemUITests Change-Id: Iae8026e7efdec8c207d1984dac4ee089abe116b9 --- .../android/view/NotificationHeaderView.java | 26 ---------- .../internal/widget/ConversationLayout.java | 48 +++++++++++++++++++ ...ication_template_material_conversation.xml | 39 +++++++++++++++ .../row/ExpandableNotificationRow.java | 4 +- .../row/NotificationContentView.java | 12 ++--- .../NotificationHeaderViewWrapper.java | 48 ++++++++++++++++++- .../row/wrapper/NotificationViewWrapper.java | 9 ++++ .../stack/NotificationChildrenContainer.java | 15 ++++++ .../row/ExpandableNotificationRowTest.java | 5 +- .../row/NotificationContentViewTest.java | 20 ++++---- 10 files changed, 177 insertions(+), 49 deletions(-) diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 0359f3b4fde7a..25bf15fc3af93 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -60,9 +60,6 @@ public class NotificationHeaderView extends ViewGroup { private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; - private View mOverlayIcon; - private View mCameraIcon; - private View mMicIcon; private View mAppOps; private View mAudiblyAlertedIcon; private boolean mExpanded; @@ -121,9 +118,6 @@ public class NotificationHeaderView extends ViewGroup { mExpandButton = findViewById(com.android.internal.R.id.expand_button); mIcon = findViewById(com.android.internal.R.id.icon); mProfileBadge = findViewById(com.android.internal.R.id.profile_badge); - mCameraIcon = findViewById(com.android.internal.R.id.camera); - mMicIcon = findViewById(com.android.internal.R.id.mic); - mOverlayIcon = findViewById(com.android.internal.R.id.overlay); mAppOps = findViewById(com.android.internal.R.id.app_ops); mAudiblyAlertedIcon = findViewById(com.android.internal.R.id.alerted_icon); } @@ -300,10 +294,6 @@ public class NotificationHeaderView extends ViewGroup { */ public void setAppOpsOnClickListener(OnClickListener l) { mAppOpsListener = l; - mAppOps.setOnClickListener(mAppOpsListener); - mCameraIcon.setOnClickListener(mAppOpsListener); - mMicIcon.setOnClickListener(mAppOpsListener); - mOverlayIcon.setOnClickListener(mAppOpsListener); updateTouchListener(); } @@ -328,22 +318,6 @@ public class NotificationHeaderView extends ViewGroup { updateExpandButton(); } - /** - * Shows or hides 'app op in use' icons based on app usage. - */ - public void showAppOpsIcons(ArraySet appOps) { - if (mOverlayIcon == null || mCameraIcon == null || mMicIcon == null || appOps == null) { - return; - } - - mOverlayIcon.setVisibility(appOps.contains(AppOpsManager.OP_SYSTEM_ALERT_WINDOW) - ? View.VISIBLE : View.GONE); - mCameraIcon.setVisibility(appOps.contains(AppOpsManager.OP_CAMERA) - ? View.VISIBLE : View.GONE); - mMicIcon.setVisibility(appOps.contains(AppOpsManager.OP_RECORD_AUDIO) - ? View.VISIBLE : View.GONE); - } - /** Updates icon visibility based on the noisiness of the notification. */ public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { mAudiblyAlertedIcon.setVisibility(audiblyAlerted ? View.VISIBLE : View.GONE); diff --git a/core/java/com/android/internal/widget/ConversationLayout.java b/core/java/com/android/internal/widget/ConversationLayout.java index 5248ca944c3d8..ab68c440483ed 100644 --- a/core/java/com/android/internal/widget/ConversationLayout.java +++ b/core/java/com/android/internal/widget/ConversationLayout.java @@ -45,6 +45,7 @@ import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.Gravity; import android.view.RemotableViewMethod; +import android.view.TouchDelegate; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; @@ -153,6 +154,9 @@ public class ConversationLayout extends FrameLayout private int mFacePileProtectionWidthExpanded; private boolean mImportantConversation; private TextView mUnreadBadge; + private ViewGroup mAppOps; + private Rect mAppOpsTouchRect = new Rect(); + private float mMinTouchSize; public ConversationLayout(@NonNull Context context) { super(context); @@ -191,6 +195,8 @@ public class ConversationLayout extends FrameLayout mConversationIcon = findViewById(R.id.conversation_icon); mConversationIconContainer = findViewById(R.id.conversation_icon_container); mIcon = findViewById(R.id.icon); + mAppOps = findViewById(com.android.internal.R.id.app_ops); + mMinTouchSize = 48 * getResources().getDisplayMetrics().density; mImportanceRingView = findViewById(R.id.conversation_icon_badge_ring); mConversationIconBadge = findViewById(R.id.conversation_icon_badge); mConversationIconBadgeBg = findViewById(R.id.conversation_icon_badge_bg); @@ -871,6 +877,7 @@ public class ConversationLayout extends FrameLayout @RemotableViewMethod public void setSenderTextColor(int color) { mSenderTextColor = color; + mConversationText.setTextColor(color); } /** @@ -1071,6 +1078,47 @@ public class ConversationLayout extends FrameLayout } }); } + if (mAppOps.getWidth() > 0) { + + // Let's increase the touch size of the app ops view if it's here + mAppOpsTouchRect.set( + mAppOps.getLeft(), + mAppOps.getTop(), + mAppOps.getRight(), + mAppOps.getBottom()); + for (int i = 0; i < mAppOps.getChildCount(); i++) { + View child = mAppOps.getChildAt(i); + if (child.getVisibility() == GONE) { + continue; + } + // Make sure each child has at least a minTouchSize touch target around it + float childTouchLeft = child.getLeft() + child.getWidth() / 2.0f + - mMinTouchSize / 2.0f; + float childTouchRight = childTouchLeft + mMinTouchSize; + mAppOpsTouchRect.left = (int) Math.min(mAppOpsTouchRect.left, + mAppOps.getLeft() + childTouchLeft); + mAppOpsTouchRect.right = (int) Math.max(mAppOpsTouchRect.right, + mAppOps.getLeft() + childTouchRight); + } + + // Increase the height + int heightIncrease = 0; + if (mAppOpsTouchRect.height() < mMinTouchSize) { + heightIncrease = (int) Math.ceil((mMinTouchSize - mAppOpsTouchRect.height()) + / 2.0f); + } + mAppOpsTouchRect.inset(0, -heightIncrease); + + // Let's adjust the hitrect since app ops isn't a direct child + ViewGroup viewGroup = (ViewGroup) mAppOps.getParent(); + while (viewGroup != this) { + mAppOpsTouchRect.offset(viewGroup.getLeft(), viewGroup.getTop()); + viewGroup = (ViewGroup) viewGroup.getParent(); + } + // + // Extend the size of the app opps to be at least 48dp + setTouchDelegate(new TouchDelegate(mAppOpsTouchRect, mAppOps)); + } } public MessagingLinearLayout getMessagingLinearLayout() { diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index 581c53fa44eee..da7636f136802 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -136,6 +136,7 @@ android:textAppearance="@style/TextAppearance.DeviceDefault.Notification.Title" android:textSize="16sp" android:singleLine="true" + android:layout_weight="1" /> + + + + + diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 9792defe0e0b2..7175c5ea8e3ba 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -1669,8 +1669,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView } public void showAppOpsIcons(ArraySet activeOps) { - if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() != null) { - mChildrenContainer.getHeaderView().showAppOpsIcons(activeOps); + if (mIsSummaryWithChildren) { + mChildrenContainer.showAppOpsIcons(activeOps); } mPrivateLayout.showAppOpsIcons(activeOps); mPublicLayout.showAppOpsIcons(activeOps); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 9b9225e0bde0a..c95291a07f9f0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1468,14 +1468,14 @@ public class NotificationContentView extends FrameLayout { } public void showAppOpsIcons(ArraySet activeOps) { - if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) { - mContractedWrapper.getNotificationHeader().showAppOpsIcons(activeOps); + if (mContractedChild != null) { + mContractedWrapper.showAppOpsIcons(activeOps); } - if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) { - mExpandedWrapper.getNotificationHeader().showAppOpsIcons(activeOps); + if (mExpandedChild != null) { + mExpandedWrapper.showAppOpsIcons(activeOps); } - if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) { - mHeadsUpWrapper.getNotificationHeader().showAppOpsIcons(activeOps); + if (mHeadsUpChild != null) { + mHeadsUpWrapper.showAppOpsIcons(activeOps); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index 7808a4b2dc741..29182d1f23cc0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -18,6 +18,8 @@ package com.android.systemui.statusbar.notification.row.wrapper; import static com.android.systemui.statusbar.notification.TransformState.TRANSFORM_Y; +import android.annotation.NonNull; +import android.app.AppOpsManager; import android.app.Notification; import android.content.Context; import android.util.ArraySet; @@ -60,6 +62,10 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { protected NotificationHeaderView mNotificationHeader; private TextView mHeaderText; private ImageView mWorkProfileImage; + private View mCameraIcon; + private View mMicIcon; + private View mOverlayIcon; + private View mAppOps; private boolean mIsLowPriority; private boolean mTransformLowPriorityTitle; @@ -107,6 +113,10 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { mExpandButton = mView.findViewById(com.android.internal.R.id.expand_button); mWorkProfileImage = mView.findViewById(com.android.internal.R.id.profile_badge); mNotificationHeader = mView.findViewById(com.android.internal.R.id.notification_header); + mCameraIcon = mView.findViewById(com.android.internal.R.id.camera); + mMicIcon = mView.findViewById(com.android.internal.R.id.mic); + mOverlayIcon = mView.findViewById(com.android.internal.R.id.overlay); + mAppOps = mView.findViewById(com.android.internal.R.id.app_ops); if (mNotificationHeader != null) { mNotificationHeader.setShowExpandButtonAtEnd(mShowExpandButtonAtEnd); mColor = mNotificationHeader.getOriginalIconColor(); @@ -114,8 +124,35 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { } private void addAppOpsOnClickListener(ExpandableNotificationRow row) { + View.OnClickListener listener = row.getAppOpsOnClickListener(); if (mNotificationHeader != null) { - mNotificationHeader.setAppOpsOnClickListener(row.getAppOpsOnClickListener()); + mNotificationHeader.setAppOpsOnClickListener(listener); + } + mAppOps.setOnClickListener(listener); + mCameraIcon.setOnClickListener(listener); + mMicIcon.setOnClickListener(listener); + mOverlayIcon.setOnClickListener(listener); + } + + /** + * Shows or hides 'app op in use' icons based on app usage. + */ + @Override + public void showAppOpsIcons(ArraySet appOps) { + if (appOps == null) { + return; + } + if (mOverlayIcon != null) { + mOverlayIcon.setVisibility(appOps.contains(AppOpsManager.OP_SYSTEM_ALERT_WINDOW) + ? View.VISIBLE : View.GONE); + } + if (mCameraIcon != null) { + mCameraIcon.setVisibility(appOps.contains(AppOpsManager.OP_CAMERA) + ? View.VISIBLE : View.GONE); + } + if (mMicIcon != null) { + mMicIcon.setVisibility(appOps.contains(AppOpsManager.OP_RECORD_AUDIO) + ? View.VISIBLE : View.GONE); } } @@ -184,6 +221,15 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { mTransformationHelper.addTransformedView(TransformableView.TRANSFORMING_VIEW_TITLE, mHeaderText); } + if (mCameraIcon != null) { + mTransformationHelper.addViewTransformingToSimilar(mCameraIcon); + } + if (mMicIcon != null) { + mTransformationHelper.addViewTransformingToSimilar(mMicIcon); + } + if (mOverlayIcon != null) { + mTransformationHelper.addViewTransformingToSimilar(mOverlayIcon); + } } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index e4fb2f7c42d43..d41f13d511a11 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -29,6 +29,7 @@ import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; +import android.util.ArraySet; import android.view.NotificationHeaderView; import android.view.View; import android.view.ViewGroup; @@ -95,6 +96,14 @@ public abstract class NotificationViewWrapper implements TransformableView { public void onContentUpdated(ExpandableNotificationRow row) { } + /** + * Show a set of app opp icons in the layout. + * + * @param appOps which app ops to show + */ + public void showAppOpsIcons(ArraySet appOps) { + } + public void onReinflated() { if (shouldClearBackgroundOnReapply()) { mBackgroundColor = 0; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java index 3d0bf3f4c1c6d..1e006d5abf315 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java @@ -22,6 +22,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.drawable.ColorDrawable; import android.service.notification.StatusBarNotification; +import android.util.ArraySet; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.NotificationHeaderView; @@ -1265,4 +1266,18 @@ public class NotificationChildrenContainer extends ViewGroup { mHeaderVisibleAmount = headerVisibleAmount; mCurrentHeaderTranslation = (int) ((1.0f - headerVisibleAmount) * mTranslationForHeader); } + + /** + * Show a set of app opp icons in the layout. + * + * @param appOps which app ops to show + */ + public void showAppOpsIcons(ArraySet appOps) { + if (mNotificationHeaderWrapper != null) { + mNotificationHeaderWrapper.showAppOpsIcons(appOps); + } + if (mNotificationHeaderWrapperLowPriority != null) { + mNotificationHeaderWrapperLowPriority.showAppOpsIcons(appOps); + } + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java index c356e0d16512d..cb379208eb946 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java @@ -229,22 +229,19 @@ public class ExpandableNotificationRowTest extends SysuiTestCase { @Test public void testShowAppOpsIcons_header() { - NotificationHeaderView mockHeader = mock(NotificationHeaderView.class); - NotificationContentView publicLayout = mock(NotificationContentView.class); mGroupRow.setPublicLayout(publicLayout); NotificationContentView privateLayout = mock(NotificationContentView.class); mGroupRow.setPrivateLayout(privateLayout); NotificationChildrenContainer mockContainer = mock(NotificationChildrenContainer.class); when(mockContainer.getNotificationChildCount()).thenReturn(1); - when(mockContainer.getHeaderView()).thenReturn(mockHeader); mGroupRow.setChildrenContainer(mockContainer); ArraySet ops = new ArraySet<>(); ops.add(AppOpsManager.OP_ANSWER_PHONE_CALLS); mGroupRow.showAppOpsIcons(ops); - verify(mockHeader, times(1)).showAppOpsIcons(ops); + verify(mockContainer, times(1)).showAppOpsIcons(ops); verify(privateLayout, times(1)).showAppOpsIcons(ops); verify(publicLayout, times(1)).showAppOpsIcons(ops); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java index 84c651368dc94..0f268984a996d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java @@ -76,14 +76,14 @@ public class NotificationContentViewTest extends SysuiTestCase { @Test @UiThreadTest public void testShowAppOpsIcons() { - NotificationHeaderView mockContracted = mock(NotificationHeaderView.class); - when(mockContracted.findViewById(com.android.internal.R.id.notification_header)) + View mockContracted = mock(View.class); + when(mockContracted.findViewById(com.android.internal.R.id.mic)) .thenReturn(mockContracted); - NotificationHeaderView mockExpanded = mock(NotificationHeaderView.class); - when(mockExpanded.findViewById(com.android.internal.R.id.notification_header)) + View mockExpanded = mock(View.class); + when(mockExpanded.findViewById(com.android.internal.R.id.mic)) .thenReturn(mockExpanded); - NotificationHeaderView mockHeadsUp = mock(NotificationHeaderView.class); - when(mockHeadsUp.findViewById(com.android.internal.R.id.notification_header)) + View mockHeadsUp = mock(View.class); + when(mockHeadsUp.findViewById(com.android.internal.R.id.mic)) .thenReturn(mockHeadsUp); mView.setContractedChild(mockContracted); @@ -91,11 +91,11 @@ public class NotificationContentViewTest extends SysuiTestCase { mView.setHeadsUpChild(mockHeadsUp); ArraySet ops = new ArraySet<>(); - ops.add(AppOpsManager.OP_ANSWER_PHONE_CALLS); + ops.add(AppOpsManager.OP_RECORD_AUDIO); mView.showAppOpsIcons(ops); - verify(mockContracted, times(1)).showAppOpsIcons(ops); - verify(mockExpanded, times(1)).showAppOpsIcons(ops); - verify(mockHeadsUp, times(1)).showAppOpsIcons(any()); + verify(mockContracted, times(1)).setVisibility(View.VISIBLE); + verify(mockExpanded, times(1)).setVisibility(View.VISIBLE); + verify(mockHeadsUp, times(1)).setVisibility(View.VISIBLE); } } From a2b1d3753be5a374426df878fc93c4a0bc92b6bd Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Tue, 31 Mar 2020 17:54:19 -0700 Subject: [PATCH 2/2] Added back the recently alerted indicator to conversations Previously this was dropped, it's now reintroduced. Fixes: 150905003 Test: atest SystemUITests Change-Id: Ia152bc4117fa9c656b3d477ef8e50708e1056148 --- core/java/android/view/NotificationHeaderView.java | 7 ------- .../notification_template_material_conversation.xml | 12 ++++++++++++ .../notification/row/ExpandableNotificationRow.java | 4 ++-- .../notification/row/NotificationContentView.java | 12 ++++++------ .../row/wrapper/NotificationHeaderViewWrapper.java | 12 ++++++++++++ .../row/wrapper/NotificationViewWrapper.java | 6 ++++++ .../stack/NotificationChildrenContainer.java | 9 +++++++++ 7 files changed, 47 insertions(+), 15 deletions(-) diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 25bf15fc3af93..a9f3e04036b57 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -61,7 +61,6 @@ public class NotificationHeaderView extends ViewGroup { private CachingIconView mIcon; private View mProfileBadge; private View mAppOps; - private View mAudiblyAlertedIcon; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; @@ -119,7 +118,6 @@ public class NotificationHeaderView extends ViewGroup { mIcon = findViewById(com.android.internal.R.id.icon); mProfileBadge = findViewById(com.android.internal.R.id.profile_badge); mAppOps = findViewById(com.android.internal.R.id.app_ops); - mAudiblyAlertedIcon = findViewById(com.android.internal.R.id.alerted_icon); } @Override @@ -318,11 +316,6 @@ public class NotificationHeaderView extends ViewGroup { updateExpandButton(); } - /** Updates icon visibility based on the noisiness of the notification. */ - public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { - mAudiblyAlertedIcon.setVisibility(audiblyAlerted ? View.VISIBLE : View.GONE); - } - private void updateExpandButton() { int drawableId; int contentDescriptionId; diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml index da7636f136802..b9ca29276cf00 100644 --- a/core/res/res/layout/notification_template_material_conversation.xml +++ b/core/res/res/layout/notification_template_material_conversation.xml @@ -166,6 +166,18 @@ android:visibility="gone" /> + + applyAudiblyAlertedRecently(false); private void applyAudiblyAlertedRecently(boolean audiblyAlertedRecently) { - if (mIsSummaryWithChildren && mChildrenContainer.getHeaderView() != null) { - mChildrenContainer.getHeaderView().setRecentlyAudiblyAlerted(audiblyAlertedRecently); + if (mIsSummaryWithChildren) { + mChildrenContainer.setRecentlyAudiblyAlerted(audiblyAlertedRecently); } mPrivateLayout.setRecentlyAudiblyAlerted(audiblyAlertedRecently); mPublicLayout.setRecentlyAudiblyAlerted(audiblyAlertedRecently); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index c95291a07f9f0..8efdc1b56e8e3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -1481,14 +1481,14 @@ public class NotificationContentView extends FrameLayout { /** Sets whether the notification being displayed audibly alerted the user. */ public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { - if (mContractedChild != null && mContractedWrapper.getNotificationHeader() != null) { - mContractedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); + if (mContractedChild != null) { + mContractedWrapper.setRecentlyAudiblyAlerted(audiblyAlerted); } - if (mExpandedChild != null && mExpandedWrapper.getNotificationHeader() != null) { - mExpandedWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); + if (mExpandedChild != null) { + mExpandedWrapper.setRecentlyAudiblyAlerted(audiblyAlerted); } - if (mHeadsUpChild != null && mHeadsUpWrapper.getNotificationHeader() != null) { - mHeadsUpWrapper.getNotificationHeader().setRecentlyAudiblyAlerted(audiblyAlerted); + if (mHeadsUpChild != null) { + mHeadsUpWrapper.setRecentlyAudiblyAlerted(audiblyAlerted); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java index 29182d1f23cc0..0c311b403c489 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java @@ -66,6 +66,7 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { private View mMicIcon; private View mOverlayIcon; private View mAppOps; + private View mAudiblyAlertedIcon; private boolean mIsLowPriority; private boolean mTransformLowPriorityTitle; @@ -117,6 +118,7 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { mMicIcon = mView.findViewById(com.android.internal.R.id.mic); mOverlayIcon = mView.findViewById(com.android.internal.R.id.overlay); mAppOps = mView.findViewById(com.android.internal.R.id.app_ops); + mAudiblyAlertedIcon = mView.findViewById(com.android.internal.R.id.alerted_icon); if (mNotificationHeader != null) { mNotificationHeader.setShowExpandButtonAtEnd(mShowExpandButtonAtEnd); mColor = mNotificationHeader.getOriginalIconColor(); @@ -230,6 +232,9 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { if (mOverlayIcon != null) { mTransformationHelper.addViewTransformingToSimilar(mOverlayIcon); } + if (mAudiblyAlertedIcon != null) { + mTransformationHelper.addViewTransformingToSimilar(mAudiblyAlertedIcon); + } } @Override @@ -240,6 +245,13 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper { } } + @Override + public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { + if (mAudiblyAlertedIcon != null) { + mAudiblyAlertedIcon.setVisibility(audiblyAlerted ? View.VISIBLE : View.GONE); + } + } + @Override public NotificationHeaderView getNotificationHeader() { return mNotificationHeader; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java index d41f13d511a11..fa7f282be74a2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java @@ -371,4 +371,10 @@ public abstract class NotificationViewWrapper implements TransformableView { public int getExtraMeasureHeight() { return 0; } + + /** + * Set the view to have recently visibly alerted. + */ + public void setRecentlyAudiblyAlerted(boolean audiblyAlerted) { + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java index 1e006d5abf315..400e794b820b2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java @@ -1280,4 +1280,13 @@ public class NotificationChildrenContainer extends ViewGroup { mNotificationHeaderWrapperLowPriority.showAppOpsIcons(appOps); } } + + public void setRecentlyAudiblyAlerted(boolean audiblyAlertedRecently) { + if (mNotificationHeaderWrapper != null) { + mNotificationHeaderWrapper.setRecentlyAudiblyAlerted(audiblyAlertedRecently); + } + if (mNotificationHeaderWrapperLowPriority != null) { + mNotificationHeaderWrapperLowPriority.setRecentlyAudiblyAlerted(audiblyAlertedRecently); + } + } }