fix: Conflict incoming changes from 15-dev

This commit is contained in:
Pun Butrach committed 2026-01-10 20:49:12 +07:00
1 parent 14e352c827
commit 2e76c99dad
1726 files changed
+146970 -95027

No files matched your search

+58 -42
View File
@@ -20,8 +20,10 @@ package com.android.launcher3;
import static com.android.launcher3.AbstractFloatingView.TYPE_WIDGET_RESIZE_FRAME;
import static com.android.launcher3.BubbleTextView.DISPLAY_FOLDER;
import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle;
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.EDIT_MODE;
@@ -32,7 +34,6 @@ import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
@@ -66,6 +67,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.Toast;
@@ -354,10 +356,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mLauncher = Launcher.getLauncher(context);
mStateTransitionAnimation = new WorkspaceStateTransitionAnimation(mLauncher, this);
mWallpaperManager = WallpaperManager.getInstance(context);
mAllAppsIconSize = mLauncher.getDeviceProfile().allAppsIconSizePx;
mAllAppsIconSize = mLauncher.getDeviceProfile().getAllAppsProfile().getIconSizePx();
mPreferenceManager2 = PreferenceManager2.getInstance(context);
mPreferenceManger = PreferenceManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
setHapticFeedbackEnabled(false);
@@ -434,7 +435,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
View view = shortcutAndWidgetContainer.getChildAt(j);
if (view instanceof LauncherAppWidgetHostView
&& view.getTag() instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo launcherAppWidgetInfo = (LauncherAppWidgetInfo) view.getTag();
LauncherAppWidgetInfo launcherAppWidgetInfo =
(LauncherAppWidgetInfo) view.getTag();
WidgetSizes.updateWidgetSizeRanges((LauncherAppWidgetHostView) view,
mLauncher, launcherAppWidgetInfo.spanX, launcherAppWidgetInfo.spanY);
}
@@ -558,7 +560,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
}
private boolean isTwoPanelEnabled() {
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels;
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.getDeviceProperties().isTwoPanels();
}
public void deferRemoveExtraEmptyScreen() {
@@ -654,9 +656,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
* Initializes and binds the first page
*/
public void bindAndInitFirstWorkspaceScreen() {
if ((!FeatureFlags.QSB_ON_FIRST_SCREEN
|| !mLauncher.getIsFirstPagePinnedItemEnabled())
|| SHOULD_SHOW_FIRST_PAGE_WIDGET) {
if (!BuildConfigs.QSB_ON_FIRST_SCREEN) {
mFirstPagePinnedItem = null;
return;
}
@@ -704,9 +704,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mWorkspaceScreens.clear();
// Ensure that the first page is always present
if (!enableSmartspaceRemovalToggle()) {
bindAndInitFirstWorkspaceScreen();
}
bindAndInitFirstWorkspaceScreen();
// Re-enable the layout transitions
enableLayoutTransitions();
@@ -736,7 +734,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// created CellLayout.
DeviceProfile dp = mLauncher.getDeviceProfile();
CellLayout newScreen;
if (FOLDABLE_SINGLE_PAGE.get() && dp.isTwoPanels) {
if (FOLDABLE_SINGLE_PAGE.get() && dp.getDeviceProperties().isTwoPanels()) {
newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen_foldable, this, false /* attachToRoot */);
} else {
@@ -869,12 +867,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
for (int i = 0; i < finalScreens.size(); i++) {
int screenId = finalScreens.keyAt(i);
// We don't want to remove the first screen even if it's empty because that's where
// first page pinned item would go if it gets turned back on.
if (enableSmartspaceRemovalToggle() && screenId == FIRST_SCREEN_ID) {
continue;
}
CellLayout screen = finalScreens.get(screenId);
mWorkspaceScreens.remove(screenId);
@@ -1102,9 +1094,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
int id = mWorkspaceScreens.keyAt(i);
CellLayout cl = mWorkspaceScreens.valueAt(i);
// FIRST_SCREEN_ID can never be removed.
if (((!FeatureFlags.QSB_ON_FIRST_SCREEN
|| SHOULD_SHOW_FIRST_PAGE_WIDGET)
|| id > FIRST_SCREEN_ID)
if ((!BuildConfigs.QSB_ON_FIRST_SCREEN || id > FIRST_SCREEN_ID)
&& cl.getShortcutsAndWidgets().getChildCount() == 0) {
removeScreens.add(id);
}
@@ -2173,9 +2163,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
// Move internally
boolean hasMovedLayouts = (getParentCellLayoutForView(cell) != dropTargetLayout);
boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout);
int container = hasMovedIntoHotseat ?
LauncherSettings.Favorites.CONTAINER_HOTSEAT :
LauncherSettings.Favorites.CONTAINER_DESKTOP;
int container = hasMovedIntoHotseat ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP;
int screenId = (mTargetCell[0] < 0) ?
mDragInfo.screenId : getCellLayoutId(dropTargetLayout);
int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
@@ -2278,8 +2266,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
lp.cellVSpan = item.spanY;
lp.isLockedToGrid = true;
if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
cell instanceof LauncherAppWidgetHostView) {
if (container != CONTAINER_HOTSEAT
&& cell instanceof LauncherAppWidgetHostView) {
// We post this call so that the widget has a chance to be placed
// in its final location
@@ -2935,11 +2923,15 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
* to add an item to one of the workspace screens.
*/
private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) {
final int container = mLauncher.isHotseatLayout(cellLayout)
? CONTAINER_HOTSEAT
: CONTAINER_DESKTOP;
if (d.dragInfo instanceof PendingAddShortcutInfo) {
WorkspaceItemInfo si = ((PendingAddShortcutInfo) d.dragInfo)
.getActivityInfo(mLauncher).createWorkspaceItemInfo();
if (si != null) {
d.dragInfo = si;
si.container = container;
}
}
@@ -2950,10 +2942,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
spanX = mDragInfo.spanX;
spanY = mDragInfo.spanY;
}
final int container = mLauncher.isHotseatLayout(cellLayout)
? LauncherSettings.Favorites.CONTAINER_HOTSEAT
: LauncherSettings.Favorites.CONTAINER_DESKTOP;
final int screenId = getCellLayoutId(cellLayout);
if (!mLauncher.isHotseatLayout(cellLayout)
&& screenId != getScreenIdForPageIndex(mCurrentPage)
@@ -3036,8 +3024,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
} else {
// This is for other drag/drop cases, like dragging from All Apps
mLauncher.getStateManager().goToState(NORMAL, SPRING_LOADED_EXIT_DELAY);
View view = mLauncher.getItemInflater()
.inflateItem(info, mLauncher.getModelWriter(), cellLayout);
// TODO(b/414409465) We could just create a new info making a copy with all the new
// needed values instead of choosing on each case what to modify.
View view = mLauncher.getItemInflater().inflateItem(info, cellLayout, container);
d.dragInfo = info = (ItemInfo) view.getTag();
// First we find the cell nearest to point at which the item is
@@ -3438,8 +3427,10 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
* Removes items that match the {@param matcher}. When applications are removed
* as a part of an update, this is called to ensure that other widgets and application
* shortcuts are not removed.
*
* @param persistChanges if true, any dependent changes will be persisted to the DB
*/
public void removeItemsByMatcher(final Predicate<ItemInfo> matcher) {
public void removeItemsByMatcher(final Predicate<ItemInfo> matcher, boolean persistChanges) {
for (CellLayout layout : getWorkspaceAndHotseatCellLayouts()) {
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
// Iterate in reverse order as we are removing items
@@ -3466,14 +3457,39 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
} else if (info instanceof AppPairInfo api) {
// If an app pair's member apps are being removed, delete the whole app pair.
if (api.anyMatch(matcher)) {
mLauncher.removeItem(child, info, true);
mLauncher.removeItem(child, info, persistChanges);
}
}
}
}
// Strip all the empty screens
stripEmptyScreens();
if (persistChanges) {
stripEmptyScreens();
}
}
@Nullable
@Override
public CellInfo getCellInfoForView(@NonNull View view) {
ViewParent parent = view.getParent();
if (parent != null
&& parent.getParent() instanceof CellLayout cl
&& view.getLayoutParams() instanceof CellLayoutLayoutParams lp) {
int container = mLauncher.isHotseatLayout(cl) ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP;
CellPos pos = getCellPosMapper().mapPresenterToModel(
lp.getCellX(), lp.getCellY(), getCellLayoutId(cl), container);
return new CellInfo(view,
pos.screenId, container, pos.cellX, pos.cellY, lp.cellHSpan, lp.cellVSpan);
}
return null;
}
@Override
public boolean isContainerSupported(int container) {
return container == CONTAINER_DESKTOP
|| container == CONTAINER_HOTSEAT
|| container == CONTAINER_ALL_APPS_PREDICTION
|| container == CONTAINER_HOTSEAT_PREDICTION;
}
@Override
@@ -3510,7 +3526,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
public void persistRemoveItemsByMatcher(Predicate<ItemInfo> matcher,
@Nullable final String reason) {
mLauncher.getModelWriter().deleteItemsFromDatabase(matcher, reason);
removeItemsByMatcher(matcher);
removeItemsByMatcher(matcher, true);
}
public boolean isOverlayShown() {
@@ -3546,13 +3562,13 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
public int getExpectedHeight() {
return getMeasuredHeight() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight();
? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : getMeasuredHeight();
}
@Override
public int getExpectedWidth() {
return getMeasuredWidth() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth();
? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() : getMeasuredWidth();
}
@Override
@@ -3618,12 +3634,12 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
protected boolean isSignificantMove(float absoluteDelta, int pageOrientedSize) {
DeviceProfile deviceProfile = mLauncher.getDeviceProfile();
if (!deviceProfile.isTablet) {
if (!deviceProfile.getDeviceProperties().isTablet()) {
return super.isSignificantMove(absoluteDelta, pageOrientedSize);
}
return absoluteDelta
> deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
> deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
}
@Override