OSDN Git Service

Notifications are now selectable by the Keyboard
authorSelim Cinek <cinek@google.com>
Tue, 2 Sep 2014 15:35:20 +0000 (17:35 +0200)
committerSelim Cinek <cinek@google.com>
Tue, 2 Sep 2014 15:35:20 +0000 (17:35 +0200)
Also adapted the ripple colors a bit to be more visible.

Bug: 17203303
Change-Id: I7d0446d2641bcabb1e09b3af9535d88c4142e216

packages/SystemUI/res/drawable/notification_material_bg_dim.xml
packages/SystemUI/res/values/colors.xml
packages/SystemUI/src/com/android/systemui/statusbar/ActivatableNotificationView.java
packages/SystemUI/src/com/android/systemui/statusbar/NotificationBackgroundView.java

index b04394d..6581942 100644 (file)
   ~ 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>
index f3a62b8..6da811f 100644 (file)
     <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>
index 500bf45..e6984b2 100644 (file)
@@ -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,
index ad274b0..5db680a 100644 (file)
@@ -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));
+        }
+    }
 }