Loading core/java/android/app/Notification.java +8 −0 Original line number Diff line number Diff line Loading @@ -5151,10 +5151,18 @@ public class Notification implements Parcelable bindHeaderChronometerAndTime(contentView, p); bindProfileBadge(contentView, p); bindAlertedIcon(contentView, p); bindActivePermissions(contentView, p); bindExpandButton(contentView, p); mN.mUsesStandardHeader = true; } private void bindActivePermissions(RemoteViews contentView, StandardTemplateParams p) { int color = getNeutralColor(p); contentView.setDrawableTint(R.id.camera, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setDrawableTint(R.id.mic, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setDrawableTint(R.id.overlay, false, color, PorterDuff.Mode.SRC_ATOP); } private void bindExpandButton(RemoteViews contentView, StandardTemplateParams p) { int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p); contentView.setDrawableTint(R.id.expand_button, false, color, Loading core/java/android/view/NotificationHeaderView.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,11 +52,13 @@ public class NotificationHeaderView extends ViewGroup { private View mHeaderText; private View mSecondaryHeaderText; private OnClickListener mExpandClickListener; private OnClickListener mAppOpsListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private LinearLayout mTransferChip; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mAppOps; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; Loading Loading @@ -113,6 +115,7 @@ 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); mAppOps = findViewById(com.android.internal.R.id.app_ops); } @Override Loading Loading @@ -140,6 +143,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge || child == mAppOps || child == mTransferChip) { iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); } else { Loading Loading @@ -204,6 +208,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge || child == mAppOps || child == mTransferChip) { if (end == getMeasuredWidth()) { layoutRight = end - mContentEndMargin; Loading Loading @@ -272,10 +277,22 @@ public class NotificationHeaderView extends ViewGroup { } private void updateTouchListener() { if (mExpandClickListener == null && mAppOpsListener == null) { setOnTouchListener(null); return; } setOnTouchListener(mTouchListener); mTouchListener.bindTouchRects(); } /** * Sets onclick listener for app ops icons. */ public void setAppOpsOnClickListener(OnClickListener l) { mAppOpsListener = l; updateTouchListener(); } @Override public void setOnClickListener(@Nullable OnClickListener l) { mExpandClickListener = l; Loading Loading @@ -363,6 +380,7 @@ public class NotificationHeaderView extends ViewGroup { private final ArrayList<Rect> mTouchRects = new ArrayList<>(); private Rect mExpandButtonRect; private Rect mAppOpsRect; private int mTouchSlop; private boolean mTrackGesture; private float mDownX; Loading @@ -375,6 +393,8 @@ public class NotificationHeaderView extends ViewGroup { mTouchRects.clear(); addRectAroundView(mIcon); mExpandButtonRect = addRectAroundView(mExpandButton); mAppOpsRect = addRectAroundView(mAppOps); setTouchDelegate(new TouchDelegate(mAppOpsRect, mAppOps)); addWidthRect(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } Loading Loading @@ -435,6 +455,11 @@ public class NotificationHeaderView extends ViewGroup { break; case MotionEvent.ACTION_UP: if (mTrackGesture) { if (mAppOps.isVisibleToUser() && (mAppOpsRect.contains((int) x, (int) y) || mAppOpsRect.contains((int) mDownX, (int) mDownY))) { mAppOps.performClick(); return true; } mExpandButton.performClick(); } break; Loading core/java/com/android/internal/widget/ConversationLayout.java +44 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ 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; private Icon mConversationIcon; private Icon mShortcutIcon; Loading Loading @@ -208,6 +210,7 @@ public class ConversationLayout extends FrameLayout mConversationIconView = 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); Loading Loading @@ -1163,6 +1166,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() { Loading core/res/res/layout/notification_template_header.xml +37 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,43 @@ android:visibility="gone" android:contentDescription="@string/notification_work_profile_content_description" /> <LinearLayout android:id="@+id/app_ops" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_marginStart="6dp" android:background="?android:selectableItemBackgroundBorderless" android:orientation="horizontal"> <ImageView android:id="@+id/camera" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_camera" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_camera_active" /> <ImageView android:id="@+id/mic" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_mic" android:layout_marginStart="4dp" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_microphone_active" /> <ImageView android:id="@+id/overlay" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_alert_window_layer" android:layout_marginStart="4dp" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_overlay_active" /> </LinearLayout> <include layout="@layout/notification_material_media_transfer_action" android:id="@+id/media_seamless" Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java +5 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,11 @@ public interface NotificationMenuRowPlugin extends Plugin { */ public MenuItem getLongpressMenuItem(Context context); /** * @return the {@link MenuItem} to display when app ops icons are pressed. */ public MenuItem getAppOpsMenuItem(Context context); /** * @return the {@link MenuItem} to display when snooze item is pressed. */ Loading Loading
core/java/android/app/Notification.java +8 −0 Original line number Diff line number Diff line Loading @@ -5151,10 +5151,18 @@ public class Notification implements Parcelable bindHeaderChronometerAndTime(contentView, p); bindProfileBadge(contentView, p); bindAlertedIcon(contentView, p); bindActivePermissions(contentView, p); bindExpandButton(contentView, p); mN.mUsesStandardHeader = true; } private void bindActivePermissions(RemoteViews contentView, StandardTemplateParams p) { int color = getNeutralColor(p); contentView.setDrawableTint(R.id.camera, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setDrawableTint(R.id.mic, false, color, PorterDuff.Mode.SRC_ATOP); contentView.setDrawableTint(R.id.overlay, false, color, PorterDuff.Mode.SRC_ATOP); } private void bindExpandButton(RemoteViews contentView, StandardTemplateParams p) { int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p); contentView.setDrawableTint(R.id.expand_button, false, color, Loading
core/java/android/view/NotificationHeaderView.java +25 −0 Original line number Diff line number Diff line Loading @@ -52,11 +52,13 @@ public class NotificationHeaderView extends ViewGroup { private View mHeaderText; private View mSecondaryHeaderText; private OnClickListener mExpandClickListener; private OnClickListener mAppOpsListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); private LinearLayout mTransferChip; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mAppOps; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; Loading Loading @@ -113,6 +115,7 @@ 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); mAppOps = findViewById(com.android.internal.R.id.app_ops); } @Override Loading Loading @@ -140,6 +143,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge || child == mAppOps || child == mTransferChip) { iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); } else { Loading Loading @@ -204,6 +208,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge || child == mAppOps || child == mTransferChip) { if (end == getMeasuredWidth()) { layoutRight = end - mContentEndMargin; Loading Loading @@ -272,10 +277,22 @@ public class NotificationHeaderView extends ViewGroup { } private void updateTouchListener() { if (mExpandClickListener == null && mAppOpsListener == null) { setOnTouchListener(null); return; } setOnTouchListener(mTouchListener); mTouchListener.bindTouchRects(); } /** * Sets onclick listener for app ops icons. */ public void setAppOpsOnClickListener(OnClickListener l) { mAppOpsListener = l; updateTouchListener(); } @Override public void setOnClickListener(@Nullable OnClickListener l) { mExpandClickListener = l; Loading Loading @@ -363,6 +380,7 @@ public class NotificationHeaderView extends ViewGroup { private final ArrayList<Rect> mTouchRects = new ArrayList<>(); private Rect mExpandButtonRect; private Rect mAppOpsRect; private int mTouchSlop; private boolean mTrackGesture; private float mDownX; Loading @@ -375,6 +393,8 @@ public class NotificationHeaderView extends ViewGroup { mTouchRects.clear(); addRectAroundView(mIcon); mExpandButtonRect = addRectAroundView(mExpandButton); mAppOpsRect = addRectAroundView(mAppOps); setTouchDelegate(new TouchDelegate(mAppOpsRect, mAppOps)); addWidthRect(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } Loading Loading @@ -435,6 +455,11 @@ public class NotificationHeaderView extends ViewGroup { break; case MotionEvent.ACTION_UP: if (mTrackGesture) { if (mAppOps.isVisibleToUser() && (mAppOpsRect.contains((int) x, (int) y) || mAppOpsRect.contains((int) mDownX, (int) mDownY))) { mAppOps.performClick(); return true; } mExpandButton.performClick(); } break; Loading
core/java/com/android/internal/widget/ConversationLayout.java +44 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,8 @@ 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; private Icon mConversationIcon; private Icon mShortcutIcon; Loading Loading @@ -208,6 +210,7 @@ public class ConversationLayout extends FrameLayout mConversationIconView = 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); Loading Loading @@ -1163,6 +1166,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() { Loading
core/res/res/layout/notification_template_header.xml +37 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,43 @@ android:visibility="gone" android:contentDescription="@string/notification_work_profile_content_description" /> <LinearLayout android:id="@+id/app_ops" android:layout_height="match_parent" android:layout_width="wrap_content" android:layout_marginStart="6dp" android:background="?android:selectableItemBackgroundBorderless" android:orientation="horizontal"> <ImageView android:id="@+id/camera" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_camera" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_camera_active" /> <ImageView android:id="@+id/mic" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_mic" android:layout_marginStart="4dp" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_microphone_active" /> <ImageView android:id="@+id/overlay" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:src="@drawable/ic_alert_window_layer" android:layout_marginStart="4dp" android:visibility="gone" android:focusable="false" android:contentDescription="@string/notification_appops_overlay_active" /> </LinearLayout> <include layout="@layout/notification_material_media_transfer_action" android:id="@+id/media_seamless" Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/statusbar/NotificationMenuRowPlugin.java +5 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,11 @@ public interface NotificationMenuRowPlugin extends Plugin { */ public MenuItem getLongpressMenuItem(Context context); /** * @return the {@link MenuItem} to display when app ops icons are pressed. */ public MenuItem getAppOpsMenuItem(Context context); /** * @return the {@link MenuItem} to display when snooze item is pressed. */ Loading