Skip to content

Commit 16ec7a2

Browse files
authored
refactor(settings): remove color customization lock and add thank you button (#144)
1 parent 4489401 commit 16ec7a2

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

app/src/main/kotlin/org/fossify/math/activities/SettingsActivity.kt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@ import android.content.Intent
55
import android.os.Bundle
66
import androidx.activity.compose.setContent
77
import androidx.appcompat.app.AppCompatActivity
8-
import androidx.compose.runtime.Composable
98
import androidx.compose.runtime.derivedStateOf
109
import androidx.compose.runtime.getValue
1110
import androidx.compose.runtime.remember
1211
import androidx.compose.ui.platform.LocalContext
1312
import androidx.lifecycle.compose.collectAsStateWithLifecycle
1413
import org.fossify.commons.activities.CustomizationActivity
15-
import org.fossify.commons.compose.alert_dialog.rememberAlertDialogState
1614
import org.fossify.commons.compose.extensions.enableEdgeToEdgeSimple
1715
import org.fossify.commons.compose.extensions.onEventValue
1816
import org.fossify.commons.compose.theme.AppThemeSurface
1917
import org.fossify.commons.compose.theme.getAppIconIds
2018
import org.fossify.commons.compose.theme.getAppLauncherName
21-
import org.fossify.commons.dialogs.FeatureLockedAlertDialog
22-
import org.fossify.commons.extensions.getCustomizeColorsString
2319
import org.fossify.commons.extensions.isOrWasThankYouInstalled
2420
import org.fossify.commons.extensions.launchPurchaseThankYouIntent
2521
import org.fossify.commons.helpers.APP_ICON_IDS
@@ -58,13 +54,14 @@ class SettingsActivity : AppCompatActivity() {
5854
(wasUseEnglishToggledFlow || Locale.getDefault().language != "en") && !isTiramisuPlus()
5955
}
6056
}
61-
val isOrWasThankYouInstalled = onEventValue { context.isOrWasThankYouInstalled() }
57+
val isOrWasThankYouInstalled = onEventValue {
58+
context.isOrWasThankYouInstalled(allowPretend = false)
59+
}
6260
val displayLanguage = remember { Locale.getDefault().displayLanguage }
63-
val featureLockedDialogState = getFeatureLockedDialogState()
6461
SettingsScreen(
6562
displayLanguage = displayLanguage,
6663
goBack = ::finish,
67-
customizeColors = ::handleCustomizeColorsClick,
64+
customizeColors = ::startCustomizationActivity,
6865
customizeWidgetColors = ::setupCustomizeWidgetColors,
6966
preventPhoneFromSleeping = preventPhoneFromSleeping,
7067
onPreventPhoneFromSleeping = preferences::preventPhoneFromSleeping::set,
@@ -80,22 +77,12 @@ class SettingsActivity : AppCompatActivity() {
8077
},
8178
onSetupLanguagePress = ::launchChangeAppLanguageIntent,
8279
showCheckmarksOnSwitches = showCheckmarksOnSwitches,
83-
lockedCustomizeColorText = getCustomizeColorsString(),
84-
featureLockedDialogState = featureLockedDialogState
8580
)
8681
}
8782
}
8883
}
8984

90-
@Composable
91-
private fun getFeatureLockedDialogState() =
92-
rememberAlertDialogState().apply {
93-
DialogMember {
94-
FeatureLockedAlertDialog(alertDialogState = this, cancelCallback = {})
95-
}
96-
}
97-
98-
private fun handleCustomizeColorsClick() {
85+
private fun startCustomizationActivity() {
9986
Intent(applicationContext, CustomizationActivity::class.java).apply {
10087
putExtra(APP_ICON_IDS, getAppIconIds())
10188
putExtra(APP_LAUNCHER_NAME, getAppLauncherName())

app/src/main/kotlin/org/fossify/math/compose/SettingsScreen.kt

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import androidx.compose.material3.MaterialTheme
55
import androidx.compose.runtime.Composable
66
import androidx.compose.ui.res.stringResource
77
import androidx.compose.ui.tooling.preview.PreviewParameter
8-
import org.fossify.commons.compose.alert_dialog.AlertDialogState
9-
import org.fossify.commons.compose.alert_dialog.rememberAlertDialogState
108
import org.fossify.commons.compose.extensions.BooleanPreviewParameterProvider
119
import org.fossify.commons.compose.extensions.MyDevices
1210
import org.fossify.commons.compose.lists.SimpleColumnScaffold
@@ -35,9 +33,7 @@ internal fun SettingsScreen(
3533
onUseEnglishPress: (Boolean) -> Unit,
3634
onSetupLanguagePress: () -> Unit,
3735
showCheckmarksOnSwitches: Boolean,
38-
lockedCustomizeColorText: String,
39-
displayLanguage: String,
40-
featureLockedDialogState: AlertDialogState
36+
displayLanguage: String
4137
) {
4238
SimpleColumnScaffold(
4339
title = stringResource(id = org.fossify.commons.R.string.settings),
@@ -47,13 +43,9 @@ internal fun SettingsScreen(
4743
SettingsTitleTextComponent(text = stringResource(id = org.fossify.commons.R.string.color_customization))
4844
}) {
4945
SettingsPreferenceComponent(
50-
label = lockedCustomizeColorText,
46+
label = stringResource(id = org.fossify.commons.R.string.customize_colors),
5147
doOnPreferenceClick = {
52-
if (isOrWasThankYouInstalled) {
53-
customizeColors()
54-
} else {
55-
featureLockedDialogState.show()
56-
}
48+
customizeColors()
5749
},
5850
preferenceLabelColor = MaterialTheme.colorScheme.onSurface
5951
)
@@ -123,9 +115,7 @@ private fun SettingsScreenPreview(
123115
isUseEnglishChecked = false,
124116
onUseEnglishPress = {},
125117
onSetupLanguagePress = {},
126-
lockedCustomizeColorText = "Customize Colors",
127118
displayLanguage = "English",
128-
featureLockedDialogState = rememberAlertDialogState(),
129119
showCheckmarksOnSwitches = showCheckmarksOnSwitches
130120
)
131121
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ evalex = "3.5.0"
2121
#Room
2222
room = "2.7.2"
2323
#Fossify
24-
commons = "4.4.2"
24+
commons = "5.0.0"
2525
#Gradle
2626
gradlePlugins-agp = "8.11.1"
2727
#build

0 commit comments

Comments
 (0)