summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Stamm <stammt@google.com>2013-10-03 20:38:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-03 20:38:12 +0000
commit339b0ec914d4ec3863aba1cba7329a2e69a308e2 (patch)
tree4601d43bccab2e23ef4dbbed4fb96338f7efe0bf
parentc95c80d13793972eebc61520497fc0dad03838e7 (diff)
parent6fecd410e8567af916b1bbd53198d9878c686177 (diff)
downloadandroid_packages_apps_Trebuchet-339b0ec914d4ec3863aba1cba7329a2e69a308e2.tar.gz
android_packages_apps_Trebuchet-339b0ec914d4ec3863aba1cba7329a2e69a308e2.tar.bz2
android_packages_apps_Trebuchet-339b0ec914d4ec3863aba1cba7329a2e69a308e2.zip
Merge "Trying to come up with a simpler approach for onShow/onHide." into jb-ub-now-indigo-rose
-rw-r--r--src/com/android/launcher3/Launcher.java88
-rw-r--r--src/com/android/launcher3/Workspace.java11
2 files changed, 49 insertions, 50 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f1d4c1d9b..5e10e8b78 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -911,6 +911,16 @@ public class Launcher extends Activity
if (DEBUG_RESUME_TIME) {
Log.d(TAG, "Time spent in onResume: " + (System.currentTimeMillis() - startTime));
}
+
+ if (mWorkspace.getCustomContentCallbacks() != null) {
+ // If we are resuming and the custom content is the current page, we call onShow().
+ // It is also poassible that onShow will instead be called slightly after first layout
+ // if PagedView#setRestorePage was set to the custom content page in onCreate().
+ if (mWorkspace.isOnOrMovingToCustomContent()) {
+ mWorkspace.getCustomContentCallbacks().onShow();
+ }
+ }
+
mWorkspace.updateInteractionForState();
}
@@ -923,6 +933,12 @@ public class Launcher extends Activity
mPaused = true;
mDragController.cancelDrag();
mDragController.resetLastGestureUpTime();
+
+ // We call onHide() aggressively. The custom content callbacks should be able to
+ // debounce excess onHide calls.
+ if (mWorkspace.getCustomContentCallbacks() != null) {
+ mWorkspace.getCustomContentCallbacks().onHide();
+ }
}
protected void onFinishBindingItems() {
@@ -1659,54 +1675,40 @@ public class Launcher extends Activity
((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
- Runnable processIntent = new Runnable() {
- public void run() {
- if (mWorkspace == null) {
- // Can be cases where mWorkspace is null, this prevents a NPE
- return;
- }
- Folder openFolder = mWorkspace.getOpenFolder();
- // In all these cases, only animate if we're already on home
- mWorkspace.exitWidgetResizeMode();
- if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
- openFolder == null) {
- mWorkspace.moveToDefaultScreen(true);
- }
-
- closeFolder();
- exitSpringLoadedDragMode();
-
- // If we are already on home, then just animate back to the workspace,
- // otherwise, just wait until onResume to set the state back to Workspace
- if (alreadyOnHome) {
- showWorkspaceAndExitOverviewMode(true);
- } else {
- mOnResumeState = State.WORKSPACE;
- }
-
- final View v = getWindow().peekDecorView();
- if (v != null && v.getWindowToken() != null) {
- InputMethodManager imm = (InputMethodManager)getSystemService(
- INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
- }
+ if (mWorkspace == null) {
+ // Can be cases where mWorkspace is null, this prevents a NPE
+ return;
+ }
+ Folder openFolder = mWorkspace.getOpenFolder();
+ // In all these cases, only animate if we're already on home
+ mWorkspace.exitWidgetResizeMode();
+ if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
+ openFolder == null) {
+ mWorkspace.moveToDefaultScreen(true);
+ }
- // Reset the apps customize page
- if (mAppsCustomizeTabHost != null) {
- mAppsCustomizeTabHost.reset();
- }
- }
- };
+ closeFolder();
+ exitSpringLoadedDragMode();
- if (alreadyOnHome && !mWorkspace.hasWindowFocus()) {
- // Delay processing of the intent to allow the status bar animation to finish
- // first in order to avoid janky animations.
- mWorkspace.postDelayed(processIntent, 350);
+ // If we are already on home, then just animate back to the workspace,
+ // otherwise, just wait until onResume to set the state back to Workspace
+ if (alreadyOnHome) {
+ showWorkspaceAndExitOverviewMode(true);
} else {
- // Process the intent immediately.
- processIntent.run();
+ mOnResumeState = State.WORKSPACE;
}
+ final View v = getWindow().peekDecorView();
+ if (v != null && v.getWindowToken() != null) {
+ InputMethodManager imm = (InputMethodManager)getSystemService(
+ INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ }
+
+ // Reset the apps customize page
+ if (mAppsCustomizeTabHost != null) {
+ mAppsCustomizeTabHost.reset();
+ }
}
if (DEBUG_RESUME_TIME) {
Log.d(TAG, "Time spent in onNewIntent: " + (System.currentTimeMillis() - startTime));
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 2b7a737a2..5a40d444e 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -853,13 +853,6 @@ public class Workspace extends SmoothPagedView
protected void onWindowVisibilityChanged (int visibility) {
mLauncher.onWindowVisibilityChanged(visibility);
- if (mCustomContentShowing && mCustomContentCallbacks != null) {
- if (visibility == View.VISIBLE) {
- mCustomContentCallbacks.onShow();
- } else if (visibility == View.GONE) {
- mCustomContentCallbacks.onHide();
- }
- }
}
@Override
@@ -1048,6 +1041,10 @@ public class Workspace extends SmoothPagedView
}
}
+ protected CustomContentCallbacks getCustomContentCallbacks() {
+ return mCustomContentCallbacks;
+ }
+
protected void setWallpaperDimension() {
String spKey = WallpaperCropActivity.getSharedPreferencesKey();
SharedPreferences sp = mLauncher.getSharedPreferences(spKey, Context.MODE_PRIVATE);