Setup basic layout and resources for the accessibility button settings page

Bug: 173940869
Test: atest AccessibilityButtonFragmentTest
Change-Id: I3f1d8b161d1baadeead36f49f18f00a91fd40b4c
This commit is contained in:
jasonwshsu
2021-02-12 00:49:51 +08:00
parent e8dba387f6
commit 93ef33655c
6 changed files with 221 additions and 0 deletions

View File

@@ -966,6 +966,38 @@
<item>-1</item>
</integer-array>
<!-- Titles for the accessibility button location. [CHAR LIMIT=35] -->
<string-array name="accessibility_button_location_selector_titles">
<item>Floating over other apps</item>
<item>Navigation bar</item>
</string-array>
<!-- Values for the accessibility button location. -->
<!-- Should Keep in sync with Settings.Secure.ACCESSIBILITY_BUTTON_MODE_* -->
<string-array name="accessibility_button_location_selector_values" translatable="false">
<!-- Floating over other apps -->
<item>1</item>
<!-- Navigation bar -->
<item>0</item>
</string-array>
<!-- Titles for the accessibility button size. [CHAR LIMIT=35] -->
<string-array name="accessibility_button_size_selector_titles">
<item>Small</item>
<item>Large</item>
<item>Half Circle</item>
</string-array>
<!-- Values for the accessibility button size. -->
<string-array name="accessibility_button_size_selector_values" translatable="false" >
<!-- Small -->
<item>0</item>
<!-- Large -->
<item>1</item>
<!-- Half Circle -->
<item>2</item>
</string-array>
<!-- Match this with the constants in VpnProfile. --> <skip />
<!-- Short names for each VPN type, not really translatable. [CHAR LIMIT=20] -->
<string-array name="vpn_types" translatable="false">

View File

@@ -5123,6 +5123,26 @@
<string name="accessibility_shortcut_service_on_lock_screen_title">Shortcut from lock screen</string>
<!-- Description of accessibility shortcut. [CHAR LIMIT=NONE] -->
<string name="accessibility_shortcut_description">Allow feature shortcut to turn on from the lock screen. Hold both volume keys for a few seconds.</string>
<!-- Title for the accessibility button page. [CHAR LIMIT=35] -->
<string name="accessibility_button_title">Accessibility button</string>
<!-- Summary text for the accessibility button preference. [CHAR LIMIT=50] -->
<string name="accessibility_button_summary">Quickly access accessibility features</string>
<!-- Description for the accessibility button page. Explain how this page works. [CHAR LIMIT=NONE] -->
<string name="accessibility_button_description">Quickly access accessibility features from any screen. \n\nTo get started, go to accessibility settings and select a feature. Tap on the shortcut and select the accessibility button.</string>
<!-- Title for the location of the accessibility button. [CHAR LIMIT=35] -->
<string name="accessibility_button_location_title">Location</string>
<!-- Title for the size of the accessibility button. [CHAR LIMIT=35] -->
<string name="accessibility_button_size_title">Size</string>
<!-- Title for the fade of the accessibility button. [CHAR LIMIT=35] -->
<string name="accessibility_button_fade_title">Fade when not in use</string>
<!-- Summary for the fade of the accessibility button. [CHAR LIMIT=80] -->
<string name="accessibility_button_fade_summary">Fades after a few seconds so it\u2019s easier to see your screen</string>
<!-- Title for the transparency of the accessibility button. Will become fade when not interact with the accessibility button. [CHAR LIMIT=40] -->
<string name="accessibility_button_opacity_title">Transparency when not in use</string>
<!-- Label on the left side of transparency adjustment slider [CHAR LIMIT=30] -->
<string name="accessibility_button_low_label">Transparent</string>
<!-- Label on the right side of transparency adjustment slider [CHAR LIMIT=30] -->
<string name="accessibility_button_high_label">Non-transparent</string>
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
<!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/accessibility_button_title">
<ListPreference
android:entries="@array/accessibility_button_location_selector_titles"
android:entryValues="@array/accessibility_button_location_selector_values"
android:key="accessibility_button_location"
android:title="@string/accessibility_button_location_title"
android:summary="%s"
android:persistent="false"/>
<ListPreference
android:entries="@array/accessibility_button_size_selector_titles"
android:entryValues="@array/accessibility_button_size_selector_values"
android:key="accessibility_button_size"
android:title="@string/accessibility_button_size_title"
android:summary="%s"
android:persistent="false"/>
<SwitchPreference
android:key="accessibility_button_fade"
android:title="@string/accessibility_button_fade_title"
android:summary="@string/accessibility_button_fade_summary"
android:persistent="false"/>
<com.android.settings.widget.SeekBarPreference
android:key="accessibility_button_opacity"
android:title="@string/accessibility_button_opacity_title"
android:selectable="true"
android:persistent="false"/>
<com.android.settingslib.widget.FooterPreference
android:key="accessibility_button_footer"
android:title="@string/accessibility_button_description"
android:selectable="false"
settings:searchable="false"
android:persistent="false"/>
</PreferenceScreen>

View File

@@ -21,6 +21,13 @@
android:persistent="false"
android:title="@string/accessibility_shortcuts_settings_title">
<Preference
android:fragment="com.android.settings.accessibility.AccessibilityButtonFragment"
android:key="accessibility_button_preference"
android:persistent="false"
android:title="@string/accessibility_button_title"
android:summary="@string/accessibility_button_summary"/>
<SwitchPreference
android:key="accessibility_shortcut_preference"
android:persistent="false"

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2021 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.app.settings.SettingsEnums;
import android.content.Context;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
/** Settings fragment containing accessibility button properties. */
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class AccessibilityButtonFragment extends DashboardFragment {
private static final String TAG = "AccessibilityButtonFragment";
@Override
protected int getPreferenceScreenResId() {
return R.xml.accessibility_button_settings;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_BUTTON_SETTINGS;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_button_settings);
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2021 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 static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.List;
/** Tests for {@link AccessibilityButtonFragment}. */
@RunWith(RobolectricTestRunner.class)
public class AccessibilityButtonFragmentTest {
private Context mContext = ApplicationProvider.getApplicationContext();
@Test
public void getNonIndexableKeys_existInXmlLayout() {
final List<String> niks = AccessibilityButtonFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
final List<String> keys =
XmlTestUtils.getKeysFromPreferenceXml(mContext,
R.xml.accessibility_button_settings);
assertThat(keys).containsAtLeastElementsIn(niks);
}
}