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

Commit 20268af0 authored by Austin Wang's avatar Austin Wang
Browse files

Inject WallpaperInteractor and repository (2/3)

Flag: ACONFIG com.android.wallpaper.multi_crop_preview_ui_flag DEVELOPMENT
Bug: 303317694
Test: launch multi crop preview
Change-Id: I0121da42a69d221b8f229d69607907495fac7779
parent a52691e3
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ViewModelProvider
import com.android.customization.model.color.ColorCustomizationManager
import com.android.customization.model.color.ColorOptionsProvider
import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET
import com.android.customization.model.grid.GridOptionsManager
import com.android.customization.model.mode.DarkModeSnapshotRestorer
@@ -197,6 +196,10 @@ internal constructor(
    }

    override fun getWallpaperInteractor(context: Context): WallpaperInteractor {
        if (getFlags().isMultiCropEnabled() && getFlags().isMultiCropPreviewUiEnabled()) {
            return injectedWallpaperInteractor
        }

        val appContext = context.applicationContext
        return wallpaperInteractor
            ?: WallpaperInteractor(
@@ -206,7 +209,6 @@ internal constructor(
                            client =
                                WallpaperClientImpl(
                                    context = appContext,
                                    infoFactory = getCurrentWallpaperInfoFactory(appContext),
                                    wallpaperManager = WallpaperManager.getInstance(appContext),
                                    wallpaperPreferences = getPreferences(appContext)
                                ),
@@ -216,7 +218,7 @@ internal constructor(
                    shouldHandleReload = {
                        TextUtils.equals(
                            getColorCustomizationManager(appContext).currentColorSource,
                            ColorOptionsProvider.COLOR_SOURCE_PRESET
                            COLOR_SOURCE_PRESET,
                        )
                    }
                )
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.wallpaper.picker.di.modules

import android.text.TextUtils
import com.android.customization.model.color.ColorCustomizationManager
import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_PRESET
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
internal object InteractorModule {

    @Provides
    @Singleton
    fun provideWallpaperInteractor(
        wallpaperRepository: WallpaperRepository,
        colorCustomizationManager: ColorCustomizationManager,
    ): WallpaperInteractor {
        return WallpaperInteractor(wallpaperRepository) {
            TextUtils.equals(colorCustomizationManager.currentColorSource, COLOR_SOURCE_PRESET)
        }
    }
}
+12 −0
Original line number Diff line number Diff line
package com.android.customization

import androidx.test.core.app.ApplicationProvider
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.CustomizationPreferences
import com.android.customization.module.logging.TestThemesUserEventLogger
@@ -66,5 +69,14 @@ abstract class TestModule {
        fun provideDefaultWallpaperModelFactory(): DefaultWallpaperModelFactory {
            return DefaultWallpaperModelFactory()
        }

        @Provides
        @Singleton
        fun provideColorCustomizationManager(): ColorCustomizationManager {
            return ColorCustomizationManager.getInstance(
                ApplicationProvider.getApplicationContext(),
                OverlayManagerCompat(ApplicationProvider.getApplicationContext())
            )
        }
    }
}