Merge "Computing the visible cell layout area without using the current scroll" into ub-launcher3-burnaby
This commit is contained in:
@@ -959,32 +959,22 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
|
|||||||
int centerY = (int) (sTempRect.top + sTempRect.height() * scale / 2);
|
int centerY = (int) (sTempRect.top + sTempRect.height() * scale / 2);
|
||||||
int centeredLeft = centerX - width / 2;
|
int centeredLeft = centerX - width / 2;
|
||||||
int centeredTop = centerY - height / 2;
|
int centeredTop = centerY - height / 2;
|
||||||
int currentPage = mLauncher.getWorkspace().getNextPage();
|
|
||||||
// In case the workspace is scrolling, we need to use the final scroll to compute
|
|
||||||
// the folders bounds.
|
|
||||||
mLauncher.getWorkspace().setFinalScrollForPageChange(currentPage);
|
|
||||||
// We first fetch the currently visible CellLayoutChildren
|
|
||||||
CellLayout currentLayout = (CellLayout) mLauncher.getWorkspace().getChildAt(currentPage);
|
|
||||||
ShortcutAndWidgetContainer boundingLayout = currentLayout.getShortcutsAndWidgets();
|
|
||||||
Rect bounds = new Rect();
|
|
||||||
parent.getDescendantRectRelativeToSelf(boundingLayout, bounds);
|
|
||||||
// We reset the workspaces scroll
|
|
||||||
mLauncher.getWorkspace().resetFinalScrollForPageChange(currentPage);
|
|
||||||
|
|
||||||
// We need to bound the folder to the currently visible CellLayoutChildren
|
// We need to bound the folder to the currently visible workspace area
|
||||||
int left = Math.min(Math.max(bounds.left, centeredLeft),
|
mLauncher.getWorkspace().getPageAreaRelativeToDragLayer(sTempRect);
|
||||||
bounds.left + bounds.width() - width);
|
int left = Math.min(Math.max(sTempRect.left, centeredLeft),
|
||||||
int top = Math.min(Math.max(bounds.top, centeredTop),
|
sTempRect.left + sTempRect.width() - width);
|
||||||
bounds.top + bounds.height() - height);
|
int top = Math.min(Math.max(sTempRect.top, centeredTop),
|
||||||
|
sTempRect.top + sTempRect.height() - height);
|
||||||
if (grid.isPhone && (grid.availableWidthPx - width) < grid.iconSizePx) {
|
if (grid.isPhone && (grid.availableWidthPx - width) < grid.iconSizePx) {
|
||||||
// Center the folder if it is full (on phones only)
|
// Center the folder if it is full (on phones only)
|
||||||
left = (grid.availableWidthPx - width) / 2;
|
left = (grid.availableWidthPx - width) / 2;
|
||||||
} else if (width >= bounds.width()) {
|
} else if (width >= sTempRect.width()) {
|
||||||
// If the folder doesn't fit within the bounds, center it about the desired bounds
|
// If the folder doesn't fit within the bounds, center it about the desired bounds
|
||||||
left = bounds.left + (bounds.width() - width) / 2;
|
left = sTempRect.left + (sTempRect.width() - width) / 2;
|
||||||
}
|
}
|
||||||
if (height >= bounds.height()) {
|
if (height >= sTempRect.height()) {
|
||||||
top = bounds.top + (bounds.height() - height) / 2;
|
top = sTempRect.top + (sTempRect.height() - height) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int folderPivotX = width / 2 + (centeredLeft - left);
|
int folderPivotX = width / 2 + (centeredLeft - left);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import android.appwidget.AppWidgetHostView;
|
|||||||
import android.appwidget.AppWidgetProviderInfo;
|
import android.appwidget.AppWidgetProviderInfo;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@@ -248,11 +247,6 @@ public class Workspace extends PagedView
|
|||||||
private SparseArray<Parcelable> mSavedStates;
|
private SparseArray<Parcelable> mSavedStates;
|
||||||
private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>();
|
private final ArrayList<Integer> mRestoredPages = new ArrayList<Integer>();
|
||||||
|
|
||||||
// These variables are used for storing the initial and final values during workspace animations
|
|
||||||
private int mSavedScrollX;
|
|
||||||
private float mSavedRotationY;
|
|
||||||
private float mSavedTranslationX;
|
|
||||||
|
|
||||||
private float mCurrentScale;
|
private float mCurrentScale;
|
||||||
private float mTransitionProgress;
|
private float mTransitionProgress;
|
||||||
|
|
||||||
@@ -2762,26 +2756,26 @@ public class Workspace extends PagedView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFinalScrollForPageChange(int pageIndex) {
|
/**
|
||||||
CellLayout cl = (CellLayout) getChildAt(pageIndex);
|
* Computes the area relative to dragLayer which is used to display a page.
|
||||||
if (cl != null) {
|
*/
|
||||||
mSavedScrollX = getScrollX();
|
public void getPageAreaRelativeToDragLayer(Rect outArea) {
|
||||||
mSavedTranslationX = cl.getTranslationX();
|
CellLayout child = (CellLayout) getChildAt(getNextPage());
|
||||||
mSavedRotationY = cl.getRotationY();
|
if (child == null) {
|
||||||
final int newX = getScrollForPage(pageIndex);
|
return;
|
||||||
setScrollX(newX);
|
|
||||||
cl.setTranslationX(0f);
|
|
||||||
cl.setRotationY(0f);
|
|
||||||
}
|
}
|
||||||
}
|
ShortcutAndWidgetContainer boundingLayout = child.getShortcutsAndWidgets();
|
||||||
|
|
||||||
public void resetFinalScrollForPageChange(int pageIndex) {
|
// Use the absolute left instead of the child left, as we want the visible area
|
||||||
if (pageIndex >= 0) {
|
// irrespective of the visible child. Since the view can only scroll horizontally, the
|
||||||
CellLayout cl = (CellLayout) getChildAt(pageIndex);
|
// top position is not affected.
|
||||||
setScrollX(mSavedScrollX);
|
mTempXY[0] = getViewportOffsetX() + getPaddingLeft() + boundingLayout.getLeft();
|
||||||
cl.setTranslationX(mSavedTranslationX);
|
mTempXY[1] = child.getTop() + boundingLayout.getTop();
|
||||||
cl.setRotationY(mSavedRotationY);
|
|
||||||
}
|
float scale = mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempXY);
|
||||||
|
outArea.set(mTempXY[0], mTempXY[1],
|
||||||
|
(int) (mTempXY[0] + scale * boundingLayout.getMeasuredWidth()),
|
||||||
|
(int) (mTempXY[1] + scale * boundingLayout.getMeasuredHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getViewLocationRelativeToSelf(View v, int[] location) {
|
public void getViewLocationRelativeToSelf(View v, int[] location) {
|
||||||
|
|||||||
Reference in New Issue
Block a user