chore: Cleanup, and hidden feature logged

Signed-off-by: Pun Butrach <pun.butrach@gmail.com>
This commit is contained in:
Pun Butrach committed 2026-01-10 20:48:25 +07:00
1 parent 5180c3d4c4
commit 11f7abcb66
1818 files changed
+104945 -147848

No files matched your search

+46 -58
View File
@@ -20,10 +20,8 @@ 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;
@@ -34,6 +32,7 @@ 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;
@@ -67,7 +66,6 @@ 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;
@@ -356,9 +354,10 @@ 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().getAllAppsProfile().getIconSizePx();
mAllAppsIconSize = mLauncher.getDeviceProfile().allAppsIconSizePx;
mPreferenceManager2 = PreferenceManager2.getInstance(context);
mPreferenceManger = PreferenceManager.getInstance(context);
mWallpaperOffset = new WallpaperOffsetInterpolator(this);
setHapticFeedbackEnabled(false);
@@ -435,8 +434,7 @@ 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);
}
@@ -560,7 +558,11 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
}
private boolean isTwoPanelEnabled() {
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.getDeviceProperties().isTwoPanels();
// pE-TODO(t35AcakE): Foldable support, DC won't report to IDP that deviceType is TYPE_MULTI_DISPLAY
Log.d("LC-WorkspaceTwoPanel", "FOLDABLE_SINGLE_PAGE: " + FOLDABLE_SINGLE_PAGE.get() + ", isTwoPanels: " + mLauncher.mDeviceProfile.isTwoPanels);
Log.d("LC-Workspace", "isTablet: " + mLauncher.mDeviceProfile.isTablet + ", isMultiDisplay: " + mLauncher.mDeviceProfile.isMultiDisplay);
Log.d("LC-Workspace", "IDP is multidisplay?: " + (mLauncher.getDeviceProfile().inv.deviceType == mLauncher.getDeviceProfile().inv.TYPE_MULTI_DISPLAY));
return !FOLDABLE_SINGLE_PAGE.get() && mLauncher.mDeviceProfile.isTwoPanels;
}
public void deferRemoveExtraEmptyScreen() {
@@ -656,7 +658,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
* Initializes and binds the first page
*/
public void bindAndInitFirstWorkspaceScreen() {
if (!BuildConfigs.QSB_ON_FIRST_SCREEN) {
if ((!FeatureFlags.QSB_ON_FIRST_SCREEN
|| !mLauncher.getIsFirstPagePinnedItemEnabled())
|| SHOULD_SHOW_FIRST_PAGE_WIDGET) {
mFirstPagePinnedItem = null;
return;
}
@@ -704,7 +708,9 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
mWorkspaceScreens.clear();
// Ensure that the first page is always present
bindAndInitFirstWorkspaceScreen();
if (!enableSmartspaceRemovalToggle()) {
bindAndInitFirstWorkspaceScreen();
}
// Re-enable the layout transitions
enableLayoutTransitions();
@@ -734,7 +740,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.getDeviceProperties().isTwoPanels()) {
if (FOLDABLE_SINGLE_PAGE.get() && dp.isTwoPanels) {
newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen_foldable, this, false /* attachToRoot */);
} else {
@@ -867,6 +873,12 @@ 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);
@@ -1094,7 +1106,9 @@ 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 ((!BuildConfigs.QSB_ON_FIRST_SCREEN || id > FIRST_SCREEN_ID)
if (((!FeatureFlags.QSB_ON_FIRST_SCREEN
|| SHOULD_SHOW_FIRST_PAGE_WIDGET)
|| id > FIRST_SCREEN_ID)
&& cl.getShortcutsAndWidgets().getChildCount() == 0) {
removeScreens.add(id);
}
@@ -2163,7 +2177,9 @@ 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 ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP;
int container = hasMovedIntoHotseat ?
LauncherSettings.Favorites.CONTAINER_HOTSEAT :
LauncherSettings.Favorites.CONTAINER_DESKTOP;
int screenId = (mTargetCell[0] < 0) ?
mDragInfo.screenId : getCellLayoutId(dropTargetLayout);
int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
@@ -2266,8 +2282,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
lp.cellVSpan = item.spanY;
lp.isLockedToGrid = true;
if (container != CONTAINER_HOTSEAT
&& cell instanceof LauncherAppWidgetHostView) {
if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT &&
cell instanceof LauncherAppWidgetHostView) {
// We post this call so that the widget has a chance to be placed
// in its final location
@@ -2923,15 +2939,11 @@ 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;
}
}
@@ -2942,6 +2954,10 @@ 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)
@@ -3024,9 +3040,8 @@ 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);
// 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);
View view = mLauncher.getItemInflater()
.inflateItem(info, mLauncher.getModelWriter(), cellLayout);
d.dragInfo = info = (ItemInfo) view.getTag();
// First we find the cell nearest to point at which the item is
@@ -3427,10 +3442,8 @@ 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, boolean persistChanges) {
public void removeItemsByMatcher(final Predicate<ItemInfo> matcher) {
for (CellLayout layout : getWorkspaceAndHotseatCellLayouts()) {
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
// Iterate in reverse order as we are removing items
@@ -3457,39 +3470,14 @@ 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, persistChanges);
mLauncher.removeItem(child, info, true);
}
}
}
}
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;
// Strip all the empty screens
stripEmptyScreens();
}
@Override
@@ -3526,7 +3514,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, true);
removeItemsByMatcher(matcher);
}
public boolean isOverlayShown() {
@@ -3562,13 +3550,13 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
@Override
public int getExpectedHeight() {
return getMeasuredHeight() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().getDeviceProperties().getHeightPx() : getMeasuredHeight();
? mLauncher.getDeviceProfile().heightPx : getMeasuredHeight();
}
@Override
public int getExpectedWidth() {
return getMeasuredWidth() <= 0 || !mIsLayoutValid
? mLauncher.getDeviceProfile().getDeviceProperties().getWidthPx() : getMeasuredWidth();
? mLauncher.getDeviceProfile().widthPx : getMeasuredWidth();
}
@Override
@@ -3634,12 +3622,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.getDeviceProperties().isTablet()) {
if (!deviceProfile.isTablet) {
return super.isSignificantMove(absoluteDelta, pageOrientedSize);
}
return absoluteDelta
> deviceProfile.getDeviceProperties().getAvailableWidthPx() * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
> deviceProfile.availableWidthPx * SIGNIFICANT_MOVE_SCREEN_WIDTH_PERCENTAGE;
}
@Override