Fixing screen jump when going to spring_loaded mode in rtl

> Removing call to snapToScreen when changing state
> Marking adjacent pages visible in overview and spring_loaded mode, so that they get drawn atleast once.

Change-Id: If305e0d4cfa63bac03f301d69017da55f89155bd
This commit is contained in:
Sunny Goyal
2015-07-08 15:44:27 -07:00
parent 0edfe2c880
commit ce5a7e5ee4
4 changed files with 51 additions and 51 deletions

View File

@@ -1825,6 +1825,16 @@ public class Workspace extends PagedView
updateChildrenLayersEnabled(false);
}
@Override
protected void getVisiblePages(int[] range) {
super.getVisiblePages(range);
if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
// In overview mode, make sure that the two side pages are visible.
range[0] = Math.min(range[0], Math.max(getCurrentPage() - 1, numCustomPages()));
range[1] = Math.max(range[0], Math.min(getCurrentPage() + 1, getPageCount() - 1));
}
}
protected void onWallpaperTap(MotionEvent ev) {
final int[] position = mTempXY;
getLocationOnScreen(position);
@@ -1945,6 +1955,10 @@ public class Workspace extends PagedView
return mState == State.OVERVIEW;
}
public void snapToPageFromOverView(int whichPage) {
mStateTransitionAnimation.snapToPageFromOverView(whichPage);
}
int getOverviewModeTranslationY() {
DeviceProfile grid = mLauncher.getDeviceProfile();
Rect overviewBar = grid.getOverviewModeButtonBarRect();
@@ -1962,15 +1976,19 @@ public class Workspace extends PagedView
* Sets the current workspace {@link State}, returning an animation transitioning the workspace
* to that new state.
*/
public Animator setStateWithAnimation(State toState, int toPage, boolean animated,
public Animator setStateWithAnimation(State toState, boolean animated,
boolean hasOverlaySearchBar, HashMap<View, Integer> layerViews) {
// Create the animation to the new state
Animator workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState,
toState, toPage, animated, hasOverlaySearchBar, layerViews);
toState, animated, hasOverlaySearchBar, layerViews);
// Update the current state
mState = toState;
updateAccessibilityFlags();
if (mState == State.OVERVIEW || mState == State.SPRING_LOADED) {
// Redraw pages, as we might want to draw pages which were not visible.
invalidate();
}
return workspaceAnim;
}
@@ -2579,7 +2597,7 @@ public class Workspace extends PagedView
}
}
int snapScreen = WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE;
int snapScreen = -1;
boolean resizeOnDrop = false;
if (d.dragSource != this) {
final int[] touchXY = new int[] { (int) mDragViewVisualCenter[0],
@@ -2740,9 +2758,7 @@ public class Workspace extends PagedView
animateWidgetDrop(info, parent, d.dragView,
onCompleteRunnable, animationType, cell, false);
} else {
int duration = snapScreen < 0 ?
WorkspaceStateTransitionAnimation.SCROLL_TO_CURRENT_PAGE :
ADJACENT_SCREEN_DROP_DURATION;
int duration = snapScreen < 0 ? -1 : ADJACENT_SCREEN_DROP_DURATION;
mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell, duration,
onCompleteRunnable, this);
}