ThemePickerLeaf: Update for U QPR2
Change-Id: I0746f89bf6b0d761b8fbb0093ed3608b19ecbe8f
diff --git a/Android.bp b/Android.bp
index 53439ae..e76c94c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 The LeafOS Project
+ * Copyright (c) 2023-2024 The LeafOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@
optimize: {
enabled: false,
},
- kotlincflags: ["-Xjvm-default=enable"],
+ kotlincflags: ["-Xjvm-default=all"],
certificate: "",
privileged: true,
diff --git a/res_override/layout/grid_section_view.xml b/res_override/layout/grid_section_view.xml
index 61ebee8..f21b0b4 100644
--- a/res_override/layout/grid_section_view.xml
+++ b/res_override/layout/grid_section_view.xml
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.customization.picker.grid.GridSectionView
+<com.android.customization.picker.grid.ui.view.GridSectionView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -50,7 +50,8 @@
android:layout_height="@dimen/option_tile_width"
android:scaleType="center"
android:src="@drawable/ic_grid_24px"
- android:background="@drawable/option_border_color"
+ android:tint="@color/system_on_surface"
+ android:background="@drawable/picker_section_icon_background"
android:contentDescription="@string/gird_picker_entry_content_description" />
-</com.android.customization.picker.grid.GridSectionView>
+</com.android.customization.picker.grid.ui.view.GridSectionView>
diff --git a/src/com/android/customization/model/theme/ThemeManager.java b/src/com/android/customization/model/theme/ThemeManager.java
index 85241c1..d371373 100644
--- a/src/com/android/customization/model/theme/ThemeManager.java
+++ b/src/com/android/customization/model/theme/ThemeManager.java
@@ -33,7 +33,6 @@
import com.android.customization.model.CustomizationManager;
import com.android.customization.model.ResourceConstants;
import com.android.customization.model.theme.custom.CustomTheme;
-import com.android.customization.module.ThemesUserEventLogger;
import org.json.JSONObject;
@@ -59,17 +58,14 @@
private final OverlayManagerCompat mOverlayManagerCompat;
protected final FragmentActivity mActivity;
- private final ThemesUserEventLogger mEventLogger;
private Map<String, String> mCurrentOverlays;
public ThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
- OverlayManagerCompat overlayManagerCompat,
- ThemesUserEventLogger logger) {
+ OverlayManagerCompat overlayManagerCompat) {
mProvider = provider;
mActivity = activity;
mOverlayManagerCompat = overlayManagerCompat;
- mEventLogger = logger;
}
@Override
@@ -90,7 +86,6 @@
}
mCurrentOverlays = null;
if (allApplied) {
- mEventLogger.logThemeApplied(theme, theme instanceof CustomTheme);
callback.onSuccess();
} else {
callback.onError(null);
diff --git a/src/com/android/customization/picker/theme/CustomThemeActivity.java b/src/com/android/customization/picker/theme/CustomThemeActivity.java
index 62a2f26..3a80481 100644
--- a/src/com/android/customization/picker/theme/CustomThemeActivity.java
+++ b/src/com/android/customization/picker/theme/CustomThemeActivity.java
@@ -48,13 +48,13 @@
import com.android.customization.model.theme.custom.ThemeComponentOption.IconOption;
import com.android.customization.model.theme.custom.ThemeComponentOption.ShapeOption;
import com.android.customization.model.theme.custom.ThemeComponentOptionProvider;
-import com.android.customization.module.CustomizationInjector;
-import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.picker.theme.CustomThemeStepFragment.CustomThemeComponentStepHost;
import com.android.wallpaper.R;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost;
+import org.leafos.customization.module.LeafThemePickerInjector;
+
import org.json.JSONException;
import java.util.ArrayList;
@@ -72,7 +72,6 @@
private static final String TAG = "CustomThemeActivity";
private static final String KEY_STATE_CURRENT_STEP = "CustomThemeActivity.currentStep";
- private ThemesUserEventLogger mUserEventLogger;
private List<ComponentStep<?>> mSteps;
private int mCurrentStep;
private CustomThemeManager mCustomThemeManager;
@@ -82,8 +81,7 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
- CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
- mUserEventLogger = (ThemesUserEventLogger) injector.getUserEventLogger(this);
+ LeafThemePickerInjector injector = (LeafThemePickerInjector) InjectorProvider.getInjector();
ThemeBundleProvider themeProvider =
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this));
Intent intent = getIntent();
@@ -106,8 +104,7 @@
mThemeManager = injector.getThemeManager(
new DefaultThemeProvider(this, injector.getCustomizationPreferences(this)),
this,
- new OverlayManagerCompat(this),
- mUserEventLogger);
+ new OverlayManagerCompat(this));
mThemeManager.fetchOptions(null, false);
mCustomThemeManager = CustomThemeManager.create(customTheme, mThemeManager);
if (savedInstanceState != null) {
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index ea9099f..d302d3c 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -88,10 +88,12 @@
mWallpaperImage,
view.findViewById(R.id.wallpaper_preview_surface));
currentWallpaperFactory.createCurrentWallpaperInfos(
+ getContext(),
+ false,
(homeWallpaper, lockWallpaper, presentationMode) -> {
wallpaperPreviewer.setWallpaper(homeWallpaper,
mThemeOptionPreviewer::updateColorForLauncherWidgets);
- }, false);
+ });
// Set theme default name.
mNameEditor = view.findViewById(R.id.custom_theme_name);
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index 3a9a56f..05b1b7c 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -42,7 +42,6 @@
import com.android.customization.model.theme.ThemeBundle;
import com.android.customization.model.theme.ThemeManager;
import com.android.customization.model.theme.custom.CustomTheme;
-import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.picker.WallpaperPreviewer;
import com.android.customization.widget.OptionSelectorController;
import com.android.wallpaper.R;
@@ -82,7 +81,6 @@
private RecyclerView mOptionsContainer;
private OptionSelectorController<ThemeBundle> mOptionsController;
private ThemeManager mThemeManager;
- private ThemesUserEventLogger mEventLogger;
private ThemeBundle mSelectedTheme;
private ContentLoadingProgressBar mLoading;
private View mContent;
@@ -99,8 +97,6 @@
public void onAttach(Context context) {
super.onAttach(context);
mThemeManager = ((ThemeFragmentHost) context).getThemeManager();
- mEventLogger = (ThemesUserEventLogger)
- InjectorProvider.getInjector().getUserEventLogger(context);
}
@Nullable
@@ -131,11 +127,13 @@
mWallpaperImage,
view.findViewById(R.id.wallpaper_preview_surface));
mCurrentWallpaperFactory.createCurrentWallpaperInfos(
+ getContext(),
+ false,
(homeWallpaper, lockWallpaper, presentationMode) -> {
mCurrentHomeWallpaper = homeWallpaper;
mWallpaperPreviewer.setWallpaper(mCurrentHomeWallpaper,
mThemeOptionPreviewer::updateColorForLauncherWidgets);
- }, false);
+ });
return view;
}
@@ -342,8 +340,6 @@
} else {
mSelectedTheme = (ThemeBundle) selectedOption;
mSelectedTheme.setOverrideThemeWallpaper(mCurrentHomeWallpaper);
- mEventLogger.logThemeSelected(mSelectedTheme,
- selectedOption instanceof CustomTheme);
mThemeOptionPreviewer.setPreviewInfo(mSelectedTheme.getPreviewInfo());
if (mThemeInfoView != null && mSelectedTheme != null) {
mThemeInfoView.populateThemeInfo(mSelectedTheme);
diff --git a/src/org/leafos/customization/module/LeafCustomizationSections.java b/src/org/leafos/customization/module/LeafCustomizationSections.java
index 2a4ed10..ab92e3b 100644
--- a/src/org/leafos/customization/module/LeafCustomizationSections.java
+++ b/src/org/leafos/customization/module/LeafCustomizationSections.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 The LeafOS Project
+ * Copyright (c) 2023-2024 The LeafOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,10 +34,10 @@
import com.android.wallpaper.model.CustomizationSectionController;
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController;
import com.android.wallpaper.model.PermissionRequester;
-import com.android.wallpaper.model.WallpaperColorsViewModel;
import com.android.wallpaper.model.WallpaperPreviewNavigator;
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
import com.android.wallpaper.module.CustomizationSections;
+import com.android.wallpaper.picker.customization.data.repository.WallpaperColorsRepository;
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor;
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationPickerViewModel;
import com.android.wallpaper.util.DisplayUtils;
@@ -56,7 +56,7 @@
Screen screen,
FragmentActivity activity,
LifecycleOwner lifecycleOwner,
- WallpaperColorsViewModel wallpaperColorsViewModel,
+ WallpaperColorsRepository WallpaperColorsRepository,
PermissionRequester permissionRequester,
WallpaperPreviewNavigator wallpaperPreviewNavigator,
CustomizationSectionNavigationController sectionNavigationController,
@@ -69,7 +69,7 @@
boolean isTwoPaneAndSmallWidth) {
List<CustomizationSectionController<?>> sections = mDefaultCustomizationSections
.getSectionControllersForScreen(screen, activity, lifecycleOwner,
- wallpaperColorsViewModel, permissionRequester, wallpaperPreviewNavigator,
+ WallpaperColorsRepository, permissionRequester, wallpaperPreviewNavigator,
sectionNavigationController, savedInstanceState, wallpaperInfoFactory,
displayUtils, customizationPickerViewModel,
wallpaperInteractor, wallpaperManager, isTwoPaneAndSmallWidth);
diff --git a/src/org/leafos/customization/module/LeafThemePickerInjector.java b/src/org/leafos/customization/module/LeafThemePickerInjector.java
index 2e4d9e2..2d4a63a 100644
--- a/src/org/leafos/customization/module/LeafThemePickerInjector.java
+++ b/src/org/leafos/customization/module/LeafThemePickerInjector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 The LeafOS Project
+ * Copyright (c) 2023-2024 The LeafOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,10 @@
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.customization.module.ThemePickerInjector;
-import com.android.wallpaper.dispatchers.BackgroundDispatcher;
-import com.android.wallpaper.dispatchers.MainDispatcher;
+import com.android.customization.module.logging.ThemesUserEventLogger;
import com.android.wallpaper.module.CustomizationSections;
+import com.android.wallpaper.picker.di.modules.BackgroundDispatcher;
+import com.android.wallpaper.picker.di.modules.MainDispatcher;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -38,8 +39,9 @@
@Inject
public LeafThemePickerInjector(@MainDispatcher CoroutineScope mainScope,
@MainDispatcher CoroutineDispatcher mainDispatcher,
- @BackgroundDispatcher CoroutineDispatcher bgDispatcher) {
- super(mainScope, mainDispatcher, bgDispatcher);
+ @BackgroundDispatcher CoroutineDispatcher bgDispatcher,
+ ThemesUserEventLogger userEventLogger) {
+ super(mainScope, mainDispatcher, bgDispatcher, userEventLogger);
}
@Override
@@ -54,8 +56,7 @@
public ThemeManager getThemeManager(
ThemeBundleProvider provider,
FragmentActivity activity,
- OverlayManagerCompat overlayManagerCompat,
- ThemesUserEventLogger logger) {
- return new ThemeManager(provider, activity, overlayManagerCompat, logger);
+ OverlayManagerCompat overlayManagerCompat) {
+ return new ThemeManager(provider, activity, overlayManagerCompat);
}
}
diff --git a/src/org/leafos/customization/picker/font/FontFragment.java b/src/org/leafos/customization/picker/font/FontFragment.java
index efd4a72..809d6ed 100644
--- a/src/org/leafos/customization/picker/font/FontFragment.java
+++ b/src/org/leafos/customization/picker/font/FontFragment.java
@@ -33,7 +33,6 @@
import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
import com.android.customization.model.CustomizationOption;
import com.android.customization.model.theme.OverlayManagerCompat;
-import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.picker.WallpaperPreviewer;
import com.android.customization.widget.OptionSelectorController;
import com.android.customization.widget.OptionSelectorController.CheckmarkStyle;
diff --git a/src/org/leafos/customization/picker/iconpack/IconPackFragment.java b/src/org/leafos/customization/picker/iconpack/IconPackFragment.java
index f35c79b..267f550 100644
--- a/src/org/leafos/customization/picker/iconpack/IconPackFragment.java
+++ b/src/org/leafos/customization/picker/iconpack/IconPackFragment.java
@@ -33,7 +33,6 @@
import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
import com.android.customization.model.CustomizationOption;
import com.android.customization.model.theme.OverlayManagerCompat;
-import com.android.customization.module.ThemesUserEventLogger;
import com.android.customization.picker.WallpaperPreviewer;
import com.android.customization.widget.OptionSelectorController;
import com.android.customization.widget.OptionSelectorController.CheckmarkStyle;
diff --git a/src_override/com/android/wallpaper/module/AppModule.java b/src_override/com/android/wallpaper/module/AppModule.java
index bfb0993..2ae7f02 100644
--- a/src_override/com/android/wallpaper/module/AppModule.java
+++ b/src_override/com/android/wallpaper/module/AppModule.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2023 The LeafOS Project
+ * Copyright (C) 2023-2024 The LeafOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,15 @@
import android.content.Context;
+import com.android.customization.model.color.ColorCustomizationManager;
+import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.module.CustomizationInjector;
import com.android.customization.module.DefaultCustomizationPreferences;
+import com.android.customization.module.logging.ThemesUserEventLogger;
+import com.android.customization.module.logging.ThemesUserEventLoggerImpl;
+import com.android.wallpaper.module.logging.UserEventLogger;
+import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory;
+import com.android.wallpaper.util.converter.WallpaperModelFactory;
import org.leafos.customization.module.LeafThemePickerInjector;
@@ -35,6 +42,18 @@
public abstract class AppModule {
@Binds @Singleton public abstract CustomizationInjector bindInjector(LeafThemePickerInjector impl);
+ @Binds
+ @Singleton
+ public abstract UserEventLogger bindUserEventLogger(ThemesUserEventLoggerImpl impl);
+
+ @Binds
+ @Singleton
+ public abstract ThemesUserEventLogger bindThemesUserEventLogger(ThemesUserEventLoggerImpl impl);
+
+ @Binds
+ @Singleton
+ public abstract WallpaperModelFactory bindWallpaperModelFactory(DefaultWallpaperModelFactory impl);
+
@Module
@InstallIn(SingletonComponent.class)
public static class Companion {
@@ -45,5 +64,13 @@
) {
return new DefaultCustomizationPreferences(context);
}
+
+ @Provides
+ @Singleton
+ public static ColorCustomizationManager provideColorCustomizationManager(
+ @ApplicationContext Context context
+ ) {
+ return ColorCustomizationManager.getInstance(context, new OverlayManagerCompat(context));
+ }
}
}
diff --git a/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.java b/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.java
new file mode 100644
index 0000000..db66ae1
--- /dev/null
+++ b/src_override/com/android/wallpaper/picker/di/modules/InteractorModule.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2024 The LeafOS 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.wallpaper.picker.di.modules;
+
+import static com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET;
+
+import android.text.TextUtils;
+import com.android.customization.model.color.ColorCustomizationManager;
+import com.android.wallpaper.picker.customization.data.repository.WallpaperRepository;
+import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor;
+
+import dagger.Module;
+import dagger.Provides;
+import dagger.hilt.InstallIn;
+import dagger.hilt.components.SingletonComponent;
+import javax.inject.Singleton;
+
+/** This class provides the singleton scoped interactors for theme picker. */
+@InstallIn(SingletonComponent.class)
+@Module
+public class InteractorModule {
+
+ @Provides
+ @Singleton
+ public static WallpaperInteractor provideWallpaperInteractor(
+ WallpaperRepository wallpaperRepository,
+ ColorCustomizationManager colorCustomizationManager
+ ) {
+ return new WallpaperInteractor(wallpaperRepository, () -> false);
+ }
+}