Loading core/java/android/view/NotificationHeaderView.java +13 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; Loading @@ -43,6 +44,7 @@ public class NotificationHeaderView extends ViewGroup { public static final int NO_COLOR = Notification.COLOR_INVALID; private final int mChildMinWidth; private final int mContentEndMargin; private final int mGravity; private View mAppName; private View mHeaderText; private OnClickListener mExpandClickListener; Loading @@ -50,7 +52,6 @@ public class NotificationHeaderView extends ViewGroup { private ImageView mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mInfo; private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; Loading @@ -61,6 +62,7 @@ public class NotificationHeaderView extends ViewGroup { private boolean mEntireHeaderClickable; private boolean mExpandOnlyOnButton; private boolean mAcceptAllTouches; private int mTotalWidth; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override Loading Loading @@ -92,6 +94,11 @@ public class NotificationHeaderView extends ViewGroup { mHeaderBackgroundHeight = res.getDimensionPixelSize( R.dimen.notification_header_background_height); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); int[] attrIds = { android.R.attr.gravity }; TypedArray ta = context.obtainStyledAttributes(attrs, attrIds, defStyleAttr, defStyleRes); mGravity = ta.getInt(0, 0); ta.recycle(); } @Override Loading Loading @@ -146,6 +153,7 @@ public class NotificationHeaderView extends ViewGroup { mHeaderText.measure(childWidthSpec, wrapContentHeightSpec); } } mTotalWidth = Math.min(totalWidth, givenWidth); setMeasuredDimension(givenWidth, givenHeight); } Loading @@ -153,6 +161,10 @@ public class NotificationHeaderView extends ViewGroup { protected void onLayout(boolean changed, int l, int t, int r, int b) { int left = getPaddingStart(); int end = getMeasuredWidth(); final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; if (centerAligned) { left += getMeasuredWidth() / 2 - mTotalWidth / 2; } int childCount = getChildCount(); int ownHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); for (int i = 0; i < childCount; i++) { Loading core/java/com/android/internal/widget/NotificationActionListLayout.java +24 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.internal.widget; import android.annotation.Nullable; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Pair; Loading @@ -37,6 +40,7 @@ import java.util.Comparator; @RemoteViews.RemoteView public class NotificationActionListLayout extends LinearLayout { private final int mGravity; private int mTotalWidth = 0; private ArrayList<Pair<Integer, TextView>> mMeasureOrderTextViews = new ArrayList<>(); private ArrayList<View> mMeasureOrderOther = new ArrayList<>(); Loading @@ -45,7 +49,20 @@ public class NotificationActionListLayout extends LinearLayout { private Drawable mDefaultBackground; public NotificationActionListLayout(Context context, AttributeSet attrs) { super(context, attrs); this(context, attrs, 0); } public NotificationActionListLayout(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public NotificationActionListLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); int[] attrIds = { android.R.attr.gravity }; TypedArray ta = context.obtainStyledAttributes(attrs, attrIds, defStyleAttr, defStyleRes); mGravity = ta.getInt(0, 0); ta.recycle(); } @Override Loading Loading @@ -95,6 +112,7 @@ public class NotificationActionListLayout extends LinearLayout { final boolean constrained = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED; final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; final int innerWidth = MeasureSpec.getSize(widthMeasureSpec) - mPaddingLeft - mPaddingRight; final int otherSize = mMeasureOrderOther.size(); Loading Loading @@ -137,7 +155,7 @@ public class NotificationActionListLayout extends LinearLayout { // Make sure to measure the last child full-width if we didn't use up the entire width, // or we didn't measure yet because there's just one child. if (lastNotGoneChild != null && (constrained && usedWidth < innerWidth if (lastNotGoneChild != null && !centerAligned && (constrained && usedWidth < innerWidth || notGoneChildren == 1)) { MarginLayoutParams lp = (MarginLayoutParams) lastNotGoneChild.getLayoutParams(); if (notGoneChildren > 1) { Loading Loading @@ -201,9 +219,10 @@ public class NotificationActionListLayout extends LinearLayout { } final boolean isLayoutRtl = isLayoutRtl(); final int paddingTop = mPaddingTop; final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; int childTop; int childLeft; int childLeft = centerAligned ? left + (right - left) / 2 - mTotalWidth / 2 : 0; // Where bottom of child should go final int height = bottom - top; Loading @@ -216,13 +235,12 @@ public class NotificationActionListLayout extends LinearLayout { final int layoutDirection = getLayoutDirection(); switch (Gravity.getAbsoluteGravity(Gravity.START, layoutDirection)) { case Gravity.RIGHT: // mTotalWidth contains the padding already childLeft = mPaddingLeft + right - left - mTotalWidth; childLeft += mPaddingLeft + right - left - mTotalWidth; break; case Gravity.LEFT: default: childLeft = mPaddingLeft; childLeft += mPaddingLeft; break; } Loading core/res/res/layout/notification_template_header.xml +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="@dimen/notification_header_app_name_margin_start" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:visibility="?attr/notificationHeaderAppNameVisibility" android:singleLine="true" /> <TextView Loading core/res/res/layout/notification_template_material_ambient.xml +19 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ android:paddingStart="@dimen/notification_extra_margin_ambient" android:paddingEnd="@dimen/notification_extra_margin_ambient" > <include layout="@layout/notification_template_header" <include layout="@layout/notification_template_ambient_header" android:theme="@style/Theme.Material.Notification.Ambient" /> <LinearLayout Loading Loading @@ -53,6 +53,7 @@ android:textAppearance="@style/TextAppearance.Material.Notification.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="top|center_horizontal" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" Loading @@ -65,7 +66,7 @@ android:textAppearance="@style/TextAppearance.Material.Notification" android:singleLine="false" android:layout_weight="1" android:gravity="top" android:gravity="top|center_horizontal" android:visibility="gone" android:textSize="16sp" android:textColor="#eeffffff" Loading @@ -75,5 +76,19 @@ /> </LinearLayout> </LinearLayout> <include layout="@layout/notification_material_action_list" /> <FrameLayout android:id="@+id/actions_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"> <com.android.internal.widget.NotificationActionListLayout android:id="@+id/actions" android:layout_width="match_parent" android:layout_height="@dimen/notification_action_list_height" android:paddingEnd="4dp" android:orientation="horizontal" android:gravity="center" android:visibility="gone" android:background="@color/notification_action_list" /> </FrameLayout> </FrameLayout> core/res/res/values/attrs.xml +8 −0 Original line number Diff line number Diff line Loading @@ -8715,6 +8715,14 @@ <attr name="notificationHeaderStyle" format="reference" /> <attr name="notificationHeaderTextAppearance" format="reference" /> <attr name="notificationHeaderIconSize" format="dimension" /> <attr name="notificationHeaderAppNameVisibility" format="enum"> <!-- Visible on screen; the default value. --> <enum name="visible" value="0" /> <!-- Not displayed, but taken into account during layout (space is left for it). --> <enum name="invisible" value="1" /> <!-- Completely hidden, as if the view had not been added. --> <enum name="gone" value="2" /> </attr> </declare-styleable> <attr name="lockPatternStyle" format="reference" /> Loading Loading
core/java/android/view/NotificationHeaderView.java +13 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Rect; Loading @@ -43,6 +44,7 @@ public class NotificationHeaderView extends ViewGroup { public static final int NO_COLOR = Notification.COLOR_INVALID; private final int mChildMinWidth; private final int mContentEndMargin; private final int mGravity; private View mAppName; private View mHeaderText; private OnClickListener mExpandClickListener; Loading @@ -50,7 +52,6 @@ public class NotificationHeaderView extends ViewGroup { private ImageView mExpandButton; private CachingIconView mIcon; private View mProfileBadge; private View mInfo; private int mIconColor; private int mOriginalNotificationColor; private boolean mExpanded; Loading @@ -61,6 +62,7 @@ public class NotificationHeaderView extends ViewGroup { private boolean mEntireHeaderClickable; private boolean mExpandOnlyOnButton; private boolean mAcceptAllTouches; private int mTotalWidth; ViewOutlineProvider mProvider = new ViewOutlineProvider() { @Override Loading Loading @@ -92,6 +94,11 @@ public class NotificationHeaderView extends ViewGroup { mHeaderBackgroundHeight = res.getDimensionPixelSize( R.dimen.notification_header_background_height); mEntireHeaderClickable = res.getBoolean(R.bool.config_notificationHeaderClickableForExpand); int[] attrIds = { android.R.attr.gravity }; TypedArray ta = context.obtainStyledAttributes(attrs, attrIds, defStyleAttr, defStyleRes); mGravity = ta.getInt(0, 0); ta.recycle(); } @Override Loading Loading @@ -146,6 +153,7 @@ public class NotificationHeaderView extends ViewGroup { mHeaderText.measure(childWidthSpec, wrapContentHeightSpec); } } mTotalWidth = Math.min(totalWidth, givenWidth); setMeasuredDimension(givenWidth, givenHeight); } Loading @@ -153,6 +161,10 @@ public class NotificationHeaderView extends ViewGroup { protected void onLayout(boolean changed, int l, int t, int r, int b) { int left = getPaddingStart(); int end = getMeasuredWidth(); final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; if (centerAligned) { left += getMeasuredWidth() / 2 - mTotalWidth / 2; } int childCount = getChildCount(); int ownHeight = getMeasuredHeight() - getPaddingTop() - getPaddingBottom(); for (int i = 0; i < childCount; i++) { Loading
core/java/com/android/internal/widget/NotificationActionListLayout.java +24 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,10 @@ package com.android.internal.widget; import android.annotation.Nullable; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Pair; Loading @@ -37,6 +40,7 @@ import java.util.Comparator; @RemoteViews.RemoteView public class NotificationActionListLayout extends LinearLayout { private final int mGravity; private int mTotalWidth = 0; private ArrayList<Pair<Integer, TextView>> mMeasureOrderTextViews = new ArrayList<>(); private ArrayList<View> mMeasureOrderOther = new ArrayList<>(); Loading @@ -45,7 +49,20 @@ public class NotificationActionListLayout extends LinearLayout { private Drawable mDefaultBackground; public NotificationActionListLayout(Context context, AttributeSet attrs) { super(context, attrs); this(context, attrs, 0); } public NotificationActionListLayout(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public NotificationActionListLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); int[] attrIds = { android.R.attr.gravity }; TypedArray ta = context.obtainStyledAttributes(attrs, attrIds, defStyleAttr, defStyleRes); mGravity = ta.getInt(0, 0); ta.recycle(); } @Override Loading Loading @@ -95,6 +112,7 @@ public class NotificationActionListLayout extends LinearLayout { final boolean constrained = MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.UNSPECIFIED; final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; final int innerWidth = MeasureSpec.getSize(widthMeasureSpec) - mPaddingLeft - mPaddingRight; final int otherSize = mMeasureOrderOther.size(); Loading Loading @@ -137,7 +155,7 @@ public class NotificationActionListLayout extends LinearLayout { // Make sure to measure the last child full-width if we didn't use up the entire width, // or we didn't measure yet because there's just one child. if (lastNotGoneChild != null && (constrained && usedWidth < innerWidth if (lastNotGoneChild != null && !centerAligned && (constrained && usedWidth < innerWidth || notGoneChildren == 1)) { MarginLayoutParams lp = (MarginLayoutParams) lastNotGoneChild.getLayoutParams(); if (notGoneChildren > 1) { Loading Loading @@ -201,9 +219,10 @@ public class NotificationActionListLayout extends LinearLayout { } final boolean isLayoutRtl = isLayoutRtl(); final int paddingTop = mPaddingTop; final boolean centerAligned = (mGravity & Gravity.CENTER_HORIZONTAL) != 0; int childTop; int childLeft; int childLeft = centerAligned ? left + (right - left) / 2 - mTotalWidth / 2 : 0; // Where bottom of child should go final int height = bottom - top; Loading @@ -216,13 +235,12 @@ public class NotificationActionListLayout extends LinearLayout { final int layoutDirection = getLayoutDirection(); switch (Gravity.getAbsoluteGravity(Gravity.START, layoutDirection)) { case Gravity.RIGHT: // mTotalWidth contains the padding already childLeft = mPaddingLeft + right - left - mTotalWidth; childLeft += mPaddingLeft + right - left - mTotalWidth; break; case Gravity.LEFT: default: childLeft = mPaddingLeft; childLeft += mPaddingLeft; break; } Loading
core/res/res/layout/notification_template_header.xml +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ android:textAppearance="?attr/notificationHeaderTextAppearance" android:layout_marginStart="@dimen/notification_header_app_name_margin_start" android:layout_marginEnd="@dimen/notification_header_separating_margin" android:visibility="?attr/notificationHeaderAppNameVisibility" android:singleLine="true" /> <TextView Loading
core/res/res/layout/notification_template_material_ambient.xml +19 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ android:paddingStart="@dimen/notification_extra_margin_ambient" android:paddingEnd="@dimen/notification_extra_margin_ambient" > <include layout="@layout/notification_template_header" <include layout="@layout/notification_template_ambient_header" android:theme="@style/Theme.Material.Notification.Ambient" /> <LinearLayout Loading Loading @@ -53,6 +53,7 @@ android:textAppearance="@style/TextAppearance.Material.Notification.Title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="top|center_horizontal" android:singleLine="true" android:ellipsize="marquee" android:fadingEdge="horizontal" Loading @@ -65,7 +66,7 @@ android:textAppearance="@style/TextAppearance.Material.Notification" android:singleLine="false" android:layout_weight="1" android:gravity="top" android:gravity="top|center_horizontal" android:visibility="gone" android:textSize="16sp" android:textColor="#eeffffff" Loading @@ -75,5 +76,19 @@ /> </LinearLayout> </LinearLayout> <include layout="@layout/notification_material_action_list" /> <FrameLayout android:id="@+id/actions_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"> <com.android.internal.widget.NotificationActionListLayout android:id="@+id/actions" android:layout_width="match_parent" android:layout_height="@dimen/notification_action_list_height" android:paddingEnd="4dp" android:orientation="horizontal" android:gravity="center" android:visibility="gone" android:background="@color/notification_action_list" /> </FrameLayout> </FrameLayout>
core/res/res/values/attrs.xml +8 −0 Original line number Diff line number Diff line Loading @@ -8715,6 +8715,14 @@ <attr name="notificationHeaderStyle" format="reference" /> <attr name="notificationHeaderTextAppearance" format="reference" /> <attr name="notificationHeaderIconSize" format="dimension" /> <attr name="notificationHeaderAppNameVisibility" format="enum"> <!-- Visible on screen; the default value. --> <enum name="visible" value="0" /> <!-- Not displayed, but taken into account during layout (space is left for it). --> <enum name="invisible" value="1" /> <!-- Completely hidden, as if the view had not been added. --> <enum name="gone" value="2" /> </attr> </declare-styleable> <attr name="lockPatternStyle" format="reference" /> Loading