Some fixes for quickstep when configuration changes
> Creating the launcher animation after first draw, so that the UI is in correct state
> Using correct workspace size, when layout is not valid
> Snapping pagedView to correct page when page size changes
> Resoting to correct workspace page on rebind
Change-Id: I74e61a05aae3a3c4912d4c5c8eb4d5d036d9005a
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7595793..639fb6c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -419,7 +419,11 @@
getStateManager().reapplyState();
// TODO: We can probably avoid rebind when only screen size changed.
- mModel.startLoader(mWorkspace.getNextPage());
+ int currentPage = mWorkspace.getNextPage();
+ if (mModel.startLoader(currentPage)) {
+ mWorkspace.setCurrentPage(currentPage);
+ setWorkspaceLoading(true);
+ }
}
mOldConfig.setTo(newConfig);
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index ad94a6b..0ebae81 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -184,6 +184,9 @@
protected final Rect mInsets = new Rect();
protected final boolean mIsRtl;
+ // Similar to the platform implementation of isLayoutValid();
+ protected boolean mIsLayoutValid;
+
public PagedView(Context context) {
this(context, null);
}
@@ -582,6 +585,18 @@
}
@Override
+ public void requestLayout() {
+ mIsLayoutValid = false;
+ super.requestLayout();
+ }
+
+ @Override
+ public void forceLayout() {
+ mIsLayoutValid = false;
+ super.forceLayout();
+ }
+
+ @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (getChildCount() == 0) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -624,6 +639,7 @@
@SuppressLint("DrawAllocation")
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ mIsLayoutValid = true;
if (getChildCount() == 0) {
return;
}
@@ -640,8 +656,10 @@
int scrollOffsetLeft = mInsets.left + getPaddingLeft();
int childLeft = scrollOffsetLeft;
+ boolean pageScrollChanged = false;
if (mPageScrolls == null || childCount != mChildCountOnLastLayout) {
mPageScrolls = new int[childCount];
+ pageScrollChanged = true;
}
for (int i = startIndex; i != endIndex; i += delta) {
@@ -658,7 +676,11 @@
child.layout(childLeft, childTop,
childLeft + child.getMeasuredWidth(), childTop + childHeight);
- mPageScrolls[i] = childLeft - scrollOffsetLeft;
+ final int pageScroll = childLeft - scrollOffsetLeft;
+ if (mPageScrolls[i] != pageScroll) {
+ pageScrollChanged = true;
+ mPageScrolls[i] = pageScroll;
+ }
childLeft += childWidth + mPageSpacing + getChildGap();
}
@@ -693,7 +715,7 @@
mFirstLayout = false;
}
- if (mScroller.isFinished() && mChildCountOnLastLayout != childCount) {
+ if (mScroller.isFinished() && pageScrollChanged) {
setCurrentPage(getNextPage());
}
mChildCountOnLastLayout = childCount;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index e6aa6be..8fb0e1c 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -22,7 +22,6 @@
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
-import static com.android.launcher3.compat.AccessibilityManagerCompat.isAccessibilityEnabled;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -48,7 +47,6 @@
import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
-import android.util.Property;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -3354,13 +3352,13 @@
@Override
public int getExpectedHeight() {
- return getMeasuredHeight() <= 0
+ return getMeasuredHeight() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight();
}
@Override
public int getExpectedWidth() {
- return getMeasuredWidth() <= 0
+ return getMeasuredWidth() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth();
}