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

Commit ac213b0b authored by Chris Poultney's avatar Chris Poultney Committed by Automerger Merge Worker
Browse files

Makes legacy Injector @Injectable and adds shared singleton Preferences am: a3c0ca22

parents 233e65db a3c0ca22
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ import com.android.wallpaper.module.CustomizationSections
import com.android.wallpaper.module.FragmentFactory
import com.android.wallpaper.module.UserEventLogger
import com.android.wallpaper.module.WallpaperPicker2Injector
import com.android.wallpaper.module.WallpaperPreferences
import com.android.wallpaper.picker.CustomizationPickerActivity
import com.android.wallpaper.picker.ImagePreviewFragment
import com.android.wallpaper.picker.LivePreviewFragment
@@ -105,7 +104,6 @@ internal constructor(
) : WallpaperPicker2Injector(mainScope, bgDispatcher), CustomizationInjector {
    private var customizationSections: CustomizationSections? = null
    private var userEventLogger: UserEventLogger? = null
    private var prefs: WallpaperPreferences? = null
    private var wallpaperInteractor: WallpaperInteractor? = null
    private var keyguardQuickAffordancePickerInteractor: KeyguardQuickAffordancePickerInteractor? =
        null
@@ -208,12 +206,6 @@ internal constructor(
                .also { userEventLogger = it }
    }

    @Synchronized
    override fun getPreferences(context: Context): WallpaperPreferences {
        return prefs
            ?: DefaultCustomizationPreferences(context.applicationContext).also { prefs = it }
    }

    override fun getFragmentFactory(): FragmentFactory? {
        return fragmentFactory ?: ThemePickerFragmentFactory().also { fragmentFactory }
    }
+3 −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.ThemePickerInjector;
import com.android.customization.module.CustomizationInjector;
import com.android.wallpaper.module.InjectorProvider;

import dagger.hilt.android.HiltAndroidApp;
@@ -30,7 +30,8 @@ import javax.inject.Inject;
@HiltAndroidApp(Application.class)
public class CustomizationPickerApplication extends Hilt_CustomizationPickerApplication {

    @Inject ThemePickerInjector mInjector;
    @Inject
    CustomizationInjector mInjector;

    @Override
    public void onCreate() {
+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.module

import android.content.Context
import com.android.customization.module.CustomizationInjector
import com.android.customization.module.DefaultCustomizationPreferences
import com.android.customization.module.ThemePickerInjector
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class AppModule {
    @Binds @Singleton abstract fun bindInjector(impl: ThemePickerInjector): CustomizationInjector

    companion object {
        @Provides
        @Singleton
        fun provideWallpaperPreferences(
            @ApplicationContext context: Context
        ): WallpaperPreferences {
            return DefaultCustomizationPreferences(context)
        }
    }
}