Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3dcc641c authored by George Lin's avatar George Lin Committed by Android (Google) Code Review
Browse files

Merge "[TP] Refector wallpaper picker injectors" into tm-qpr-dev

parents 23514122 d99462a2
Loading
Loading
Loading
Loading
+32 −74
Original line number Diff line number Diff line
@@ -32,71 +32,45 @@ import androidx.fragment.app.FragmentActivity;
import com.android.customization.model.theme.OverlayManagerCompat;
import com.android.customization.model.theme.ThemeBundleProvider;
import com.android.customization.model.theme.ThemeManager;
import com.android.wallpaper.model.CategoryProvider;
import com.android.wallpaper.model.LiveWallpaperInfo;
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.BaseWallpaperInjector;
import com.android.wallpaper.module.CustomizationSections;
import com.android.wallpaper.module.DefaultCategoryProvider;
import com.android.wallpaper.module.LoggingOptInStatusProvider;
import com.android.wallpaper.module.WallpaperPicker2Injector;
import com.android.wallpaper.module.WallpaperPreferences;
import com.android.wallpaper.module.WallpaperRotationRefresher;
import com.android.wallpaper.monitor.PerformanceMonitor;
import com.android.wallpaper.picker.CustomizationPickerActivity;
import com.android.wallpaper.picker.ImagePreviewFragment;
import com.android.wallpaper.picker.LivePreviewFragment;
import com.android.wallpaper.picker.PreviewFragment;

public class DefaultCustomizationInjector extends BaseWallpaperInjector
/**
 * A concrete, real implementation of the dependency provider.
 */
public class ThemePickerInjector extends WallpaperPicker2Injector
        implements CustomizationInjector {
    private CategoryProvider mCategoryProvider;
    private CustomizationSections mCustomizationSections;
    private ThemesUserEventLogger mUserEventLogger;
    private WallpaperRotationRefresher mWallpaperRotationRefresher;
    private PerformanceMonitor mPerformanceMonitor;
    private WallpaperPreferences mPrefs;
    private CustomizationSections mCustomizationSections;

    @Override
    public synchronized WallpaperPreferences getPreferences(Context context) {
        if (mPrefs == null) {
            mPrefs = new DefaultCustomizationPreferences(context.getApplicationContext());
        }
        return mPrefs;
    }

    @Override
    public CustomizationPreferences getCustomizationPreferences(Context context) {
        return (CustomizationPreferences) getPreferences(context);
    }

    @Override
    public synchronized CategoryProvider getCategoryProvider(Context context) {
        if (mCategoryProvider == null) {
            mCategoryProvider = new DefaultCategoryProvider(context.getApplicationContext());
    public CustomizationSections getCustomizationSections() {
        if (mCustomizationSections == null) {
            mCustomizationSections = new DefaultCustomizationSections();
        }
        return mCategoryProvider;
        return mCustomizationSections;
    }

    @Override
    public synchronized ThemesUserEventLogger getUserEventLogger(Context context) {
        if (mUserEventLogger == null) {
            mUserEventLogger = new StatsLogUserEventLogger(context);
        }
        return mUserEventLogger;
    public Intent getDeepLinkRedirectIntent(Context context, Uri uri) {
        Intent intent = new Intent();
        intent.setClass(context, CustomizationPickerActivity.class);
        intent.setData(uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        return intent;
    }

    @Override
    public synchronized WallpaperRotationRefresher getWallpaperRotationRefresher() {
        if (mWallpaperRotationRefresher == null) {
            mWallpaperRotationRefresher = new WallpaperRotationRefresher() {
                @Override
                public void refreshWallpaper(Context context, Listener listener) {
                    // Not implemented
                    listener.onError();
                }
            };
        }
        return mWallpaperRotationRefresher;
    public String getDownloadableIntentAction() {
        return null;
    }

    @Override
@@ -120,35 +94,27 @@ public class DefaultCustomizationInjector extends BaseWallpaperInjector
    }

    @Override
    public Intent getDeepLinkRedirectIntent(Context context, Uri uri) {
        Intent intent = new Intent();
        intent.setClass(context, CustomizationPickerActivity.class);
        intent.setData(uri);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        return intent;
    public synchronized ThemesUserEventLogger getUserEventLogger(Context context) {
        if (mUserEventLogger == null) {
            mUserEventLogger = new StatsLogUserEventLogger(context);
        }

    @Override
    public String getDownloadableIntentAction() {
        return null;
        return mUserEventLogger;
    }

    @Override
    public synchronized PerformanceMonitor getPerformanceMonitor() {
        if (mPerformanceMonitor == null) {
            mPerformanceMonitor = new PerformanceMonitor() {
                @Override
                public void recordFullResPreviewLoadedMemorySnapshot() {
                    // No Op
                }
            };
    public synchronized WallpaperPreferences getPreferences(Context context) {
        if (mPrefs == null) {
            mPrefs = new DefaultCustomizationPreferences(context.getApplicationContext());
        }
        return mPerformanceMonitor;
        return mPrefs;
    }

    //
    // Functions from {@link CustomizationInjector}
    //
    @Override
    public synchronized LoggingOptInStatusProvider getLoggingOptInStatusProvider(Context context) {
        return null;
    public CustomizationPreferences getCustomizationPreferences(Context context) {
        return (CustomizationPreferences) getPreferences(context);
    }

    @Override
@@ -156,12 +122,4 @@ public class DefaultCustomizationInjector extends BaseWallpaperInjector
            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger) {
        return new ThemeManager(provider, activity, overlayManagerCompat, logger);
    }

    @Override
    public CustomizationSections getCustomizationSections() {
        if (mCustomizationSections == null) {
            mCustomizationSections = new DefaultCustomizationSections();
        }
        return mCustomizationSections;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ package com.android.customization.picker;

import android.app.Application;

import com.android.customization.module.DefaultCustomizationInjector;
import com.android.customization.module.ThemePickerInjector;
import com.android.wallpaper.module.InjectorProvider;

public class CustomizationPickerApplication extends Application {
@@ -26,6 +26,6 @@ public class CustomizationPickerApplication extends Application {
        super.onCreate();

        // Initialize the injector.
        InjectorProvider.setInjector(new DefaultCustomizationInjector());
        InjectorProvider.setInjector(new ThemePickerInjector());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ public class GridFragment extends AppbarFragment {
                getActivity(), view.findViewById(R.id.wallpaper_preview_image), wallpaperSurface);
        // Loads current Wallpaper.
        CurrentWallpaperInfoFactory factory = InjectorProvider.getInjector()
                .getCurrentWallpaperFactory(getContext().getApplicationContext());
                .getCurrentWallpaperInfoFactory(getContext().getApplicationContext());
        factory.createCurrentWallpaperInfos((homeWallpaper, lockWallpaper, presentationMode) -> {
            mHomeWallpaper = homeWallpaper;
            wallpaperPreviewer.setWallpaper(mHomeWallpaper, /* listener= */ null);
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ public class CustomThemeNameFragment extends CustomThemeStepFragment {
        mTitle = view.findViewById(R.id.component_options_title);
        mTitle.setText(mTitleResId);
        CurrentWallpaperInfoFactory currentWallpaperFactory = InjectorProvider.getInjector()
                .getCurrentWallpaperFactory(getActivity().getApplicationContext());
                .getCurrentWallpaperInfoFactory(getActivity().getApplicationContext());
        CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
        mCustomizationPreferences = injector.getCustomizationPreferences(getContext());

+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ public class ThemeFragment extends AppbarFragment {
        mLoading = view.findViewById(R.id.loading_indicator);
        mError = view.findViewById(R.id.error_section);
        mCurrentWallpaperFactory = InjectorProvider.getInjector()
                .getCurrentWallpaperFactory(getActivity().getApplicationContext());
                .getCurrentWallpaperInfoFactory(getActivity().getApplicationContext());
        mOptionsContainer = view.findViewById(R.id.options_container);

        mThemeOptionPreviewer = new ThemeOptionPreviewer(
Loading