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

Commit 77166b07 authored by bobyang's avatar bobyang
Browse files

Show toast if the theme is uninstalled

Flag: com.android.wallpaper.enable_pack_theme_entry
Bug: 433180644
Test: manually

Change-Id: I38d12c056eeefce2e005f5079607877d83466b77
parent 215a9fc1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import kotlinx.coroutines.flow.StateFlow

/** Repository for accessing pack theme data settings. */
interface PackThemeRepository {
    val packThemeData: StateFlow<PackThemeData?>
    val packThemeData: StateFlow<PackThemeData>

    fun refetchPackTheme()
}
+30 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.compose.ui.platform.ComposeView
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.graphics.drawable.DrawableCompat
@@ -528,8 +529,20 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
                                    navigateToPackThemeActivity.invoke(intent)
                                }
                            } else {
                                optionPackThemeHome?.setOnClickListener(null)
                                optionPackThemeLock?.setOnClickListener(null)
                                optionPackThemeHome?.setOnClickListener({
                                    showNoPackThemeIntentErrorMessage(
                                        lifecycleOwner,
                                        view,
                                        optionsViewModel,
                                    )
                                })
                                optionPackThemeLock?.setOnClickListener({
                                    showNoPackThemeIntentErrorMessage(
                                        lifecycleOwner,
                                        view,
                                        optionsViewModel,
                                    )
                                })
                            }
                        }
                    }
@@ -611,6 +624,21 @@ constructor(private val defaultCustomizationOptionsBinder: DefaultCustomizationO
    // Track the current show clock flag. If it turns from false to true, animate fade-in.
    private var isClockCurrentlyShown: Boolean? = null

    private fun showNoPackThemeIntentErrorMessage(
        lifecycleOwner: LifecycleOwner,
        view: View,
        optionsViewModel: ThemePickerCustomizationOptionsViewModel,
    ) {
        lifecycleOwner.lifecycleScope.launch {
            Toast.makeText(
                    view.context,
                    optionsViewModel.packThemeViewModel.noAppErrorMessage,
                    Toast.LENGTH_SHORT,
                )
                .show()
        }
    }

    override fun bindClockPreview(
        context: Context,
        rootView: View,
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ class PackThemeViewModel @Inject constructor(private val interactor: PackThemeIn
            }
        }
    val packThemeData: Flow<PackThemeData> = interactor.packThemeData
    val noAppErrorMessage: String = interactor.noAppErrorMessage

    fun refetchPackTheme() {
        interactor.refetchPackTheme()
+2 −0
Original line number Diff line number Diff line
@@ -27,4 +27,6 @@ interface PackThemeInteractor {
    val packThemeData: Flow<PackThemeData>

    fun refetchPackTheme()

    val noAppErrorMessage: String
}
+2 −0
Original line number Diff line number Diff line
@@ -28,4 +28,6 @@ class ThemePickerPackThemeInteractor @Inject constructor() : PackThemeInteractor
    override val packThemeData: Flow<PackThemeData> = emptyFlow()

    override fun refetchPackTheme() {}

    override val noAppErrorMessage: String = ""
}