Merge "Changing the way the media image scales" into oc-dr1-dev

This commit is contained in:
Selim Cinek
2017-07-25 22:45:55 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 13 deletions

View File

@@ -33,13 +33,13 @@ import android.widget.RemoteViews;
@RemoteViews.RemoteView
public class MediaNotificationView extends FrameLayout {
private final int mSmallImageSize;
private final int mNotificationContentMarginEnd;
private final int mNotificationContentImageMarginEnd;
private ImageView mRightIcon;
private View mActions;
private View mHeader;
private View mMainColumn;
private int mImagePushIn;
public MediaNotificationView(Context context) {
this(context, null);
@@ -62,6 +62,7 @@ public class MediaNotificationView extends FrameLayout {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int mode = MeasureSpec.getMode(widthMeasureSpec);
boolean reMeasure = false;
mImagePushIn = 0;
if (hasIcon && mode != MeasureSpec.UNSPECIFIED) {
int size = MeasureSpec.getSize(widthMeasureSpec);
size = size - mActions.getMeasuredWidth();
@@ -70,14 +71,15 @@ public class MediaNotificationView extends FrameLayout {
int imageEndMargin = layoutParams.getMarginEnd();
size -= imageEndMargin;
int fullHeight = getMeasuredHeight();
if (size < fullHeight) {
size = mSmallImageSize;
} else {
if (size > fullHeight) {
size = fullHeight;
} else if (size < fullHeight) {
size = Math.max(0, size);
mImagePushIn = fullHeight - size;
}
if (layoutParams.width != size || layoutParams.height != size) {
layoutParams.width = size;
layoutParams.height = size;
if (layoutParams.width != fullHeight || layoutParams.height != fullHeight) {
layoutParams.width = fullHeight;
layoutParams.height = fullHeight;
mRightIcon.setLayoutParams(layoutParams);
reMeasure = true;
}
@@ -111,6 +113,15 @@ public class MediaNotificationView extends FrameLayout {
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mImagePushIn > 0) {
mRightIcon.layout(mRightIcon.getLeft() + mImagePushIn, mRightIcon.getTop(),
mRightIcon.getRight() + mImagePushIn, mRightIcon.getBottom());
}
}
private void resetHeaderIndention() {
if (mHeader.getPaddingEnd() != mNotificationContentMarginEnd) {
mHeader.setPaddingRelative(mHeader.getPaddingStart(),
@@ -130,8 +141,6 @@ public class MediaNotificationView extends FrameLayout {
public MediaNotificationView(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mSmallImageSize = context.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.media_notification_expanded_image_small_size);
mNotificationContentMarginEnd = context.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.notification_content_margin_end);
mNotificationContentImageMarginEnd = context.getResources().getDimensionPixelSize(

View File

@@ -237,9 +237,6 @@
<!-- The minimum height of the content if there are at least two lines or a picture-->
<dimen name="notification_min_content_height">41dp</dimen>
<!-- The small size of the image if the height drawing doesn't work anymore -->
<dimen name="media_notification_expanded_image_small_size">72dp</dimen>
<!-- The size of the media actions in the media notification. -->
<dimen name="media_notification_action_button_size">48dp</dimen>

View File

@@ -2640,7 +2640,6 @@
<java-symbol type="string" name="new_sms_notification_title" />
<java-symbol type="string" name="new_sms_notification_content" />
<java-symbol type="dimen" name="media_notification_expanded_image_small_size" />
<java-symbol type="dimen" name="media_notification_expanded_image_margin_bottom" />
<java-symbol type="dimen" name="notification_content_image_margin_end" />