summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/NotificationTopLineView.java42
-rw-r--r--core/res/res/layout/notification_template_material_conversation.xml45
-rw-r--r--core/res/res/layout/notification_top_line_views.xml24
3 files changed, 44 insertions, 67 deletions
diff --git a/core/java/android/view/NotificationTopLineView.java b/core/java/android/view/NotificationTopLineView.java
index f6073ca2f0b2..a8eabe5a7967 100644
--- a/core/java/android/view/NotificationTopLineView.java
+++ b/core/java/android/view/NotificationTopLineView.java
@@ -26,9 +26,6 @@ import android.widget.RemoteViews;
import com.android.internal.R;
-import java.util.Arrays;
-import java.util.List;
-
/**
* The top line of content in a notification view.
* This includes the text views and badges but excludes the icon and the expander.
@@ -39,17 +36,14 @@ import java.util.List;
public class NotificationTopLineView extends ViewGroup {
private final int mGravityY;
private final int mChildMinWidth;
- private final int mContentEndMargin;
@Nullable private View mAppName;
@Nullable private View mTitle;
private View mHeaderText;
private View mSecondaryHeaderText;
private OnClickListener mFeedbackListener;
private HeaderTouchListener mTouchListener = new HeaderTouchListener();
- private View mProfileBadge;
private View mFeedbackIcon;
private int mHeaderTextMarginEnd;
- private List<View> mIconsAtEnd;
private int mMaxAscent;
private int mMaxDescent;
@@ -72,7 +66,6 @@ public class NotificationTopLineView extends ViewGroup {
super(context, attrs, defStyleAttr, defStyleRes);
Resources res = getResources();
mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width);
- mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end);
// NOTE: Implementation only supports TOP, BOTTOM, and CENTER_VERTICAL gravities,
// with CENTER_VERTICAL being the default.
@@ -96,9 +89,7 @@ public class NotificationTopLineView extends ViewGroup {
mTitle = findViewById(R.id.title);
mHeaderText = findViewById(R.id.header_text);
mSecondaryHeaderText = findViewById(R.id.header_text_secondary);
- mProfileBadge = findViewById(R.id.profile_badge);
mFeedbackIcon = findViewById(R.id.feedback);
- mIconsAtEnd = Arrays.asList(mProfileBadge, mFeedbackIcon);
}
@Override
@@ -111,7 +102,6 @@ public class NotificationTopLineView extends ViewGroup {
int wrapContentHeightSpec = MeasureSpec.makeMeasureSpec(givenHeight,
MeasureSpec.AT_MOST);
int totalWidth = getPaddingStart();
- int iconWidth = getPaddingEnd();
int maxChildHeight = -1;
mMaxAscent = -1;
mMaxDescent = -1;
@@ -127,12 +117,7 @@ public class NotificationTopLineView extends ViewGroup {
int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec,
lp.topMargin + lp.bottomMargin, lp.height);
child.measure(childWidthSpec, childHeightSpec);
- // Icons that should go at the end
- if (mIconsAtEnd.contains(child)) {
- iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
- } else {
- totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
- }
+ totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
int childBaseline = child.getBaseline();
int childHeight = child.getMeasuredHeight();
if (childBaseline != -1) {
@@ -143,7 +128,7 @@ public class NotificationTopLineView extends ViewGroup {
}
// Ensure that there is at least enough space for the icons
- int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth);
+ int endMargin = Math.max(mHeaderTextMarginEnd, getPaddingEnd());
if (totalWidth > givenWidth - endMargin) {
int overFlow = totalWidth - givenWidth + endMargin;
if (mAppName != null) {
@@ -184,7 +169,6 @@ public class NotificationTopLineView 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 = b - t;
int childSpace = ownHeight - mPaddingTop - mPaddingBottom;
@@ -238,22 +222,12 @@ public class NotificationTopLineView extends ViewGroup {
childTop = mPaddingTop;
}
- // Icons that should go at the end
- if (mIconsAtEnd.contains(child)) {
- if (end == getMeasuredWidth()) {
- layoutRight = end - mContentEndMargin;
- } else {
- layoutRight = end - params.getMarginEnd();
- }
- layoutLeft = layoutRight - child.getMeasuredWidth();
- end = layoutLeft - params.getMarginStart();
- } else {
- left += params.getMarginStart();
- int right = left + child.getMeasuredWidth();
- layoutLeft = left;
- layoutRight = right;
- left = right + params.getMarginEnd();
- }
+ left += params.getMarginStart();
+ int right = left + child.getMeasuredWidth();
+ layoutLeft = left;
+ layoutRight = right;
+ left = right + params.getMarginEnd();
+
if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
int ltrLeft = layoutLeft;
layoutLeft = getWidth() - layoutRight;
diff --git a/core/res/res/layout/notification_template_material_conversation.xml b/core/res/res/layout/notification_template_material_conversation.xml
index a0dcd84ea8f1..520ae282b942 100644
--- a/core/res/res/layout/notification_template_material_conversation.xml
+++ b/core/res/res/layout/notification_template_material_conversation.xml
@@ -207,17 +207,19 @@
android:visibility="gone"
/>
- <ImageView
- android:id="@+id/alerted_icon"
- android:layout_width="@dimen/notification_alerted_size"
- android:layout_height="@dimen/notification_alerted_size"
+ <ImageButton
+ android:id="@+id/feedback"
+ android:layout_width="@dimen/notification_feedback_size"
+ android:layout_height="@dimen/notification_feedback_size"
android:layout_gravity="center"
- android:layout_marginStart="4dp"
+ android:layout_marginStart="@dimen/notification_header_separating_margin"
+ android:background="?android:selectableItemBackgroundBorderless"
+ android:contentDescription="@string/notification_feedback_indicator"
android:paddingTop="2dp"
android:scaleType="fitCenter"
+ android:src="@drawable/ic_feedback_indicator"
android:visibility="gone"
- android:contentDescription="@string/notification_alerted_content_description"
- android:src="@drawable/ic_notifications_alerted"/>
+ />
<ImageView
android:id="@+id/profile_badge"
@@ -229,7 +231,21 @@
android:scaleType="fitCenter"
android:visibility="gone"
android:contentDescription="@string/notification_work_profile_content_description"
- />
+ />
+
+ <ImageView
+ android:id="@+id/alerted_icon"
+ android:layout_width="@dimen/notification_alerted_size"
+ android:layout_height="@dimen/notification_alerted_size"
+ android:layout_gravity="center"
+ android:layout_marginStart="4dp"
+ android:contentDescription="@string/notification_alerted_content_description"
+ android:paddingTop="2dp"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_notifications_alerted"
+ android:visibility="gone"
+ />
+
<LinearLayout
android:id="@+id/app_ops"
android:layout_height="wrap_content"
@@ -269,19 +285,6 @@
android:contentDescription="@string/notification_appops_overlay_active"
/>
</LinearLayout>
- <ImageButton
- android:id="@+id/feedback"
- android:layout_width="@dimen/notification_feedback_size"
- android:layout_height="@dimen/notification_feedback_size"
- android:layout_marginStart="@dimen/notification_header_separating_margin"
- android:paddingTop="2dp"
- android:layout_gravity="center"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_feedback_indicator"
- android:background="?android:selectableItemBackgroundBorderless"
- android:visibility="gone"
- android:contentDescription="@string/notification_feedback_indicator"
- />
</LinearLayout>
<!-- Messages -->
diff --git a/core/res/res/layout/notification_top_line_views.xml b/core/res/res/layout/notification_top_line_views.xml
index 5d3feeb0725d..51974ac7dcf3 100644
--- a/core/res/res/layout/notification_top_line_views.xml
+++ b/core/res/res/layout/notification_top_line_views.xml
@@ -98,18 +98,6 @@
android:visibility="gone"
/>
- <ImageView
- android:id="@+id/alerted_icon"
- android:layout_width="@dimen/notification_alerted_size"
- android:layout_height="@dimen/notification_alerted_size"
- android:layout_marginStart="4dp"
- android:baseline="10dp"
- android:scaleType="fitCenter"
- android:visibility="gone"
- android:contentDescription="@string/notification_alerted_content_description"
- android:src="@drawable/ic_notifications_alerted"
- />
-
<ImageButton
android:id="@+id/feedback"
android:layout_width="@dimen/notification_feedback_size"
@@ -134,5 +122,17 @@
android:visibility="gone"
android:contentDescription="@string/notification_work_profile_content_description"
/>
+
+ <ImageView
+ android:id="@+id/alerted_icon"
+ android:layout_width="@dimen/notification_alerted_size"
+ android:layout_height="@dimen/notification_alerted_size"
+ android:layout_marginStart="4dp"
+ android:baseline="10dp"
+ android:contentDescription="@string/notification_alerted_content_description"
+ android:scaleType="fitCenter"
+ android:src="@drawable/ic_notifications_alerted"
+ android:visibility="gone"
+ />
</merge>