Merge "Media notifications now properly respect font size changes" into nyc-dev
This commit is contained in:
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.RemoteViews;
|
||||
@@ -31,16 +32,16 @@ import android.widget.RemoteViews;
|
||||
* @hide
|
||||
*/
|
||||
@RemoteViews.RemoteView
|
||||
public class MediaNotificationView extends RelativeLayout {
|
||||
public class MediaNotificationView extends FrameLayout {
|
||||
|
||||
private final int mMaxImageSize;
|
||||
private final int mImageMarginBottom;
|
||||
private final int mImageMinTopMargin;
|
||||
private final int mNotificationContentMarginEnd;
|
||||
private final int mNotificationContentImageMarginEnd;
|
||||
private ImageView mRightIcon;
|
||||
private View mActions;
|
||||
private View mHeader;
|
||||
private View mMainColumn;
|
||||
|
||||
public MediaNotificationView(Context context) {
|
||||
this(context, null);
|
||||
@@ -61,39 +62,49 @@ public class MediaNotificationView extends RelativeLayout {
|
||||
if (hasIcon && mode != MeasureSpec.UNSPECIFIED) {
|
||||
measureChild(mActions, widthMeasureSpec, heightMeasureSpec);
|
||||
int size = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
size = size - mActions.getMeasuredWidth();
|
||||
ViewGroup.MarginLayoutParams layoutParams =
|
||||
(MarginLayoutParams) mRightIcon.getLayoutParams();
|
||||
size -= layoutParams.getMarginEnd();
|
||||
int imageEndMargin = layoutParams.getMarginEnd();
|
||||
size -= imageEndMargin;
|
||||
size = Math.min(size, mMaxImageSize);
|
||||
size = Math.max(size, mRightIcon.getMinimumWidth());
|
||||
layoutParams.width = size;
|
||||
layoutParams.height = size;
|
||||
// because we can't allign it to the bottom with a margin, we add a topmargin to it
|
||||
layoutParams.topMargin = height - size - mImageMarginBottom;
|
||||
// If the topMargin is high enough we can also remove the header constraint!
|
||||
if (layoutParams.topMargin >= mImageMinTopMargin) {
|
||||
resetHeaderIndention();
|
||||
} else {
|
||||
int paddingEnd = mNotificationContentImageMarginEnd;
|
||||
ViewGroup.MarginLayoutParams headerParams =
|
||||
(MarginLayoutParams) mHeader.getLayoutParams();
|
||||
headerParams.setMarginEnd(size + layoutParams.getMarginEnd());
|
||||
if (mHeader.getPaddingEnd() != paddingEnd) {
|
||||
mHeader.setPadding(
|
||||
isLayoutRtl() ? paddingEnd : mHeader.getPaddingLeft(),
|
||||
mHeader.getPaddingTop(),
|
||||
isLayoutRtl() ? mHeader.getPaddingLeft() : paddingEnd,
|
||||
mHeader.getPaddingBottom());
|
||||
mHeader.setLayoutParams(headerParams);
|
||||
}
|
||||
}
|
||||
mRightIcon.setLayoutParams(layoutParams);
|
||||
} else if (!hasIcon && mHeader.getPaddingEnd() != mNotificationContentMarginEnd) {
|
||||
resetHeaderIndention();
|
||||
|
||||
// lets ensure that the main column doesn't run into the image
|
||||
ViewGroup.MarginLayoutParams mainParams
|
||||
= (MarginLayoutParams) mMainColumn.getLayoutParams();
|
||||
int marginEnd = size + imageEndMargin + mNotificationContentMarginEnd;
|
||||
if (marginEnd != mainParams.getMarginEnd()) {
|
||||
mainParams.setMarginEnd(marginEnd);
|
||||
mMainColumn.setLayoutParams(mainParams);
|
||||
}
|
||||
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
ViewGroup.MarginLayoutParams iconParams =
|
||||
(MarginLayoutParams) mRightIcon.getLayoutParams();
|
||||
int topMargin = getMeasuredHeight() - mRightIcon.getMeasuredHeight()
|
||||
- iconParams.bottomMargin;
|
||||
// If the topMargin is high enough we can also remove the header constraint!
|
||||
if (!hasIcon || topMargin >= mImageMinTopMargin) {
|
||||
resetHeaderIndention();
|
||||
} else {
|
||||
int paddingEnd = mNotificationContentImageMarginEnd;
|
||||
ViewGroup.MarginLayoutParams headerParams =
|
||||
(MarginLayoutParams) mHeader.getLayoutParams();
|
||||
headerParams.setMarginEnd(mRightIcon.getMeasuredWidth() + iconParams.getMarginEnd());
|
||||
if (mHeader.getPaddingEnd() != paddingEnd) {
|
||||
mHeader.setPadding(
|
||||
isLayoutRtl() ? paddingEnd : mHeader.getPaddingLeft(),
|
||||
mHeader.getPaddingTop(),
|
||||
isLayoutRtl() ? mHeader.getPaddingLeft() : paddingEnd,
|
||||
mHeader.getPaddingBottom());
|
||||
mHeader.setLayoutParams(headerParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resetHeaderIndention() {
|
||||
@@ -115,8 +126,6 @@ public class MediaNotificationView extends RelativeLayout {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
mMaxImageSize = context.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.media_notification_expanded_image_max_size);
|
||||
mImageMarginBottom = context.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.media_notification_expanded_image_margin_bottom);
|
||||
mImageMinTopMargin = (int) (context.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.notification_content_margin_top)
|
||||
+ getResources().getDisplayMetrics().density * 2);
|
||||
@@ -132,5 +141,6 @@ public class MediaNotificationView extends RelativeLayout {
|
||||
mRightIcon = (ImageView) findViewById(com.android.internal.R.id.right_icon);
|
||||
mActions = findViewById(com.android.internal.R.id.media_actions);
|
||||
mHeader = findViewById(com.android.internal.R.id.notification_header);
|
||||
mMainColumn = findViewById(com.android.internal.R.id.notification_main_column);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,41 +19,45 @@
|
||||
<com.android.internal.widget.MediaNotificationView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/status_bar_latest_event_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="126dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:tag="bigMediaNarrow"
|
||||
>
|
||||
<include layout="@layout/notification_template_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentStart="true"/>
|
||||
android:layout_gravity="start"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/notification_main_column"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/notification_content_margin_top"
|
||||
android:layout_marginStart="@dimen/notification_content_margin_start"
|
||||
android:layout_marginBottom="@dimen/notification_content_margin_bottom"
|
||||
android:layout_marginEnd="@dimen/notification_content_margin_end"
|
||||
android:layout_toStartOf="@id/right_icon"
|
||||
android:minHeight="@dimen/notification_min_content_height"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<include layout="@layout/notification_template_part_line1" />
|
||||
<include layout="@layout/notification_template_text" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/media_actions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:layoutDirection="ltr"
|
||||
>
|
||||
<!-- media buttons will be added here -->
|
||||
<LinearLayout
|
||||
android:id="@+id/notification_main_column"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/notification_content_margin_top"
|
||||
android:layout_marginStart="@dimen/notification_content_margin_start"
|
||||
android:layout_marginBottom="@dimen/notification_content_margin_bottom"
|
||||
android:layout_marginEnd="@dimen/notification_content_margin_end"
|
||||
android:minHeight="@dimen/notification_min_content_height"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<include layout="@layout/notification_template_part_line1" />
|
||||
<include layout="@layout/notification_template_text" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/media_actions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-15dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:layoutDirection="ltr"
|
||||
>
|
||||
<!-- media buttons will be added here -->
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView android:id="@+id/right_icon"
|
||||
@@ -61,9 +65,8 @@
|
||||
android:layout_height="@dimen/media_notification_expanded_image_max_size"
|
||||
android:minWidth="40dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:scaleType="centerCrop"
|
||||
/>
|
||||
</com.android.internal.widget.MediaNotificationView>
|
||||
|
||||
Reference in New Issue
Block a user