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

Commit b2269c93 authored by Xiaomiao Zhang's avatar Xiaomiao Zhang
Browse files

[Web Content Filters] Implement the top intro preference.

Test: atest SupervisionWebContentFiltersScreenTest
Test: atest SupervisionWebContentFiltersTopIntroPreferenceTest
Test: deploy locally
Fix: 417805808
Flag: android.app.supervision.flags.enable_web_content_filters_screen
Change-Id: Ie98f62385d38b2f152dbe8531594fe96957d5bbe
parent 62754873
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14487,6 +14487,8 @@ Data usage charges may apply.</string>
    <string name="supervision_verify_pin_recovery_title">Verify your email</string>
    <!-- Title for web content filters entry [CHAR LIMIT=60] -->
    <string name="supervision_web_content_filters_title">Web content filters</string>
    <!-- Top intro for web content filters [CHAR LIMIT=NONE] -->
    <string name="supervision_web_content_filters_top_intro">Block mature content on websites and search results on supported apps on this device. Unsupported apps may still show explicit content.</string>
    <!-- Title for web content filters browser category [CHAR LIMIT=60] -->
    <string name="supervision_web_content_filters_browser_title">Websites</string>
    <!-- Title for web content filters browser category block explicit sites option [CHAR LIMIT=60] -->
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ open class SupervisionWebContentFiltersScreen : PreferenceScreenMixin, Preferenc

    override fun getPreferenceHierarchy(context: Context) =
        preferenceHierarchy(context, this) {
            +SupervisionWebContentFiltersTopIntroPreference()
            +PreferenceCategory(
                BROWSER_RADIO_BUTTON_GROUP,
                R.string.supervision_web_content_filters_browser_title,
+38 −0
Original line number Diff line number Diff line
/*
 * 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.settings.R
import com.android.settingslib.metadata.PreferenceMetadata
import com.android.settingslib.preference.PreferenceBinding
import com.android.settingslib.widget.TopIntroPreference

class SupervisionWebContentFiltersTopIntroPreference : PreferenceMetadata, PreferenceBinding {
    override val key: String
        get() = KEY

    override val title: Int
        get() = R.string.supervision_web_content_filters_top_intro

    override fun createWidget(context: Context) = TopIntroPreference(context)

    override fun isIndexable(context: Context) = false

    companion object {
        const val KEY = "supervision_web_content_filters_intro"
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.settingslib.ipc.MessengerServiceRule
import com.android.settingslib.preference.launchFragmentScenario
import com.android.settingslib.widget.FooterPreference
import com.android.settingslib.widget.SelectorWithWidgetPreference
import com.android.settingslib.widget.TopIntroPreference
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
@@ -113,6 +114,18 @@ class SupervisionWebContentFiltersScreenTest {
            .isEqualTo(SettingsEnums.SUPERVISION_WEB_CONTENT_FILTERS)
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
    fun topIntroExists() {
        supervisionWebContentFiltersScreen.launchFragmentScenario().onFragment { fragment ->
                val topIntroPreference =
                    fragment.findPreference<TopIntroPreference>(
                        SupervisionWebContentFiltersTopIntroPreference.KEY
                    )
                assertThat(topIntroPreference).isNotNull()
            }
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
    fun switchSafeSitesPreferences_succeedWithParentPin() {
+33 −0
Original line number Diff line number Diff line
/*
 * 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 androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SupervisionWebContentFiltersTopIntroPreferenceTest {
    private val topIntroPreference = SupervisionWebContentFiltersTopIntroPreference()

    @Test
    fun getTitle() {
        assertThat(topIntroPreference.title)
            .isEqualTo(R.string.supervision_web_content_filters_top_intro)
    }
}