Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8818f6b authored by Selim Cinek's avatar Selim Cinek
Browse files

Changing the way the media image scales

Before, the media image could get really small
under certain conditions. We now just push it off
a bit.

Test: manual, test media notification with different densities
Change-Id: If0fec49510a0dee627ce4a8ddb7075534c0e15c3
Fixes: 63142413
parent c48e304b
Loading
Loading
Loading
Loading
+18 −9
Original line number Original line Diff line number Diff line
@@ -33,13 +33,13 @@ import android.widget.RemoteViews;
@RemoteViews.RemoteView
@RemoteViews.RemoteView
public class MediaNotificationView extends FrameLayout {
public class MediaNotificationView extends FrameLayout {


    private final int mSmallImageSize;
    private final int mNotificationContentMarginEnd;
    private final int mNotificationContentMarginEnd;
    private final int mNotificationContentImageMarginEnd;
    private final int mNotificationContentImageMarginEnd;
    private ImageView mRightIcon;
    private ImageView mRightIcon;
    private View mActions;
    private View mActions;
    private View mHeader;
    private View mHeader;
    private View mMainColumn;
    private View mMainColumn;
    private int mImagePushIn;


    public MediaNotificationView(Context context) {
    public MediaNotificationView(Context context) {
        this(context, null);
        this(context, null);
@@ -62,6 +62,7 @@ public class MediaNotificationView extends FrameLayout {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int mode = MeasureSpec.getMode(widthMeasureSpec);
        int mode = MeasureSpec.getMode(widthMeasureSpec);
        boolean reMeasure = false;
        boolean reMeasure = false;
        mImagePushIn = 0;
        if (hasIcon && mode != MeasureSpec.UNSPECIFIED) {
        if (hasIcon && mode != MeasureSpec.UNSPECIFIED) {
            int size = MeasureSpec.getSize(widthMeasureSpec);
            int size = MeasureSpec.getSize(widthMeasureSpec);
            size = size - mActions.getMeasuredWidth();
            size = size - mActions.getMeasuredWidth();
@@ -70,14 +71,15 @@ public class MediaNotificationView extends FrameLayout {
            int imageEndMargin = layoutParams.getMarginEnd();
            int imageEndMargin = layoutParams.getMarginEnd();
            size -= imageEndMargin;
            size -= imageEndMargin;
            int fullHeight = getMeasuredHeight();
            int fullHeight = getMeasuredHeight();
            if (size < fullHeight) {
            if (size > fullHeight) {
                size = mSmallImageSize;
            } else {
                size = fullHeight;
                size = fullHeight;
            } else if (size < fullHeight) {
                size = Math.max(0, size);
                mImagePushIn = fullHeight - size;
            }
            }
            if (layoutParams.width != size || layoutParams.height != size) {
            if (layoutParams.width != fullHeight || layoutParams.height != fullHeight) {
                layoutParams.width = size;
                layoutParams.width = fullHeight;
                layoutParams.height = size;
                layoutParams.height = fullHeight;
                mRightIcon.setLayoutParams(layoutParams);
                mRightIcon.setLayoutParams(layoutParams);
                reMeasure = true;
                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() {
    private void resetHeaderIndention() {
        if (mHeader.getPaddingEnd() != mNotificationContentMarginEnd) {
        if (mHeader.getPaddingEnd() != mNotificationContentMarginEnd) {
            mHeader.setPaddingRelative(mHeader.getPaddingStart(),
            mHeader.setPaddingRelative(mHeader.getPaddingStart(),
@@ -130,8 +141,6 @@ public class MediaNotificationView extends FrameLayout {
    public MediaNotificationView(Context context, AttributeSet attrs, int defStyleAttr,
    public MediaNotificationView(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
            int defStyleRes) {
        super(context, attrs, defStyleAttr, 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(
        mNotificationContentMarginEnd = context.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.notification_content_margin_end);
                com.android.internal.R.dimen.notification_content_margin_end);
        mNotificationContentImageMarginEnd = context.getResources().getDimensionPixelSize(
        mNotificationContentImageMarginEnd = context.getResources().getDimensionPixelSize(
+0 −3
Original line number Original line Diff line number Diff line
@@ -237,9 +237,6 @@
    <!-- The minimum height of the content if there are at least two lines or a picture-->
    <!-- The minimum height of the content if there are at least two lines or a picture-->
    <dimen name="notification_min_content_height">41dp</dimen>
    <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. -->
    <!-- The size of the media actions in the media notification. -->
    <dimen name="media_notification_action_button_size">48dp</dimen>
    <dimen name="media_notification_action_button_size">48dp</dimen>


+0 −1
Original line number Original line Diff line number Diff line
@@ -2652,7 +2652,6 @@
  <java-symbol type="string" name="new_sms_notification_title" />
  <java-symbol type="string" name="new_sms_notification_title" />
  <java-symbol type="string" name="new_sms_notification_content" />
  <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="media_notification_expanded_image_margin_bottom" />
  <java-symbol type="dimen" name="notification_content_image_margin_end" />
  <java-symbol type="dimen" name="notification_content_image_margin_end" />