summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values-large/themes.xml15
-rw-r--r--core/res/res/values/styles_material.xml8
-rw-r--r--graphics/java/android/graphics/drawable/Ripple.java4
-rw-r--r--graphics/java/android/graphics/drawable/RippleDrawable.java48
4 files changed, 45 insertions, 30 deletions
diff --git a/core/res/res/values-large/themes.xml b/core/res/res/values-large/themes.xml
index 448e7c873c11..8c8f86c906a8 100644
--- a/core/res/res/values-large/themes.xml
+++ b/core/res/res/values-large/themes.xml
@@ -46,4 +46,19 @@ please see themes_device_defaults.xml.
<style name="Theme.Holo.Light.DialogWhenLarge.NoActionBar"
parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar.FixedSize">
</style>
+
+ <style name="Theme.Material.DialogWhenLarge"
+ parent="@android:style/Theme.Material.Dialog.FixedSize">
+ <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
+ </style>
+ <style name="Theme.Material.DialogWhenLarge.NoActionBar"
+ parent="@android:style/Theme.Material.Dialog.NoActionBar.FixedSize">
+ <item name="preferencePanelStyle">@style/PreferencePanel.Dialog</item>
+ </style>
+ <style name="Theme.Material.Light.DialogWhenLarge"
+ parent="@android:style/Theme.Material.Light.Dialog.FixedSize">
+ </style>
+ <style name="Theme.Material.Light.DialogWhenLarge.NoActionBar"
+ parent="@android:style/Theme.Material.Light.Dialog.NoActionBar.FixedSize">
+ </style>
</resources>
diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml
index 929e61552a59..3d739959434c 100644
--- a/core/res/res/values/styles_material.xml
+++ b/core/res/res/values/styles_material.xml
@@ -296,8 +296,8 @@ please see styles_device_defaults.xml.
<item name="textAllCaps">@bool/config_actionMenuItemAllCaps</item>
</style>
- <style name="TextAppearance.Material.WindowTitle" parent="TextAppearance.Material.Headline" />
- <style name="TextAppearance.Material.DialogWindowTitle" parent="TextAppearance.Material.Headline" />
+ <style name="TextAppearance.Material.WindowTitle" parent="TextAppearance.Material.Title" />
+ <style name="TextAppearance.Material.DialogWindowTitle" parent="TextAppearance.Material.Title" />
<style name="TextAppearance.Material.CalendarViewWeekDayView" parent="TextAppearance.Material.Small">
<item name="textStyle">bold</item>
@@ -966,8 +966,6 @@ please see styles_device_defaults.xml.
<item name="textAppearance">@style/TextAppearance.Material.DialogWindowTitle</item>
</style>
- <style name="DialogWindowTitle.Material.Light">
- <item name="textAppearance">@style/TextAppearance.Material.DialogWindowTitle</item>
- </style>
+ <style name="DialogWindowTitle.Material.Light" />
</resources>
diff --git a/graphics/java/android/graphics/drawable/Ripple.java b/graphics/java/android/graphics/drawable/Ripple.java
index b3187c7208d1..4623fa88629b 100644
--- a/graphics/java/android/graphics/drawable/Ripple.java
+++ b/graphics/java/android/graphics/drawable/Ripple.java
@@ -236,7 +236,7 @@ class Ripple {
// Cache the paint alpha so we can restore it later.
final int paintAlpha = p.getAlpha();
- final int outerAlpha = (int) (255 * mOuterOpacity + 0.5f);
+ final int outerAlpha = (int) (paintAlpha * mOuterOpacity + 0.5f);
if (outerAlpha > 0 && mOuterRadius > 0) {
p.setAlpha(outerAlpha);
p.setStyle(Style.FILL);
@@ -244,7 +244,7 @@ class Ripple {
hasContent = true;
}
- final int alpha = (int) (255 * mOpacity + 0.5f);
+ final int alpha = (int) (paintAlpha * mOpacity + 0.5f);
final float radius = MathUtils.lerp(0, mOuterRadius, mTweenRadius);
if (alpha > 0 && radius > 0) {
final float x = MathUtils.lerp(mStartingX - mBounds.exactCenterX(), mOuterX, mTweenX);
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java
index 58f6eaa53773..e37fbeb165ea 100644
--- a/graphics/java/android/graphics/drawable/RippleDrawable.java
+++ b/graphics/java/android/graphics/drawable/RippleDrawable.java
@@ -172,16 +172,20 @@ public class RippleDrawable extends LayerDrawable {
protected boolean onStateChange(int[] stateSet) {
super.onStateChange(stateSet);
+ // TODO: This would make more sense in a StateListDrawable.
boolean active = false;
+ boolean enabled = false;
final int N = stateSet.length;
for (int i = 0; i < N; i++) {
+ if (stateSet[i] == R.attr.state_enabled) {
+ enabled = true;
+ }
if (stateSet[i] == R.attr.state_focused
|| stateSet[i] == R.attr.state_pressed) {
active = true;
- break;
}
}
- setActive(active);
+ setActive(active && enabled);
// Update the paint color. Only applicable when animated in software.
if (mRipplePaint != null && mState.mTint != null) {
@@ -471,16 +475,21 @@ public class RippleDrawable extends LayerDrawable {
@Override
public void draw(Canvas canvas) {
- final Rect bounds = isProjected() ? getDirtyBounds() : getBounds();
+ final boolean isProjected = isProjected();
+ final boolean hasMask = mMask != null;
+ final boolean drawNonMaskContent = mLayerState.mNum > (hasMask ? 1 : 0);
+ final boolean drawMask = hasMask && mMask.getOpacity() != PixelFormat.OPAQUE;
+ final Rect bounds = isProjected ? getDirtyBounds() : getBounds();
- // Draw the content into a layer first.
- final int contentLayer = drawContentLayer(canvas, bounds, SRC_OVER);
+ // If we have content, draw it into a layer first.
+ final int contentLayer = drawNonMaskContent ?
+ drawContentLayer(canvas, bounds, SRC_OVER) : -1;
- // Next, draw the ripples into a layer.
+ // Next, try to draw the ripples (into a layer if necessary).
final int rippleLayer = drawRippleLayer(canvas, bounds, mState.mTintXfermode);
- // If we have ripples, draw the masking layer.
- if (rippleLayer >= 0) {
+ // If we have ripples and a non-opaque mask, draw the masking layer.
+ if (rippleLayer >= 0 && drawMask) {
drawMaskingLayer(canvas, bounds, DST_IN);
}
@@ -524,17 +533,14 @@ public class RippleDrawable extends LayerDrawable {
}
private int drawContentLayer(Canvas canvas, Rect bounds, PorterDuffXfermode mode) {
- final int count = mLayerState.mNum;
- if (count == 0 || (mMask != null && count == 1)) {
- return -1;
- }
-
+ // TODO: We don't need a layer if all the content is opaque.
final Paint maskingPaint = getMaskingPaint(mode);
final int restoreToCount = canvas.saveLayer(bounds.left, bounds.top,
bounds.right, bounds.bottom, maskingPaint);
// Draw everything except the mask.
final ChildDrawable[] array = mLayerState.mChildren;
+ final int count = mLayerState.mNum;
for (int i = 0; i < count; i++) {
if (array[i].mId != R.id.mask) {
array[i].mDrawable.draw(canvas);
@@ -559,14 +565,15 @@ public class RippleDrawable extends LayerDrawable {
rippleARGB = Color.TRANSPARENT;
}
- final int rippleAlpha = Color.alpha(rippleARGB);
- final int rippleColor = rippleARGB | (0xFF << 24);
if (mRipplePaint == null) {
mRipplePaint = new Paint();
mRipplePaint.setAntiAlias(true);
}
+
+ final int rippleAlpha = Color.alpha(rippleARGB);
final Paint ripplePaint = mRipplePaint;
- ripplePaint.setColor(rippleColor);
+ ripplePaint.setColor(rippleARGB);
+ ripplePaint.setAlpha(0xFF);
boolean drewRipples = false;
int restoreToCount = -1;
@@ -584,7 +591,6 @@ public class RippleDrawable extends LayerDrawable {
maskingPaint.setAlpha(rippleAlpha);
restoreToCount = canvas.saveLayer(bounds.left, bounds.top,
bounds.right, bounds.bottom, maskingPaint);
- maskingPaint.setAlpha(255);
restoreTranslate = canvas.save();
// Translate the canvas to the current hotspot bounds.
@@ -609,18 +615,13 @@ public class RippleDrawable extends LayerDrawable {
}
private int drawMaskingLayer(Canvas canvas, Rect bounds, PorterDuffXfermode mode) {
- final Drawable mask = mMask;
- if (mask == null) {
- return -1;
- }
-
final int restoreToCount = canvas.saveLayer(bounds.left, bounds.top,
bounds.right, bounds.bottom, getMaskingPaint(mode));
// Ensure that DST_IN blends using the entire layer.
canvas.drawColor(Color.TRANSPARENT);
- mask.draw(canvas);
+ mMask.draw(canvas);
return restoreToCount;
}
@@ -630,6 +631,7 @@ public class RippleDrawable extends LayerDrawable {
mMaskingPaint = new Paint();
}
mMaskingPaint.setXfermode(xfermode);
+ mMaskingPaint.setAlpha(0xFF);
return mMaskingPaint;
}