feat : Add setting to toggle app version visibility in grid popup (#1843)

* Add gridAppVersion setting and wiring

* Implement app version visibility toggle in grid popup

* Add hideAppDetails setting and wiring

* feat : add hideAppDetails toggle and remove gridShowAppVersion
This commit is contained in:
Snow
2026-05-31 16:52:32 +05:30
committed by GitHub
parent b071668743
commit 9017a06239
8 changed files with 53 additions and 12 deletions

View File

@@ -17,11 +17,13 @@ import de.mm20.launcher2.preferences.MeasurementSystem
import de.mm20.launcher2.preferences.TimeFormat
import de.mm20.launcher2.preferences.ui.GridSettings
import de.mm20.launcher2.preferences.ui.LocaleSettings
import de.mm20.launcher2.preferences.ui.SearchUiSettings
import de.mm20.launcher2.preferences.ui.UiSettings
import de.mm20.launcher2.ui.component.ProvideIconShape
import de.mm20.launcher2.ui.locals.LocalCalendarSystemIds
import de.mm20.launcher2.ui.locals.LocalCalendarSystems
import de.mm20.launcher2.ui.locals.LocalFavoritesEnabled
import de.mm20.launcher2.ui.locals.LocalHideAppDetails
import de.mm20.launcher2.ui.locals.LocalGridSettings
import de.mm20.launcher2.ui.locals.LocalMeasurementSystem
import de.mm20.launcher2.ui.locals.LocalTimeFormat
@@ -39,6 +41,7 @@ fun ProvideSettings(
val context = LocalContext.current
val settings: UiSettings = koinInject()
val searchUiSettings: SearchUiSettings = koinInject()
val widgetRepository: WidgetRepository = koinInject()
val localeSettings: LocaleSettings = koinInject()
@@ -57,6 +60,10 @@ fun ProvideSettings(
settings.gridSettings.distinctUntilChanged()
}.collectAsState(GridSettings())
val hideAppDetails by remember {
searchUiSettings.hideAppDetails.distinctUntilChanged()
}.collectAsState(false)
val timeFormat by remember(context) {
localeSettings.timeFormat
.map {
@@ -116,6 +123,7 @@ fun ProvideSettings(
CompositionLocalProvider(
LocalFavoritesEnabled provides favoritesEnabled,
LocalHideAppDetails provides hideAppDetails,
LocalGridSettings provides gridSettings,
LocalTimeFormat provides timeFormat!!,
LocalMeasurementSystem provides measurementSystem!!,

View File

@@ -65,6 +65,7 @@ import de.mm20.launcher2.ui.launcher.search.common.SearchableItemVM
import de.mm20.launcher2.ui.launcher.search.listItemViewModel
import de.mm20.launcher2.ui.launcher.sheets.LocalBottomSheetManager
import de.mm20.launcher2.ui.locals.LocalFavoritesEnabled
import de.mm20.launcher2.ui.locals.LocalHideAppDetails
import de.mm20.launcher2.ui.locals.LocalGridSettings
import kotlinx.coroutines.launch
@@ -80,6 +81,7 @@ fun AppItem(
val badge by viewModel.badge.collectAsStateWithLifecycle(null)
val icon by viewModel.icon.collectAsStateWithLifecycle()
val hideAppDetails = LocalHideAppDetails.current
LaunchedEffect(app) {
viewModel.init(app, iconSize.toInt())
@@ -122,23 +124,24 @@ fun AppItem(
)
}
app.versionName?.let {
if (!hideAppDetails) {
app.versionName?.let {
Text(
text = stringResource(R.string.app_info_version, it),
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(top = 4.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
Text(
text = stringResource(R.string.app_info_version, it),
text = app.componentName.packageName,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(top = 4.dp),
modifier = Modifier.padding(top = 1.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
)
}
Text(
text = app.componentName.packageName,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(top = 1.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
} else {
Text(
stringResource(R.string.profile_private_profile_state_locked),

View File

@@ -21,6 +21,8 @@ val LocalCardStyle = compositionLocalOf { CardStyle() }
val LocalFavoritesEnabled = compositionLocalOf { true }
val LocalHideAppDetails = compositionLocalOf { false }
val LocalGridSettings = compositionLocalOf { GridSettings() }
val LocalTimeFormat = staticCompositionLocalOf { TimeFormat.TwentyFourHour }

View File

@@ -22,6 +22,7 @@ fun AppSearchSettingsScreen() {
val viewModel = viewModel<AppSearchSettingsScreenVM>()
val allApps by viewModel.allApps.collectAsStateWithLifecycle()
val hideAppDetails by viewModel.hideAppDetails.collectAsStateWithLifecycle()
val showList by viewModel.showList.collectAsStateWithLifecycle()
val showListIcons by viewModel.showListIcons.collectAsStateWithLifecycle()
@@ -39,6 +40,14 @@ fun AppSearchSettingsScreen() {
viewModel.setAllApps(it)
}
)
SwitchPreference(
title = stringResource(R.string.preference_search_apps_hide_details),
summary = stringResource(R.string.preference_search_apps_hide_details_summary),
value = hideAppDetails == true,
onValueChanged = {
viewModel.setHideAppDetails(it)
}
)
}
}
item {

View File

@@ -17,10 +17,17 @@ class AppSearchSettingsScreenVM: ViewModel(), KoinComponent {
val allApps = searchUiSettings.allApps
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
val hideAppDetails = searchUiSettings.hideAppDetails
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
fun setAllApps(allApps: Boolean) {
searchUiSettings.setAllApps(allApps)
}
fun setHideAppDetails(hideAppDetails: Boolean) {
searchUiSettings.setHideAppDetails(hideAppDetails)
}
val showList = uiSettings.gridSettings.map { it.showList }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)

View File

@@ -628,6 +628,8 @@
<string name="preference_search_favorites_summary">Show pinned and frequently used items above app grid</string>
<string name="preference_search_apps">Apps</string>
<string name="preference_search_apps_summary">Show all apps when the search field is empty</string>
<string name="preference_search_apps_hide_details">Hide app details</string>
<string name="preference_search_apps_hide_details_summary">When enabled, long-pressing an app item will not show its version and package name</string>
<string name="preference_search_files">Files</string>
<string name="preference_search_files_summary">Search local files and cloud files</string>
<string name="preference_search_contacts">Contacts</string>

View File

@@ -72,6 +72,7 @@ data class LauncherSettingsData internal constructor(
val favoritesCompactTags: Boolean = false,
val searchAllApps: Boolean = true,
val hideAppDetails: Boolean = false,
val fileSearchProviders: Set<String> = setOf("local"),

View File

@@ -70,4 +70,13 @@ class SearchUiSettings internal constructor(
}
}
val hideAppDetails
get() = launcherDataStore.data.map { it.hideAppDetails }.distinctUntilChanged()
fun setHideAppDetails(hideAppDetails: Boolean) {
launcherDataStore.update {
it.copy(hideAppDetails = hideAppDetails)
}
}
}