From bfadd2f44898268e74d98ea70aedb16447eb75d8 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 9 Oct 2023 12:05:55 +0200 Subject: [PATCH 1/5] introduce simple scaffold --- .../commons/compose/lists/SimpleLazyListScaffold.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/lists/SimpleLazyListScaffold.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/lists/SimpleLazyListScaffold.kt index 9eb3b6d98..659c1a00b 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/lists/SimpleLazyListScaffold.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/lists/SimpleLazyListScaffold.kt @@ -254,7 +254,7 @@ fun SimpleLazyListScaffold( } @Composable -fun SimpleLazyListScaffold( +fun SimpleScaffold( modifier: Modifier = Modifier, darkStatusBarIcons: Boolean = true, customTopBar: @Composable (scrolledColor: Color, navigationInteractionSource: MutableInteractionSource, scrollBehavior: TopAppBarScrollBehavior, statusBarColor: Int, colorTransitionFraction: Float, contrastColor: Color) -> Unit, From 9b95029ea7379ffe5c868c0e6befda4aaa4aa992 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 9 Oct 2023 12:08:01 +0200 Subject: [PATCH 2/5] introduce simple scaffold --- .../commons/compose/screens/ManageBlockedNumbersScreen.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt index 4f3ad3ccc..c440b5347 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt @@ -66,6 +66,7 @@ private const val RESET_IMMEDIATELY = 1L private const val RESET_IDLE = -1L private const val BETWEEN_CLICKS_TIME = 200 //time between a click which is slightly lower than the reset time private const val ON_LONG_CLICK_LABEL = "select" + @Composable internal fun ManageBlockedNumbersScreen( goBack: () -> Unit, @@ -96,7 +97,7 @@ internal fun ManageBlockedNumbersScreen( clearSelection() } - SimpleLazyListScaffold( + SimpleScaffold( darkStatusBarIcons = !isInActionMode, customTopBar = { scrolledColor: Color, navigationInteractionSource: MutableInteractionSource, From c4bc4dab1996779740d948b3e522a9e3cecebaaa Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 9 Oct 2023 12:58:57 +0200 Subject: [PATCH 3/5] derive state of for licenses --- .../simplemobiletools/commons/activities/LicenseActivity.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt index 387e9a090..ab0cbb6e9 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/LicenseActivity.kt @@ -3,6 +3,8 @@ package com.simplemobiletools.commons.activities import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import com.simplemobiletools.commons.R import com.simplemobiletools.commons.compose.extensions.enableEdgeToEdgeSimple @@ -19,7 +21,7 @@ class LicenseActivity : ComponentActivity() { enableEdgeToEdgeSimple() setContent { val licenseMask = remember { intent.getLongExtra(APP_LICENSES, 0) or LICENSE_KOTLIN } - val thirdPartyLicenses = remember { initLicenses().filter { licenseMask and it.id != 0L }.toImmutableList() } + val thirdPartyLicenses by remember { derivedStateOf { initLicenses().filter { licenseMask and it.id != 0L }.toImmutableList() } } AppThemeSurface { LicenseScreen( goBack = ::finish, From 869eb0f1636664b8db053c14f19f765862c50c63 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Mon, 9 Oct 2023 12:59:23 +0200 Subject: [PATCH 4/5] refactor: verbosity --- .../commons/activities/ManageBlockedNumbersActivity.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt index c3beee6d2..adb278592 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/activities/ManageBlockedNumbersActivity.kt @@ -82,12 +82,12 @@ class ManageBlockedNumbersActivity : BaseSimpleActivity() { AddOrEditBlockedNumberAlertDialog( blockedNumber = clickedBlockedNumber, alertDialogState = addBlockedNumberDialogState, - deleteBlockedNumber = { - deleteBlockedNumber(it) + deleteBlockedNumber = { blockedNumber -> + deleteBlockedNumber(blockedNumber) updateBlockedNumbers() }, - addBlockedNumber = { - addBlockedNumber(it) + addBlockedNumber = { blockedNumber -> + addBlockedNumber(blockedNumber) clickedBlockedNumber = null updateBlockedNumbers() } From eecd4af5cc7f4b36d423e5c8d262ec418a58dfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Mon, 9 Oct 2023 12:59:49 +0200 Subject: [PATCH 5/5] Add helpers to `BaseConfig` to be able to use `useEnglish` in compose --- .../com/simplemobiletools/commons/helpers/BaseConfig.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt index b82b86759..c82c2cbdd 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/BaseConfig.kt @@ -218,10 +218,14 @@ open class BaseConfig(val context: Context) { prefs.edit().putBoolean(USE_ENGLISH, useEnglish).commit() } + val useEnglishFlow = ::useEnglish.asFlowNonNull() + var wasUseEnglishToggled: Boolean get() = prefs.getBoolean(WAS_USE_ENGLISH_TOGGLED, false) set(wasUseEnglishToggled) = prefs.edit().putBoolean(WAS_USE_ENGLISH_TOGGLED, wasUseEnglishToggled).apply() + val wasUseEnglishToggledFlow = ::wasUseEnglishToggled.asFlowNonNull() + var wasSharedThemeEverActivated: Boolean get() = prefs.getBoolean(WAS_SHARED_THEME_EVER_ACTIVATED, false) set(wasSharedThemeEverActivated) = prefs.edit().putBoolean(WAS_SHARED_THEME_EVER_ACTIVATED, wasSharedThemeEverActivated).apply()