diff --git a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt index 7a2e207b..8a84379c 100644 --- a/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt +++ b/app/src/main/kotlin/me/eternal/purrfectsnap/ui/manager/pages/home/HomeRootSection.kt @@ -46,13 +46,13 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.automirrored.filled.Help import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Bolt import androidx.compose.material.icons.filled.BugReport import androidx.compose.material.icons.filled.Check import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.Download +import androidx.compose.material.icons.filled.Language import androidx.compose.material.icons.filled.Info import androidx.compose.material.icons.filled.Notifications import androidx.compose.material.icons.filled.Schedule @@ -137,6 +137,7 @@ class HomeRootSection : Routes.Route() { override val translation by lazy { context.translation.getCategory("manager.sections.home") } companion object { + private const val QUICK_TILES_INITIALIZED_PREF = "quick_tiles_initialized" val cardMargin = 10.dp val pageBackgroundGradient = Brush.verticalGradient( listOf( @@ -408,7 +409,7 @@ class HomeRootSection : Routes.Route() { onUpdateAction: () -> Unit, channelLabel: String, isPurrAuraActive: Boolean, - onWikiClick: () -> Unit, + onWebsiteClick: () -> Unit, onTelegramClick: () -> Unit, onGithubClick: () -> Unit, authorName: String, @@ -649,15 +650,15 @@ class HomeRootSection : Routes.Route() { ) { Button( modifier = Modifier.weight(1f), - onClick = onWikiClick, + onClick = onWebsiteClick, colors = ButtonDefaults.buttonColors( containerColor = Color.White, contentColor = Color(0xFF1B152E) ) ) { - Icon(Icons.AutoMirrored.Filled.Help, contentDescription = null, modifier = Modifier.size(18.dp)) + Icon(Icons.Filled.Language, contentDescription = null, modifier = Modifier.size(18.dp)) Spacer(modifier = Modifier.width(8.dp)) - Text(text = translation["wiki_button"], maxLines = 1, overflow = TextOverflow.Ellipsis) + Text(text = "Site", maxLines = 1, overflow = TextOverflow.Ellipsis) } OutlinedButton( modifier = Modifier.weight(1f), @@ -736,8 +737,25 @@ class HomeRootSection : Routes.Route() { val avenirNext = remember { FontFamily(Font(R.font.avenir_next_medium, FontWeight.Medium)) } - val selectedTiles = rememberAsyncMutableStateList(defaultValue = listOf()) { - context.database.getQuickTiles().filter { it.isNotBlank() } + val prefs = remember { context.sharedPreferences } + val allQuickTileNames = remember(cards) { cards.keys.map { it.first } } + val selectedTiles = rememberAsyncMutableStateList(defaultValue = allQuickTileNames) { + val storedTiles = context.database.getQuickTiles().filter { it.isNotBlank() } + val hasInitializedQuickTiles = prefs.getBoolean(QUICK_TILES_INITIALIZED_PREF, false) + when { + storedTiles.isNotEmpty() -> { + if (!hasInitializedQuickTiles) { + prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply() + } + storedTiles + } + hasInitializedQuickTiles -> storedTiles + else -> { + context.database.setQuickTiles(allQuickTileNames) + prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply() + allQuickTileNames + } + } } val updateChannel = context.config.root.global.updateSettings.updateChannel.getNullable() ?: "stable" val channelLabel = if (updateChannel == "prerelease") translation["channel_label_prerelease"] else translation["channel_label_stable"] @@ -952,9 +970,9 @@ class HomeRootSection : Routes.Route() { onUpdateAction = onUpdateButtonClick, channelLabel = channelLabel, isPurrAuraActive = isPurrAuraActive, - onWikiClick = { + onWebsiteClick = { context.androidContext.openLink( - "https://github.com/particle-box/PurrfectSnap/wiki", + "https://purrfectsnap.vercel.app/", context.translation["toast_open_link_failed"] ) }, @@ -1313,6 +1331,7 @@ class HomeRootSection : Routes.Route() { newList.forEach { clearTileOffset(it) } selectedTiles.clear() selectedTiles.addAll(newList) + prefs.edit().putBoolean(QUICK_TILES_INITIALIZED_PREF, true).apply() context.coroutineScope.launch { context.database.setQuickTiles(selectedTiles) }