From 3de1e805afc243c10721fb32c3eeac51e4d0bd33 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Tue, 1 Jul 2014 18:01:58 -0700 Subject: Fix Settings Panel bug causing frozen overview. Previously, toggling search panel would freeze Overview mode until the user exited back to the regular launcher. Also, the current page would be lost. Fix this by computing the new scroll bounds immediately when the setting is toggled. Change-Id: Ib3587cfcea61e15b3d8b280113ce986cc57f2f9d --- src/com/android/launcher3/PagedView.java | 2 +- src/com/android/launcher3/Workspace.java | 32 ++++++++++++++++++++++ .../list/SettingsPinnedHeaderAdapter.java | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src/com') diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 7f145aea2..11b2bf77a 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -143,7 +143,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc private boolean mCancelTap; - private int[] mPageScrolls; + protected int[] mPageScrolls; protected final static int TOUCH_STATE_REST = 0; protected final static int TOUCH_STATE_SCROLLING = 1; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 7e3584115..9617ace5b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2261,6 +2261,38 @@ public class Workspace extends SmoothPagedView setImportantForAccessibility(accessible); } + public void updatePageScrollForCustomPage(boolean enabled) { + int diff; + // If multiple PageScrolls have been computed already, + // find the distance between the first and second scroll. + if(mPageScrolls.length > 1) { + diff = mPageScrolls[1] - mPageScrolls[0]; + } else { + // The scroll distance will just be the width of the viewport + diff = getViewportWidth(); + } + + // Create an ArrayList to hold PageScrolls while we work with them + ArrayList list = new ArrayList(); + for(int i : mPageScrolls) { + list.add(i); + } + + // If custom page is enabled, add another page scroll entry + if(enabled){ + list.add(list.get(list.size() - 1) + diff); + } else { + // disabling custom page, remove the last element + list.remove(list.size() - 1); + } + + // Replace mPageScrolls with the list content + mPageScrolls = new int[list.size()]; + for(int i = 0; i < list.size();i++) { + mPageScrolls[i] = list.get(i); + } + } + Animator getChangeStateAnimation(final State state, boolean animated, int delay, int snapPage) { if (mState == state) { return null; diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 805b51e37..4b0d40833 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -310,6 +310,8 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { v, SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, R.bool.preferences_interface_homescreen_search_screen_left_default); + mLauncher.restoreGelSetting(); + mLauncher.getWorkspace().updatePageScrollForCustomPage(!current); mLauncher.updateDynamicGrid(); } } else if (value.equals(res -- cgit v1.2.3