Merge "Enable previewing themed icon in wallpaper picker" into main

This commit is contained in:
Treehugger Robot
2025-03-28 09:49:54 -07:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 6 deletions
@@ -387,8 +387,8 @@ public class GridCustomizationsProxy implements ProxyProvider {
break;
case MESSAGE_ID_UPDATE_ICON_THEMED:
if (Flags.newCustomizationPickerUi()) {
Boolean iconThemed = message.getData().getBoolean(BOOLEAN_VALUE);
// TODO Update icon themed in the preview
boolean iconThemed = message.getData().getBoolean(BOOLEAN_VALUE);
renderer.updateTheme(iconThemed);
}
break;
default:
@@ -30,6 +30,7 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
import static com.android.launcher3.graphics.ThemeManager.PREF_ICON_SHAPE;
import static com.android.launcher3.graphics.ThemeManager.THEMED_ICONS;
import static com.android.launcher3.model.ModelUtils.currentScreenContentFilter;
import static com.android.launcher3.widget.LauncherWidgetHolder.APPWIDGET_HOST_ID;
@@ -154,12 +155,13 @@ public class LauncherPreviewRenderer extends BaseContext
private final File mDbDir;
public PreviewContext(Context base, String gridName, String shapeKey) {
this(base, gridName, shapeKey, APPWIDGET_HOST_ID, null);
public PreviewContext(Context base, String gridName, String shapeKey,
boolean isMonoThemeEnabled) {
this(base, gridName, shapeKey, APPWIDGET_HOST_ID, null, isMonoThemeEnabled);
}
public PreviewContext(Context base, String gridName, String shapeKey,
int widgetHostId, @Nullable String layoutXml) {
int widgetHostId, @Nullable String layoutXml, boolean isMonoThemeEnabled) {
super(base);
String randomUid = UUID.randomUUID().toString();
mPrefName = "preview-" + randomUid;
@@ -167,6 +169,7 @@ public class LauncherPreviewRenderer extends BaseContext
new ProxyPrefs(this, getSharedPreferences(mPrefName, MODE_PRIVATE));
prefs.put(GRID_NAME, gridName);
prefs.put(PREF_ICON_SHAPE, shapeKey);
prefs.put(THEMED_ICONS, isMonoThemeEnabled);
PreviewAppComponent.Builder builder =
DaggerLauncherPreviewRenderer_PreviewAppComponent.builder().bindPrefs(prefs);
@@ -25,6 +25,7 @@ import static com.android.launcher3.LauncherPrefs.GRID_NAME;
import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID;
import static com.android.launcher3.WorkspaceLayoutManager.SECOND_SCREEN_ID;
import static com.android.launcher3.graphics.ThemeManager.PREF_ICON_SHAPE;
import static com.android.launcher3.graphics.ThemeManager.THEMED_ICONS;
import static com.android.launcher3.provider.LauncherDbUtils.selectionForWorkspaceScreen;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -103,6 +104,7 @@ public class PreviewSurfaceRenderer {
private String mGridName;
private String mShapeKey;
private String mLayoutXml;
private boolean mIsMonoThemeEnabled;
@Nullable private Boolean mDarkMode;
private boolean mDestroyed = false;
@@ -132,6 +134,7 @@ public class PreviewSurfaceRenderer {
mGridName = LauncherPrefs.get(context).get(GRID_NAME);
}
mShapeKey = LauncherPrefs.get(context).get(PREF_ICON_SHAPE);
mIsMonoThemeEnabled = LauncherPrefs.get(context).get(THEMED_ICONS);
mWallpaperColors = bundle.getParcelable(KEY_COLORS);
if (Flags.newCustomizationPickerUi()) {
updateColorOverrides(bundle);
@@ -248,6 +251,19 @@ public class PreviewSurfaceRenderer {
loadAsync();
}
/**
* Update whether to enable monochrome themed icon
*
* @param isMonoThemeEnabled True if enabling mono themed icons
*/
public void updateTheme(boolean isMonoThemeEnabled) {
if (mIsMonoThemeEnabled == isMonoThemeEnabled) {
return;
}
mIsMonoThemeEnabled = isMonoThemeEnabled;
loadAsync();
}
/**
* Hides the components in the bottom row.
*
@@ -347,6 +363,7 @@ public class PreviewSurfaceRenderer {
final Context inflationContext = getPreviewContext();
if (!mGridName.equals(LauncherPrefs.INSTANCE.get(mContext).get(GRID_NAME))
|| !mShapeKey.equals(LauncherPrefs.INSTANCE.get(mContext).get(PREF_ICON_SHAPE))
|| mIsMonoThemeEnabled != LauncherPrefs.INSTANCE.get(mContext).get(THEMED_ICONS)
|| !TextUtils.isEmpty(mLayoutXml)) {
boolean isCustomLayout = extendibleThemeManager() && !TextUtils.isEmpty(mLayoutXml);
@@ -354,7 +371,8 @@ public class PreviewSurfaceRenderer {
// Start the migration
PreviewContext previewContext = new PreviewContext(
inflationContext, mGridName, mShapeKey, widgetHostId, mLayoutXml);
inflationContext, mGridName, mShapeKey, widgetHostId, mLayoutXml,
mIsMonoThemeEnabled);
PreviewAppComponent appComponent =
(PreviewAppComponent) LauncherComponentProvider.get(previewContext);