Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt +4 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.settingslib.spaprivileged.template.common.UserProfilePager /** * The full screen template for an App List page. * * @param showSystemAppsInitially default false. If true, show system apps initially. * @param noMoreOptions default false. If true, then do not display more options action button, * including the "Show System" / "Hide System" action. * @param header the description header appears before all the applications. Loading @@ -42,6 +43,7 @@ fun <T : AppRecord> AppListPage( title: String, listModel: AppListModel<T>, showInstantApps: Boolean = false, showSystemAppsInitially: Boolean = false, noMoreOptions: Boolean = false, matchAnyUserForAdmin: Boolean = false, noItemMessage: String? = null, Loading @@ -49,7 +51,7 @@ fun <T : AppRecord> AppListPage( header: @Composable () -> Unit = {}, appList: @Composable AppListInput<T>.() -> Unit = { AppList() }, ) { var showSystem by rememberSaveable { mutableStateOf(false) } var showSystem by rememberSaveable { mutableStateOf(showSystemAppsInitially) } SearchScaffold( title = title, actions = { Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt +4 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ interface TogglePermissionAppListModel<T : AppRecord> { val enhancedConfirmationKey: String? get() = null /** Whether the App List page shows the system apps initially. */ val showSystemAppsInitially: Boolean get() = false /** * Loads the extra info for the App List, and generates the [AppRecord] List. * Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppListPage.kt +1 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ internal fun <T : AppRecord> TogglePermissionAppListModel<T>.TogglePermissionApp restrictionsProviderFactory = restrictionsProviderFactory, ) }, showSystemAppsInitially = showSystemAppsInitially, appList = appList, ) } Loading packages/SettingsLib/SpaPrivileged/tests/unit/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt +40 −6 Original line number Diff line number Diff line Loading @@ -51,8 +51,8 @@ class AppListPageTest { } @Test fun appListState_hasCorrectInitialState() { val inputState by setContent() fun appListState_hideSystemAppsInitially_hasCorrectInitialState() { val inputState by setContent(showSystemAppsInitially = false) val state = inputState!!.state assertThat(state.showSystem()).isFalse() Loading @@ -60,8 +60,17 @@ class AppListPageTest { } @Test fun canShowSystem() { val inputState by setContent() fun appListState_showSystemAppsInitially_hasCorrectInitialState() { val inputState by setContent(showSystemAppsInitially = true) val state = inputState!!.state assertThat(state.showSystem()).isTrue() assertThat(state.searchQuery()).isEqualTo("") } @Test fun hideSystemAppsInitially_canShowSystem() { val inputState by setContent(showSystemAppsInitially = false) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() Loading @@ -71,8 +80,19 @@ class AppListPageTest { } @Test fun afterShowSystem_displayHideSystem() { setContent() fun showSystemAppsInitially_canHideSystem() { val inputState by setContent(showSystemAppsInitially = true) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_hide_system)).performClick() val state = inputState!!.state assertThat(state.showSystem()).isFalse() } @Test fun hideSystemAppsInitially_afterShowSystem_displayHideSystem() { setContent(showSystemAppsInitially = false) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() Loading @@ -82,6 +102,18 @@ class AppListPageTest { .assertIsDisplayed() } @Test fun showSystemAppsInitially_afterHideSystem_displayShowSystem() { setContent(showSystemAppsInitially = true) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_hide_system)).performClick() onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)) .assertIsDisplayed() } @Test fun noMoreOptions_notDisplayMoreOptions() { setContent(noMoreOptions = true) Loading @@ -98,6 +130,7 @@ class AppListPageTest { } private fun setContent( showSystemAppsInitially: Boolean = false, noMoreOptions: Boolean = false, header: @Composable () -> Unit = {}, ): State<AppListInput<TestAppRecord>?> { Loading @@ -106,6 +139,7 @@ class AppListPageTest { AppListPage( title = TITLE, listModel = TestAppListModel(), showSystemAppsInitially = showSystemAppsInitially, noMoreOptions = noMoreOptions, header = header, appList = { appListState.value = this }, Loading Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt +4 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.settingslib.spaprivileged.template.common.UserProfilePager /** * The full screen template for an App List page. * * @param showSystemAppsInitially default false. If true, show system apps initially. * @param noMoreOptions default false. If true, then do not display more options action button, * including the "Show System" / "Hide System" action. * @param header the description header appears before all the applications. Loading @@ -42,6 +43,7 @@ fun <T : AppRecord> AppListPage( title: String, listModel: AppListModel<T>, showInstantApps: Boolean = false, showSystemAppsInitially: Boolean = false, noMoreOptions: Boolean = false, matchAnyUserForAdmin: Boolean = false, noItemMessage: String? = null, Loading @@ -49,7 +51,7 @@ fun <T : AppRecord> AppListPage( header: @Composable () -> Unit = {}, appList: @Composable AppListInput<T>.() -> Unit = { AppList() }, ) { var showSystem by rememberSaveable { mutableStateOf(false) } var showSystem by rememberSaveable { mutableStateOf(showSystemAppsInitially) } SearchScaffold( title = title, actions = { Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppList.kt +4 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ interface TogglePermissionAppListModel<T : AppRecord> { val enhancedConfirmationKey: String? get() = null /** Whether the App List page shows the system apps initially. */ val showSystemAppsInitially: Boolean get() = false /** * Loads the extra info for the App List, and generates the [AppRecord] List. * Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/TogglePermissionAppListPage.kt +1 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ internal fun <T : AppRecord> TogglePermissionAppListModel<T>.TogglePermissionApp restrictionsProviderFactory = restrictionsProviderFactory, ) }, showSystemAppsInitially = showSystemAppsInitially, appList = appList, ) } Loading
packages/SettingsLib/SpaPrivileged/tests/unit/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt +40 −6 Original line number Diff line number Diff line Loading @@ -51,8 +51,8 @@ class AppListPageTest { } @Test fun appListState_hasCorrectInitialState() { val inputState by setContent() fun appListState_hideSystemAppsInitially_hasCorrectInitialState() { val inputState by setContent(showSystemAppsInitially = false) val state = inputState!!.state assertThat(state.showSystem()).isFalse() Loading @@ -60,8 +60,17 @@ class AppListPageTest { } @Test fun canShowSystem() { val inputState by setContent() fun appListState_showSystemAppsInitially_hasCorrectInitialState() { val inputState by setContent(showSystemAppsInitially = true) val state = inputState!!.state assertThat(state.showSystem()).isTrue() assertThat(state.searchQuery()).isEqualTo("") } @Test fun hideSystemAppsInitially_canShowSystem() { val inputState by setContent(showSystemAppsInitially = false) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() Loading @@ -71,8 +80,19 @@ class AppListPageTest { } @Test fun afterShowSystem_displayHideSystem() { setContent() fun showSystemAppsInitially_canHideSystem() { val inputState by setContent(showSystemAppsInitially = true) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_hide_system)).performClick() val state = inputState!!.state assertThat(state.showSystem()).isFalse() } @Test fun hideSystemAppsInitially_afterShowSystem_displayHideSystem() { setContent(showSystemAppsInitially = false) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() Loading @@ -82,6 +102,18 @@ class AppListPageTest { .assertIsDisplayed() } @Test fun showSystemAppsInitially_afterHideSystem_displayShowSystem() { setContent(showSystemAppsInitially = true) onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_hide_system)).performClick() onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)) .assertIsDisplayed() } @Test fun noMoreOptions_notDisplayMoreOptions() { setContent(noMoreOptions = true) Loading @@ -98,6 +130,7 @@ class AppListPageTest { } private fun setContent( showSystemAppsInitially: Boolean = false, noMoreOptions: Boolean = false, header: @Composable () -> Unit = {}, ): State<AppListInput<TestAppRecord>?> { Loading @@ -106,6 +139,7 @@ class AppListPageTest { AppListPage( title = TITLE, listModel = TestAppListModel(), showSystemAppsInitially = showSystemAppsInitially, noMoreOptions = noMoreOptions, header = header, appList = { appListState.value = this }, Loading