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

Commit b7fea668 authored by George Lin's avatar George Lin Committed by Android (Google) Code Review
Browse files

Merge "Workspace callback binding (2/2)" into main

parents 3add1dd5 8e69804d
Loading
Loading
Loading
Loading
+128 −107
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.wallpaper.picker.customization.ui.viewmodel.ColorUpdateViewMo
import com.android.wallpaper.picker.customization.ui.viewmodel.CustomizationOptionsViewModel
import javax.inject.Inject
import javax.inject.Singleton
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch

@@ -57,6 +58,9 @@ constructor(
    private val materialColorsGenerator: MaterialColorsGenerator,
) : WorkspaceCallbackBinder {

    private var lockScreenJob: Job? = null
    private var homeScreenJob: Job? = null

    override fun bind(
        workspaceCallback: Message,
        viewModel: CustomizationOptionsViewModel,
@@ -81,7 +85,9 @@ constructor(
        }

        when (screen) {
            Screen.LOCK_SCREEN ->
            Screen.LOCK_SCREEN -> {
                lockScreenJob?.cancel()
                lockScreenJob =
                    lifecycleOwner.lifecycleScope.launch {
                        lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
                            launch {
@@ -152,7 +158,10 @@ constructor(
                            }
                        }
                    }
            Screen.HOME_SCREEN ->
            }
            Screen.HOME_SCREEN -> {
                homeScreenJob?.cancel()
                homeScreenJob =
                    lifecycleOwner.lifecycleScope.launch {
                        lifecycleOwner.repeatOnLifecycle(Lifecycle.State.CREATED) {
                            launch {
@@ -197,12 +206,16 @@ constructor(
                                                    putBoolean(KEY_DARK_MODE, darkMode)
                                                }
                                            }
                                    workspaceCallback.sendMessage(MESSAGE_ID_UPDATE_COLOR, bundle)
                                        workspaceCallback.sendMessage(
                                            MESSAGE_ID_UPDATE_COLOR,
                                            bundle,
                                        )
                                    }
                            }

                            launch {
                            viewModel.appIconPickerViewModel.previewingIsThemeIconEnabled.collect {
                                viewModel.appIconPickerViewModel.previewingIsThemeIconEnabled
                                    .collect {
                                        workspaceCallback.sendMessage(
                                            MESSAGE_ID_UPDATE_ICON_THEMED,
                                            Bundle().apply { putBoolean(KEY_BOOLEAN_VALUE, it) },
@@ -213,6 +226,14 @@ constructor(
                    }
            }
        }
    }

    override fun unbind() {
        lockScreenJob?.cancel()
        lockScreenJob = null
        homeScreenJob?.cancel()
        homeScreenJob = null
    }

    companion object {
        const val MESSAGE_ID_UPDATE_SHAPE = 2586