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
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 57148d2..81b37a9 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -280,6 +280,8 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
"or use the exported attribute for this activity. "
+ "tag="+ tag + " intent=" + intent, e);
}
+ return false;
}
void startActivityForResultSafely(Intent intent, int requestCode) {