am dc4c4198: Merge "Switched to round rect clipping while appearing notifications" into mnc-dev
* commit 'dc4c4198f06290ddcb2afec70ae74842ca781a37': Switched to round rect clipping while appearing notifications
This commit is contained in:
@@ -21,15 +21,8 @@ import android.animation.AnimatorListenerAdapter;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapShader;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.PorterDuffColorFilter;
|
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Shader;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -100,7 +93,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
|||||||
private boolean mDark;
|
private boolean mDark;
|
||||||
|
|
||||||
private int mBgTint = 0;
|
private int mBgTint = 0;
|
||||||
private final int mRoundedRectCornerRadius;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag to indicate that the notification has been touched once and the second touch will
|
* Flag to indicate that the notification has been touched once and the second touch will
|
||||||
@@ -126,10 +118,8 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
|||||||
private NotificationBackgroundView mBackgroundDimmed;
|
private NotificationBackgroundView mBackgroundDimmed;
|
||||||
private ObjectAnimator mBackgroundAnimator;
|
private ObjectAnimator mBackgroundAnimator;
|
||||||
private RectF mAppearAnimationRect = new RectF();
|
private RectF mAppearAnimationRect = new RectF();
|
||||||
private PorterDuffColorFilter mAppearAnimationFilter;
|
|
||||||
private float mAnimationTranslationY;
|
private float mAnimationTranslationY;
|
||||||
private boolean mDrawingAppearAnimation;
|
private boolean mDrawingAppearAnimation;
|
||||||
private Paint mAppearPaint = new Paint();
|
|
||||||
private ValueAnimator mAppearAnimator;
|
private ValueAnimator mAppearAnimator;
|
||||||
private float mAppearAnimationFraction = -1.0f;
|
private float mAppearAnimationFraction = -1.0f;
|
||||||
private float mAppearAnimationTranslation;
|
private float mAppearAnimationTranslation;
|
||||||
@@ -151,9 +141,6 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
|||||||
mLinearInterpolator = new LinearInterpolator();
|
mLinearInterpolator = new LinearInterpolator();
|
||||||
setClipChildren(false);
|
setClipChildren(false);
|
||||||
setClipToPadding(false);
|
setClipToPadding(false);
|
||||||
mAppearAnimationFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP);
|
|
||||||
mRoundedRectCornerRadius = getResources().getDimensionPixelSize(
|
|
||||||
R.dimen.notification_material_rounded_rect_radius);
|
|
||||||
mLegacyColor = context.getColor(R.color.notification_legacy_background_color);
|
mLegacyColor = context.getColor(R.color.notification_legacy_background_color);
|
||||||
mNormalColor = context.getColor(R.color.notification_material_background_color);
|
mNormalColor = context.getColor(R.color.notification_material_background_color);
|
||||||
mLowPriorityColor = context.getColor(
|
mLowPriorityColor = context.getColor(
|
||||||
@@ -661,20 +648,26 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAppearAnimationAlpha() {
|
private void updateAppearAnimationAlpha() {
|
||||||
int backgroundColor = getBgColor();
|
float contentAlphaProgress = mAppearAnimationFraction;
|
||||||
if (backgroundColor != -1) {
|
contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
|
||||||
float contentAlphaProgress = mAppearAnimationFraction;
|
contentAlphaProgress = Math.min(1.0f, contentAlphaProgress);
|
||||||
contentAlphaProgress = contentAlphaProgress / (1.0f - ALPHA_ANIMATION_END);
|
contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress);
|
||||||
contentAlphaProgress = Math.min(1.0f, contentAlphaProgress);
|
setContentAlpha(contentAlphaProgress);
|
||||||
contentAlphaProgress = mCurrentAlphaInterpolator.getInterpolation(contentAlphaProgress);
|
|
||||||
int sourceColor = Color.argb((int) (255 * (1.0f - contentAlphaProgress)),
|
|
||||||
Color.red(backgroundColor), Color.green(backgroundColor),
|
|
||||||
Color.blue(backgroundColor));
|
|
||||||
mAppearAnimationFilter.setColor(sourceColor);
|
|
||||||
mAppearPaint.setColorFilter(mAppearAnimationFilter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setContentAlpha(float contentAlpha) {
|
||||||
|
int layerType = contentAlpha == 0.0f || contentAlpha == 1.0f ? LAYER_TYPE_NONE
|
||||||
|
: LAYER_TYPE_HARDWARE;
|
||||||
|
View contentView = getContentView();
|
||||||
|
int currentLayerType = contentView.getLayerType();
|
||||||
|
if (currentLayerType != layerType) {
|
||||||
|
contentView.setLayerType(layerType, null);
|
||||||
|
}
|
||||||
|
contentView.setAlpha(contentAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract View getContentView();
|
||||||
|
|
||||||
private int getBgColor() {
|
private int getBgColor() {
|
||||||
if (mBgTint != 0) {
|
if (mBgTint != 0) {
|
||||||
return mBgTint;
|
return mBgTint;
|
||||||
@@ -708,41 +701,24 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
|||||||
*/
|
*/
|
||||||
private void enableAppearDrawing(boolean enable) {
|
private void enableAppearDrawing(boolean enable) {
|
||||||
if (enable != mDrawingAppearAnimation) {
|
if (enable != mDrawingAppearAnimation) {
|
||||||
if (enable) {
|
|
||||||
if (getWidth() == 0 || getActualHeight() == 0) {
|
|
||||||
// TODO: This should not happen, but it can during expansion. Needs
|
|
||||||
// investigation
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getActualHeight(),
|
|
||||||
Bitmap.Config.ARGB_8888);
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
|
||||||
draw(canvas);
|
|
||||||
mAppearPaint.setShader(new BitmapShader(bitmap, Shader.TileMode.CLAMP,
|
|
||||||
Shader.TileMode.CLAMP));
|
|
||||||
} else {
|
|
||||||
mAppearPaint.setShader(null);
|
|
||||||
}
|
|
||||||
mDrawingAppearAnimation = enable;
|
mDrawingAppearAnimation = enable;
|
||||||
|
if (!enable) {
|
||||||
|
setContentAlpha(1.0f);
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dispatchDraw(Canvas canvas) {
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
if (!mDrawingAppearAnimation) {
|
if (mDrawingAppearAnimation) {
|
||||||
super.dispatchDraw(canvas);
|
canvas.save();
|
||||||
} else {
|
canvas.translate(0, mAppearAnimationTranslation);
|
||||||
drawAppearRect(canvas);
|
}
|
||||||
|
super.dispatchDraw(canvas);
|
||||||
|
if (mDrawingAppearAnimation) {
|
||||||
|
canvas.restore();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void drawAppearRect(Canvas canvas) {
|
|
||||||
canvas.save();
|
|
||||||
canvas.translate(0, mAppearAnimationTranslation);
|
|
||||||
canvas.drawRoundRect(mAppearAnimationRect, mRoundedRectCornerRadius,
|
|
||||||
mRoundedRectCornerRadius, mAppearPaint);
|
|
||||||
canvas.restore();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnActivatedListener(OnActivatedListener onActivatedListener) {
|
public void setOnActivatedListener(OnActivatedListener onActivatedListener) {
|
||||||
|
|||||||
@@ -855,6 +855,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
|
|||||||
return showingLayout.isContentExpandable();
|
return showingLayout.isContentExpandable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View getContentView() {
|
||||||
|
return getShowingLayout();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setActualHeight(int height, boolean notifyListeners) {
|
public void setActualHeight(int height, boolean notifyListeners) {
|
||||||
super.setActualHeight(height, notifyListeners);
|
super.setActualHeight(height, notifyListeners);
|
||||||
|
|||||||
@@ -24,16 +24,21 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewOutlineProvider;
|
import android.view.ViewOutlineProvider;
|
||||||
|
|
||||||
|
import com.android.systemui.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like {@link ExpandableView}, but setting an outline for the height and clipping.
|
* Like {@link ExpandableView}, but setting an outline for the height and clipping.
|
||||||
*/
|
*/
|
||||||
public abstract class ExpandableOutlineView extends ExpandableView {
|
public abstract class ExpandableOutlineView extends ExpandableView {
|
||||||
|
|
||||||
private final Rect mOutlineRect = new Rect();
|
private final Rect mOutlineRect = new Rect();
|
||||||
|
protected final int mRoundedRectCornerRadius;
|
||||||
private boolean mCustomOutline;
|
private boolean mCustomOutline;
|
||||||
|
|
||||||
public ExpandableOutlineView(Context context, AttributeSet attrs) {
|
public ExpandableOutlineView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
mRoundedRectCornerRadius = getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.notification_material_rounded_rect_radius);
|
||||||
setOutlineProvider(new ViewOutlineProvider() {
|
setOutlineProvider(new ViewOutlineProvider() {
|
||||||
@Override
|
@Override
|
||||||
public void getOutline(View view, Outline outline) {
|
public void getOutline(View view, Outline outline) {
|
||||||
@@ -43,7 +48,7 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
|||||||
getWidth(),
|
getWidth(),
|
||||||
Math.max(getActualHeight(), mClipTopAmount));
|
Math.max(getActualHeight(), mClipTopAmount));
|
||||||
} else {
|
} else {
|
||||||
outline.setRect(mOutlineRect);
|
outline.setRoundRect(mOutlineRect, mRoundedRectCornerRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -66,12 +71,14 @@ public abstract class ExpandableOutlineView extends ExpandableView {
|
|||||||
setOutlineRect(rect.left, rect.top, rect.right, rect.bottom);
|
setOutlineRect(rect.left, rect.top, rect.right, rect.bottom);
|
||||||
} else {
|
} else {
|
||||||
mCustomOutline = false;
|
mCustomOutline = false;
|
||||||
|
setClipToOutline(false);
|
||||||
invalidateOutline();
|
invalidateOutline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setOutlineRect(float left, float top, float right, float bottom) {
|
protected void setOutlineRect(float left, float top, float right, float bottom) {
|
||||||
mCustomOutline = true;
|
mCustomOutline = true;
|
||||||
|
setClipToOutline(true);
|
||||||
|
|
||||||
mOutlineRect.set((int) left, (int) top, (int) right, (int) bottom);
|
mOutlineRect.set((int) left, (int) top, (int) right, (int) bottom);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -32,6 +33,7 @@ public class NotificationOverflowContainer extends ActivatableNotificationView {
|
|||||||
private NotificationOverflowIconsView mIconsView;
|
private NotificationOverflowIconsView mIconsView;
|
||||||
private ViewInvertHelper mViewInvertHelper;
|
private ViewInvertHelper mViewInvertHelper;
|
||||||
private boolean mDark;
|
private boolean mDark;
|
||||||
|
private View mContent;
|
||||||
|
|
||||||
public NotificationOverflowContainer(Context context, AttributeSet attrs) {
|
public NotificationOverflowContainer(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -43,7 +45,8 @@ public class NotificationOverflowContainer extends ActivatableNotificationView {
|
|||||||
mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view);
|
mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view);
|
||||||
mIconsView.setMoreText((TextView) findViewById(R.id.more_text));
|
mIconsView.setMoreText((TextView) findViewById(R.id.more_text));
|
||||||
mIconsView.setOverflowIndicator(findViewById(R.id.more_icon_overflow));
|
mIconsView.setOverflowIndicator(findViewById(R.id.more_icon_overflow));
|
||||||
mViewInvertHelper = new ViewInvertHelper(findViewById(R.id.content),
|
mContent = findViewById(R.id.content);
|
||||||
|
mViewInvertHelper = new ViewInvertHelper(mContent,
|
||||||
NotificationPanelView.DOZE_ANIMATION_DURATION);
|
NotificationPanelView.DOZE_ANIMATION_DURATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +62,11 @@ public class NotificationOverflowContainer extends ActivatableNotificationView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View getContentView() {
|
||||||
|
return mContent;
|
||||||
|
}
|
||||||
|
|
||||||
public NotificationOverflowIconsView getIconsView() {
|
public NotificationOverflowIconsView getIconsView() {
|
||||||
return mIconsView;
|
return mIconsView;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user