diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 678cbcfbd7..c894ea4d9b 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1466,7 +1466,7 @@ public class Launcher extends Activity } if (!foundCellSpan) { - showOutOfSpaceMessage(isHotseatLayout(layout)); + mWorkspace.onNoCellFound(layout); return; } @@ -1612,11 +1612,6 @@ public class Launcher extends Activity } } - public void showOutOfSpaceMessage(boolean isHotseatLayout) { - int strId = (isHotseatLayout ? R.string.hotseat_out_of_space : R.string.out_of_space); - Toast.makeText(this, getString(strId), Toast.LENGTH_SHORT).show(); - } - public DragLayer getDragLayer() { return mDragLayer; } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 13998a81b7..f6f98d7881 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -52,6 +52,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; +import android.widget.Toast; import com.android.launcher3.Launcher.CustomContentCallbacks; import com.android.launcher3.Launcher.LauncherOverlay; @@ -2406,18 +2407,7 @@ public class Workspace extends PagedView // Don't accept the drop if there's no room for the item if (!foundCell) { - // Don't show the message if we are dropping on the AllApps button and the hotseat - // is full - boolean isHotseat = mLauncher.isHotseatLayout(dropTargetLayout); - if (mTargetCell != null && isHotseat && !FeatureFlags.NO_ALL_APPS_ICON) { - Hotseat hotseat = mLauncher.getHotseat(); - if (mLauncher.getDeviceProfile().inv.isAllAppsButtonRank( - hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1]))) { - return false; - } - } - - mLauncher.showOutOfSpaceMessage(isHotseat); + onNoCellFound(dropTargetLayout); return false; } } @@ -2703,6 +2693,8 @@ public class Workspace extends PagedView LauncherModel.modifyItemInDatabase(mLauncher, info, container, screenId, lp.cellX, lp.cellY, item.spanX, item.spanY); } else { + onNoCellFound(dropTargetLayout); + // If we can't find a drop location, we return the item to its original position CellLayout.LayoutParams lp = (CellLayout.LayoutParams) cell.getLayoutParams(); mTargetCell[0] = lp.cellX; @@ -2748,6 +2740,26 @@ public class Workspace extends PagedView } } + public void onNoCellFound(View dropTargetLayout) { + if (mLauncher.isHotseatLayout(dropTargetLayout)) { + Hotseat hotseat = mLauncher.getHotseat(); + boolean droppedOnAllAppsIcon = !FeatureFlags.NO_ALL_APPS_ICON + && mTargetCell != null && !mLauncher.getDeviceProfile().inv.isAllAppsButtonRank( + hotseat.getOrderInHotseat(mTargetCell[0], mTargetCell[1])); + if (!droppedOnAllAppsIcon) { + // Only show message when hotseat is full and drop target was not AllApps button + showOutOfSpaceMessage(true); + } + } else { + showOutOfSpaceMessage(false); + } + } + + private void showOutOfSpaceMessage(boolean isHotseatLayout) { + int strId = (isHotseatLayout ? R.string.hotseat_out_of_space : R.string.out_of_space); + Toast.makeText(mLauncher, mLauncher.getString(strId), Toast.LENGTH_SHORT).show(); + } + /** * Computes the area relative to dragLayer which is used to display a page. */ diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index 8ef9312fc8..768d17becf 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -32,7 +32,6 @@ import android.view.ViewGroup; import com.android.launcher3.AppInfo; import com.android.launcher3.BaseContainerView; -import com.android.launcher3.CellLayout; import com.android.launcher3.DeleteDropTarget; import com.android.launcher3.DeviceProfile; import com.android.launcher3.DragSource; @@ -44,7 +43,6 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherTransitionable; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.Workspace; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragOptions; @@ -419,24 +417,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc } mLauncher.unlockScreenOrientation(false); - // Display an error message if the drag failed due to there not being enough space on the - // target layout we were dropping on. if (!success) { - boolean showOutOfSpaceMessage = false; - if (target instanceof Workspace) { - int currentScreen = mLauncher.getCurrentWorkspaceScreen(); - Workspace workspace = (Workspace) target; - CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen); - ItemInfo itemInfo = d.dragInfo; - if (layout != null) { - showOutOfSpaceMessage = - !layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY); - } - } - if (showOutOfSpaceMessage) { - mLauncher.showOutOfSpaceMessage(false); - } - d.deferDragViewCleanupPostAnimation = false; } } diff --git a/src/com/android/launcher3/widget/WidgetsContainerView.java b/src/com/android/launcher3/widget/WidgetsContainerView.java index ecc853d905..56702cc253 100644 --- a/src/com/android/launcher3/widget/WidgetsContainerView.java +++ b/src/com/android/launcher3/widget/WidgetsContainerView.java @@ -28,7 +28,6 @@ import android.view.ViewGroup; import android.widget.Toast; import com.android.launcher3.BaseContainerView; -import com.android.launcher3.CellLayout; import com.android.launcher3.DeleteDropTarget; import com.android.launcher3.DragSource; import com.android.launcher3.DropTarget.DragObject; @@ -42,7 +41,6 @@ import com.android.launcher3.PendingAddItemInfo; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.WidgetPreviewLoader; -import com.android.launcher3.Workspace; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.model.WidgetsModel; @@ -291,23 +289,7 @@ public class WidgetsContainerView extends BaseContainerView } mLauncher.unlockScreenOrientation(false); - // Display an error message if the drag failed due to there not being enough space on the - // target layout we were dropping on. if (!success) { - boolean showOutOfSpaceMessage = false; - if (target instanceof Workspace) { - int currentScreen = mLauncher.getCurrentWorkspaceScreen(); - Workspace workspace = (Workspace) target; - CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen); - ItemInfo itemInfo = d.dragInfo; - if (layout != null) { - showOutOfSpaceMessage = - !layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY); - } - } - if (showOutOfSpaceMessage) { - mLauncher.showOutOfSpaceMessage(false); - } d.deferDragViewCleanupPostAnimation = false; } }