summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Beth Thibodeau <ethibodeau@google.com> 2019-03-07 15:06:11 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-03-07 15:06:11 +0000
commitff0e66270b2e7b1ccfeace68f8409bf69a01294e (patch)
tree173e3a4e58ace5dd3147fae0fc19badae0bd8a1e
parentfce0615a7dfe6e1ad1e485e978c9e470a47e8c2f (diff)
parent837bfc2c51f5a2c06ad95a079333264fa133f4dc (diff)
Merge "Fix position of expand/collapse button"
-rw-r--r--core/java/android/view/NotificationHeaderView.java40
-rw-r--r--core/java/com/android/internal/widget/MediaNotificationView.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java20
3 files changed, 50 insertions, 22 deletions
diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java
index f8d5014a29c9..b2f3f5edcd20 100644
--- a/core/java/android/view/NotificationHeaderView.java
+++ b/core/java/android/view/NotificationHeaderView.java
@@ -67,6 +67,7 @@ public class NotificationHeaderView extends ViewGroup {
private boolean mExpanded;
private boolean mShowExpandButtonAtEnd;
private boolean mShowWorkBadgeAtEnd;
+ private int mHeaderTextMarginEnd;
private Drawable mBackground;
private boolean mEntireHeaderClickable;
private boolean mExpandOnlyOnButton;
@@ -133,7 +134,8 @@ public class NotificationHeaderView extends ViewGroup {
MeasureSpec.AT_MOST);
int wrapContentHeightSpec = MeasureSpec.makeMeasureSpec(givenHeight,
MeasureSpec.AT_MOST);
- int totalWidth = getPaddingStart() + getPaddingEnd();
+ int totalWidth = getPaddingStart();
+ int iconWidth = getPaddingEnd();
for (int i = 0; i < getChildCount(); i++) {
final View child = getChildAt(i);
if (child.getVisibility() == GONE) {
@@ -146,10 +148,19 @@ public class NotificationHeaderView extends ViewGroup {
int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec,
lp.topMargin + lp.bottomMargin, lp.height);
child.measure(childWidthSpec, childHeightSpec);
- totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
+ if ((child == mExpandButton && mShowExpandButtonAtEnd)
+ || child == mProfileBadge
+ || child == mAppOps) {
+ iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
+ } else {
+ totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
+ }
}
- if (totalWidth > givenWidth) {
- int overFlow = totalWidth - givenWidth;
+
+ // Ensure that there is at least enough space for the icons
+ int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth);
+ if (totalWidth > givenWidth - endMargin) {
+ int overFlow = totalWidth - givenWidth + endMargin;
// We are overflowing, lets shrink the app name first
overFlow = shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mAppName,
mChildMinWidth);
@@ -161,6 +172,7 @@ public class NotificationHeaderView extends ViewGroup {
shrinkViewForOverflow(wrapContentHeightSpec, overFlow, mSecondaryHeaderText,
0);
}
+ totalWidth += getPaddingEnd();
mTotalWidth = Math.min(totalWidth, givenWidth);
setMeasuredDimension(givenWidth, givenHeight);
}
@@ -383,6 +395,26 @@ public class NotificationHeaderView extends ViewGroup {
return mIcon;
}
+ /**
+ * Sets the margin end for the text portion of the header, excluding right-aligned elements
+ * @param headerTextMarginEnd margin size
+ */
+ @RemotableViewMethod
+ public void setHeaderTextMarginEnd(int headerTextMarginEnd) {
+ if (mHeaderTextMarginEnd != headerTextMarginEnd) {
+ mHeaderTextMarginEnd = headerTextMarginEnd;
+ requestLayout();
+ }
+ }
+
+ /**
+ * Get the current margin end value for the header text
+ * @return margin size
+ */
+ public int getHeaderTextMarginEnd() {
+ return mHeaderTextMarginEnd;
+ }
+
public class HeaderTouchListener implements View.OnTouchListener {
private final ArrayList<Rect> mTouchRects = new ArrayList<>();
diff --git a/core/java/com/android/internal/widget/MediaNotificationView.java b/core/java/com/android/internal/widget/MediaNotificationView.java
index 498bc5a7d598..de86d923d1e3 100644
--- a/core/java/com/android/internal/widget/MediaNotificationView.java
+++ b/core/java/com/android/internal/widget/MediaNotificationView.java
@@ -19,6 +19,7 @@ package com.android.internal.widget;
import android.annotation.Nullable;
import android.content.Context;
import android.util.AttributeSet;
+import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
@@ -37,7 +38,7 @@ public class MediaNotificationView extends FrameLayout {
private final int mNotificationContentImageMarginEnd;
private ImageView mRightIcon;
private View mActions;
- private View mHeader;
+ private NotificationHeaderView mHeader;
private View mMainColumn;
private View mMediaContent;
private int mImagePushIn;
@@ -94,7 +95,14 @@ public class MediaNotificationView extends FrameLayout {
mMainColumn.setLayoutParams(params);
reMeasure = true;
}
- int headerMarginEnd = size + imageEndMargin;
+ // margin for the entire header line
+ int headerMarginEnd = imageEndMargin;
+ // margin for the header text (not including the expand button and other icons)
+ int headerTextMarginEnd = size + imageEndMargin;
+ if (headerTextMarginEnd != mHeader.getHeaderTextMarginEnd()) {
+ mHeader.setHeaderTextMarginEnd(headerTextMarginEnd);
+ reMeasure = true;
+ }
params = (MarginLayoutParams) mHeader.getLayoutParams();
if (params.getMarginEnd() != headerMarginEnd) {
params.setMarginEnd(headerMarginEnd);
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 4690aeb9245f..78500357f41f 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
@@ -328,22 +328,10 @@ public class NotificationContentView extends FrameLayout {
if (mExpandedChild != null
&& mExpandedWrapper.getNotificationHeader() != null) {
NotificationHeaderView expandedHeader = mExpandedWrapper.getNotificationHeader();
- int expandedSize = expandedHeader.getMeasuredWidth()
- - expandedHeader.getPaddingEnd();
- int collapsedSize = contractedHeader.getMeasuredWidth()
- - expandedHeader.getPaddingEnd();
- if (expandedSize != collapsedSize) {
- int paddingEnd = contractedHeader.getMeasuredWidth() - expandedSize;
- contractedHeader.setPadding(
- contractedHeader.isLayoutRtl()
- ? paddingEnd
- : contractedHeader.getPaddingLeft(),
- contractedHeader.getPaddingTop(),
- contractedHeader.isLayoutRtl()
- ? contractedHeader.getPaddingLeft()
- : paddingEnd,
- contractedHeader.getPaddingBottom());
- contractedHeader.setShowWorkBadgeAtEnd(true);
+
+ int headerTextMargin = expandedHeader.getHeaderTextMarginEnd();
+ if (headerTextMargin != contractedHeader.getHeaderTextMarginEnd()) {
+ contractedHeader.setHeaderTextMarginEnd(headerTextMargin);
return true;
}
} else {