From cae95210719c7d520afcf1b5c6f088d776c974d2 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Fri, 19 Jun 2015 13:11:08 -0700 Subject: Fix unintended dynamic grid resize side effects. - Do not attempt to resize the grid unless the dynamic grid resize has been explicitly triggered. - Workspace Ids are 1 indexed not 0, so on resize, start at 1. - After resizing the grid, persist the changes to the DB. The initial implementation only did the resize in memory and did not persist this, causing side effects later. Bugs fixed: 1. Resize the dynamic grid from large to small. Add a new icon by installing a new app or adding a shortcut from file manager. The new icon will overlap one on one of the new pages. 2. Resize the grid from large to small in a previous version of trebuchet (before the grid resize feature was added). Icons on the outer edges of the grid will be lost but persist in the DB. Upgrade to a new version of Trebuchet. The icons will return to the workspace. Change-Id: I8b0defafb3299d1f3d534526a75f9253495d739d --- src/com/android/launcher3/Launcher.java | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/com/android/launcher3/Launcher.java') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 813d091df..682758909 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -337,6 +337,7 @@ public class Launcher extends Activity private boolean mWorkspaceLoading = true; private boolean mDynamicGridUpdateRequired = false; + private boolean mDynamicGridResizeRequired = false; private boolean mPaused = true; private boolean mRestoring; @@ -457,7 +458,7 @@ public class Launcher extends Activity Runnable mUpdateDynamicGridRunnable = new Runnable() { @Override public void run() { - updateDynamicGrid(); + updateDynamicGrid(false); } }; @@ -469,7 +470,7 @@ public class Launcher extends Activity return; } - updateDynamicGrid(); + updateDynamicGrid(false); } }; @@ -1323,7 +1324,7 @@ public class Launcher extends Activity SettingsProvider.putInt(this, SettingsProvider.SETTINGS_UI_DYNAMIC_GRID_SIZE, size.getValue()); - setUpdateDynamicGrid(); + setUpdateDynamicGrid(true); } mOverviewSettingsPanel.notifyDataSetInvalidated(); @@ -5862,11 +5863,11 @@ public class Launcher extends Activity return effect == null ? TransitionEffect.TRANSITION_EFFECT_NONE : effect.getName(); } - public void updateDynamicGrid() { - updateDynamicGrid(mWorkspace.getRestorePage()); + public void updateDynamicGrid(boolean resizeGridIfNeeded) { + updateDynamicGrid(mWorkspace.getRestorePage(), resizeGridIfNeeded); } - public void updateDynamicGrid(int page) { + public void updateDynamicGrid(int page, boolean resizeGridIfNeeded) { mSearchDropTargetBar.setupQSB(Launcher.this); initializeDynamicGrid(true); @@ -5875,19 +5876,22 @@ public class Launcher extends Activity // Synchronized reload mModel.resetLoadedState(true, true); - mModel.startLoader(true, page); + int flag = resizeGridIfNeeded ? LauncherModel.LOADER_FLAG_RESIZE_GRID : + LauncherModel.LOADER_FLAG_NONE; + mModel.startLoader(true, page, flag); mWorkspace.updateCustomContentVisibility(); mAppDrawerAdapter.reset(); } - public void setUpdateDynamicGrid() { + public void setUpdateDynamicGrid(boolean resizeDynamicGrid) { mDynamicGridUpdateRequired = true; + mDynamicGridResizeRequired = resizeDynamicGrid; } public boolean updateGridIfNeeded() { if (mDynamicGridUpdateRequired) { - updateDynamicGrid(mWorkspace.getCurrentPage()); + updateDynamicGrid(mWorkspace.getCurrentPage(), mDynamicGridResizeRequired); mDynamicGridUpdateRequired = false; return true; } -- cgit v1.2.3