Merge "When undoing a removal, always return to the page it came from" into ub-launcher3-master
This commit is contained in:
commit
f5c3cddd05
5 files changed
+19
-9
No files matched your search
@@ -113,10 +113,11 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
public void completeDrop(DragObject d) {
|
||||
ItemInfo item = d.dragInfo;
|
||||
if (canRemove(item)) {
|
||||
int itemPage = mLauncher.getWorkspace().getCurrentPage();
|
||||
onAccessibilityDrop(null, item);
|
||||
ModelWriter modelWriter = mLauncher.getModelWriter();
|
||||
Snackbar.show(mLauncher, R.string.item_removed, R.string.undo,
|
||||
modelWriter::commitDelete, modelWriter::abortDelete);
|
||||
modelWriter::commitDelete, () -> modelWriter.abortDelete(itemPage));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2112,7 +2112,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
*
|
||||
* 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 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||
public void bindItems(List<ItemInfo> shortcuts, boolean forceAnimateIcons);
|
||||
public void bindScreens(IntArray orderedScreenIds);
|
||||
public void finishFirstPageBind(ViewOnDrawExecutor executor);
|
||||
public void finishBindingItems(int currentScreen);
|
||||
public void finishBindingItems(int pageBoundFirst);
|
||||
public void bindAllApplications(ArrayList<AppInfo> apps);
|
||||
public void bindAppsAddedOrUpdated(ArrayList<AppInfo> apps);
|
||||
public void preAddApps();
|
||||
@@ -372,11 +372,16 @@ public class LauncherModel extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
public void forceReload() {
|
||||
forceReload(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the workspace items from the DB and re-binds the workspace. This should generally
|
||||
* not be called as DB updates are automatically followed by UI update
|
||||
* @param synchronousBindPage The page to bind first. Can pass -1 to use the current page.
|
||||
*/
|
||||
public void forceReload() {
|
||||
public void forceReload(int synchronousBindPage) {
|
||||
synchronized (mLock) {
|
||||
// Stop any existing loaders first, so they don't set mModelLoaded to true later
|
||||
stopLoader();
|
||||
@@ -387,7 +392,10 @@ public class LauncherModel extends BroadcastReceiver
|
||||
// the next time launcher starts
|
||||
Callbacks callbacks = getCallback();
|
||||
if (callbacks != null) {
|
||||
startLoader(callbacks.getCurrentWorkspaceScreen());
|
||||
if (synchronousBindPage < 0) {
|
||||
synchronousBindPage = callbacks.getCurrentWorkspaceScreen();
|
||||
}
|
||||
startLoader(synchronousBindPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ public abstract class BaseLoaderResults {
|
||||
public void run() {
|
||||
Callbacks callbacks = mCallbacks.get();
|
||||
if (callbacks != null) {
|
||||
callbacks.finishBindingItems(currentScreen);
|
||||
callbacks.finishBindingItems(mPageToBindFirst);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -349,12 +349,12 @@ public class ModelWriter {
|
||||
mDeleteRunnables.clear();
|
||||
}
|
||||
|
||||
public void abortDelete() {
|
||||
public void abortDelete(int pageToBindFirst) {
|
||||
mPreparingToUndo = false;
|
||||
mDeleteRunnables.clear();
|
||||
// We do a full reload here instead of just a rebind because Folders change their internal
|
||||
// state when dragging an item out, which clobbers the rebind unless we load from the DB.
|
||||
mModel.forceReload();
|
||||
mModel.forceReload(pageToBindFirst);
|
||||
}
|
||||
|
||||
private class UpdateItemRunnable extends UpdateItemBaseRunnable {
|
||||
|
||||
Reference in new issue
Block a user