Update for AppListItem
Bug: 260660819 Test: Manually with Settings Change-Id: I67b8ff2d8e280c18e191c63ca891a8d7d3706aed
This commit is contained in:
@@ -64,10 +64,9 @@ private fun AllAppListPage() {
|
||||
listModel = remember { AllAppListModel() },
|
||||
showInstantApps = true,
|
||||
moreOptions = { ResetAppPreferences(resetAppDialogPresenter::open) }
|
||||
) { itemModel ->
|
||||
) {
|
||||
AppListItem(
|
||||
itemModel = itemModel,
|
||||
onClick = AppInfoSettingsProvider.navigator(app = itemModel.record.app),
|
||||
onClick = AppInfoSettingsProvider.navigator(app = record.app),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,7 @@ object UsageStatsPageProvider : SettingsPageProvider {
|
||||
title = stringResource(R.string.testing_usage_stats),
|
||||
listModel = rememberContext(::UsageStatsListModel),
|
||||
primaryUserOnly = true,
|
||||
) { itemModel ->
|
||||
AppListItem(itemModel) {}
|
||||
}
|
||||
) { AppListItem {} }
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -46,9 +46,7 @@ object AppListNotificationsPageProvider : SettingsPageProvider {
|
||||
AppListPage(
|
||||
title = stringResource(R.string.app_notifications_title),
|
||||
listModel = rememberContext(::AppNotificationsListModel),
|
||||
) {
|
||||
AppNotificationsItem(it)
|
||||
}
|
||||
) { AppNotificationsItem() }
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -62,24 +60,21 @@ object AppListNotificationsPageProvider : SettingsPageProvider {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppNotificationsItem(
|
||||
itemModel: AppListItemModel<AppNotificationsRecord>,
|
||||
) {
|
||||
private fun AppListItemModel<AppNotificationsRecord>.AppNotificationsItem() {
|
||||
val appNotificationsRepository = rememberContext(::AppNotificationRepository)
|
||||
val context = LocalContext.current
|
||||
AppListSwitchItem(
|
||||
itemModel = itemModel,
|
||||
onClick = {
|
||||
navigateToAppNotificationSettings(
|
||||
context = context,
|
||||
app = itemModel.record.app,
|
||||
app = record.app,
|
||||
)
|
||||
},
|
||||
checked = itemModel.record.controller.isEnabled.observeAsState(),
|
||||
checked = record.controller.isEnabled.observeAsState(),
|
||||
changeable = produceState(initialValue = false) {
|
||||
value = appNotificationsRepository.isChangeable(itemModel.record.app)
|
||||
value = appNotificationsRepository.isChangeable(record.app)
|
||||
},
|
||||
onCheckedChange = itemModel.record.controller::setEnabled,
|
||||
onCheckedChange = record.controller::setEnabled,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,7 @@ object AppLanguagesPageProvider : SettingsPageProvider {
|
||||
SettingsBody(stringResource(R.string.desc_app_locale_selection_supported))
|
||||
}
|
||||
},
|
||||
) {
|
||||
AppLanguageItem(it)
|
||||
}
|
||||
) { AppLanguageItem() }
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -68,16 +66,13 @@ object AppLanguagesPageProvider : SettingsPageProvider {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppLanguageItem(itemModel: AppListItemModel<AppLanguagesRecord>) {
|
||||
private fun AppListItemModel<AppLanguagesRecord>.AppLanguageItem() {
|
||||
val context = LocalContext.current
|
||||
AppListItem(
|
||||
itemModel = itemModel,
|
||||
onClick = {
|
||||
val intent = Intent(context, AppLocalePickerActivity::class.java).apply {
|
||||
setData(Uri.parse("package:${itemModel.record.app.packageName}"))
|
||||
putExtra("uid", itemModel.record.app.uid)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
AppListItem {
|
||||
val intent = Intent(context, AppLocalePickerActivity::class.java).apply {
|
||||
data = Uri.parse("package:${record.app.packageName}")
|
||||
putExtra("uid", record.app.uid)
|
||||
}
|
||||
)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user