From 893615f241a036b3a6097521585262e4fe8f5cc5 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 8 Nov 2022 10:40:59 -0800 Subject: [PATCH 1/6] Reorder widgets no longer overlaps when no space is available In the previous refactor I got confused between findNearestVacantArea and findNearestArea thinking the later did the former. So it ignored the occupied spaces and treat it as a solution. Changed the names to prevent further confusion. Fix: 258023561 Test: manual, need to add this case to ReorderWidgets Change-Id: I04b262ecce168d5c93a9d66ef62d5b0e148e38b6 --- src/com/android/launcher3/CellLayout.java | 51 ++++++++++++------- src/com/android/launcher3/Workspace.java | 3 +- .../launcher3/folder/FolderPagedView.java | 2 +- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index de2a1f91ed..e500e59369 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1651,8 +1651,19 @@ public class CellLayout extends ViewGroup { } } - private ItemConfiguration findConfigurationNoShuffle(int pixelX, int pixelY, int minSpanX, int minSpanY, - int spanX, int spanY, View dragView, ItemConfiguration solution) { + /** + * Returns a "reorder" where we simply drop the item in the closest empty space, without moving + * any other item in the way. + * + * @param pixelX X coordinate in pixels in the screen + * @param pixelY Y coordinate in pixels in the screen + * @param spanX horizontal cell span + * @param spanY vertical cell span + * @return the configuration that represents the found reorder + */ + private ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX, + int minSpanY, int spanX, int spanY) { + ItemConfiguration solution = new ItemConfiguration(); int[] result = new int[2]; int[] resultSpan = new int[2]; findNearestVacantArea(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY, result, @@ -1697,7 +1708,7 @@ public class CellLayout extends ViewGroup { boolean isNearestDropLocationOccupied(int pixelX, int pixelY, int spanX, int spanY, View dragView, int[] result) { - result = findNearestArea(pixelX, pixelY, spanX, spanY, result); + result = findNearestAreaIgnoreOccupied(pixelX, pixelY, spanX, spanY, result); getViewsIntersectingRegion(result[0], result[1], spanX, spanY, dragView, null, mIntersectingViews); return !mIntersectingViews.isEmpty(); @@ -2247,7 +2258,8 @@ public class CellLayout extends ViewGroup { //TODO(adamcohen) b/151776141 use the items visual center for the direction vector int[] targetDestination = new int[2]; - findNearestArea(dragViewCenterX, dragViewCenterY, spanX, spanY, targetDestination); + findNearestAreaIgnoreOccupied(dragViewCenterX, dragViewCenterY, spanX, spanY, + targetDestination); Rect dragRect = new Rect(); cellToRect(targetDestination[0], targetDestination[1], spanX, spanY, dragRect); dragRect.offset(dragViewCenterX - dragRect.centerX(), dragViewCenterY - dragRect.centerY()); @@ -2400,7 +2412,7 @@ public class CellLayout extends ViewGroup { // We find the nearest cell into which we would place the dragged item, assuming there's // nothing in its way. int result[] = new int[2]; - result = findNearestArea(pixelX, pixelY, spanX, spanY, result); + result = findNearestAreaIgnoreOccupied(pixelX, pixelY, spanX, spanY, result); boolean success; // First we try the exact nearest position of the item being dragged, @@ -2445,19 +2457,21 @@ public class CellLayout extends ViewGroup { } /** - * Returns a "reorder" where we simply drop the item in the closest empty space, without moving - * any other item in the way. + * Returns a "reorder" if there is empty space without rearranging anything. * * @param pixelX X coordinate in pixels in the screen * @param pixelY Y coordinate in pixels in the screen * @param spanX horizontal cell span * @param spanY vertical cell span + * @param dragView view being dragged in reorder * @return the configuration that represents the found reorder */ - public ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int spanX, - int spanY) { + public ItemConfiguration dropInPlaceSolution(int pixelX, int pixelY, int spanX, + int spanY, View dragView) { int[] result = new int[2]; - result = findNearestArea(pixelX, pixelY, spanX, spanY, result); + if (isNearestDropLocationOccupied(pixelX, pixelY, spanX, spanY, dragView, result)) { + result[0] = result[1] = -1; + } ItemConfiguration solution = new ItemConfiguration(); copyCurrentStateToSolution(solution, false); solution.isSolution = result[0] != -1; @@ -2490,25 +2504,25 @@ public class CellLayout extends ViewGroup { int spanX, int spanY, View dragView) { getDirectionVectorForDrop(pixelX, pixelY, spanX, spanY, dragView, mDirectionVector); - ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(pixelX, pixelY, spanX, - spanY); + ItemConfiguration dropInPlaceSolution = dropInPlaceSolution(pixelX, pixelY, spanX, spanY, + dragView); // Find a solution involving pushing / displacing any items in the way ItemConfiguration swapSolution = findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY, mDirectionVector, dragView, true, new ItemConfiguration()); // We attempt the approach which doesn't shuffle views at all - ItemConfiguration noShuffleSolution = findConfigurationNoShuffle(pixelX, pixelY, minSpanX, - minSpanY, spanX, spanY, dragView, new ItemConfiguration()); + ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(pixelX, pixelY, minSpanX, + minSpanY, spanX, spanY); // If the reorder solution requires resizing (shrinking) the item being dropped, we instead // favor a solution in which the item is not resized, but - if (swapSolution.isSolution && swapSolution.area() >= noShuffleSolution.area()) { + if (swapSolution.isSolution && swapSolution.area() >= closestSpaceSolution.area()) { return swapSolution; - } else if (noShuffleSolution.isSolution) { - return noShuffleSolution; } else if (closestSpaceSolution.isSolution) { return closestSpaceSolution; + } else if (dropInPlaceSolution.isSolution) { + return dropInPlaceSolution; } return null; } @@ -2665,7 +2679,8 @@ public class CellLayout extends ViewGroup { * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ - public int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, int[] result) { + public int[] findNearestAreaIgnoreOccupied(int pixelX, int pixelY, int spanX, int spanY, + int[] result) { return findNearestArea(pixelX, pixelY, spanX, spanY, spanX, spanY, true, result, null); } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 27e1ba143b..b31db82ab3 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2615,7 +2615,6 @@ public class Workspace extends PagedView setDragMode(DRAG_MODE_REORDER); } - boolean resize = resultSpan[0] != spanX || resultSpan[1] != spanY; mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], resultSpan[0], resultSpan[1], dragObject); } @@ -2972,7 +2971,7 @@ public class Workspace extends PagedView */ @Thunk int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, CellLayout layout, int[] recycle) { - return layout.findNearestArea( + return layout.findNearestAreaIgnoreOccupied( pixelX, pixelY, spanX, spanY, recycle); } diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index efd511de37..b87ab17cb3 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -365,7 +365,7 @@ public class FolderPagedView extends PagedView implements Cli public int findNearestArea(int pixelX, int pixelY) { int pageIndex = getNextPage(); CellLayout page = getPageAt(pageIndex); - page.findNearestArea(pixelX, pixelY, 1, 1, sTmpArray); + page.findNearestAreaIgnoreOccupied(pixelX, pixelY, 1, 1, sTmpArray); if (mFolder.isLayoutRtl()) { sTmpArray[0] = page.getCountX() - sTmpArray[0] - 1; } From 431f05b3a0cf42cfb5dcb188abafc8d9df69ca90 Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Wed, 21 Sep 2022 14:10:28 +0000 Subject: [PATCH 2/6] [Toast] Update A-Z <-> Toast transition for drawable backgrounds. This and the other change in the topic are protected by a new feature flag (included here). Bug: 229297414 Bug: 248006105 Test: manual (see screenshots and recordings in the second bug) Change-Id: I3478d7e194ee5d3bc4f8affdadbec969c033d084 --- .../allapps/SearchTransitionController.java | 44 +++++++++++++++---- .../launcher3/config/FeatureFlags.java | 4 ++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/com/android/launcher3/allapps/SearchTransitionController.java b/src/com/android/launcher3/allapps/SearchTransitionController.java index 9c3dab4ec3..495f5c3eff 100644 --- a/src/com/android/launcher3/allapps/SearchTransitionController.java +++ b/src/com/android/launcher3/allapps/SearchTransitionController.java @@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable; import android.util.FloatProperty; import android.util.Log; import android.view.View; +import android.view.ViewGroup; import android.view.animation.Interpolator; import com.android.launcher3.BubbleTextView; @@ -39,6 +40,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.model.data.ItemInfo; /** Coordinates the transition between Search and A-Z in All Apps. */ @@ -225,16 +227,35 @@ public class SearchTransitionController { numSearchResultsAnimated++; } - searchResultView.setAlpha(contentAlpha); - // Apply background alpha to decorator if possible. - if (adapterPosition != NO_POSITION) { - searchRecyclerView.getApps().getAdapterItems() - .get(adapterPosition).setDecorationFillAlpha((int) (255 * backgroundAlpha)); - } - // Apply background alpha to view's background (e.g. for Search Edu card). + Drawable background = searchResultView.getBackground(); - if (background != null) { + if (background != null + && searchResultView instanceof ViewGroup + && FeatureFlags.ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES.get()) { + searchResultView.setAlpha(1f); + + // Apply content alpha to each child, since the view needs to be fully opaque for + // the background to show properly. + ViewGroup searchResultViewGroup = (ViewGroup) searchResultView; + for (int j = 0; j < searchResultViewGroup.getChildCount(); j++) { + searchResultViewGroup.getChildAt(j).setAlpha(contentAlpha); + } + + // Apply background alpha to the background drawable directly. background.setAlpha((int) (255 * backgroundAlpha)); + } else { + searchResultView.setAlpha(contentAlpha); + + // Apply background alpha to decorator if possible. + if (adapterPosition != NO_POSITION) { + searchRecyclerView.getApps().getAdapterItems().get(adapterPosition) + .setDecorationFillAlpha((int) (255 * backgroundAlpha)); + } + + // Apply background alpha to view's background (e.g. for Search Edu card). + if (background != null) { + background.setAlpha((int) (255 * backgroundAlpha)); + } } float scaleY = 1; @@ -304,6 +325,13 @@ public class SearchTransitionController { getSearchRecyclerView().getApps().getAdapterItems().get(adapterPosition) .setDecorationFillAlpha(255); } + if (child instanceof ViewGroup + && FeatureFlags.ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES.get()) { + ViewGroup childGroup = (ViewGroup) child; + for (int i = 0; i < childGroup.getChildCount(); i++) { + childGroup.getChildAt(i).setAlpha(1f); + } + } if (child.getBackground() != null) { child.getBackground().setAlpha(255); } diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 4287779c31..7b221dcc8a 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -264,6 +264,10 @@ public final class FeatureFlags { public static final BooleanFlag ENABLE_ONE_SEARCH_MOTION = new DeviceFlag( "ENABLE_ONE_SEARCH_MOTION", true, "Enables animations in OneSearch."); + public static final BooleanFlag ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES = new DeviceFlag( + "ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES", false, + "Enable option to replace decorator-based search result backgrounds with drawables"); + public static final BooleanFlag ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS = new DeviceFlag( "ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS", true, "Enable option to show keyboard when going to all-apps"); From 2a8ed8a3e88078e7428b949e418731aba8d9ea4a Mon Sep 17 00:00:00 2001 From: Federico Baron Date: Mon, 14 Nov 2022 10:13:28 -0800 Subject: [PATCH 3/6] Make settings button touch target size larger The touch target of this item was 32dp, now we change it to 48dp to make it easier to interact with the button Fix: 179116216 Test: enable talkback, then go to home settings -> suggestions -> suggestions on home screen. Turn on suggestions on home screen. Notice touch target size is small in settings button of toast. Change-Id: I5b8b2ac99f3843cf6fe838cf572565a334e23b2a --- res/values/dimens.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 0a28b6c62f..5e7ac20474 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -333,7 +333,7 @@ 48dp - 32dp + 48dp 8dp 6dp 72dp From 7eac37254b13b39d4729ab026bdbd9d5261f3fe8 Mon Sep 17 00:00:00 2001 From: Saumya Prakash Date: Mon, 14 Nov 2022 22:38:21 +0000 Subject: [PATCH 4/6] Add a flag for the redesigned Gesture Nav Tutorial We plan to improve the gesture navigation education tutorial as discussed and shown in go/gesture-nav-education. Test: N/A Bug: 241813570 Change-Id: I2ad8d12cf14c1b3f0eec3208ad12a24ac54b9dbc --- src/com/android/launcher3/config/FeatureFlags.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index d98a7f378a..9466576af1 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -327,6 +327,10 @@ public final class FeatureFlags { "LARGE_SCREEN_WIDGET_PICKER", false, "Enable new widget picker that takes " + "advantage of large screen format"); + public static final BooleanFlag ENABLE_NEW_GESTURE_NAV_TUTORIAL = getDebugFlag( + "ENABLE_NEW_GESTURE_NAV_TUTORIAL", false, + "Enable the redesigned gesture navigation tutorial"); + public static final BooleanFlag ENABLE_TOAST_IMPRESSION_LOGGING = getDebugFlag( "ENABLE_TOAST_IMPRESSION_LOGGING", false, "Enable toast impression logging"); From 39a3ac6fe5b8e2003bc320925be8da4fecafa503 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Mon, 31 Oct 2022 15:27:41 +0000 Subject: [PATCH 5/6] Update string for "swipe to go home" when in button nav. Bug: 252938555 Test: manual Change-Id: Id52867ec6a9b82a44ab0a803a9824258d9ad4044 --- quickstep/res/values/strings.xml | 2 ++ .../quickstep/interaction/AllSetActivity.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index c0d52a42bd..8f6f60b0af 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -187,6 +187,8 @@ All set! Swipe up to go Home + + Tap the home button to go to your home screen You\u2019re ready to start using your phone diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java index 8986c054dd..897b55949c 100644 --- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java +++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java @@ -53,6 +53,7 @@ import android.widget.TextView; import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -120,10 +121,9 @@ public class AllSetActivity extends Activity { mContentView = findViewById(R.id.content_view); mSwipeUpShift = getResources().getDimension(R.dimen.allset_swipe_up_shift); - boolean isTablet = InvariantDeviceProfile.INSTANCE.get(getApplicationContext()) - .getDeviceProfile(this).isTablet; + DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(this).getDeviceProfile(this); TextView subtitle = findViewById(R.id.subtitle); - subtitle.setText(isTablet + subtitle.setText(dp.isTablet ? R.string.allset_description_tablet : R.string.allset_description); TextView tv = findViewById(R.id.navigation_settings); @@ -137,7 +137,11 @@ public class AllSetActivity extends Activity { } }); - findViewById(R.id.hint).setAccessibilityDelegate(new SkipButtonAccessibilityDelegate()); + TextView hintTextView = findViewById(R.id.hint); + if (!dp.isGestureMode) { + hintTextView.setText(R.string.allset_button_hint); + } + hintTextView.setAccessibilityDelegate(new SkipButtonAccessibilityDelegate()); mTISBindHelper = new TISBindHelper(this, this::onTISConnected); mVibrator = getSystemService(Vibrator.class); From 3dad4fec9f82b8c8553ad8b7ded8baddb1f0392c Mon Sep 17 00:00:00 2001 From: Sam Dubey Date: Tue, 15 Nov 2022 13:22:08 +0000 Subject: [PATCH 6/6] Revert "Reorder widgets no longer overlaps when no space is avai..." Revert "Reorder widgets no longer overlaps when no space is avai..." Revert submission 20427045-258023561 Reason for revert: Likely causing NPE while running launcher shortcut tests (Part of DM+Platinum monitor rotation. The revert won't be submitted if proven otherwise) Bug: 259234533 Reverted Changes: Ie599f7cb7:Reorder widgets no longer overlaps when no space i... I04b262ecc:Reorder widgets no longer overlaps when no space i... Change-Id: I4cc552588c8099356bc3f05c4c63d17a524f2a24 --- src/com/android/launcher3/CellLayout.java | 51 +++++++------------ src/com/android/launcher3/Workspace.java | 3 +- .../launcher3/folder/FolderPagedView.java | 2 +- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index e500e59369..de2a1f91ed 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1651,19 +1651,8 @@ public class CellLayout extends ViewGroup { } } - /** - * Returns a "reorder" where we simply drop the item in the closest empty space, without moving - * any other item in the way. - * - * @param pixelX X coordinate in pixels in the screen - * @param pixelY Y coordinate in pixels in the screen - * @param spanX horizontal cell span - * @param spanY vertical cell span - * @return the configuration that represents the found reorder - */ - private ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX, - int minSpanY, int spanX, int spanY) { - ItemConfiguration solution = new ItemConfiguration(); + private ItemConfiguration findConfigurationNoShuffle(int pixelX, int pixelY, int minSpanX, int minSpanY, + int spanX, int spanY, View dragView, ItemConfiguration solution) { int[] result = new int[2]; int[] resultSpan = new int[2]; findNearestVacantArea(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY, result, @@ -1708,7 +1697,7 @@ public class CellLayout extends ViewGroup { boolean isNearestDropLocationOccupied(int pixelX, int pixelY, int spanX, int spanY, View dragView, int[] result) { - result = findNearestAreaIgnoreOccupied(pixelX, pixelY, spanX, spanY, result); + result = findNearestArea(pixelX, pixelY, spanX, spanY, result); getViewsIntersectingRegion(result[0], result[1], spanX, spanY, dragView, null, mIntersectingViews); return !mIntersectingViews.isEmpty(); @@ -2258,8 +2247,7 @@ public class CellLayout extends ViewGroup { //TODO(adamcohen) b/151776141 use the items visual center for the direction vector int[] targetDestination = new int[2]; - findNearestAreaIgnoreOccupied(dragViewCenterX, dragViewCenterY, spanX, spanY, - targetDestination); + findNearestArea(dragViewCenterX, dragViewCenterY, spanX, spanY, targetDestination); Rect dragRect = new Rect(); cellToRect(targetDestination[0], targetDestination[1], spanX, spanY, dragRect); dragRect.offset(dragViewCenterX - dragRect.centerX(), dragViewCenterY - dragRect.centerY()); @@ -2412,7 +2400,7 @@ public class CellLayout extends ViewGroup { // We find the nearest cell into which we would place the dragged item, assuming there's // nothing in its way. int result[] = new int[2]; - result = findNearestAreaIgnoreOccupied(pixelX, pixelY, spanX, spanY, result); + result = findNearestArea(pixelX, pixelY, spanX, spanY, result); boolean success; // First we try the exact nearest position of the item being dragged, @@ -2457,21 +2445,19 @@ public class CellLayout extends ViewGroup { } /** - * Returns a "reorder" if there is empty space without rearranging anything. + * Returns a "reorder" where we simply drop the item in the closest empty space, without moving + * any other item in the way. * * @param pixelX X coordinate in pixels in the screen * @param pixelY Y coordinate in pixels in the screen * @param spanX horizontal cell span * @param spanY vertical cell span - * @param dragView view being dragged in reorder * @return the configuration that represents the found reorder */ - public ItemConfiguration dropInPlaceSolution(int pixelX, int pixelY, int spanX, - int spanY, View dragView) { + public ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int spanX, + int spanY) { int[] result = new int[2]; - if (isNearestDropLocationOccupied(pixelX, pixelY, spanX, spanY, dragView, result)) { - result[0] = result[1] = -1; - } + result = findNearestArea(pixelX, pixelY, spanX, spanY, result); ItemConfiguration solution = new ItemConfiguration(); copyCurrentStateToSolution(solution, false); solution.isSolution = result[0] != -1; @@ -2504,25 +2490,25 @@ public class CellLayout extends ViewGroup { int spanX, int spanY, View dragView) { getDirectionVectorForDrop(pixelX, pixelY, spanX, spanY, dragView, mDirectionVector); - ItemConfiguration dropInPlaceSolution = dropInPlaceSolution(pixelX, pixelY, spanX, spanY, - dragView); + ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(pixelX, pixelY, spanX, + spanY); // Find a solution involving pushing / displacing any items in the way ItemConfiguration swapSolution = findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY, mDirectionVector, dragView, true, new ItemConfiguration()); // We attempt the approach which doesn't shuffle views at all - ItemConfiguration closestSpaceSolution = closestEmptySpaceReorder(pixelX, pixelY, minSpanX, - minSpanY, spanX, spanY); + ItemConfiguration noShuffleSolution = findConfigurationNoShuffle(pixelX, pixelY, minSpanX, + minSpanY, spanX, spanY, dragView, new ItemConfiguration()); // If the reorder solution requires resizing (shrinking) the item being dropped, we instead // favor a solution in which the item is not resized, but - if (swapSolution.isSolution && swapSolution.area() >= closestSpaceSolution.area()) { + if (swapSolution.isSolution && swapSolution.area() >= noShuffleSolution.area()) { return swapSolution; + } else if (noShuffleSolution.isSolution) { + return noShuffleSolution; } else if (closestSpaceSolution.isSolution) { return closestSpaceSolution; - } else if (dropInPlaceSolution.isSolution) { - return dropInPlaceSolution; } return null; } @@ -2679,8 +2665,7 @@ public class CellLayout extends ViewGroup { * @return The X, Y cell of a vacant area that can contain this object, * nearest the requested location. */ - public int[] findNearestAreaIgnoreOccupied(int pixelX, int pixelY, int spanX, int spanY, - int[] result) { + public int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, int[] result) { return findNearestArea(pixelX, pixelY, spanX, spanY, spanX, spanY, true, result, null); } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b31db82ab3..27e1ba143b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2615,6 +2615,7 @@ public class Workspace extends PagedView setDragMode(DRAG_MODE_REORDER); } + boolean resize = resultSpan[0] != spanX || resultSpan[1] != spanY; mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1], resultSpan[0], resultSpan[1], dragObject); } @@ -2971,7 +2972,7 @@ public class Workspace extends PagedView */ @Thunk int[] findNearestArea(int pixelX, int pixelY, int spanX, int spanY, CellLayout layout, int[] recycle) { - return layout.findNearestAreaIgnoreOccupied( + return layout.findNearestArea( pixelX, pixelY, spanX, spanY, recycle); } diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index b87ab17cb3..efd511de37 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -365,7 +365,7 @@ public class FolderPagedView extends PagedView implements Cli public int findNearestArea(int pixelX, int pixelY) { int pageIndex = getNextPage(); CellLayout page = getPageAt(pageIndex); - page.findNearestAreaIgnoreOccupied(pixelX, pixelY, 1, 1, sTmpArray); + page.findNearestArea(pixelX, pixelY, 1, 1, sTmpArray); if (mFolder.isLayoutRtl()) { sTmpArray[0] = page.getCountX() - sTmpArray[0] - 1; }