Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2a42f21 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Update for AppListItem

Bug: 260660819
Test: Manually with Settings
Change-Id: I67b8ff2d8e280c18e191c63ca891a8d7d3706aed
parent fb8200ae
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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),
        )
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -37,9 +37,7 @@ object UsageStatsPageProvider : SettingsPageProvider {
            title = stringResource(R.string.testing_usage_stats),
            listModel = rememberContext(::UsageStatsListModel),
            primaryUserOnly = true,
        ) { itemModel ->
            AppListItem(itemModel) {}
        }
        ) { AppListItem {} }
    }

    @Composable
+6 −11
Original line number Diff line number Diff line
@@ -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,
    )
}

+9 −14
Original line number Diff line number Diff line
@@ -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 = {
    AppListItem {
        val intent = Intent(context, AppLocalePickerActivity::class.java).apply {
                setData(Uri.parse("package:${itemModel.record.app.packageName}"))
                putExtra("uid", itemModel.record.app.uid)
            data = Uri.parse("package:${record.app.packageName}")
            putExtra("uid", record.app.uid)
        }
        context.startActivity(intent)
    }
    )
}