diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml
index 10cddc118c..22293f1cf0 100644
--- a/lawnchair/res/values/strings.xml
+++ b/lawnchair/res/values/strings.xml
@@ -38,7 +38,6 @@
Notification Dots
Preferences
About
- Lawnchair 11
News
Support
Twitter
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt
index d7abcceaf8..672a1f0ebc 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt
@@ -41,7 +41,7 @@ fun GeneralPreferences(navController: NavController, interactor: PreferenceInter
NavActionPreference(
label = stringResource(id = R.string.icon_pack),
navController = navController,
- destination = Screen.IconPackPreferences.route,
+ destination = iconPackPreferencesRoute,
showDivider = false
)
}
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryLink.kt b/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryLink.kt
index 3359760a87..e3e6d36f8f 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryLink.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryLink.kt
@@ -13,7 +13,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
@Composable
-fun PreferenceCategoryLink(titleResId: Int, onClick: () -> Unit, subtitleResId: Int?, iconResId: Int?) {
+fun PreferenceCategoryLink(titleResId: Int, onClick: () -> Unit, subtitle: String?, iconResId: Int?) {
Row(
modifier = Modifier
.clickable(onClick = onClick)
@@ -37,13 +37,13 @@ fun PreferenceCategoryLink(titleResId: Int, onClick: () -> Unit, subtitleResId:
style = MaterialTheme.typography.subtitle1,
color = MaterialTheme.colors.onBackground
)
- subtitleResId?.let {
+ subtitle?.let {
CompositionLocalProvider(
LocalContentAlpha provides ContentAlpha.medium,
LocalContentColor provides MaterialTheme.colors.onBackground
) {
Text(
- text = stringResource(id = it),
+ text = it,
style = MaterialTheme.typography.body2,
)
}
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryList.kt b/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryList.kt
index c1ecd4702e..565715db1c 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryList.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/PreferenceCategoryList.kt
@@ -3,16 +3,19 @@ package app.lawnchair.ui.preferences
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.runtime.Composable
+import androidx.compose.ui.platform.LocalContext
import androidx.navigation.NavController
import androidx.navigation.compose.navigate
@Composable
fun PreferenceCategoryList(navController: NavController) {
+ val context = LocalContext.current
+
LazyColumn {
- items(screens) { screen ->
+ items(screens(context)) { screen ->
PreferenceCategoryLink(
titleResId = screen.labelResId,
- subtitleResId = screen.descriptionResId,
+ subtitle = screen.description,
iconResId = screen.iconResId,
onClick = { navController.navigate(screen.route) })
}
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt
index c27fb1e1ee..90628c9bcd 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/Preferences.kt
@@ -2,6 +2,7 @@ package app.lawnchair.ui.preferences
import android.app.Application
import android.content.ComponentName
+import android.content.Context
import android.content.Intent
import android.content.pm.ResolveInfo
import android.provider.Settings.Secure.getString
@@ -24,19 +25,30 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
+import app.lawnchair.ui.preferences.PreferenceViewModel.Screen
import app.lawnchair.util.preferences.PrefManager
+import app.lawnchair.util.preferences.getMajorVersion
import com.android.launcher3.R
import com.android.launcher3.notification.NotificationListener
+const val topRoute = "top"
+const val generalPreferencesRoute = "generalPreferences"
+const val homeScreenPreferencesRoute = "homeScreenPreferences"
+const val iconPackPreferencesRoute = "iconPackPreferences"
+const val dockPreferencesRoute = "dockPreferences"
+const val appDrawerPreferencesRoute = "appDrawerPreferences"
+const val folderPreferencesRoute = "folderPreferences"
+const val aboutRoute = "about"
+
class PreferenceViewModel(application: Application) : AndroidViewModel(application), PreferenceInteractor {
private val pm = PrefManager(application)
+ private val lawnchairNotificationListener = ComponentName(application, NotificationListener::class.java)
private val enabledNotificationListeners: String? by lazy {
getString(
application.contentResolver,
"enabled_notification_listeners"
)
}
- private val lawnchairNotificationListener = ComponentName(application, NotificationListener::class.java)
override val iconPackPackage: MutableState = mutableStateOf(pm.iconPackPackage)
override val allowRotation: MutableState = mutableStateOf(pm.allowRotation)
@@ -161,71 +173,71 @@ class PreferenceViewModel(application: Application) : AndroidViewModel(applicati
return iconPacks
}
+
+ sealed class Screen(
+ val route: String,
+ @StringRes val labelResId: Int,
+ val description: String? = null,
+ @DrawableRes val iconResId: Int? = null
+ ) {
+ object Top : Screen(route = "top", labelResId = R.string.settings)
+
+ class GeneralPreferences(description: String = "") : Screen(
+ route = generalPreferencesRoute,
+ labelResId = R.string.general_label,
+ description = description,
+ iconResId = R.drawable.ic_general
+ )
+
+ class HomeScreenPreferences(description: String = "") : Screen(
+ route = homeScreenPreferencesRoute,
+ labelResId = R.string.home_screen_label,
+ description = description,
+ iconResId = R.drawable.ic_home_screen
+ )
+
+ object IconPackPreferences : Screen(
+ route = iconPackPreferencesRoute,
+ labelResId = R.string.icon_pack
+ )
+
+ class DockPreferences(description: String = "") : Screen(
+ route = dockPreferencesRoute,
+ labelResId = R.string.dock_label,
+ description = description,
+ iconResId = R.drawable.ic_dock
+ )
+
+ class AppDrawerPreferences(description: String = "") : Screen(
+ route = appDrawerPreferencesRoute,
+ labelResId = R.string.app_drawer_label,
+ description = description,
+ iconResId = R.drawable.ic_app_drawer
+ )
+
+ class FolderPreferences(description: String = "") : Screen(
+ route = folderPreferencesRoute,
+ labelResId = R.string.folders_label,
+ description = description,
+ iconResId = R.drawable.ic_folder
+ )
+
+ class About(description: String = "") : Screen(
+ route = aboutRoute,
+ labelResId = R.string.about_label,
+ description = description,
+ iconResId = R.drawable.ic_about
+ )
+ }
}
-sealed class Screen(
- val route: String,
- @StringRes val labelResId: Int,
- @StringRes val descriptionResId: Int? = null,
- @DrawableRes val iconResId: Int? = null
-) {
- object Top : Screen(route = "top", labelResId = R.string.settings)
-
- object GeneralPreferences : Screen(
- route = "generalPreferences",
- labelResId = R.string.general_label,
- descriptionResId = R.string.general_description,
- iconResId = R.drawable.ic_general
- )
-
- object HomeScreenPreferences : Screen(
- route = "homeScreenPreferences",
- labelResId = R.string.home_screen_label,
- descriptionResId = R.string.home_screen_description,
- iconResId = R.drawable.ic_home_screen
- )
-
- object IconPackPreferences : Screen(
- route = "iconPackPreferences",
- labelResId = R.string.icon_pack
- )
-
- object DockPreferences : Screen(
- route = "dockPreferences",
- labelResId = R.string.dock_label,
- descriptionResId = R.string.dock_description,
- iconResId = R.drawable.ic_dock
- )
-
- object AppDrawerPreferences : Screen(
- route = "appDrawerPreferences",
- labelResId = R.string.app_drawer_label,
- descriptionResId = R.string.app_drawer_description,
- iconResId = R.drawable.ic_app_drawer
- )
-
- object FolderPreferences : Screen(
- route = "folderPreferences",
- labelResId = R.string.folders_label,
- descriptionResId = R.string.folders_description,
- iconResId = R.drawable.ic_folder
- )
-
- object About : Screen(
- route = "about",
- labelResId = R.string.about_label,
- descriptionResId = R.string.about_description,
- iconResId = R.drawable.ic_about
- )
-}
-
-val screens = listOf(
- Screen.GeneralPreferences,
- Screen.HomeScreenPreferences,
- Screen.DockPreferences,
- Screen.AppDrawerPreferences,
- Screen.FolderPreferences,
- Screen.About
+fun screens(context: Context) = listOf(
+ Screen.GeneralPreferences(context.getString(R.string.general_description)),
+ Screen.HomeScreenPreferences(context.getString(R.string.home_screen_description)),
+ Screen.DockPreferences(context.getString(R.string.dock_description)),
+ Screen.AppDrawerPreferences(context.getString(R.string.app_drawer_description)),
+ Screen.FolderPreferences(context.getString(R.string.folders_description)),
+ Screen.About("${context.getString(R.string.derived_app_name)} ${getMajorVersion(context)}")
)
@ExperimentalAnimationApi
@@ -241,15 +253,15 @@ fun Preferences(interactor: PreferenceInteractor = viewModel stringResource(id = R.string.settings)
- "homeScreenPreferences" -> stringResource(id = R.string.home_screen_label)
- "generalPreferences" -> stringResource(id = R.string.general_label)
- "iconPackPreferences" -> stringResource(id = R.string.icon_pack)
- "dockPreferences" -> stringResource(id = R.string.dock_label)
- "appDrawerPreferences" -> stringResource(id = R.string.app_drawer_label)
- "folderPreferences" -> stringResource(id = R.string.folders_label)
- "about" -> stringResource(id = R.string.about_label)
+ topRoute -> stringResource(id = R.string.settings)
+ homeScreenPreferencesRoute -> stringResource(id = R.string.home_screen_label)
+ generalPreferencesRoute -> stringResource(id = R.string.general_label)
+ iconPackPreferencesRoute -> stringResource(id = R.string.icon_pack)
+ dockPreferencesRoute -> stringResource(id = R.string.dock_label)
+ appDrawerPreferencesRoute -> stringResource(id = R.string.app_drawer_label)
+ folderPreferencesRoute -> stringResource(id = R.string.folders_label)
+ aboutRoute -> stringResource(id = R.string.about_label)
else -> ""
}
diff --git a/lawnchair/src/app/lawnchair/util/preferences/Versioning.kt b/lawnchair/src/app/lawnchair/util/preferences/Versioning.kt
index 7a99659a54..d6c30ce99a 100644
--- a/lawnchair/src/app/lawnchair/util/preferences/Versioning.kt
+++ b/lawnchair/src/app/lawnchair/util/preferences/Versioning.kt
@@ -19,4 +19,10 @@ fun getFormattedVersionName(context: Context): String {
}
return "$versionSegment $stabilitySegment"
+}
+
+fun getMajorVersion(context: Context): String {
+ val packageInfo: PackageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
+ val versionName = packageInfo.versionName
+ return versionName.split(".")[0]
}
\ No newline at end of file