summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-02-16 17:49:14 -0800
committerMichael Jurka <mikejurka@google.com>2011-02-16 17:49:32 -0800
commitddd62e9f3dd21c52dffceef9b168629ebb7f4c03 (patch)
treeaf3d66496e3317722983de4b78d9560861d5da1a /src/com/android
parenta88b213087ea46060bbbebbae52e069b873f3097 (diff)
downloadandroid_packages_apps_Trebuchet-ddd62e9f3dd21c52dffceef9b168629ebb7f4c03.tar.gz
android_packages_apps_Trebuchet-ddd62e9f3dd21c52dffceef9b168629ebb7f4c03.tar.bz2
android_packages_apps_Trebuchet-ddd62e9f3dd21c52dffceef9b168629ebb7f4c03.zip
Improve feedback when launching apps
- Keep "pressed" state until the activity is launched - Properly invalidate icons, which solves issue where the edge of "pressed" blue glow was still being rendered
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/BubbleTextView.java29
-rw-r--r--src/com/android/launcher2/Launcher.java16
2 files changed, 38 insertions, 7 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index ad01fac4f..3ef054637 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -66,6 +66,8 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
private boolean mBackgroundSizeChanged;
private Drawable mBackground;
+ private boolean mStayPressed;
+
private VisibilityChangedListener mOnVisibilityChangedListener;
public BubbleTextView(Context context) {
@@ -124,27 +126,37 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
return who == mBackground || super.verifyDrawable(who);
}
+ private void invalidatePressedOrFocusedBackground() {
+ int padding = HolographicOutlineHelper.MAX_OUTER_BLUR_RADIUS / 2;
+ ((View)getParent()).invalidate(getLeft() - padding, getTop() - padding,
+ getRight() + padding, getBottom() + padding);
+ invalidate();
+ }
+
@Override
protected void drawableStateChanged() {
if (isPressed()) {
// In this case, we have already created the pressed outline on ACTION_DOWN,
// so we just need to do an invalidate to trigger draw
if (!mDidInvalidateForPressedState) {
- invalidate();
+ invalidatePressedOrFocusedBackground();
}
} else {
// Otherwise, either clear the pressed/focused background, or create a background
// for the focused state
final boolean backgroundEmptyBefore = mPressedOrFocusedBackground == null;
- mPressedOrFocusedBackground = null;
+ if (!mStayPressed) {
+ mPressedOrFocusedBackground = null;
+ }
if (isFocused()) {
mPressedOrFocusedBackground = createGlowingOutline(
mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor);
- invalidate();
+ mStayPressed = false;
+ invalidatePressedOrFocusedBackground();
}
final boolean backgroundEmptyNow = mPressedOrFocusedBackground == null;
if (!backgroundEmptyBefore && backgroundEmptyNow) {
- invalidate();
+ invalidatePressedOrFocusedBackground();
}
}
@@ -244,9 +256,16 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca
super.onVisibilityChanged(changedView, visibility);
}
+ void setStayPressed(boolean stayPressed) {
+ mStayPressed = stayPressed;
+ if (!stayPressed) {
+ mPressedOrFocusedBackground = null;
+ }
+ invalidatePressedOrFocusedBackground();
+ }
@Override
public void draw(Canvas canvas) {
- if (mPressedOrFocusedBackground != null && (isPressed() || isFocused())) {
+ if (mPressedOrFocusedBackground != null && (isPressed() || isFocused() || mStayPressed)) {
// The blue glow can extend outside of our clip region, so we first temporarily expand
// the canvas's clip region
canvas.save(Canvas.CLIP_SAVE_FLAG);
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 57148d26d..81b37a94c 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -280,6 +280,8 @@ public final class Launcher extends Activity
private static Drawable.ConstantState sVoiceSearchIcon;
private static Drawable.ConstantState sAppMarketIcon;
+ private BubbleTextView mWaitingForResume;
+
private CustomizationType getCustomizeFilterForTabTag(String tag) {
if (tag.equals(WIDGETS_TAG)) {
return CustomizationType.WidgetCustomization;
@@ -761,6 +763,9 @@ public final class Launcher extends Activity
mRestoring = false;
mOnResumeNeedsLoad = false;
}
+ if (mWaitingForResume != null) {
+ mWaitingForResume.setStayPressed(false);
+ }
// When we resume Launcher, a different Activity might be responsible for the app
// market intent, so refresh the icon
updateAppMarketIcon();
@@ -2037,7 +2042,12 @@ public final class Launcher extends Activity
v.getLocationOnScreen(pos);
intent.setSourceBounds(new Rect(pos[0], pos[1],
pos[0] + v.getWidth(), pos[1] + v.getHeight()));
- startActivitySafely(intent, tag);
+ boolean success = startActivitySafely(intent, tag);
+
+ if (success && v instanceof BubbleTextView) {
+ mWaitingForResume = (BubbleTextView) v;
+ mWaitingForResume.setStayPressed(true);
+ }
} else if (tag instanceof FolderInfo) {
handleFolderClick((FolderInfo) tag);
} else if (v == mHandleView) {
@@ -2130,10 +2140,11 @@ public final class Launcher extends Activity
}
}
- void startActivitySafely(Intent intent, Object tag) {
+ boolean startActivitySafely(Intent intent, Object tag) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
startActivity(intent);
+ return true;
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
Log.e(TAG, "Unable to launch. tag=" + tag + " intent=" + intent, e);
@@ -2144,6 +2155,7 @@ public final class Launcher extends Activity
"or use the exported attribute for this activity. "
+ "tag="+ tag + " intent=" + intent, e);
}
+ return false;
}
void startActivityForResultSafely(Intent intent, int requestCode) {