summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/BubbleTextView.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-08-04 10:53:22 -0700
committerSunny Goyal <sunnygoyal@google.com>2014-08-11 12:32:04 -0700
commit95abbb330ce9bbaf23594245f0f8a795c8118038 (patch)
tree3d72a2655eb05efd10c9d5c5e29cc40d2b40838b /src/com/android/launcher3/BubbleTextView.java
parent6551b7ef07b4d73c096cbfb22002e080b498cbbb (diff)
downloadandroid_packages_apps_Trebuchet-95abbb330ce9bbaf23594245f0f8a795c8118038.tar.gz
android_packages_apps_Trebuchet-95abbb330ce9bbaf23594245f0f8a795c8118038.tar.bz2
android_packages_apps_Trebuchet-95abbb330ce9bbaf23594245f0f8a795c8118038.zip
Updating the virtual preloader UX.
> No click feedback when in preloader mode > No preloader UI when drawn in drag layer > The preloader consists of a background 9 patch image and a circular progress is drawn in the content region of the background. > The preloader is drawn in a slightly larget area than the actual bounds to make the circular progress more prominent compared to the icon. issue: 15835307 Change-Id: Ifec3d93ecf1fac994d1128b517da3797247e7ed6
Diffstat (limited to 'src/com/android/launcher3/BubbleTextView.java')
-rw-r--r--src/com/android/launcher3/BubbleTextView.java36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index ab94814c3..5c2bb9946 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
+import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -28,6 +29,7 @@ import android.graphics.Region.Op;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
+import android.util.SparseArray;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
@@ -39,6 +41,9 @@ import android.widget.TextView;
* too aggressive.
*/
public class BubbleTextView extends TextView {
+
+ private static SparseArray<Theme> sPreloaderThemes = new SparseArray<>(2);
+
static final float SHADOW_LARGE_RADIUS = 4.0f;
static final float SHADOW_SMALL_RADIUS = 1.75f;
static final float SHADOW_Y_OFFSET = 2.0f;
@@ -128,10 +133,7 @@ public class BubbleTextView extends TextView {
LauncherAppState app = LauncherAppState.getInstance();
FastBitmapDrawable iconDrawable = Utilities.createIconDrawable(b);
- if (info.isDisabled) {
- iconDrawable.setSaturation(0);
- iconDrawable.setBrightness(20);
- }
+ iconDrawable.setGhostModeEnabled(info.isDisabled);
setCompoundDrawables(null, iconDrawable, null, null);
if (setDefaultPadding) {
@@ -315,7 +317,9 @@ public class BubbleTextView extends TextView {
}
void setCellLayoutPressedOrFocusedIcon() {
- if (getParent() instanceof ShortcutAndWidgetContainer) {
+ // Disable pressed state when the icon is in preloader state.
+ if ((getParent() instanceof ShortcutAndWidgetContainer) &&
+ !(getCompoundDrawables()[1] instanceof PreloadIconDrawable)){
ShortcutAndWidgetContainer parent = (ShortcutAndWidgetContainer) getParent();
if (parent != null) {
CellLayout layout = (CellLayout) parent.getParent();
@@ -385,7 +389,13 @@ public class BubbleTextView extends TextView {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+
if (mBackground != null) mBackground.setCallback(this);
+ Drawable top = getCompoundDrawables()[1];
+
+ if (top instanceof PreloadIconDrawable) {
+ ((PreloadIconDrawable) top).applyTheme(getPreloaderTheme());
+ }
mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
@@ -466,7 +476,7 @@ public class BubbleTextView extends TextView {
if (top instanceof PreloadIconDrawable) {
preloadDrawable = (PreloadIconDrawable) top;
} else {
- preloadDrawable = new PreloadIconDrawable(top, getResources());
+ preloadDrawable = new PreloadIconDrawable(top, getPreloaderTheme());
setCompoundDrawables(drawables[0], preloadDrawable, drawables[2], drawables[3]);
}
@@ -478,4 +488,18 @@ public class BubbleTextView extends TextView {
}
}
}
+
+ private Theme getPreloaderTheme() {
+ Object tag = getTag();
+ int style = ((tag != null) && (tag instanceof ShortcutInfo) &&
+ (((ShortcutInfo) tag).container >= 0)) ? R.style.PreloadIcon_Folder
+ : R.style.PreloadIcon;
+ Theme theme = sPreloaderThemes.get(style);
+ if (theme == null) {
+ theme = getResources().newTheme();
+ theme.applyStyle(style, true);
+ sPreloaderThemes.put(style, theme);
+ }
+ return theme;
+ }
}