Loading toruslib/lib-torus/build.gradle +0 −3 Original line number Diff line number Diff line Loading @@ -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" Loading weathereffects/debug/src/com/google/android/wallpaper/weathereffects/WallpaperEffectsDebugActivity.kt +11 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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) Loading Loading @@ -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 Loading weathereffects/src/com/google/android/wallpaper/weathereffects/data/repository/WeatherEffectsRepository.kt +26 −21 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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 } } Loading @@ -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") } } Loading weathereffects/src/com/google/android/wallpaper/weathereffects/domain/WeatherEffectsInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,8 @@ class WeatherEffectsInteractor @Inject constructor( suspend fun loadWallpaper() { repository.loadWallpaperFromLocalStorage() } suspend fun saveWallpaper() { repository.saveWallpaper() } } Loading
toruslib/lib-torus/build.gradle +0 −3 Original line number Diff line number Diff line Loading @@ -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" Loading
weathereffects/debug/src/com/google/android/wallpaper/weathereffects/WallpaperEffectsDebugActivity.kt +11 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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) Loading Loading @@ -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 Loading
weathereffects/src/com/google/android/wallpaper/weathereffects/data/repository/WeatherEffectsRepository.kt +26 −21 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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 } } Loading @@ -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") } } Loading
weathereffects/src/com/google/android/wallpaper/weathereffects/domain/WeatherEffectsInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,8 @@ class WeatherEffectsInteractor @Inject constructor( suspend fun loadWallpaper() { repository.loadWallpaperFromLocalStorage() } suspend fun saveWallpaper() { repository.saveWallpaper() } }