summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java4
-rw-r--r--src/com/android/launcher3/Hotseat.java10
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java12
-rw-r--r--src/com/android/launcher3/Workspace.java4
5 files changed, 19 insertions, 13 deletions
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 3fcc2b904..d51ae46e8 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -115,6 +115,10 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) {
super.getHitRect(outRect);
outRect.bottom += mBottomDragPadding;
+
+ int[] coords = new int[2];
+ mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, coords);
+ outRect.offsetTo(coords[0], coords[1]);
}
private boolean isRtl() {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 054ef2fc1..7b96d6514 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -114,8 +114,9 @@ public class Hotseat extends FrameLayout {
mContent.removeAllViewsInLayout();
}
- void addAllAppsFolder(IconCache iconCache, ArrayList<ApplicationInfo> allApps,
- ArrayList<ComponentName> onWorkspace, Launcher launcher) {
+ void addAllAppsFolder(IconCache iconCache,
+ ArrayList<ApplicationInfo> allApps, ArrayList<ComponentName> onWorkspace,
+ Launcher launcher, Workspace workspace) {
FolderInfo fi = new FolderInfo();
fi.cellX = getCellXFromOrder(mAllAppsButtonRank);
@@ -130,9 +131,8 @@ public class Hotseat extends FrameLayout {
fi.cellY, false);
FolderIcon folder = FolderIcon.fromXml(R.layout.folder_icon, launcher,
getLayout(), fi, iconCache);
-
- CellLayout.LayoutParams lp = new CellLayout.LayoutParams(fi.cellX,fi.cellY,1,1);
- mContent.addViewToCellLayout(folder, -1, 0, lp, true);
+ workspace.addInScreen(folder, fi.container, fi.screenId, fi.cellX, fi.cellY,
+ fi.spanX, fi.spanY);
for (ApplicationInfo info: allApps) {
ComponentName cn = info.intent.getComponent();
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d1959dfec..d1284d85b 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3779,7 +3779,7 @@ public class Launcher extends Activity
public void bindAllApplications(final ArrayList<ApplicationInfo> apps) {
if (mIntentsOnWorkspaceFromUpgradePath != null) {
getHotseat().addAllAppsFolder(mIconCache, apps,
- mIntentsOnWorkspaceFromUpgradePath, Launcher.this);
+ mIntentsOnWorkspaceFromUpgradePath, Launcher.this, mWorkspace);
mIntentsOnWorkspaceFromUpgradePath = null;
}
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0b69a09c9..07787cc7d 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -237,7 +237,8 @@ public class LauncherModel extends BroadcastReceiver {
return CellLayout.findVacantCell(xy, 1, 1, xCount, yCount, occupied);
}
static Pair<Long, int[]> findNextAvailableIconSpace(Context context, String name,
- Intent launchIntent) {
+ Intent launchIntent,
+ int firstScreenIndex) {
// Lock on the app so that we don't try and get the items while apps are being added
LauncherAppState app = LauncherAppState.getInstance();
LauncherModel model = app.getModel();
@@ -253,7 +254,9 @@ public class LauncherModel extends BroadcastReceiver {
// Try adding to the workspace screens incrementally, starting at the default or center
// screen and alternating between +1, -1, +2, -2, etc. (using ~ ceil(i/2f)*(-1)^(i-1))
- for (int screen = 0; screen < sBgWorkspaceScreens.size() && !found; screen++) {
+ firstScreenIndex = Math.min(firstScreenIndex, sBgWorkspaceScreens.size());
+ int count = sBgWorkspaceScreens.size();
+ for (int screen = firstScreenIndex; screen < count && !found; screen++) {
int[] tmpCoordinates = new int[2];
if (findNextAvailableIconSpaceInScreen(items, tmpCoordinates,
sBgWorkspaceScreens.get(screen))) {
@@ -287,8 +290,9 @@ public class LauncherModel extends BroadcastReceiver {
}
// Add this icon to the db, creating a new page if necessary
+ int startSearchPageIndex = 1;
Pair<Long, int[]> coords = LauncherModel.findNextAvailableIconSpace(context,
- name, launchIntent);
+ name, launchIntent, startSearchPageIndex);
if (coords == null) {
// If we can't find a valid position, then just add a new screen.
// This takes time so we need to re-queue the add until the new
@@ -303,7 +307,7 @@ public class LauncherModel extends BroadcastReceiver {
addedWorkspaceScreensFinal.add(screenId);
// Find the coordinate again
coords = LauncherModel.findNextAvailableIconSpace(context,
- a.title.toString(), a.intent);
+ a.title.toString(), a.intent, startSearchPageIndex);
}
if (coords == null) {
throw new RuntimeException("Coordinates should not be null");
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 2ab4bbd93..d9582adfb 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2725,9 +2725,7 @@ public class Workspace extends SmoothPagedView
mTempPt[0] = (int) xy[0];
mTempPt[1] = (int) xy[1];
mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true);
-
- mTempPt[0] -= hotseat.getLeft();
- mTempPt[1] -= hotseat.getTop();
+ mLauncher.getDragLayer().mapCoordInSelfToDescendent(hotseat.getLayout(), mTempPt);
xy[0] = mTempPt[0];
xy[1] = mTempPt[1];