When undoing a removal, always return to the page it came from
We were already returning to the current page, but this wasn't
always right, e.g. when removing the last item on the last page.
So now we mark the page the item was removed from, and bind that
page first when undo is clicked.
This also addresses an issue where we incorrectly returned to the
first page if currentPage = INVALID_RESTORE_PAGE, which happens if
there are no items on the first page.
Bug: 118846684
Change-Id: I4ec1f64b24ba1cc308ce08bfb3111b5981fae99b
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9125a98..f09b6e8 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2112,7 +2112,7 @@
*
* Implementation of the method from LauncherModel.Callbacks.
*/
- public void finishBindingItems(int currentScreen) {
+ public void finishBindingItems(int pageBoundFirst) {
TraceHelper.beginSection("finishBindingItems");
mWorkspace.restoreInstanceStateForRemainingPages();
@@ -2127,7 +2127,8 @@
InstallShortcutReceiver.disableAndFlushInstallQueue(
InstallShortcutReceiver.FLAG_LOADER_RUNNING, this);
- mWorkspace.setCurrentPage(currentScreen);
+ // When undoing the removal of the last item on a page, return to that page.
+ mWorkspace.setCurrentPage(pageBoundFirst);
TraceHelper.endSection("finishBindingItems");
}