diff options
Diffstat (limited to 'src')
22 files changed, 203 insertions, 29 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 5dfb10feec..e17f5b26c5 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -1950,13 +1950,18 @@ public class DeviceProfile { int remainingSpaceOnSide = (availableWidthPxForHotseat - hotseatPlusQSBWidth) / 2; hotseatBarPadding.set( - (remainingSpaceOnSide + qsbWidth) + mInsets.left + workspacePadding.left + remainingSpaceOnSide + mInsets.left + workspacePadding.left + cellLayoutPaddingPx.left, hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx, remainingSpaceOnSide + mInsets.right + workspacePadding.right + cellLayoutPaddingPx.right, hotseatBarBottomPadding ); + if (Utilities.isRtl(context.getResources())) { + hotseatBarPadding.right += qsbWidth; + } else { + hotseatBarPadding.left += qsbWidth; + } } else if (isTaskbarPresent) { // Center the QSB vertically with hotseat int hotseatBarBottomPadding = getHotseatBarBottomPadding(); diff --git a/src/com/android/launcher3/GridType.kt b/src/com/android/launcher3/GridType.kt new file mode 100644 index 0000000000..d006b8f35f --- /dev/null +++ b/src/com/android/launcher3/GridType.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3 + +import androidx.annotation.IntDef + +/** The type of grid. */ +@IntDef(GridType.GRID_TYPE_ONE_GRID, GridType.GRID_TYPE_NON_ONE_GRID, GridType.GRID_TYPE_ANY) +@Retention(AnnotationRetention.SOURCE) +annotation class GridType { + companion object { + /** These are grids that use one grid spec. */ + const val GRID_TYPE_ONE_GRID = 1 + /** These are grids that don't use one grid spec. */ + const val GRID_TYPE_NON_ONE_GRID = 2 + /** Any grid type. */ + const val GRID_TYPE_ANY = GRID_TYPE_NON_ONE_GRID or GRID_TYPE_ONE_GRID + } +} diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index f189549463..15a4fc4072 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -16,6 +16,9 @@ package com.android.launcher3; +import static com.android.launcher3.GridType.GRID_TYPE_ANY; +import static com.android.launcher3.GridType.GRID_TYPE_NON_ONE_GRID; +import static com.android.launcher3.GridType.GRID_TYPE_ONE_GRID; import static com.android.launcher3.LauncherPrefs.DB_FILE; import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE; import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE; @@ -241,6 +244,8 @@ public class InvariantDeviceProfile { */ public boolean isFixedLandscape = false; + @GridType + public int gridType; public String dbFile; public int defaultLayoutId; public int demoModeLayoutId; @@ -369,6 +374,7 @@ public class InvariantDeviceProfile { numColumns = closestProfile.numColumns; numSearchContainerColumns = closestProfile.numSearchContainerColumns; dbFile = closestProfile.dbFile; + gridType = closestProfile.gridType; defaultLayoutId = closestProfile.defaultLayoutId; demoModeLayoutId = closestProfile.demoModeLayoutId; @@ -936,10 +942,7 @@ public class InvariantDeviceProfile { private static final int DEVICE_CATEGORY_PHONE = 1 << 0; private static final int DEVICE_CATEGORY_TABLET = 1 << 1; private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2; - private static final int GRID_TYPE_ONE_GRID = 1 << 0; - private static final int GRID_TYPE_NON_ONE_GRID = 1 << 1; - private static final int GRID_TYPE_ALL = 1 << 2; - private static final int DEVICE_CATEGORY_ALL = + private static final int DEVICE_CATEGORY_ANY = DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY; private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0; @@ -955,6 +958,7 @@ public class InvariantDeviceProfile { public final int numColumns; public final int numSearchContainerColumns; public final int deviceCategory; + @GridType public final int gridType; private final int[] numFolderRows = new int[COUNT_SIZES]; @@ -1003,7 +1007,7 @@ public class InvariantDeviceProfile { gridIconId = a.getResourceId( R.styleable.GridDisplayOption_gridIconId, INVALID_RESOURCE_HANDLE); deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory, - DEVICE_CATEGORY_ALL); + DEVICE_CATEGORY_ANY); mGridSizeSpecsId = a.getResourceId( R.styleable.GridDisplayOption_gridSizeSpecsId, INVALID_RESOURCE_HANDLE); mIsDualGrid = a.getBoolean(R.styleable.GridDisplayOption_isDualGrid, false); @@ -1141,7 +1145,7 @@ public class InvariantDeviceProfile { } mIsFixedLandscape = a.getBoolean(R.styleable.GridDisplayOption_isFixedLandscape, false); - gridType = a.getInt(R.styleable.GridDisplayOption_gridType, GRID_TYPE_ALL); + gridType = a.getInt(R.styleable.GridDisplayOption_gridType, GRID_TYPE_ANY); int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb, DONT_INLINE_QSB); diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt index 7a04b0f950..30c4529613 100644 --- a/src/com/android/launcher3/LauncherPrefs.kt +++ b/src/com/android/launcher3/LauncherPrefs.kt @@ -20,6 +20,7 @@ import android.content.Context.MODE_PRIVATE import android.content.SharedPreferences import androidx.annotation.VisibleForTesting import com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN +import com.android.launcher3.GridType.Companion.GRID_TYPE_ANY import com.android.launcher3.InvariantDeviceProfile.GRID_NAME_PREFS_KEY import com.android.launcher3.InvariantDeviceProfile.NON_FIXED_LANDSCAPE_GRID_NAME_PREFS_KEY import com.android.launcher3.LauncherFiles.DEVICE_PREFERENCES_KEY @@ -266,6 +267,9 @@ constructor(@ApplicationContext private val encryptedContext: Context) { @JvmField val DB_FILE = backedUpItem(DeviceGridState.KEY_DB_FILE, "", EncryptionType.ENCRYPTED) @JvmField + val GRID_TYPE = + backedUpItem(DeviceGridState.KEY_GRID_TYPE, GRID_TYPE_ANY, EncryptionType.ENCRYPTED) + @JvmField val SHOULD_SHOW_SMARTSPACE = backedUpItem( SHOULD_SHOW_SMARTSPACE_KEY, diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index 32b47d0b22..f38dc418a0 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -95,7 +95,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { synchronouslyBoundPages = boundPages pagesToBindSynchronously = LIntSet() clearPendingBinds() - if (!launcher.isInState(LauncherState.ALL_APPS)) { + if (!launcher.isInState(LauncherState.ALL_APPS) && !Flags.enableWorkspaceInflation()) { launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW) pendingTasks.add { launcher.appsView.appsStore.disableDeferUpdates( diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index f60896eb6d..3d8ebbc75b 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -575,6 +575,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> } protected void rebindAdapters(boolean force) { + Log.d(TAG, "rebindAdapters: force: " + force); if (mSearchTransitionController.isRunning()) { mRebindAdaptersAfterSearchAnimation = true; return; @@ -583,6 +584,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> boolean showTabs = shouldShowTabs(); if (showTabs == mUsingTabs && !force) { + Log.d(TAG, "rebindAdapters: Not needed."); return; } @@ -678,6 +680,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> } private void replaceAppsRVContainer(boolean showTabs) { + Log.d(TAG, "replaceAppsRVContainer: showTabs: " + showTabs); for (int i = AdapterHolder.MAIN; i <= AdapterHolder.WORK; i++) { AdapterHolder adapterHolder = mAH.get(i); if (adapterHolder.mRecyclerView != null) { @@ -711,7 +714,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> mWorkManager.reset(); post(() -> mAH.get(AdapterHolder.WORK).applyPadding()); - } else { mWorkManager.detachWorkUtilityViews(); mViewPager = null; @@ -1017,6 +1019,7 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext> @VisibleForTesting public void onAppsUpdated() { + Log.d(TAG, "onAppsUpdated; number of apps: " + mAllAppsStore.getApps().length); mHasWorkApps = Stream.of(mAllAppsStore.getApps()) .anyMatch(mWorkManager.getItemInfoMatcher()); mHasPrivateApps = Stream.of(mAllAppsStore.getApps()) diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index d5a4022792..821027e2bd 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -20,6 +20,7 @@ import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY; import android.content.Context; import android.os.UserHandle; +import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -53,6 +54,7 @@ import java.util.function.Predicate; */ public class AllAppsStore<T extends Context & ActivityContext> { + private static final String TAG = "AllAppsStore"; // Defer updates flag used to defer all apps updates to the next draw. public static final int DEFER_UPDATES_NEXT_DRAW = 1 << 0; // Defer updates flag used to defer all apps updates by a test's request. @@ -102,6 +104,7 @@ public class AllAppsStore<T extends Context & ActivityContext> { public void setApps(@Nullable AppInfo[] apps, int flags, Map<PackageUserKey, Integer> map, boolean shouldPreinflate) { mApps = apps == null ? EMPTY_ARRAY : apps; + Log.d(TAG, "setApps: apps.length=" + mApps.length); mModelFlags = flags; notifyUpdate(); mPackageUserKeytoUidMap = map; @@ -159,10 +162,12 @@ public class AllAppsStore<T extends Context & ActivityContext> { public void enableDeferUpdates(int flag) { mDeferUpdatesFlags |= flag; + Log.d(TAG, "enableDeferUpdates: " + flag + " mDeferUpdatesFlags=" + mDeferUpdatesFlags); } public void disableDeferUpdates(int flag) { mDeferUpdatesFlags &= ~flag; + Log.d(TAG, "disableDeferUpdates: " + flag + " mDeferUpdatesFlags=" + mDeferUpdatesFlags); if (mDeferUpdatesFlags == 0 && mUpdatePending) { notifyUpdate(); mUpdatePending = false; @@ -171,6 +176,9 @@ public class AllAppsStore<T extends Context & ActivityContext> { public void disableDeferUpdatesSilently(int flag) { mDeferUpdatesFlags &= ~flag; + Log.d(TAG, "disableDeferUpdatesSilently: " + flag + + " mDeferUpdatesFlags=" + mDeferUpdatesFlags); + } public int getDeferUpdatesFlags() { @@ -179,9 +187,11 @@ public class AllAppsStore<T extends Context & ActivityContext> { private void notifyUpdate() { if (mDeferUpdatesFlags != 0) { + Log.d(TAG, "notifyUpdate: deferring update"); mUpdatePending = true; return; } + Log.d(TAG, "notifyUpdate: notifying listeners"); for (OnUpdateListener listener : mUpdateListeners) { listener.onAppsUpdated(); } diff --git a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java index 929e52e1fc..813ed3ec7c 100644 --- a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java +++ b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java @@ -38,7 +38,6 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.android.launcher3.folder.FolderIcon; -import com.android.launcher3.folder.PreviewBackground; import com.android.launcher3.icons.BitmapRenderer; import com.android.launcher3.util.Preconditions; import com.android.launcher3.views.ActivityContext; @@ -143,7 +142,6 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable { icon.getPreviewBounds(sTmpRect); final int previewSize = sTmpRect.width(); - PreviewBackground bg = icon.getFolderBackground(); final int margin = (size - previewSize) / 2; final float previewShiftX = -sTmpRect.left + margin; final float previewShiftY = -sTmpRect.top + margin; @@ -162,11 +160,10 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable { foregroundCanvas.restore(); // Draw background - Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - backgroundPaint.setColor(bg.getBgColor()); - bg.drawShadow(backgroundCanvas); - backgroundCanvas.drawPaint(backgroundPaint); - bg.drawBackgroundStroke(backgroundCanvas); + backgroundCanvas.save(); + backgroundCanvas.translate(previewShiftX, previewShiftY); + icon.getFolderBackground().drawBackground(backgroundCanvas); + backgroundCanvas.restore(); } @Override diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 967af053fb..996c5e7f55 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -18,6 +18,7 @@ package com.android.launcher3.folder; import static android.text.TextUtils.isEmpty; +import static com.android.launcher3.Flags.enableLauncherVisualRefresh; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; import static com.android.launcher3.LauncherState.EDIT_MODE; import static com.android.launcher3.LauncherState.NORMAL; @@ -299,6 +300,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mContent.setFolder(this); mPageIndicator = findViewById(R.id.folder_page_indicator); + if (enableLauncherVisualRefresh()) { + MarginLayoutParams params = ((MarginLayoutParams) mPageIndicator.getLayoutParams()); + int horizontalMargin = getContext().getResources() + .getDimensionPixelSize(R.dimen.folder_footer_horiz_padding); + params.setMarginStart(horizontalMargin); + params.setMarginEnd(horizontalMargin); + } mFooter = findViewById(R.id.folder_footer); mFooterHeight = dp.folderFooterHeightPx; mFolderName = findViewById(R.id.folder_name); @@ -312,7 +320,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo | InputType.TYPE_TEXT_FLAG_CAP_WORDS); mFolderName.forceDisableSuggestions(true); - mKeyboardInsetAnimationCallback = new KeyboardInsetAnimationCallback(this); setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback); } @@ -1270,6 +1277,23 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo } /** + * If the Folder Title has less than 100dp of available width, we hide it. The reason we do this + * calculation in onSizeChange is because this callback is called 1x when the folder is opened. + * <p> + * The PageIndicator and the Folder Title share the same horizontal linear layout, but both + * are dynamically sized. Therefore, we are setting visibility of the folder title AFTER the + * layout is measured. + */ + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + int minTitleWidth = getResources().getDimensionPixelSize(R.dimen.folder_title_min_width); + if (enableLauncherVisualRefresh() && mFolderName.getMeasuredWidth() < minTitleWidth) { + mFolderName.setVisibility(View.GONE); + } + } + + /** * Rearranges the children based on their rank. */ public void rearrangeChildren() { diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index 119a6b122b..1e80d03727 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -159,9 +159,15 @@ public class IconCache extends BaseIconCache { */ public synchronized void updateIconsForPkg(@NonNull final String packageName, @NonNull final UserHandle user) { + List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(packageName, user); + if (Flags.restoreArchivedAppIconsFromDb() + && apps.stream().anyMatch(app -> app.getApplicationInfo().isArchived)) { + // When archiving app icon, don't delete old icon so it can be re-used. + return; + } removeIconsForPkg(packageName, user); long userSerial = mUserManager.getSerialNumberForUser(user); - for (LauncherActivityInfo app : mLauncherApps.getActivityList(packageName, user)) { + for (LauncherActivityInfo app : apps) { addIconToDBAndMemCache(app, LauncherActivityCachingLogic.INSTANCE, userSerial); } } diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 44d2e266f7..40b597f838 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -890,6 +890,12 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "Row shift grid migration occurred") LAUNCHER_ROW_SHIFT_GRID_MIGRATION(2201), + @UiEvent(doc = "Do standard migration when upgrading to one grid") + LAUNCHER_STANDARD_ONE_GRID_MIGRATION(2205), + + @UiEvent(doc = "Do row shift migration when upgrading to one grid") + LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION(2206), + // ADD MORE ; diff --git a/src/com/android/launcher3/model/BaseLauncherBinder.java b/src/com/android/launcher3/model/BaseLauncherBinder.java index c4bbae416b..1d19a17d42 100644 --- a/src/com/android/launcher3/model/BaseLauncherBinder.java +++ b/src/com/android/launcher3/model/BaseLauncherBinder.java @@ -323,8 +323,10 @@ public class BaseLauncherBinder { Executor pendingExecutor = pendingTasks::add; RunnableList onCompleteSignal = new RunnableList(); + onCompleteSignal.add(() -> Log.d(TAG, "Calling onCompleteSignal")); if (enableWorkspaceInflation() && inflater != null) { + Log.d(TAG, "Starting async inflation"); MODEL_EXECUTOR.execute(() -> { inflateAsyncAndBind(otherWorkspaceItems, inflater, pendingExecutor); inflateAsyncAndBind(otherAppWidgets, inflater, pendingExecutor); @@ -335,6 +337,7 @@ public class BaseLauncherBinder { MAIN_EXECUTOR.execute(onCompleteSignal::executeAllAndDestroy); }); } else { + Log.d(TAG, "Starting sync inflation"); bindItemsInChunks(otherWorkspaceItems, ITEMS_CHUNK, pendingExecutor); bindItemsInChunks(otherAppWidgets, 1, pendingExecutor); setupPendingBind(currentScreenIds, pendingExecutor); diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java index 96ce4c83db..32ea4b5fd7 100644 --- a/src/com/android/launcher3/model/DeviceGridState.java +++ b/src/com/android/launcher3/model/DeviceGridState.java @@ -19,6 +19,7 @@ package com.android.launcher3.model; import static com.android.launcher3.InvariantDeviceProfile.DeviceType; import static com.android.launcher3.LauncherPrefs.DB_FILE; import static com.android.launcher3.LauncherPrefs.DEVICE_TYPE; +import static com.android.launcher3.LauncherPrefs.GRID_TYPE; import static com.android.launcher3.LauncherPrefs.HOTSEAT_COUNT; import static com.android.launcher3.LauncherPrefs.WORKSPACE_SIZE; @@ -41,17 +42,21 @@ public class DeviceGridState implements Comparable<DeviceGridState> { public static final String KEY_HOTSEAT_COUNT = "migration_src_hotseat_count"; public static final String KEY_DEVICE_TYPE = "migration_src_device_type"; public static final String KEY_DB_FILE = "migration_src_db_file"; + public static final String KEY_GRID_TYPE = "migration_src_grid_type"; private final String mGridSizeString; private final int mNumHotseat; private final @DeviceType int mDeviceType; private final String mDbFile; + private final int mGridType; - public DeviceGridState(int columns, int row, int numHotseat, int deviceType, String dbFile) { + public DeviceGridState(int columns, int row, int numHotseat, int deviceType, String dbFile, + int gridType) { mGridSizeString = String.format(Locale.ENGLISH, "%d,%d", columns, row); mNumHotseat = numHotseat; mDeviceType = deviceType; mDbFile = dbFile; + mGridType = gridType; } public DeviceGridState(InvariantDeviceProfile idp) { @@ -59,6 +64,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> { mNumHotseat = idp.numDatabaseHotseatIcons; mDeviceType = idp.deviceType; mDbFile = idp.dbFile; + mGridType = idp.gridType; } public DeviceGridState(Context context) { @@ -70,6 +76,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> { mNumHotseat = lp.get(HOTSEAT_COUNT); mDeviceType = lp.get(DEVICE_TYPE); mDbFile = lp.get(DB_FILE); + mGridType = lp.get(GRID_TYPE); } /** @@ -94,6 +101,13 @@ public class DeviceGridState implements Comparable<DeviceGridState> { } /** + * Returns the grid type. + */ + public int getGridType() { + return mGridType; + } + + /** * Stores the device state to shared preferences */ public void writeToPrefs(Context context) { @@ -101,7 +115,9 @@ public class DeviceGridState implements Comparable<DeviceGridState> { WORKSPACE_SIZE.to(mGridSizeString), HOTSEAT_COUNT.to(mNumHotseat), DEVICE_TYPE.to(mDeviceType), - DB_FILE.to(mDbFile)); + DB_FILE.to(mDbFile), + GRID_TYPE.to(mGridType)); + } /** diff --git a/src/com/android/launcher3/model/GridSizeMigrationDBController.java b/src/com/android/launcher3/model/GridSizeMigrationDBController.java index 3e4394373a..12ba07de4e 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationDBController.java +++ b/src/com/android/launcher3/model/GridSizeMigrationDBController.java @@ -17,11 +17,16 @@ package com.android.launcher3.model; import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle; +import static com.android.launcher3.GridType.GRID_TYPE_NON_ONE_GRID; +import static com.android.launcher3.GridType.GRID_TYPE_ONE_GRID; +import static com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET; import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME; import static com.android.launcher3.LauncherSettings.Favorites.TMP_TABLE; import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_GRID_MIGRATION; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_GRID_MIGRATION; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_ONE_GRID_MIGRATION; import static com.android.launcher3.model.LoaderTask.SMARTSPACE_ON_HOME_SCREEN; import static com.android.launcher3.provider.LauncherDbUtils.copyTable; import static com.android.launcher3.provider.LauncherDbUtils.dropTable; @@ -157,6 +162,9 @@ public class GridSizeMigrationDBController { // Save current configuration, so that the migration does not run again. destDeviceState.writeToPrefs(context); t.commit(); + if (isOneGridMigration(srcDeviceState, destDeviceState)) { + statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION); + } statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_GRID_MIGRATION); return true; } @@ -169,6 +177,9 @@ public class GridSizeMigrationDBController { destDeviceState.getNumHotseat(), targetSize, srcDeviceState, destDeviceState); dropTable(t.getDb(), TMP_TABLE); t.commit(); + if (isOneGridMigration(srcDeviceState, destDeviceState)) { + statsLogManager.logger().log(LAUNCHER_STANDARD_ONE_GRID_MIGRATION); + } statsLogManager.logger().log(LAUNCHER_STANDARD_GRID_MIGRATION); return true; } catch (Exception e) { @@ -291,6 +302,12 @@ public class GridSizeMigrationDBController { return true; } + protected static boolean isOneGridMigration(DeviceGridState srcDeviceState, + DeviceGridState destDeviceState) { + return srcDeviceState.getDeviceType() != TYPE_TABLET + && srcDeviceState.getGridType() == GRID_TYPE_NON_ONE_GRID + && destDeviceState.getGridType() == GRID_TYPE_ONE_GRID; + } /** * Calculate the differences between {@code src} (denoted by A) and {@code dest} * (denoted by B). diff --git a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt index 2957e3c608..d88f6ccfc6 100644 --- a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt +++ b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt @@ -32,8 +32,11 @@ import com.android.launcher3.config.FeatureFlags import com.android.launcher3.logging.FileLog import com.android.launcher3.logging.StatsLogManager import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_GRID_MIGRATION +import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_GRID_MIGRATION +import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_ONE_GRID_MIGRATION import com.android.launcher3.model.GridSizeMigrationDBController.DbReader +import com.android.launcher3.model.GridSizeMigrationDBController.isOneGridMigration import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction import com.android.launcher3.provider.LauncherDbUtils.copyTable import com.android.launcher3.provider.LauncherDbUtils.dropTable @@ -95,7 +98,12 @@ class GridSizeMigrationLogic { // Save current configuration, so that the migration does not run again. destDeviceState.writeToPrefs(context) t.commit() + + if (isOneGridMigration(srcDeviceState, destDeviceState)) { + statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION) + } statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_GRID_MIGRATION) + return } @@ -125,6 +133,10 @@ class GridSizeMigrationLogic { dropTable(t.db, TMP_TABLE) t.commit() + + if (isOneGridMigration(srcDeviceState, destDeviceState)) { + statsLogManager.logger().log(LAUNCHER_STANDARD_ONE_GRID_MIGRATION) + } statsLogManager.logger().log(LAUNCHER_STANDARD_GRID_MIGRATION) } } catch (e: Exception) { diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index efe61572fe..8f116bbd6b 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -326,6 +326,7 @@ public class LoaderCursor extends CursorWrapper { // the fallback icon if (!loadIconFromDb(info)) { + FileLog.d(TAG, "loadIconFromDb failed, getting from cache - intent=" + intent); mIconCache.getTitleAndIcon(info, DEFAULT_LOOKUP_FLAG); } diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 78e5d898cd..6dc20de490 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -762,7 +762,7 @@ public class LoaderTask implements Runnable { } IconRequestInfo<AppInfo> iconRequestInfo = getAppInfoIconRequestInfo( - appInfo, app, mWorkspaceIconRequestInfos); + appInfo, app, mWorkspaceIconRequestInfos, mIsRestoreFromBackup); allAppsItemRequestInfos.add(iconRequestInfo); mBgAllAppsList.add(appInfo, app, false); } @@ -831,9 +831,10 @@ public class LoaderTask implements Runnable { IconRequestInfo<AppInfo> getAppInfoIconRequestInfo( AppInfo appInfo, LauncherActivityInfo activityInfo, - List<IconRequestInfo<WorkspaceItemInfo>> workspaceRequestInfos + List<IconRequestInfo<WorkspaceItemInfo>> workspaceRequestInfos, + boolean isRestoreFromBackup ) { - if (Flags.restoreArchivedAppIconsFromDb()) { + if (Flags.restoreArchivedAppIconsFromDb() && isRestoreFromBackup) { Optional<IconRequestInfo<WorkspaceItemInfo>> workspaceIconRequest = workspaceRequestInfos.stream() .filter(request -> appInfo.getTargetComponent().equals( diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 7b8f21866a..bf71099f41 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -524,15 +524,14 @@ class WorkspaceItemProcessor( WidgetInflater.TYPE_PENDING -> { tempPackageKey.update(component.packageName, c.user) val si = installingPkgs[tempPackageKey] - + val isArchived = + ApplicationInfoWrapper(context, component.packageName, c.user).isArchived() if ( !c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED) && !isSafeMode && (si == null) && (lapi == null) && - !(Flags.enableSupportForArchiving() && - ApplicationInfoWrapper(context, component.packageName, c.user) - .isArchived()) + !isArchived ) { // Restore never started c.markDeleted( @@ -559,7 +558,13 @@ class WorkspaceItemProcessor( appWidgetInfo.providerName, appWidgetInfo.user, ) - iconCache.getTitleAndIconForApp(appWidgetInfo.pendingItemInfo, DEFAULT_LOOKUP_FLAG) + val iconLookupFlag = + if (isArchived && Flags.restoreArchivedAppIconsFromDb()) { + DEFAULT_LOOKUP_FLAG.withSkipAddToMemCache() + } else { + DEFAULT_LOOKUP_FLAG + } + iconCache.getTitleAndIconForApp(appWidgetInfo.pendingItemInfo, iconLookupFlag) } WidgetInflater.TYPE_REAL -> WidgetSizes.updateWidgetSizeRangesAsync( diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java index 384f87623a..8f80515e36 100644 --- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java +++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java @@ -600,6 +600,13 @@ public class PageIndicatorDots extends View implements Insettable, PageIndicator } if (Math.round(mCurrentPosition) == i) { sLastActiveRect.set(sTempRect); + if (mCurrentPosition == 0) { + // The outline is calculated before onDraw is called. If the user has + // paginated, closed the folder, and opened the folder again, the + // first drawn outline will use stale bounds. + // Invalidation is cheap, and is only needed when scroll is 0. + invalidateOutline(); + } } canvas.drawRoundRect(sTempRect, mDotRadius, mDotRadius, mPaginationPaint); diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 39f68bfe70..9a226df8db 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -24,7 +24,9 @@ import static com.android.launcher3.Utilities.squaredTouchSlop; import static com.android.launcher3.allapps.AlphabeticalAppsList.PRIVATE_SPACE_PACKAGE; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE; import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS; +import static com.android.launcher3.shortcuts.DeepShortcutTextView.GOOGLE_SANS_FLEX_LABEL_LARGE; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; +import static com.android.wm.shell.Flags.enableGsf; import android.animation.AnimatorSet; import android.animation.LayoutTransition; @@ -32,6 +34,7 @@ import android.content.Context; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; +import android.graphics.Typeface; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; @@ -479,6 +482,10 @@ public class PopupContainerWithArrow<T extends Context & ActivityContext> if (view instanceof DeepShortcutView) { // System shortcut takes entire row with icon and text final DeepShortcutView shortcutView = (DeepShortcutView) view; + if (enableGsf()) { + shortcutView.getBubbleText().setTypeface( + Typeface.create(GOOGLE_SANS_FLEX_LABEL_LARGE, Typeface.NORMAL)); + } info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText()); } else if (view instanceof ImageView) { // System shortcut is just an icon diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java index ded2ceee42..b1d095b52e 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java @@ -16,9 +16,12 @@ package com.android.launcher3.shortcuts; +import static com.android.wm.shell.Flags.enableGsf; + import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.AttributeSet; @@ -31,6 +34,7 @@ import com.android.launcher3.Utilities; * A {@link BubbleTextView} that has the shortcut icon on the left and drag handle on the right. */ public class DeepShortcutTextView extends BubbleTextView { + public static final String GOOGLE_SANS_FLEX_LABEL_LARGE = "variable-label-large"; private boolean mShowLoadingState; private Drawable mLoadingStatePlaceholder; @@ -47,6 +51,9 @@ public class DeepShortcutTextView extends BubbleTextView { public DeepShortcutTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); showLoadingState(true); + if (enableGsf()) { + setTypeface(Typeface.create(GOOGLE_SANS_FLEX_LABEL_LARGE, Typeface.NORMAL)); + } } @Override diff --git a/src/com/android/launcher3/util/ViewOnDrawExecutor.java b/src/com/android/launcher3/util/ViewOnDrawExecutor.java index 26bfd36dcf..dad76299b7 100644 --- a/src/com/android/launcher3/util/ViewOnDrawExecutor.java +++ b/src/com/android/launcher3/util/ViewOnDrawExecutor.java @@ -16,6 +16,7 @@ package com.android.launcher3.util; +import android.util.Log; import android.view.View; import android.view.View.OnAttachStateChangeListener; import android.view.ViewTreeObserver.OnDrawListener; @@ -32,6 +33,7 @@ import java.util.function.Consumer; public class ViewOnDrawExecutor implements OnDrawListener, Runnable, OnAttachStateChangeListener { + private static final String TAG = "ViewOnDrawExecutor"; private final RunnableList mTasks; private final Consumer<ViewOnDrawExecutor> mOnClearCallback; private View mAttachedView; @@ -88,7 +90,10 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, * Executes all tasks immediately */ public void markCompleted() { - if (!mCancelled) { + if (mCancelled) { + Log.d(TAG, "markCompleted ignored: cancelled"); + } else { + Log.d(TAG, "markCompleted: executing tasks"); mTasks.executeAllAndDestroy(); } mCompleted = true; @@ -101,6 +106,7 @@ public class ViewOnDrawExecutor implements OnDrawListener, Runnable, } public void cancel() { + Log.d(TAG, "Cancelling tasks"); mCancelled = true; markCompleted(); } |