From 688cc9441388b9ce51c746a4de8f99faaa931f81 Mon Sep 17 00:00:00 2001 From: Chun-Ku Lin Date: Thu, 17 Oct 2024 19:16:51 +0000 Subject: [PATCH] Create an empty color and motion screen with Catalyst Infra Bug: 373451690 Test: atest ColorAndMotionScreenTest Flag: com.android.settings.flags.catalyst_accessibility_color_and_motion Change-Id: I4bfa5ec4d15bd745d691f586e49318b1b0a9bf6c --- aconfig/catalyst/accessibility.aconfig | 9 +++- .../accessibility/ColorAndMotionFragment.java | 9 ++++ .../accessibility/ColorAndMotionScreen.kt | 43 +++++++++++++++++++ tests/robotests/OWNERS | 3 +- .../accessibility/ColorAndMotionScreenTest.kt | 38 ++++++++++++++++ 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/com/android/settings/accessibility/ColorAndMotionScreen.kt create mode 100644 tests/robotests/src/com/android/settings/accessibility/ColorAndMotionScreenTest.kt diff --git a/aconfig/catalyst/accessibility.aconfig b/aconfig/catalyst/accessibility.aconfig index 80a9d628de8..783706709a1 100644 --- a/aconfig/catalyst/accessibility.aconfig +++ b/aconfig/catalyst/accessibility.aconfig @@ -1,9 +1,16 @@ package: "com.android.settings.flags" container: "system" +flag { + name: "catalyst_accessibility_color_and_motion" + namespace: "android_settings" + description: "Migrate Color and motion screen to the Catalyst infrastructure" + bug: "323791114" +} + 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/ColorAndMotionFragment.java b/src/com/android/settings/accessibility/ColorAndMotionFragment.java index 4ea22260c79..7a7c21dd1af 100644 --- a/src/com/android/settings/accessibility/ColorAndMotionFragment.java +++ b/src/com/android/settings/accessibility/ColorAndMotionFragment.java @@ -17,12 +17,15 @@ package com.android.settings.accessibility; import android.app.settings.SettingsEnums; +import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; import android.view.accessibility.Flags; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.preference.TwoStatePreference; @@ -148,6 +151,12 @@ public class ColorAndMotionFragment extends DashboardFragment { } } + @Nullable + @Override + public String getPreferenceScreenBindingKey(@NonNull Context context) { + return ColorAndMotionScreen.KEY; + } + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider(R.xml.accessibility_color_and_motion); } diff --git a/src/com/android/settings/accessibility/ColorAndMotionScreen.kt b/src/com/android/settings/accessibility/ColorAndMotionScreen.kt new file mode 100644 index 00000000000..20a71e31de4 --- /dev/null +++ b/src/com/android/settings/accessibility/ColorAndMotionScreen.kt @@ -0,0 +1,43 @@ +/* + * 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.flags.Flags +import com.android.settings.R +import com.android.settingslib.metadata.ProvidePreferenceScreen +import com.android.settingslib.metadata.preferenceHierarchy +import com.android.settingslib.preference.PreferenceScreenCreator + +@ProvidePreferenceScreen +class ColorAndMotionScreen : PreferenceScreenCreator { + override val key: String = KEY + override val title: Int = R.string.accessibility_color_and_motion_title + + override fun isFlagEnabled(context: Context) = Flags.catalystAccessibilityColorAndMotion() + + override fun hasCompleteHierarchy(): Boolean = false + + override fun fragmentClass() = ColorAndMotionFragment::class.java + + override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(this) {} + + + companion object { + const val KEY = "accessibility_color_and_motion" + } +} \ No newline at end of file diff --git a/tests/robotests/OWNERS b/tests/robotests/OWNERS index 8a7a27ee4e2..e15af1c1e96 100644 --- a/tests/robotests/OWNERS +++ b/tests/robotests/OWNERS @@ -1,2 +1,3 @@ # We do not guard tests - everyone is welcomed to contribute to tests. -per-file *.java=* \ No newline at end of file +per-file *.java=* +per-file *.kt=* diff --git a/tests/robotests/src/com/android/settings/accessibility/ColorAndMotionScreenTest.kt b/tests/robotests/src/com/android/settings/accessibility/ColorAndMotionScreenTest.kt new file mode 100644 index 00000000000..6d7164eb2a0 --- /dev/null +++ b/tests/robotests/src/com/android/settings/accessibility/ColorAndMotionScreenTest.kt @@ -0,0 +1,38 @@ +/* + * 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.android.settingslib.preference.PreferenceScreenCreator +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class ColorAndMotionScreenTest : CatalystScreenTestCase() { + override val preferenceScreenCreator: PreferenceScreenCreator = ColorAndMotionScreen() + override val flagName: String = Flags.FLAG_CATALYST_ACCESSIBILITY_COLOR_AND_MOTION + + override fun migration() {} + + @Test + fun key() { + assertThat(preferenceScreenCreator.key).isEqualTo(ColorAndMotionScreen.KEY) + } +} \ No newline at end of file