diff --git a/aconfig/catalyst/accessibility.aconfig b/aconfig/catalyst/accessibility.aconfig new file mode 100644 index 00000000000..80a9d628de8 --- /dev/null +++ b/aconfig/catalyst/accessibility.aconfig @@ -0,0 +1,9 @@ +package: "com.android.settings.flags" +container: "system" + +flag { + name: "catalyst_text_reading_screen" + namespace: "android_settings" + description: "Flag for Display size and text" + bug: "323791114" +} \ No newline at end of file diff --git a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java index a90af2182f7..9fc9e1044fc 100644 --- a/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java +++ b/src/com/android/settings/accessibility/TextReadingPreferenceFragment.java @@ -30,6 +30,8 @@ import android.view.View; import android.widget.Toast; import androidx.annotation.IntDef; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import com.android.settings.R; @@ -313,4 +315,9 @@ public class TextReadingPreferenceFragment extends DashboardFragment { public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider(R.xml.accessibility_text_reading_options); + + @Override + public @Nullable String getPreferenceScreenBindingKey(@NonNull Context context) { + return TextReadingScreen.KEY; + } } diff --git a/src/com/android/settings/accessibility/TextReadingScreen.kt b/src/com/android/settings/accessibility/TextReadingScreen.kt new file mode 100644 index 00000000000..8970d5228db --- /dev/null +++ b/src/com/android/settings/accessibility/TextReadingScreen.kt @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 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.accessibility + +import android.content.Context +import com.android.settings.R +import com.android.settings.flags.Flags +import com.android.settingslib.metadata.ProvidePreferenceScreen +import com.android.settingslib.metadata.preferenceHierarchy +import com.android.settingslib.preference.PreferenceScreenCreator + +@ProvidePreferenceScreen +class TextReadingScreen : PreferenceScreenCreator { + override val key: String + get() = KEY + + override val title: Int + get() = R.string.accessibility_text_reading_options_title + + override fun isFlagEnabled(context: Context) = Flags.catalystTextReadingScreen() + + override fun fragmentClass() = TextReadingPreferenceFragment::class.java + + override fun hasCompleteHierarchy() = false + + override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {} + + companion object { + const val KEY = "text_reading_screen" + } +} diff --git a/tests/robotests/src/com/android/settings/accessibility/TextReadingScreenTest.kt b/tests/robotests/src/com/android/settings/accessibility/TextReadingScreenTest.kt new file mode 100644 index 00000000000..bdc69c94587 --- /dev/null +++ b/tests/robotests/src/com/android/settings/accessibility/TextReadingScreenTest.kt @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 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.accessibility + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.android.settings.flags.Flags +import com.android.settingslib.preference.CatalystScreenTestCase +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class TextReadingScreenTest : CatalystScreenTestCase() { + + override val preferenceScreenCreator = TextReadingScreen() + + override val flagName: String + get() = Flags.FLAG_CATALYST_TEXT_READING_SCREEN + + override fun migration() {} + + @Test + fun key() { + assertThat(preferenceScreenCreator.key).isEqualTo(TextReadingScreen.KEY) + } +}