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

Commit a41fcd37 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11097608 from d63cb1b2 to 24Q1-release

Change-Id: I4df0e9701a586a4c30e88d5ee257b38df1c7983e
parents 36cf9fd9 d63cb1b2
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -55,9 +55,6 @@ android {

dependencies {
    implementation "androidx.appcompat:appcompat:$versions.appcompat"

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlin"

    implementation "androidx.core:core-ktx:$versions.ktx"
    implementation "androidx.slice:slice-builders:$versions.androidXLib"
    implementation "androidx.slice:slice-core:$versions.androidXLib"
+11 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import com.google.android.torus.core.activity.TorusViewerActivity
import com.google.android.torus.core.engine.TorusEngine
import com.google.android.torus.utils.extensions.setImmersiveFullScreen
import com.google.android.wallpaper.weathereffects.dagger.BackgroundScope
import com.google.android.wallpaper.weathereffects.dagger.MainScope
import com.google.android.wallpaper.weathereffects.provider.WallpaperInfoContract
import com.google.android.wallpaper.weathereffects.shared.model.WallpaperFileModel
@@ -50,6 +51,9 @@ class WallpaperEffectsDebugActivity : TorusViewerActivity() {
    @MainScope
    lateinit var mainScope: CoroutineScope
    @Inject
    @BackgroundScope
    lateinit var bgScope: CoroutineScope
    @Inject
    lateinit var context: Context
    @Inject
    lateinit var interactor: WeatherEffectsInteractor
@@ -116,6 +120,7 @@ class WallpaperEffectsDebugActivity : TorusViewerActivity() {
                ComponentName(this, WeatherWallpaperService::class.java)
            )
            this.startActivityForResult(i, SET_WALLPAPER_REQUEST_CODE)
            saveWallpaper()
        }

        rootView.requireViewById<FrameLayout>(R.id.wallpaper_layout)
@@ -187,6 +192,12 @@ class WallpaperEffectsDebugActivity : TorusViewerActivity() {
        }
    }

    private fun saveWallpaper() {
        bgScope.launch {
            interactor.saveWallpaper()
        }
    }

    private fun setDebugText(text: String? = null) {
        val output = rootView.requireViewById<TextView>(R.id.output)
        output.text = text
+26 −21
Original line number Diff line number Diff line
@@ -61,23 +61,6 @@ class WeatherEffectsRepository @Inject constructor(

            val foreground = fgBitmap!!
            val background = bgBitmap!!

            var success = true
            // TODO: Only persist assets when the wallpaper is applied.
            success = success and WallpaperFileUtils.export(
                context,
                WallpaperFileUtils.FG_FILE_NAME,
                foreground,
            )
            success = success and WallpaperFileUtils.export(
                context,
                WallpaperFileUtils.BG_FILE_NAME,
                background,
            )
            if (!success) {
                Log.e(TAG, "Failed to export assets during wallpaper generation")
                return
            }
            _wallpaperImage.value = WallpaperImageModel(
                foreground,
                background,
@@ -85,10 +68,8 @@ class WeatherEffectsRepository @Inject constructor(
            )
        } catch (e: RuntimeException) {
            Log.e(TAG, "Unable to load wallpaper: ", e)
            null
        } catch (e: OutOfMemoryError) {
            Log.e(TAG, "Unable to load wallpaper: ", e)
            null
        }
    }

@@ -115,10 +96,34 @@ class WeatherEffectsRepository @Inject constructor(
            )
        } catch (e: RuntimeException) {
            Log.e(TAG, "Unable to load wallpaper: ", e)
            null
        } catch (e: OutOfMemoryError) {
            Log.e(TAG, "Unable to load wallpaper: ", e)
            null
        }
    }

    suspend fun saveWallpaper() {
        val foreground = _wallpaperImage.value?.foreground
        val background = _wallpaperImage.value?.background

        var success = true
        success = success and (foreground?.let {
            WallpaperFileUtils.export(
                context,
                WallpaperFileUtils.FG_FILE_NAME,
                it,
            )
        } == true)
        success = success and (background?.let {
            WallpaperFileUtils.export(
                context,
                WallpaperFileUtils.BG_FILE_NAME,
                it,
            )
        } == true)
        if (success) {
            Log.d(TAG, "Successfully save wallpaper")
        } else {
            Log.e(TAG, "Failed to save wallpaper")
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -34,4 +34,8 @@ class WeatherEffectsInteractor @Inject constructor(
    suspend fun loadWallpaper() {
        repository.loadWallpaperFromLocalStorage()
    }

    suspend fun saveWallpaper() {
        repository.saveWallpaper()
    }
}