Fix qsb in backup screenshot

This commit is contained in:
Suphon Thanakornpakapong
2022-05-22 12:25:51 +07:00
parent 5abb969476
commit fdc9e9735d
2 changed files with 19 additions and 1 deletions
@@ -4,6 +4,23 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import com.patrykmichalik.preferencemanager.Preference
import com.patrykmichalik.preferencemanager.firstBlocking
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@Composable
fun <C, S> Preference<C, S>.asState() = get().collectAsState(initial = firstBlocking())
fun <C, S> Preference<C, S>.subscribeBlocking(
scope: CoroutineScope,
block: (C) -> Unit,
) {
block(firstBlocking())
get()
.onEach { block(it) }
.drop(1)
.distinctUntilChanged()
.launchIn(scope = scope)
}
+2 -1
View File
@@ -19,6 +19,7 @@ import app.lawnchair.launcher
import app.lawnchair.launcherNullable
import app.lawnchair.preferences.PreferenceManager
import app.lawnchair.preferences2.PreferenceManager2
import app.lawnchair.preferences2.subscribeBlocking
import app.lawnchair.qsb.providers.AppSearch
import app.lawnchair.qsb.providers.Google
import app.lawnchair.qsb.providers.GoogleGo
@@ -68,7 +69,7 @@ class QsbLayout(context: Context, attrs: AttributeSet?) : FrameLayout(context, a
val supportsLens = searchProvider == Google
preferenceManager2.themedHotseatQsb.onEach(launchIn = viewAttachedScope) { themed ->
preferenceManager2.themedHotseatQsb.subscribeBlocking(scope = viewAttachedScope) { themed ->
setUpBackground(themed)
val iconRes = if (themed) searchProvider.themedIcon else searchProvider.icon