summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2013-10-09 18:57:02 -0700
committerAdam Cohen <adamcohen@google.com>2013-10-10 12:51:44 -0700
commit21cd002fef13ff0b6336f10f97e29738a2b0ecb9 (patch)
treed36bc94c8b734d5121528c12c46e8da0d0dd9741 /src
parent82e5c98446e1f1765aabca1725cba181a56edcb4 (diff)
downloadandroid_packages_apps_Trebuchet-21cd002fef13ff0b6336f10f97e29738a2b0ecb9.tar.gz
android_packages_apps_Trebuchet-21cd002fef13ff0b6336f10f97e29738a2b0ecb9.tar.bz2
android_packages_apps_Trebuchet-21cd002fef13ff0b6336f10f97e29738a2b0ecb9.zip
Fix issue where custom content would show up on boot (issue 10713745)
Change-Id: I1c03784970fe1a88e2561f1c5367979cda825973
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java9
-rw-r--r--src/com/android/launcher3/PagedView.java9
-rw-r--r--src/com/android/launcher3/Workspace.java16
3 files changed, 25 insertions, 9 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 324a479c4..afaf2234a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1082,8 +1082,9 @@ public class Launcher extends Activity
mOnResumeState = State.APPS_CUSTOMIZE;
}
- int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN, -1);
- if (currentScreen > -1) {
+ int currentScreen = savedState.getInt(RUNTIME_STATE_CURRENT_SCREEN,
+ PagedView.INVALID_RESTORE_PAGE);
+ if (currentScreen != PagedView.INVALID_RESTORE_PAGE) {
mWorkspace.setRestorePage(currentScreen);
}
@@ -1703,7 +1704,9 @@ public class Launcher extends Activity
@Override
protected void onSaveInstanceState(Bundle outState) {
- outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getNextPage());
+ if (mWorkspace.getChildCount() > 0) {
+ outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getRestorePage());
+ }
super.onSaveInstanceState(outState);
outState.putInt(RUNTIME_STATE, mState.ordinal());
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 2a339c039..e982985f1 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -97,6 +97,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private static final boolean DISABLE_TOUCH_SIDE_PAGES = true;
private static final boolean DISABLE_FLING_TO_DELETE = true;
+ public static final int INVALID_RESTORE_PAGE = -1001;
+
private boolean mFreeScroll = false;
private int mFreeScrollMinScrollX = -1;
private int mFreeScrollMaxScrollX = -1;
@@ -115,7 +117,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private int mNormalChildHeight;
protected int mCurrentPage;
- protected int mRestorePage = -1;
+ protected int mRestorePage = INVALID_RESTORE_PAGE;
protected int mChildCountOnLastLayout;
protected int mNextPage = INVALID_PAGE;
@@ -546,7 +548,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (getChildCount() == 0) {
return;
}
-
mForceScreenScrolled = true;
mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
updateCurrentPageScroll();
@@ -982,9 +983,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
if (mScroller.isFinished() && mChildCountOnLastLayout != getChildCount() &&
!mDeferringForDelete) {
- if (mRestorePage > -1) {
+ if (mRestorePage != INVALID_RESTORE_PAGE) {
setCurrentPage(mRestorePage);
- mRestorePage = -1;
+ mRestorePage = INVALID_RESTORE_PAGE;
} else {
setCurrentPage(getNextPage());
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 3c9a139fe..7a1647413 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -538,10 +538,14 @@ public class Workspace extends SmoothPagedView
// Ensure that the current page and default page are maintained.
mDefaultPage = mOriginalDefaultPage + 1;
- setCurrentPage(getCurrentPage() + 1);
// Update the custom content hint
mLauncher.updateCustomContentHintVisibility();
+ if (mRestorePage != INVALID_RESTORE_PAGE) {
+ mRestorePage = mRestorePage + 1;
+ } else {
+ setCurrentPage(getCurrentPage() + 1);
+ }
}
public void removeCustomContentPage() {
@@ -557,10 +561,14 @@ public class Workspace extends SmoothPagedView
// Ensure that the current page and default page are maintained.
mDefaultPage = mOriginalDefaultPage - 1;
- setCurrentPage(getCurrentPage() - 1);
// Update the custom content hint
mLauncher.updateCustomContentHintVisibility();
+ if (mRestorePage != INVALID_RESTORE_PAGE) {
+ mRestorePage = mRestorePage - 1;
+ } else {
+ setCurrentPage(getCurrentPage() - 1);
+ }
}
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks,
@@ -3722,6 +3730,10 @@ public class Workspace extends SmoothPagedView
return mDragInfo;
}
+ public int getRestorePage() {
+ return getNextPage() - numCustomPages();
+ }
+
/**
* Calculate the nearest cell where the given object would be dropped.
*