summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/HolographicViewHelper.java
diff options
context:
space:
mode:
authorCristina Stancu <crstn@google.com>2013-08-16 11:15:40 +0100
committerCristina Stancu <crstn@google.com>2013-08-16 12:06:59 +0100
commitd791998dd8643048ae40adaad2311fed0543bbb1 (patch)
tree54f65ffa38c97eb9710e705e70c655872ff362ef /src/com/android/launcher3/HolographicViewHelper.java
parente3381e11b0dbee7e956f72c0d1b92904ab171acf (diff)
downloadandroid_packages_apps_Trebuchet-d791998dd8643048ae40adaad2311fed0543bbb1.tar.gz
android_packages_apps_Trebuchet-d791998dd8643048ae40adaad2311fed0543bbb1.tar.bz2
android_packages_apps_Trebuchet-d791998dd8643048ae40adaad2311fed0543bbb1.zip
Modify qsb bar elements to handle hotword state.
They currently handle a pressed mode (showing a blue overlay), we'd like them to also handle a hotword state that would modify their appearance when hotword is available and active. Meant to work with: ag/344334 Change-Id: I07e261ce64307fdad8a4c16fc02eb009ca826ece
Diffstat (limited to 'src/com/android/launcher3/HolographicViewHelper.java')
-rw-r--r--src/com/android/launcher3/HolographicViewHelper.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/com/android/launcher3/HolographicViewHelper.java b/src/com/android/launcher3/HolographicViewHelper.java
index 9d3ad70a8..7ef035555 100644
--- a/src/com/android/launcher3/HolographicViewHelper.java
+++ b/src/com/android/launcher3/HolographicViewHelper.java
@@ -30,11 +30,12 @@ public class HolographicViewHelper {
private final Canvas mTempCanvas = new Canvas();
private boolean mStatesUpdated;
- private int mHighlightColor;
+ private int mHighlightColor, mHotwordColor;
public HolographicViewHelper(Context context) {
Resources res = context.getResources();
mHighlightColor = res.getColor(android.R.color.holo_blue_light);
+ mHotwordColor = res.getColor(android.R.color.holo_green_light);
}
/**
@@ -44,13 +45,17 @@ public class HolographicViewHelper {
if (!mStatesUpdated && v != null) {
mStatesUpdated = true;
Bitmap original = createOriginalImage(v, mTempCanvas);
- Bitmap outline = createPressImage(v, mTempCanvas);
+ Bitmap outline = createImageWithOverlay(v, mTempCanvas, mHighlightColor);
+ Bitmap hotword = createImageWithOverlay(v, mTempCanvas, mHotwordColor);
FastBitmapDrawable originalD = new FastBitmapDrawable(original);
FastBitmapDrawable outlineD = new FastBitmapDrawable(outline);
+ FastBitmapDrawable hotwordD = new FastBitmapDrawable(hotword);
StateListDrawable states = new StateListDrawable();
+
states.addState(new int[] {android.R.attr.state_pressed}, outlineD);
states.addState(new int[] {android.R.attr.state_focused}, outlineD);
+ states.addState(new int[] {R.attr.stateHotwordOn}, hotwordD);
states.addState(new int[] {}, originalD);
v.setImageDrawable(states);
}
@@ -76,7 +81,7 @@ public class HolographicViewHelper {
canvas.setBitmap(b);
canvas.save();
- d.draw(canvas);
+ d.draw(canvas);
canvas.restore();
canvas.setBitmap(null);
@@ -87,16 +92,16 @@ public class HolographicViewHelper {
* Creates a new press state image which is the old image with a blue overlay.
* Responsibility for the bitmap is transferred to the caller.
*/
- private Bitmap createPressImage(ImageView v, Canvas canvas) {
+ private Bitmap createImageWithOverlay(ImageView v, Canvas canvas, int color) {
final Drawable d = v.getDrawable();
final Bitmap b = Bitmap.createBitmap(
d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
canvas.setBitmap(b);
canvas.save();
- d.draw(canvas);
+ d.draw(canvas);
canvas.restore();
- canvas.drawColor(mHighlightColor, PorterDuff.Mode.SRC_IN);
+ canvas.drawColor(color, PorterDuff.Mode.SRC_IN);
canvas.setBitmap(null);
return b;