~ See the License for the specific language governing permissions and
~ limitations under the License
-->
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <solid android:color="@color/notification_material_background_dimmed_color" />
- <corners android:radius="@dimen/notification_material_rounded_rect_radius" />
-</shape>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <shape>
+ <solid android:color="@color/notification_material_background_dimmed_color" />
+ <corners android:radius="@dimen/notification_material_rounded_rect_radius" />
+ </shape>
+ </item>
+</ripple>
<color name="notification_material_background_media_default_color">#ff424242</color>
<!-- The color of the ripples on the untinted notifications -->
- <color name="notification_ripple_untinted_color">#20000000</color>
+ <color name="notification_ripple_untinted_color">#28000000</color>
+
+ <!-- The color of the ripples on the low priority notifications -->
+ <color name="notification_ripple_color_low_priority">#30000000</color>
<!-- The color of the ripples on the tinted notifications -->
<color name="notification_ripple_tinted_color">#30ffffff</color>
= new PathInterpolator(0.6f, 0, 0.5f, 1);
private static final Interpolator ACTIVATE_INVERSE_ALPHA_INTERPOLATOR
= new PathInterpolator(0, 0, 0.5f, 1);
+ private final int mTintedRippleColor;
+ private final int mLowPriorityRippleColor;
+ private final int mNormalRippleColor;
private boolean mDimmed;
private boolean mDark;
mNormalColor = getResources().getColor(R.color.notification_material_background_color);
mLowPriorityColor = getResources().getColor(
R.color.notification_material_background_low_priority_color);
+ mTintedRippleColor = context.getResources().getColor(
+ R.color.notification_ripple_tinted_color);
+ mLowPriorityRippleColor = context.getResources().getColor(
+ R.color.notification_ripple_color_low_priority);
+ mNormalRippleColor = context.getResources().getColor(
+ R.color.notification_ripple_untinted_color);
}
@Override
}
}
+ @Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+ if (mDimmed) {
+ mBackgroundDimmed.setState(getDrawableState());
+ } else {
+ mBackgroundNormal.setState(getDrawableState());
+ }
+ }
+
private boolean handleTouchEventDimmed(MotionEvent event) {
int action = event.getActionMasked();
switch (action) {
private void updateBackgroundTint() {
int color = getBackgroundColor();
+ int rippleColor = getRippleColor();
if (color == mNormalColor) {
// We don't need to tint a normal notification
color = 0;
}
mBackgroundDimmed.setTint(color);
mBackgroundNormal.setTint(color);
+ mBackgroundDimmed.setRippleColor(rippleColor);
+ mBackgroundNormal.setRippleColor(rippleColor);
}
private void fadeBackground() {
}
}
+ private int getRippleColor() {
+ if (mBgTint != 0) {
+ return mTintedRippleColor;
+ } else if (mShowingLegacyBackground) {
+ return mTintedRippleColor;
+ } else if (mIsBelowSpeedBump) {
+ return mLowPriorityRippleColor;
+ } else {
+ return mNormalRippleColor;
+ }
+ }
+
/**
* When we draw the appear animation, we render the view in a bitmap and render this bitmap
* as a shader of a rect. This call creates the Bitmap and switches the drawing mode,
private Drawable mBackground;
private int mClipTopAmount;
private int mActualHeight;
- private final int mTintedRippleColor;
- private final int mNormalRippleColor;
public NotificationBackgroundView(Context context, AttributeSet attrs) {
super(context, attrs);
- mTintedRippleColor = context.getResources().getColor(
- R.color.notification_ripple_tinted_color);
- mNormalRippleColor = context.getResources().getColor(
- R.color.notification_ripple_untinted_color);
}
@Override
}
public void setTint(int tintColor) {
- int rippleColor;
if (tintColor != 0) {
mBackground.setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP);
- rippleColor = mTintedRippleColor;
} else {
mBackground.clearColorFilter();
- rippleColor = mNormalRippleColor;
- }
- if (mBackground instanceof RippleDrawable) {
- RippleDrawable ripple = (RippleDrawable) mBackground;
- ripple.setColor(ColorStateList.valueOf(rippleColor));
}
invalidate();
}
// Prevents this view from creating a layer when alpha is animating.
return false;
}
+
+ public void setState(int[] drawableState) {
+ mBackground.setState(drawableState);
+ }
+
+ public void setRippleColor(int color) {
+ if (mBackground instanceof RippleDrawable) {
+ RippleDrawable ripple = (RippleDrawable) mBackground;
+ ripple.setColor(ColorStateList.valueOf(color));
+ }
+ }
}