Notifications are now selectable by the Keyboard
Also adapted the ripple colors a bit to be more visible. Bug: 17203303 Change-Id: I7d0446d2641bcabb1e09b3af9535d88c4142e216
This commit is contained in:
@@ -14,7 +14,11 @@
|
||||
~ 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>
|
||||
|
||||
@@ -90,7 +90,10 @@
|
||||
<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>
|
||||
|
||||
@@ -88,6 +88,9 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
= 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;
|
||||
@@ -153,6 +156,12 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
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
|
||||
@@ -191,6 +200,16 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
@@ -372,12 +391,15 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
|
||||
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() {
|
||||
@@ -618,6 +640,18 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -35,15 +35,9 @@ public class NotificationBackgroundView extends View {
|
||||
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
|
||||
@@ -103,17 +97,10 @@ public class NotificationBackgroundView extends View {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -138,4 +125,15 @@ public class NotificationBackgroundView extends View {
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user