diff --git a/res/drawable/ic_globe.xml b/res/drawable/ic_globe.xml new file mode 100644 index 00000000000..5227b89db56 --- /dev/null +++ b/res/drawable/ic_globe.xml @@ -0,0 +1,25 @@ + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 63bf8b21744..e4a4ab6cfe8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -14255,4 +14255,6 @@ Data usage charges may apply. Change PIN Forgot PIN + + Web content filters diff --git a/src/com/android/settings/supervision/SupervisionDashboardScreen.kt b/src/com/android/settings/supervision/SupervisionDashboardScreen.kt index 5f0159e3f35..86f77f726b6 100644 --- a/src/com/android/settings/supervision/SupervisionDashboardScreen.kt +++ b/src/com/android/settings/supervision/SupervisionDashboardScreen.kt @@ -58,7 +58,7 @@ class SupervisionDashboardScreen : PreferenceScreenCreator { preferenceHierarchy(context, this) { +SupervisionMainSwitchPreference() +TitlelessPreferenceGroup(SUPERVISION_DYNAMIC_GROUP_1) += { - // Empty category for dynamic injection targeting. + +SupervisionWebContentFiltersScreen.KEY } +SupervisionPinManagementScreen.KEY } diff --git a/src/com/android/settings/supervision/SupervisionWebContentFiltersFragment.kt b/src/com/android/settings/supervision/SupervisionWebContentFiltersFragment.kt new file mode 100644 index 00000000000..76db5839c54 --- /dev/null +++ b/src/com/android/settings/supervision/SupervisionWebContentFiltersFragment.kt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.supervision + +import android.content.Context +import com.android.settingslib.preference.PreferenceFragment + +/** + * Fragment to display the Supervision web content filters page (Settings > Supervision> Web content + * filters). + * + * See [SupervisionWebContentFiltersScreen] for details on the page contents. + */ +class SupervisionWebContentFiltersFragment : PreferenceFragment() { + override fun getPreferenceScreenBindingKey(context: Context) = + SupervisionWebContentFiltersScreen.KEY +} diff --git a/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt b/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt new file mode 100644 index 00000000000..ef46b2084da --- /dev/null +++ b/src/com/android/settings/supervision/SupervisionWebContentFiltersScreen.kt @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.supervision + +import android.app.supervision.flags.Flags +import android.content.Context +import com.android.settings.R +import com.android.settingslib.metadata.ProvidePreferenceScreen +import com.android.settingslib.metadata.preferenceHierarchy +import com.android.settingslib.preference.PreferenceScreenCreator + +/** Web content filters landing page (Settings > Supervision > Web content filters). */ +@ProvidePreferenceScreen(SupervisionWebContentFiltersScreen.KEY) +class SupervisionWebContentFiltersScreen : PreferenceScreenCreator { + override fun isFlagEnabled(context: Context) = Flags.enableWebContentFiltersScreen() + + override val key: String + get() = KEY + + override val title: Int + get() = R.string.supervision_web_content_filters_title + + // TODO(b/395134536) update the summary once the string is finalized. + override val icon: Int + get() = R.drawable.ic_globe + + override fun fragmentClass() = SupervisionWebContentFiltersFragment::class.java + + override fun getPreferenceHierarchy(context: Context) = + preferenceHierarchy(context, this) { + // TODO(b/395134536) implement the screen. + } + + companion object { + const val KEY = "supervision_web_content_filters" + } +} diff --git a/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt b/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt new file mode 100644 index 00000000000..b8e208c50b0 --- /dev/null +++ b/tests/robotests/src/com/android/settings/supervision/SupervisionWebContentFiltersScreenTest.kt @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.supervision + +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class SupervisionWebContentFiltersScreenTest { + private val context: Context = ApplicationProvider.getApplicationContext() + private val supervisionWebContentFiltersScreen = SupervisionWebContentFiltersScreen() + + @Test + fun key() { + assertThat(supervisionWebContentFiltersScreen.key) + .isEqualTo(SupervisionWebContentFiltersScreen.KEY) + } + + @Test + fun getTitle() { + assertThat(supervisionWebContentFiltersScreen.getPreferenceTitle(context)) + .isEqualTo("Web content filters") + } +}