Initialize shape with PreviewContext init and remove nullability
Bug: 372887760 Bug: 348664593 Flag: com.android.launcher3.enable_launcher_icon_shapes Test: previewing shapes with flag on/off Change-Id: I4d7278c54a0d69e38142d31dd7a9605a74db3348
This commit is contained in:
@@ -377,7 +377,9 @@ public class GridCustomizationsProxy implements ProxyProvider {
|
||||
if (Flags.newCustomizationPickerUi()
|
||||
&& com.android.launcher3.Flags.enableLauncherIconShapes()) {
|
||||
String shapeKey = message.getData().getString(KEY_SHAPE_KEY);
|
||||
renderer.updateShape(shapeKey);
|
||||
if (!TextUtils.isEmpty(shapeKey)) {
|
||||
renderer.updateShape(shapeKey);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MESSAGE_ID_UPDATE_GRID:
|
||||
|
||||
@@ -28,6 +28,7 @@ import static com.android.launcher3.LauncherPrefs.GRID_NAME;
|
||||
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.model.ModelUtils.currentScreenContentFilter;
|
||||
|
||||
import android.app.Fragment;
|
||||
@@ -137,12 +138,13 @@ public class LauncherPreviewRenderer extends ContextWrapper
|
||||
|
||||
private final String mPrefName;
|
||||
|
||||
public PreviewContext(Context base, String gridName) {
|
||||
public PreviewContext(Context base, String gridName, String shapeKey) {
|
||||
super(base);
|
||||
mPrefName = "preview-" + UUID.randomUUID().toString();
|
||||
LauncherPrefs prefs =
|
||||
new ProxyPrefs(this, getSharedPreferences(mPrefName, MODE_PRIVATE));
|
||||
prefs.put(GRID_NAME, gridName);
|
||||
prefs.put(PREF_ICON_SHAPE, shapeKey);
|
||||
initDaggerComponent(
|
||||
DaggerLauncherPreviewRenderer_PreviewAppComponent.builder().bindPrefs(prefs));
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ import com.android.systemui.shared.Flags;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/** Render preview using surface view. */
|
||||
@@ -120,6 +119,7 @@ public class PreviewSurfaceRenderer {
|
||||
if (mGridName == null) {
|
||||
mGridName = LauncherPrefs.get(context).get(GRID_NAME);
|
||||
}
|
||||
mShapeKey = LauncherPrefs.get(context).get(PREF_ICON_SHAPE);
|
||||
mWallpaperColors = bundle.getParcelable(KEY_COLORS);
|
||||
if (Flags.newCustomizationPickerUi()) {
|
||||
updateColorOverrides(bundle);
|
||||
@@ -225,8 +225,8 @@ public class PreviewSurfaceRenderer {
|
||||
*
|
||||
* @param shapeKey key for the IconShape model
|
||||
*/
|
||||
public void updateShape(@Nullable String shapeKey) {
|
||||
if (Objects.equals(mShapeKey, shapeKey)) {
|
||||
public void updateShape(String shapeKey) {
|
||||
if (shapeKey.equals(mShapeKey)) {
|
||||
Log.w(TAG, "Preview shape already set, skipping. shape=" + mShapeKey);
|
||||
return;
|
||||
}
|
||||
@@ -332,12 +332,10 @@ public class PreviewSurfaceRenderer {
|
||||
private void loadModelData() {
|
||||
final Context inflationContext = getPreviewContext();
|
||||
if (!mGridName.equals(LauncherPrefs.INSTANCE.get(mContext).get(GRID_NAME))
|
||||
|| mShapeKey != null) {
|
||||
|| !mShapeKey.equals(LauncherPrefs.INSTANCE.get(mContext).get(PREF_ICON_SHAPE))) {
|
||||
// Start the migration
|
||||
PreviewContext previewContext = new PreviewContext(inflationContext, mGridName);
|
||||
if (mShapeKey != null) {
|
||||
LauncherPrefs.INSTANCE.get(previewContext).put(PREF_ICON_SHAPE, mShapeKey);
|
||||
}
|
||||
PreviewContext previewContext =
|
||||
new PreviewContext(inflationContext, mGridName, mShapeKey);
|
||||
// Copy existing data to preview DB
|
||||
LauncherDbUtils.copyTable(LauncherAppState.getInstance(mContext)
|
||||
.getModel().getModelDbController().getDb(),
|
||||
|
||||
Reference in New Issue
Block a user