summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher2/DragLayer.java2
-rw-r--r--src/com/android/launcher2/Folder.java47
-rw-r--r--src/com/android/launcher2/Launcher.java18
-rw-r--r--src/com/android/launcher2/Workspace.java26
4 files changed, 36 insertions, 57 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index 101ed5ddc..0cdfd2863 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -146,7 +146,7 @@ public class DragLayer extends FrameLayout {
return mDragController.onTouchEvent(ev);
}
- private void getDescendantRectRelativeToSelf(View descendant, Rect r) {
+ public void getDescendantRectRelativeToSelf(View descendant, Rect r) {
descendant.getHitRect(r);
ViewParent viewParent = descendant.getParent();
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 80428fa5a..d682a6b81 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -100,6 +100,7 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
private TextView mFolderName;
private int mFolderNameHeight;
private Rect mHitRect = new Rect();
+ private Rect mTempRect = new Rect();
private boolean mIsEditingName = false;
private InputMethodManager mInputMethodManager;
@@ -118,8 +119,8 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
setAlwaysDrawnWithCacheEnabled(false);
mInflater = LayoutInflater.from(context);
mIconCache = ((LauncherApplication)context.getApplicationContext()).getIconCache();
- mMaxCountX = LauncherModel.getCellCountX() - 1;
- mMaxCountY = LauncherModel.getCellCountY() - 1;
+ mMaxCountX = LauncherModel.getCellCountX();
+ mMaxCountY = LauncherModel.getCellCountY();
mInputMethodManager = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -319,9 +320,8 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
}
void onClose() {
- CellLayoutChildren clc = (CellLayoutChildren) getParent();
- final CellLayout cellLayout = (CellLayout) clc.getParent();
- cellLayout.removeViewWithoutMarkingCells(Folder.this);
+ DragLayer parent = (DragLayer) getParent();
+ parent.removeView(Folder.this);
clearFocus();
}
@@ -373,8 +373,8 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
private void positionAndSizeAsIcon() {
if (!(getParent() instanceof CellLayoutChildren)) return;
- CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
+ DragLayer.LayoutParams iconLp = (DragLayer.LayoutParams) mFolderIcon.getLayoutParams();
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
if (mMode == PARTIAL_GROW) {
setScaleX(0.8f);
@@ -394,10 +394,10 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
if (mState != STATE_SMALL) {
positionAndSizeAsIcon();
}
- if (!(getParent() instanceof CellLayoutChildren)) return;
+ if (!(getParent() instanceof DragLayer)) return;
ObjectAnimator oa;
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
centerAboutIcon();
if (mMode == PARTIAL_GROW) {
@@ -439,7 +439,7 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
}
public void animateClosed() {
- if (!(getParent() instanceof CellLayoutChildren)) return;
+ if (!(getParent() instanceof DragLayer)) return;
ObjectAnimator oa;
if (mMode == PARTIAL_GROW) {
@@ -448,8 +448,8 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f);
oa = ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY);
} else {
- CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
+ DragLayer.LayoutParams iconLp = (DragLayer.LayoutParams) mFolderIcon.getLayoutParams();
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
PropertyValuesHolder width = PropertyValuesHolder.ofInt("width", iconLp.width);
PropertyValuesHolder height = PropertyValuesHolder.ofInt("height", iconLp.height);
@@ -720,25 +720,26 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
}
private void centerAboutIcon() {
- CellLayout.LayoutParams iconLp = (CellLayout.LayoutParams) mFolderIcon.getLayoutParams();
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth();
// Technically there is no padding at the bottom, but we add space equal to the padding
// and have to account for that here.
int height = getPaddingTop() + mContent.getDesiredHeight() + mFolderNameHeight;
+ DragLayer parent = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
+
+ parent.getDescendantRectRelativeToSelf(mFolderIcon, mTempRect);
- int centerX = iconLp.x + iconLp.width / 2;
- int centerY = iconLp.y + iconLp.height / 2;
+ int centerX = mTempRect.centerX();
+ int centerY = mTempRect.centerY();
int centeredLeft = centerX - width / 2;
int centeredTop = centerY - height / 2;
- CellLayoutChildren clc = (CellLayoutChildren) getParent();
int parentWidth = 0;
int parentHeight = 0;
- if (clc != null) {
- parentWidth = clc.getMeasuredWidth();
- parentHeight = clc.getMeasuredHeight();
+ if (parent != null) {
+ parentWidth = parent.getMeasuredWidth();
+ parentHeight = parent.getMeasuredHeight();
}
int left = Math.min(Math.max(0, centeredLeft), parentWidth - width);
@@ -768,10 +769,10 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL
private void setupContentForNumItems(int count) {
setupContentDimension(count);
- CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
+ DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
if (lp == null) {
- lp = new CellLayout.LayoutParams(0, 0, -1, -1);
- lp.isLockedToGrid = false;
+ lp = new DragLayer.LayoutParams(0, 0);
+ lp.customPosition = true;
setLayoutParams(lp);
}
centerAboutIcon();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 3f4a47c7a..b52a4f734 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1297,14 +1297,10 @@ public final class Launcher extends Activity
protected void onSaveInstanceState(Bundle outState) {
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getCurrentPage());
- final ArrayList<Folder> folders = mWorkspace.getOpenFolders();
- if (folders.size() > 0) {
- final int count = folders.size();
- long[] ids = new long[count];
- for (int i = 0; i < count; i++) {
- final FolderInfo info = folders.get(i).getInfo();
- ids[i] = info.id;
- }
+ final Folder folder = mWorkspace.getOpenFolder();
+ if (folder != null) {
+ long[] ids = new long[1];
+ ids[0] = folder.getInfo().id;
outState.putLongArray(RUNTIME_STATE_FOLDERS, ids);
} else {
super.onSaveInstanceState(outState);
@@ -1712,7 +1708,7 @@ public final class Launcher extends Activity
ViewGroup parent = (ViewGroup) folder.getParent().getParent();
if (parent != null) {
- CellLayout cl = (CellLayout) parent;
+ CellLayout cl = (CellLayout) mWorkspace.getChildAt(folder.mInfo.screen);
FolderIcon fi = (FolderIcon) cl.getChildAt(folder.mInfo.cellX, folder.mInfo.cellY);
shrinkAndFadeInFolderIcon(fi);
mDragController.removeDropTarget((DropTarget)folder);
@@ -1945,7 +1941,9 @@ public final class Launcher extends Activity
growAndFadeOutFolderIcon(folderIcon);
info.opened = true;
- mWorkspace.addInFullScreen(folder, info.screen);
+ mDragLayer.addView(folder);
+ mDragController.addDropTarget((DropTarget) folder);
+
folder.animateOpen();
folder.onOpen();
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index a4e162fe2..4eea5c3a8 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -415,10 +415,10 @@ public class Workspace extends SmoothPagedView
* @return The open folder on the current screen, or null if there is none
*/
Folder getOpenFolder() {
- ViewGroup currentPage = ((CellLayout) getChildAt(mCurrentPage)).getChildrenLayout();
- int count = currentPage.getChildCount();
+ DragLayer dragLayer = (DragLayer) mLauncher.findViewById(R.id.drag_layer);
+ int count = dragLayer.getChildCount();
for (int i = 0; i < count; i++) {
- View child = currentPage.getChildAt(i);
+ View child = dragLayer.getChildAt(i);
if (child instanceof Folder) {
Folder folder = (Folder) child;
if (folder.getInfo().opened)
@@ -428,26 +428,6 @@ public class Workspace extends SmoothPagedView
return null;
}
- ArrayList<Folder> getOpenFolders() {
- final int screenCount = getChildCount();
- ArrayList<Folder> folders = new ArrayList<Folder>(screenCount);
-
- for (int screen = 0; screen < screenCount; screen++) {
- ViewGroup currentPage = ((CellLayout) getChildAt(screen)).getChildrenLayout();
- int count = currentPage.getChildCount();
- for (int i = 0; i < count; i++) {
- View child = currentPage.getChildAt(i);
- if (child instanceof Folder) {
- Folder folder = (Folder) child;
- if (folder.getInfo().opened)
- folders.add(folder);
- break;
- }
- }
- }
- return folders;
- }
-
boolean isTouchActive() {
return mTouchState != TOUCH_STATE_REST;
}