diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java index c396eec50e..14c3a92f49 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialController.java @@ -20,9 +20,7 @@ import static com.android.quickstep.interaction.TutorialController.TutorialType. import static com.android.quickstep.interaction.TutorialController.TutorialType.RIGHT_EDGE_BACK_NAVIGATION; import android.graphics.PointF; -import android.view.View; -import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import com.android.launcher3.R; @@ -36,11 +34,6 @@ final class BackGestureTutorialController extends TutorialController { super(fragment, tutorialType); } - @Nullable - public View getMockLauncherView() { - return null; - } - @Override public Integer getIntroductionTitle() { return mTutorialType == LEFT_EDGE_BACK_NAVIGATION diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java index 3c59ed3007..06610e6ad6 100644 --- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java @@ -16,15 +16,11 @@ package com.android.quickstep.interaction; import static com.android.launcher3.anim.Interpolators.ACCEL; -import static com.android.quickstep.interaction.TutorialController.TutorialType.OVERVIEW_NAVIGATION_COMPLETE; import android.animation.AnimatorSet; import android.annotation.TargetApi; import android.graphics.PointF; import android.os.Build; -import android.view.View; - -import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.anim.PendingAnimation; @@ -52,12 +48,6 @@ final class OverviewGestureTutorialController extends SwipeUpGestureTutorialCont return R.string.overview_gesture_intro_subtitle; } - @Nullable - @Override - public View getMockLauncherView() { - return null; - } - @Override public void onBackGestureAttempted(BackGestureResult result) { switch (mTutorialType) { diff --git a/quickstep/src/com/android/quickstep/interaction/SandboxLauncherRenderer.java b/quickstep/src/com/android/quickstep/interaction/SandboxLauncherRenderer.java deleted file mode 100644 index 80ffe6609e..0000000000 --- a/quickstep/src/com/android/quickstep/interaction/SandboxLauncherRenderer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2020 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.quickstep.interaction; - -import android.content.Context; -import android.view.View; - -import com.android.launcher3.InvariantDeviceProfile; -import com.android.launcher3.graphics.LauncherPreviewRenderer; - -/** Renders a fake Launcher for use in the Sandbox. */ -class SandboxLauncherRenderer extends LauncherPreviewRenderer { - SandboxLauncherRenderer(Context context, InvariantDeviceProfile idp, boolean migrated) { - super(context, idp, migrated); - } - - @Override - public boolean shouldShowRealLauncherPreview() { - return false; - } - - @Override - public boolean shouldShowQsb() { - return false; - } - - @Override - public View.OnLongClickListener getWorkspaceChildOnLongClickListener() { - return null; - } -} diff --git a/quickstep/src/com/android/quickstep/interaction/TutorialController.java b/quickstep/src/com/android/quickstep/interaction/TutorialController.java index 6f82f8596b..55972adcbe 100644 --- a/quickstep/src/com/android/quickstep/interaction/TutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/TutorialController.java @@ -37,7 +37,6 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; -import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.views.ClipIconView; @@ -129,13 +128,6 @@ abstract class TutorialController implements BackGestureAttemptCallback, return R.drawable.default_sandbox_app_previous_task_thumbnail; } - @Nullable - public View getMockLauncherView() { - InvariantDeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext); - - return new SandboxLauncherRenderer(mContext, dp, true).getRenderedView(); - } - @DrawableRes public int getMockAppIconResId() { return R.drawable.default_sandbox_app_icon; diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 2ace796ca0..3d044d68ce 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -317,7 +317,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, @UiThread protected void applyIconAndLabel(ItemInfoWithIcon info) { - FastBitmapDrawable iconDrawable = info.newIcon(getContext()); + boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER; + FastBitmapDrawable iconDrawable = info.newIcon(getContext(), useTheme); mDotParams.color = IconPalette.getMutedColor(info.bitmap.color, 0.54f); setIcon(iconDrawable); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index a799b4a33a..be5463ec2c 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -74,9 +74,9 @@ import com.android.launcher3.dragndrop.FolderAdaptiveIcon; import com.android.launcher3.graphics.GridCustomizationsProvider; import com.android.launcher3.graphics.TintedDrawableSpan; import com.android.launcher3.icons.FastBitmapDrawable; -import com.android.launcher3.icons.IconProvider; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.icons.ShortcutCachingLogic; +import com.android.launcher3.icons.ThemedIconDrawable.ThemedAdaptiveIcon; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.ItemInfoWithIcon; import com.android.launcher3.pm.ShortcutConfigActivityInfo; @@ -596,13 +596,23 @@ public final class Utilities { */ public static Drawable getFullDrawable(Launcher launcher, ItemInfo info, int width, int height, Object[] outObj) { + Drawable icon = loadFullDrawableWithoutTheme(launcher, info, width, height, outObj); + if (icon instanceof ThemedAdaptiveIcon) { + icon = ((ThemedAdaptiveIcon) icon).getThemedDrawable(launcher); + } + return icon; + } + + private static Drawable loadFullDrawableWithoutTheme(Launcher launcher, ItemInfo info, + int width, int height, Object[] outObj) { LauncherAppState appState = LauncherAppState.getInstance(launcher); if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) { LauncherActivityInfo activityInfo = launcher.getSystemService(LauncherApps.class) .resolveActivity(info.getIntent(), info.user); outObj[0] = activityInfo; - return activityInfo == null ? null : new IconProvider(launcher).getIcon( - activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi); + return activityInfo == null ? null : LauncherAppState.getInstance(launcher) + .getIconCache().getIconProvider().getIcon( + activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi); } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { if (info instanceof PendingAddShortcutInfo) { ShortcutConfigActivityInfo activityInfo = diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index bad87043ef..88476dee22 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -137,8 +137,8 @@ public final class FeatureFlags { public static final BooleanFlag MULTI_DB_GRID_MIRATION_ALGO = getDebugFlag( "MULTI_DB_GRID_MIRATION_ALGO", true, "Use the multi-db grid migration algorithm"); - public static final BooleanFlag ENABLE_LAUNCHER_PREVIEW_IN_GRID_PICKER = getDebugFlag( - "ENABLE_LAUNCHER_PREVIEW_IN_GRID_PICKER", true, "Show launcher preview in grid picker"); + public static final BooleanFlag ENABLE_THEMED_ICONS = getDebugFlag( + "ENABLE_THEMED_ICONS", false, "Enable themed icons on workspace"); // Keep as DeviceFlag for remote disable in emergency. public static final BooleanFlag ENABLE_OVERVIEW_SELECTIONS = new DeviceFlag( diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index d7f6cdb8bb..575b8fdd99 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -22,7 +22,6 @@ import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.Utilities.ATLEAST_Q; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import android.animation.ValueAnimator; import android.content.ComponentName; import android.content.res.Resources; import android.graphics.Point; @@ -307,17 +306,12 @@ public class DragController implements DragDriver.EventListener, TouchController mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/); } mIsInPreDrag = false; + mDragObject.dragView.onDragStart(); for (DragListener listener : new ArrayList<>(mListeners)) { listener.onDragStart(mDragObject, mOptions); } } - public void addFirstFrameAnimationHelper(ValueAnimator anim) { - if (mDragObject != null && mDragObject.dragView != null) { - mDragObject.dragView.mFirstFrameAnimatorHelper.addTo(anim); - } - } - public Optional getLogInstanceId() { return Optional.ofNullable(mDragObject) .map(dragObject -> dragObject.logInstanceId); diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 68a8af238e..30ee9ecddd 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -51,7 +51,6 @@ import androidx.dynamicanimation.animation.FloatPropertyCompat; import androidx.dynamicanimation.animation.SpringAnimation; import androidx.dynamicanimation.animation.SpringForce; -import com.android.launcher3.FirstFrameAnimatorHelper; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherState; @@ -62,6 +61,7 @@ import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.statemanager.StateManager.StateListener; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.Thunk; import com.android.launcher3.views.BaseDragLayer; @@ -85,12 +85,13 @@ public class DragView extends FrameLayout implements StateListener { + new Handler(Looper.getMainLooper()).post(() -> mOnDragStartCallback.add(() -> { + // TODO: Consider fade-in animation // Assign the variable on the UI thread to avoid race conditions. mScaledMaskPath = mask; // Avoid relayout as we do not care about children affecting layout @@ -290,11 +291,18 @@ public class DragView extends FrameLayout implements StateListener currentWorkspaceItems = new ArrayList<>(); - ArrayList otherWorkspaceItems = new ArrayList<>(); - ArrayList currentAppWidgets = new ArrayList<>(); - ArrayList otherAppWidgets = new ArrayList<>(); - filterCurrentWorkspaceItems(0 /* currentScreenId */, - workspaceResult.mWorkspaceItems, currentWorkspaceItems, - otherWorkspaceItems); - filterCurrentWorkspaceItems(0 /* currentScreenId */, workspaceResult.mAppWidgets, - currentAppWidgets, otherAppWidgets); - sortWorkspaceItemsSpatially(mIdp, currentWorkspaceItems); - for (ItemInfo itemInfo : currentWorkspaceItems) { - switch (itemInfo.itemType) { - case Favorites.ITEM_TYPE_APPLICATION: - case Favorites.ITEM_TYPE_SHORTCUT: - case Favorites.ITEM_TYPE_DEEP_SHORTCUT: - inflateAndAddIcon((WorkspaceItemInfo) itemInfo); - break; - case Favorites.ITEM_TYPE_FOLDER: - inflateAndAddFolder((FolderInfo) itemInfo); - break; - default: - break; - } - } - for (ItemInfo itemInfo : currentAppWidgets) { - switch (itemInfo.itemType) { - case Favorites.ITEM_TYPE_APPWIDGET: - case Favorites.ITEM_TYPE_CUSTOM_APPWIDGET: - if (mMigrated) { - inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, - workspaceResult.mWidgetProvidersMap); - } else { - inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, - workspaceResult.mWidgetsModel); - } - break; - default: - break; - } - } - IntArray ranks = getMissingHotseatRanks(currentWorkspaceItems, - mDp.numShownHotseatIcons); - List predictions = workspaceResult.mHotseatPredictions == null - ? Collections.emptyList() : workspaceResult.mHotseatPredictions.items; - int count = Math.min(ranks.size(), predictions.size()); - for (int i = 0; i < count; i++) { - int rank = ranks.get(i); - WorkspaceItemInfo itemInfo = - new WorkspaceItemInfo((WorkspaceItemInfo) predictions.get(i)); - itemInfo.container = CONTAINER_HOTSEAT_PREDICTION; - itemInfo.rank = rank; - itemInfo.cellX = mHotseat.getCellXFromOrder(rank); - itemInfo.cellY = mHotseat.getCellYFromOrder(rank); - itemInfo.screenId = rank; - inflateAndAddPredictedIcon(itemInfo); - } + WorkspaceFetcher fetcher; + PreviewContext previewContext = null; + if (mMigrated) { + previewContext = new PreviewContext(mContext, mIdp); + LauncherAppState appForPreview = new LauncherAppState( + previewContext, null /* iconCacheFileName */); + fetcher = new WorkspaceItemsInfoFromPreviewFetcher(appForPreview); + MODEL_EXECUTOR.execute(fetcher); } else { - // Add hotseat icons - for (int i = 0; i < mDp.numShownHotseatIcons; i++) { - WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo); - info.container = Favorites.CONTAINER_HOTSEAT; - info.screenId = i; - inflateAndAddIcon(info); + fetcher = new WorkspaceItemsInfoFetcher(); + LauncherAppState.getInstance(mContext).getModel().enqueueModelUpdateTask( + (LauncherModel.ModelUpdateTask) fetcher); + } + WorkspaceResult workspaceResult = fetcher.get(); + if (previewContext != null) { + previewContext.onDestroy(); + } + + if (workspaceResult == null) { + return; + } + + // Separate the items that are on the current screen, and the other remaining items. + ArrayList currentWorkspaceItems = new ArrayList<>(); + ArrayList otherWorkspaceItems = new ArrayList<>(); + ArrayList currentAppWidgets = new ArrayList<>(); + ArrayList otherAppWidgets = new ArrayList<>(); + filterCurrentWorkspaceItems(0 /* currentScreenId */, + workspaceResult.mWorkspaceItems, currentWorkspaceItems, + otherWorkspaceItems); + filterCurrentWorkspaceItems(0 /* currentScreenId */, workspaceResult.mAppWidgets, + currentAppWidgets, otherAppWidgets); + sortWorkspaceItemsSpatially(mIdp, currentWorkspaceItems); + for (ItemInfo itemInfo : currentWorkspaceItems) { + switch (itemInfo.itemType) { + case Favorites.ITEM_TYPE_APPLICATION: + case Favorites.ITEM_TYPE_SHORTCUT: + case Favorites.ITEM_TYPE_DEEP_SHORTCUT: + inflateAndAddIcon((WorkspaceItemInfo) itemInfo); + break; + case Favorites.ITEM_TYPE_FOLDER: + inflateAndAddFolder((FolderInfo) itemInfo); + break; + default: + break; } - // Add workspace icons - for (int i = 0; i < mIdp.numColumns; i++) { - WorkspaceItemInfo info = new WorkspaceItemInfo(mWorkspaceItemInfo); - info.container = Favorites.CONTAINER_DESKTOP; - info.screenId = 0; - info.cellX = i; - info.cellY = mIdp.numRows - 1; - inflateAndAddIcon(info); + } + for (ItemInfo itemInfo : currentAppWidgets) { + switch (itemInfo.itemType) { + case Favorites.ITEM_TYPE_APPWIDGET: + case Favorites.ITEM_TYPE_CUSTOM_APPWIDGET: + if (mMigrated) { + inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, + workspaceResult.mWidgetProvidersMap); + } else { + inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, + workspaceResult.mWidgetsModel); + } + break; + default: + break; } } + IntArray ranks = getMissingHotseatRanks(currentWorkspaceItems, + mDp.numShownHotseatIcons); + List predictions = workspaceResult.mHotseatPredictions == null + ? Collections.emptyList() : workspaceResult.mHotseatPredictions.items; + int count = Math.min(ranks.size(), predictions.size()); + for (int i = 0; i < count; i++) { + int rank = ranks.get(i); + WorkspaceItemInfo itemInfo = + new WorkspaceItemInfo((WorkspaceItemInfo) predictions.get(i)); + itemInfo.container = CONTAINER_HOTSEAT_PREDICTION; + itemInfo.rank = rank; + itemInfo.cellX = mHotseat.getCellXFromOrder(rank); + itemInfo.cellY = mHotseat.getCellYFromOrder(rank); + itemInfo.screenId = rank; + inflateAndAddPredictedIcon(itemInfo); + } // Add first page QSB - if (shouldShowQsb()) { + if (FeatureFlags.QSB_ON_FIRST_SCREEN) { View qsb = mHomeElementInflater.inflate( R.layout.search_container_workspace, mWorkspace, false); CellLayout.LayoutParams lp = diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java index fdc3a947a3..6193570e1f 100644 --- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java @@ -20,6 +20,7 @@ import static com.android.launcher3.config.FeatureFlags.MULTI_DB_GRID_MIRATION_A import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; +import android.app.WallpaperColors; import android.content.Context; import android.hardware.display.DisplayManager; import android.os.Bundle; @@ -28,18 +29,23 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Messenger; +import android.view.ContextThemeWrapper; import android.view.Display; import android.view.SurfaceControlViewHost; import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import com.android.launcher3.InvariantDeviceProfile; +import com.android.launcher3.R; import com.android.launcher3.model.GridSizeMigrationTask; import com.android.launcher3.model.GridSizeMigrationTaskV2; +import com.android.launcher3.util.Themes; +import com.android.launcher3.widget.LocalColorExtractor; import java.util.concurrent.TimeUnit; /** Render preview using surface view. */ +@SuppressWarnings("NewApi") public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { private static final int FADE_IN_ANIMATION_DURATION = 200; @@ -50,6 +56,7 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { private static final String KEY_DISPLAY_ID = "display_id"; private static final String KEY_SURFACE_PACKAGE = "surface_package"; private static final String KEY_CALLBACK = "callback"; + private static final String KEY_COLORS = "wallpaper_colors"; private final Context mContext; private final InvariantDeviceProfile mIdp; @@ -57,6 +64,7 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { private final int mWidth; private final int mHeight; private final Display mDisplay; + private final WallpaperColors mWallpaperColors; private SurfaceControlViewHost mSurfaceControlViewHost; @@ -68,6 +76,8 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { if (gridName == null) { gridName = InvariantDeviceProfile.getCurrentGridName(context); } + mWallpaperColors = bundle.getParcelable(KEY_COLORS); + mIdp = new InvariantDeviceProfile(context, gridName); mHostToken = bundle.getBinder(KEY_HOST_TOKEN); @@ -100,6 +110,19 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { MODEL_EXECUTOR.post(() -> { final boolean success = doGridMigrationIfNecessary(); + final Context inflationContext; + if (mWallpaperColors != null) { + // Workaround to create a themed context + Context context = mContext.createDisplayContext(mDisplay); + LocalColorExtractor.newInstance(mContext) + .applyColorsOverride(context, mWallpaperColors); + + inflationContext = new ContextThemeWrapper(context, + Themes.getActivityThemeRes(context, mWallpaperColors.getColorHints())); + } else { + inflationContext = new ContextThemeWrapper(mContext, R.style.AppTheme); + } + MAIN_EXECUTOR.post(() -> { // If mSurfaceControlViewHost is null due to any reason (e.g. binder died, // happening when user leaves the preview screen before preview rendering finishes), @@ -109,7 +132,8 @@ public class PreviewSurfaceRenderer implements IBinder.DeathRecipient { return; } - View view = new LauncherPreviewRenderer(mContext, mIdp, success).getRenderedView(); + View view = new LauncherPreviewRenderer(inflationContext, mIdp, success) + .getRenderedView(); // This aspect scales the view to fit in the surface and centers it final float scale = Math.min(mWidth / (float) view.getMeasuredWidth(), mHeight / (float) view.getMeasuredHeight()); diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java index a2c0f5cdf4..bc93a1e3d9 100644 --- a/src/com/android/launcher3/icons/IconCache.java +++ b/src/com/android/launcher3/icons/IconCache.java @@ -52,7 +52,6 @@ import com.android.launcher3.model.data.PackageItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.shortcuts.ShortcutKey; -import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.Preconditions; @@ -94,7 +93,7 @@ public class IconCache extends BaseIconCache { mLauncherApps = mContext.getSystemService(LauncherApps.class); mUserManager = UserCache.INSTANCE.get(mContext); mInstantAppResolver = InstantAppResolver.newInstance(mContext); - mIconProvider = new IconProvider(context); + mIconProvider = new IconProvider(context, true /* supportsIconTheme */); } @Override @@ -107,8 +106,12 @@ public class IconCache extends BaseIconCache { return mInstantAppResolver.isInstantApp(info); } + public IconProvider getIconProvider() { + return mIconProvider; + } + @Override - protected BaseIconFactory getIconFactory() { + public BaseIconFactory getIconFactory() { return LauncherIcons.obtain(mContext); } @@ -333,15 +336,6 @@ public class IconCache extends BaseIconCache { + ",flags_asi:" + FeatureFlags.APP_SEARCH_IMPROVEMENTS.get(); } - @Override - protected boolean getEntryFromDB(ComponentKey cacheKey, CacheEntry entry, boolean lowRes) { - if (mIconProvider.isClockIcon(cacheKey)) { - // For clock icon, we always load the dynamic icon - return false; - } - return super.getEntryFromDB(cacheKey, entry, lowRes); - } - /** * Interface for receiving itemInfo with high-res icon. */ diff --git a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java index 93de35a88a..8fc397738e 100644 --- a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java +++ b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.pm.LauncherActivityInfo; import android.os.UserHandle; +import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.icons.cache.CachingLogic; import com.android.launcher3.util.ResourceBasedOverride; @@ -56,8 +57,8 @@ public class LauncherActivityCachingLogic @Override public BitmapInfo loadIcon(Context context, LauncherActivityInfo object) { try (LauncherIcons li = LauncherIcons.obtain(context)) { - return li.createBadgedIconBitmap(new IconProvider(context) - .getIcon(object, li.mFillResIconDpi), + return li.createBadgedIconBitmap(LauncherAppState.getInstance(context) + .getIconCache().getIconProvider().getIcon(object, li.mFillResIconDpi), object.getUser(), object.getApplicationInfo().targetSdkVersion); } } diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java index 76b2ab0e85..0754c293b6 100644 --- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java +++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java @@ -16,6 +16,8 @@ package com.android.launcher3.model.data; +import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS; + import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -223,7 +225,15 @@ public abstract class ItemInfoWithIcon extends ItemInfo { * Returns a FastBitmapDrawable with the icon. */ public FastBitmapDrawable newIcon(Context context) { - FastBitmapDrawable drawable = bitmap.newIcon(context); + return newIcon(context, false); + } + + /** + * Returns a FastBitmapDrawable with the icon and context theme applied + */ + public FastBitmapDrawable newIcon(Context context, boolean applyTheme) { + FastBitmapDrawable drawable = applyTheme && ENABLE_THEMED_ICONS.get() + ? bitmap.newThemedIcon(context) : bitmap.newIcon(context); drawable.setIsDisabled(isDisabled()); return drawable; } diff --git a/src/com/android/launcher3/widget/LocalColorExtractor.java b/src/com/android/launcher3/widget/LocalColorExtractor.java index 097158b072..be4faea68f 100644 --- a/src/com/android/launcher3/widget/LocalColorExtractor.java +++ b/src/com/android/launcher3/widget/LocalColorExtractor.java @@ -16,6 +16,7 @@ package com.android.launcher3.widget; +import android.app.WallpaperColors; import android.appwidget.AppWidgetHostView; import android.content.Context; import android.graphics.RectF; @@ -43,7 +44,10 @@ public class LocalColorExtractor implements ResourceBasedOverride { void onColorsChanged(RectF rect, SparseIntArray extractedColors); } - static LocalColorExtractor newInstance(Context context) { + /** + * Creates a new instance of LocalColorExtractor + */ + public static LocalColorExtractor newInstance(Context context) { return Overrides.getObject(LocalColorExtractor.class, context.getApplicationContext(), R.string.local_colors_extraction_class); } @@ -62,4 +66,9 @@ public class LocalColorExtractor implements ResourceBasedOverride { public void removeLocations() { // no-op } + + /** + * Updates the base context to contain the colors override + */ + public void applyColorsOverride(Context base, WallpaperColors colors) { } }