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
This commit is contained in:
Chun-Ku Lin
2024-10-17 19:16:51 +00:00
parent 037aae979d
commit 688cc94413
5 changed files with 100 additions and 2 deletions

View File

@@ -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"
}
}

View File

@@ -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);
}

View File

@@ -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"
}
}

View File

@@ -1,2 +1,3 @@
# We do not guard tests - everyone is welcomed to contribute to tests.
per-file *.java=*
per-file *.java=*
per-file *.kt=*

View File

@@ -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)
}
}