Loading core/java/android/view/NotificationHeaderView.java +44 −20 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.view; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; Loading @@ -27,6 +28,7 @@ import android.util.AttributeSet; import android.widget.ImageView; import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import java.util.ArrayList; Loading @@ -52,9 +54,12 @@ public class NotificationHeaderView extends ViewGroup { private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; private Drawable mBackground; private int mHeaderBackgroundHeight; private boolean mEntireHeaderClickable; private boolean mAcceptAllTouches; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override Loading @@ -65,7 +70,6 @@ public class NotificationHeaderView extends ViewGroup { } } }; private boolean mAcceptAllTouches; public NotificationHeaderView(Context context) { this(context, null); Loading @@ -81,12 +85,12 @@ public class NotificationHeaderView extends ViewGroup { public NotificationHeaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mChildMinWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_shrink_min_width); mContentEndMargin = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_background_height); Resources res = getResources(); mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width); mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = res.getDimensionPixelSize( R.dimen.notification_header_background_height); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); } @Override Loading Loading @@ -147,8 +151,9 @@ public class NotificationHeaderView extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int left = getPaddingStart(); int end = getMeasuredWidth(); int childCount = getChildCount(); int ownHeight = getHeight() - getPaddingTop() - getPaddingBottom(); int ownHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child.getVisibility() == GONE) { Loading @@ -162,13 +167,17 @@ public class NotificationHeaderView extends ViewGroup { int bottom = top + childHeight; int layoutLeft = left; int layoutRight = right; if (child == mExpandButton && mShowExpandButtonAtEnd) { layoutRight = end - mContentEndMargin; end = layoutLeft = layoutRight - child.getMeasuredWidth(); } if (child == mProfileBadge) { int paddingEnd = getPaddingEnd(); if (mShowWorkBadgeAtEnd) { paddingEnd = mContentEndMargin; } layoutRight = getWidth() - paddingEnd; layoutLeft = layoutRight - child.getMeasuredWidth(); layoutRight = end - paddingEnd; end = layoutLeft = layoutRight - child.getMeasuredWidth(); } if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { int ltrLeft = layoutLeft; Loading Loading @@ -265,13 +274,11 @@ public class NotificationHeaderView extends ViewGroup { int drawableId; int contentDescriptionId; if (mExpanded) { drawableId = com.android.internal.R.drawable.ic_collapse_notification; contentDescriptionId = com.android.internal.R.string.expand_button_content_description_expanded; drawableId = R.drawable.ic_collapse_notification; contentDescriptionId = R.string.expand_button_content_description_expanded; } else { drawableId = com.android.internal.R.drawable.ic_expand_notification; contentDescriptionId = com.android.internal.R.string.expand_button_content_description_collapsed; drawableId = R.drawable.ic_expand_notification; contentDescriptionId = R.string.expand_button_content_description_collapsed; } mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); mExpandButton.setColorFilter(mOriginalNotificationColor); Loading @@ -285,6 +292,18 @@ public class NotificationHeaderView extends ViewGroup { } } /** * Sets whether or not the expand button appears at the end of the NotificationHeaderView. If * both this and {@link #setShowWorkBadgeAtEnd(boolean)} have been set to true, then the * expand button will appear closer to the end than the work badge. */ public void setShowExpandButtonAtEnd(boolean showExpandButtonAtEnd) { if (showExpandButtonAtEnd != mShowExpandButtonAtEnd) { setClipToPadding(!showExpandButtonAtEnd); mShowExpandButtonAtEnd = showExpandButtonAtEnd; } } public View getWorkProfileIcon() { return mProfileBadge; } Loading @@ -306,8 +325,8 @@ public class NotificationHeaderView extends ViewGroup { public void bindTouchRects() { mTouchRects.clear(); addRectAroundViewView(mIcon); addRectAroundViewView(mExpandButton); addRectAroundView(mIcon); addRectAroundView(mExpandButton); addWidthRect(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } Loading @@ -321,7 +340,7 @@ public class NotificationHeaderView extends ViewGroup { mTouchRects.add(r); } private void addRectAroundViewView(View view) { private void addRectAroundView(View view) { final Rect r = getRectAroundView(view); mTouchRects.add(r); } Loading Loading @@ -412,8 +431,13 @@ public class NotificationHeaderView extends ViewGroup { return mTouchListener.isInside(x, y); } /** * Sets whether or not all touches to this header view will register as a click. Note that * if the config value for {@code config_notificationHeaderClickableForExpand} is {@code true}, * then calling this method with {@code false} will not override that configuration. */ @RemotableViewMethod public void setAcceptAllTouches(boolean acceptAllTouches) { mAcceptAllTouches = acceptAllTouches; mAcceptAllTouches = mEntireHeaderClickable || acceptAllTouches; } } core/res/res/layout/notification_template_header.xml +18 −17 Original line number Diff line number Diff line Loading @@ -28,15 +28,15 @@ android:id="@+id/icon" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:layout_marginEnd="3dp" android:layout_marginEnd="@dimen/notification_header_icon_margin_end" /> <TextView android:id="@+id/app_name_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="3dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_app_name_margin_start" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:singleLine="true" /> <TextView Loading @@ -44,8 +44,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:text="@string/notification_header_divider_symbol" android:visibility="gone"/> <TextView Loading @@ -53,8 +53,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:visibility="gone" android:singleLine="true"/> <TextView Loading @@ -62,8 +62,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:text="@string/notification_header_divider_symbol" android:singleLine="true" android:visibility="gone"/> Loading @@ -73,8 +73,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:showRelative="true" android:singleLine="true" android:visibility="gone" /> Loading @@ -82,21 +82,22 @@ android:id="@+id/chronometer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:layout="@layout/notification_template_part_chronometer" android:visibility="gone" /> <com.android.internal.widget.NotificationExpandButton android:id="@+id/expand_button" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="1dp" android:layout_width="@dimen/notification_header_expand_icon_size" android:layout_height="@dimen/notification_header_expand_icon_size" android:paddingTop="@dimen/notification_expand_button_padding_top" android:visibility="gone" android:contentDescription="@string/expand_button_content_description_collapsed" /> <ImageView android:id="@+id/profile_badge" <ImageView android:id="@+id/profile_badge" android:layout_width="@dimen/notification_badge_size" android:layout_height="@dimen/notification_badge_size" android:layout_gravity="center" Loading core/res/res/layout/notification_template_material_big_media.xml +3 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,8 @@ --> <!-- Layout for the expanded media notification --> <com.android.internal.widget.MediaNotificationView xmlns:android="http://schemas.android.com/apk/res/android" <com.android.internal.widget.MediaNotificationView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" Loading @@ -25,7 +26,7 @@ > <include layout="@layout/notification_template_header" android:layout_width="match_parent" android:layout_height="53dp" android:layout_height="@dimen/media_notification_header_height" android:layout_gravity="start"/> <LinearLayout android:layout_width="match_parent" Loading core/res/res/layout/notification_template_material_media.xml +2 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ android:tag="media" > <include layout="@layout/notification_template_header" android:layout_width="fill_parent" android:layout_height="53dp" /> android:layout_width="match_parent" android:layout_height="@dimen/media_notification_header_height" /> <LinearLayout android:id="@+id/notification_main_column" android:layout_width="match_parent" Loading core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -2838,4 +2838,9 @@ <!-- Whether the device uses the default focus highlight when focus state isn't specified. --> <bool name="config_useDefaultFocusHighlight">true</bool> <!-- Flag indicating that the entire notification header can be clicked to expand the notification. If false, then the expand icon has to be clicked in order for the expand to occur. The expand button will have increased touch boundaries to accomodate this. --> <bool name="config_notificationHeaderClickableForExpand">false</bool> </resources> Loading
core/java/android/view/NotificationHeaderView.java +44 −20 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.view; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; Loading @@ -27,6 +28,7 @@ import android.util.AttributeSet; import android.widget.ImageView; import android.widget.RemoteViews; import com.android.internal.R; import com.android.internal.widget.CachingIconView; import java.util.ArrayList; Loading @@ -52,9 +54,12 @@ public class NotificationHeaderView extends ViewGroup { private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; private boolean mShowExpandButtonAtEnd; private boolean mShowWorkBadgeAtEnd; private Drawable mBackground; private int mHeaderBackgroundHeight; private boolean mEntireHeaderClickable; private boolean mAcceptAllTouches; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override Loading @@ -65,7 +70,6 @@ public class NotificationHeaderView extends ViewGroup { } } }; private boolean mAcceptAllTouches; public NotificationHeaderView(Context context) { this(context, null); Loading @@ -81,12 +85,12 @@ public class NotificationHeaderView extends ViewGroup { public NotificationHeaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mChildMinWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_shrink_min_width); mContentEndMargin = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = getResources().getDimensionPixelSize( com.android.internal.R.dimen.notification_header_background_height); Resources res = getResources(); mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width); mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end); mHeaderBackgroundHeight = res.getDimensionPixelSize( R.dimen.notification_header_background_height); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); } @Override Loading Loading @@ -147,8 +151,9 @@ public class NotificationHeaderView extends ViewGroup { @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { int left = getPaddingStart(); int end = getMeasuredWidth(); int childCount = getChildCount(); int ownHeight = getHeight() - getPaddingTop() - getPaddingBottom(); int ownHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child.getVisibility() == GONE) { Loading @@ -162,13 +167,17 @@ public class NotificationHeaderView extends ViewGroup { int bottom = top + childHeight; int layoutLeft = left; int layoutRight = right; if (child == mExpandButton && mShowExpandButtonAtEnd) { layoutRight = end - mContentEndMargin; end = layoutLeft = layoutRight - child.getMeasuredWidth(); } if (child == mProfileBadge) { int paddingEnd = getPaddingEnd(); if (mShowWorkBadgeAtEnd) { paddingEnd = mContentEndMargin; } layoutRight = getWidth() - paddingEnd; layoutLeft = layoutRight - child.getMeasuredWidth(); layoutRight = end - paddingEnd; end = layoutLeft = layoutRight - child.getMeasuredWidth(); } if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { int ltrLeft = layoutLeft; Loading Loading @@ -265,13 +274,11 @@ public class NotificationHeaderView extends ViewGroup { int drawableId; int contentDescriptionId; if (mExpanded) { drawableId = com.android.internal.R.drawable.ic_collapse_notification; contentDescriptionId = com.android.internal.R.string.expand_button_content_description_expanded; drawableId = R.drawable.ic_collapse_notification; contentDescriptionId = R.string.expand_button_content_description_expanded; } else { drawableId = com.android.internal.R.drawable.ic_expand_notification; contentDescriptionId = com.android.internal.R.string.expand_button_content_description_collapsed; drawableId = R.drawable.ic_expand_notification; contentDescriptionId = R.string.expand_button_content_description_collapsed; } mExpandButton.setImageDrawable(getContext().getDrawable(drawableId)); mExpandButton.setColorFilter(mOriginalNotificationColor); Loading @@ -285,6 +292,18 @@ public class NotificationHeaderView extends ViewGroup { } } /** * Sets whether or not the expand button appears at the end of the NotificationHeaderView. If * both this and {@link #setShowWorkBadgeAtEnd(boolean)} have been set to true, then the * expand button will appear closer to the end than the work badge. */ public void setShowExpandButtonAtEnd(boolean showExpandButtonAtEnd) { if (showExpandButtonAtEnd != mShowExpandButtonAtEnd) { setClipToPadding(!showExpandButtonAtEnd); mShowExpandButtonAtEnd = showExpandButtonAtEnd; } } public View getWorkProfileIcon() { return mProfileBadge; } Loading @@ -306,8 +325,8 @@ public class NotificationHeaderView extends ViewGroup { public void bindTouchRects() { mTouchRects.clear(); addRectAroundViewView(mIcon); addRectAroundViewView(mExpandButton); addRectAroundView(mIcon); addRectAroundView(mExpandButton); addWidthRect(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); } Loading @@ -321,7 +340,7 @@ public class NotificationHeaderView extends ViewGroup { mTouchRects.add(r); } private void addRectAroundViewView(View view) { private void addRectAroundView(View view) { final Rect r = getRectAroundView(view); mTouchRects.add(r); } Loading Loading @@ -412,8 +431,13 @@ public class NotificationHeaderView extends ViewGroup { return mTouchListener.isInside(x, y); } /** * Sets whether or not all touches to this header view will register as a click. Note that * if the config value for {@code config_notificationHeaderClickableForExpand} is {@code true}, * then calling this method with {@code false} will not override that configuration. */ @RemotableViewMethod public void setAcceptAllTouches(boolean acceptAllTouches) { mAcceptAllTouches = acceptAllTouches; mAcceptAllTouches = mEntireHeaderClickable || acceptAllTouches; } }
core/res/res/layout/notification_template_header.xml +18 −17 Original line number Diff line number Diff line Loading @@ -28,15 +28,15 @@ android:id="@+id/icon" android:layout_width="?attr/notificationHeaderIconSize" android:layout_height="?attr/notificationHeaderIconSize" android:layout_marginEnd="3dp" android:layout_marginEnd="@dimen/notification_header_icon_margin_end" /> <TextView android:id="@+id/app_name_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="3dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_app_name_margin_start" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:singleLine="true" /> <TextView Loading @@ -44,8 +44,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:text="@string/notification_header_divider_symbol" android:visibility="gone"/> <TextView Loading @@ -53,8 +53,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:visibility="gone" android:singleLine="true"/> <TextView Loading @@ -62,8 +62,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:text="@string/notification_header_divider_symbol" android:singleLine="true" android:visibility="gone"/> Loading @@ -73,8 +73,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:showRelative="true" android:singleLine="true" android:visibility="gone" /> Loading @@ -82,21 +82,22 @@ android:id="@+id/chronometer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="2dp" android:layout_marginEnd="2dp" android:layout_marginStart="@dimen/notification_header_separating_margin" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:layout="@layout/notification_template_part_chronometer" android:visibility="gone" /> <com.android.internal.widget.NotificationExpandButton android:id="@+id/expand_button" android:background="@null" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="1dp" android:layout_width="@dimen/notification_header_expand_icon_size" android:layout_height="@dimen/notification_header_expand_icon_size" android:paddingTop="@dimen/notification_expand_button_padding_top" android:visibility="gone" android:contentDescription="@string/expand_button_content_description_collapsed" /> <ImageView android:id="@+id/profile_badge" <ImageView android:id="@+id/profile_badge" android:layout_width="@dimen/notification_badge_size" android:layout_height="@dimen/notification_badge_size" android:layout_gravity="center" Loading
core/res/res/layout/notification_template_material_big_media.xml +3 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,8 @@ --> <!-- Layout for the expanded media notification --> <com.android.internal.widget.MediaNotificationView xmlns:android="http://schemas.android.com/apk/res/android" <com.android.internal.widget.MediaNotificationView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/status_bar_latest_event_content" android:layout_width="match_parent" android:layout_height="wrap_content" Loading @@ -25,7 +26,7 @@ > <include layout="@layout/notification_template_header" android:layout_width="match_parent" android:layout_height="53dp" android:layout_height="@dimen/media_notification_header_height" android:layout_gravity="start"/> <LinearLayout android:layout_width="match_parent" Loading
core/res/res/layout/notification_template_material_media.xml +2 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ android:tag="media" > <include layout="@layout/notification_template_header" android:layout_width="fill_parent" android:layout_height="53dp" /> android:layout_width="match_parent" android:layout_height="@dimen/media_notification_header_height" /> <LinearLayout android:id="@+id/notification_main_column" android:layout_width="match_parent" Loading
core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -2838,4 +2838,9 @@ <!-- Whether the device uses the default focus highlight when focus state isn't specified. --> <bool name="config_useDefaultFocusHighlight">true</bool> <!-- Flag indicating that the entire notification header can be clicked to expand the notification. If false, then the expand icon has to be clicked in order for the expand to occur. The expand button will have increased touch boundaries to accomodate this. --> <bool name="config_notificationHeaderClickableForExpand">false</bool> </resources>