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

Commit 16ba90e5 authored by Xiaomiao Zhang's avatar Xiaomiao Zhang Committed by Android (Google) Code Review
Browse files

Merge "Create footer preference for web content filters screen." into main

parents d311936f a2995299
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14504,6 +14504,8 @@ Data usage charges may apply.</string>
    <string name="supervision_web_content_filters_search_filter_off_title">SafeSearch filtering OFF</string>
    <!-- Summary for web content filters search category filter off option [CHAR LIMIT=NONE] -->
    <string name="supervision_web_content_filters_search_filter_off_summary">Account settings may still filter or blur explicit results</string>
    <!-- Content of web content filters footer [CHAR LIMIT=NONE] -->
    <string name="supervision_web_content_filters_footer_content">These filters only apply to this device when you visit sites using Chrome and in some Android apps, or use Search.</string>
    <!-- Generic content description that is attached to the preview illustration at the top of an Accessibility feature toggle page. [CHAR LIMIT=NONE] -->
    <!-- Title for supervision PIN verification screen [CHAR LIMIT=60] -->
    <string name="supervision_full_screen_pin_verification_title">Enter supervision PIN</string>
+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 com.android.settings.R
import com.android.settings.widget.FooterPreferenceMetadata

class SupervisionWebContentFiltersFooterPreference : FooterPreferenceMetadata {
    override val key: String
        get() = KEY

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

    // TODO(b/411104868): Add learn more link once help article link is retrieved.

    companion object {
        const val KEY = "web_content_filters_footer"
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ class SupervisionWebContentFiltersScreen : PreferenceScreenCreator {
                    +SupervisionSearchFilterOnPreference(dataStore)
                    +SupervisionSearchFilterOffPreference(dataStore)
                }
            +SupervisionWebContentFiltersFooterPreference()
        }

    companion object {
+37 −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 androidx.test.core.app.ApplicationProvider
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 SupervisionWebContentFiltersFooterPreferenceTest {
    private val context: Context = ApplicationProvider.getApplicationContext()

    private val footerPreference = SupervisionWebContentFiltersFooterPreference()

    @Test
    fun getTitle() {
        assertThat(footerPreference.title)
            .isEqualTo(R.string.supervision_web_content_filters_footer_content)
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.fragment.app.testing.FragmentScenario
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.settings.R
import com.android.settingslib.widget.FooterPreference
import com.android.settingslib.widget.SelectorWithWidgetPreference
import com.google.common.truth.Truth.assertThat
import org.junit.Before
@@ -210,4 +211,18 @@ class SupervisionWebContentFiltersScreenTest {
                assertThat(searchFilterOffPreference.isChecked).isTrue()
            }
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_WEB_CONTENT_FILTERS_SCREEN)
    fun footerPreferenceExists() {
        FragmentScenario.launchInContainer(supervisionWebContentFiltersScreen.fragmentClass())
            .onFragment { fragment ->
                val footerPreference =
                    fragment.findPreference<FooterPreference>(
                        SupervisionWebContentFiltersFooterPreference.KEY
                    )!!

                assertThat(footerPreference).isNotNull()
            }
    }
}