Use SettingsLib's MainSwitchPreference to replace the Switches which use

LayoutPreference.

Bug: 175181773
Test: Run robotest and apply the widget in Settings and see the ui
Change-Id: I4588d1fc3004970b174e7c5c5d1aa7745f774985
This commit is contained in:
Stanley Wang
2021-01-05 16:09:37 +08:00
parent adcd4f165d
commit 57098f4589
11 changed files with 57 additions and 99 deletions

View File

@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 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.
-->
<!-- For use in a LayoutPreference -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:importantForAccessibility="no">
<com.android.settings.widget.SwitchBar
android:id="@+id/switch_bar"
android:minHeight="?android:attr/actionBarSize"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:paddingStart="0dp"
android:theme="?attr/switchBarTheme"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginStart="@dimen/actionbar_subsettings_contentInsetStart"
android:layout_marginVertical="16dp"
android:text="@string/emergency_gesture_screen_summary"/>
</LinearLayout>

View File

@@ -12581,4 +12581,8 @@
<string name="category_name_others">Others</string>
<!-- General category name [CHAR LIMIT=none] -->
<string name="category_name_general">General</string>
<!-- Do not translate. Title for prevent ringing main switch. [CHAR LIMIT=50] -->
<string name="prevent_ringing_main_switch_title" translatable="false">Use prevent ringing</string>
</resources>

View File

@@ -22,9 +22,8 @@
android:key="pref_app_header"
android:layout="@layout/settings_entity_header" />
<com.android.settingslib.widget.LayoutPreference
android:key="block"
android:layout="@layout/styled_switch_bar" />
<com.android.settingslib.widget.MainSwitchPreference
android:key="block" />
<com.android.settings.notification.app.NotificationFooterPreference
android:key="block_desc" />

View File

@@ -20,16 +20,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/emergency_gesture_screen_title">
<com.android.settingslib.widget.MainSwitchPreference
android:key="gesture_emergency_button_switch_bar"
app:controller="com.android.settings.gestures.EmergencyGesturePreferenceController" />
<com.android.settings.widget.VideoPreference
android:key="emergency_gesture_screen_video"
app:animation="@raw/gesture_double_tap"
app:preview="@drawable/gesture_double_tap"/>
<com.android.settingslib.widget.LayoutPreference
android:key="gesture_emergency_button_switch_bar"
android:layout="@layout/emergency_gesture_switch_bar"
app:controller="com.android.settings.gestures.EmergencyGesturePreferenceController"
app:allowDividerBelow="true"/>
<com.android.settingslib.widget.TopIntroPreference
android:title="@string/emergency_gesture_screen_summary"
app:allowDividerBelow="true" />
<SwitchPreference
android:key="emergency_gesture_sound"

View File

@@ -20,16 +20,15 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/gesture_prevent_ringing_screen_title">
<com.android.settingslib.widget.MainSwitchPreference
android:key="gesture_prevent_ringing_switch" />
<com.android.settings.widget.VideoPreference
android:key="gesture_prevent_ringing_video"
app:animation="@raw/gesture_prevent_ringing"
app:preview="@drawable/gesture_prevent_ringing"
app:controller="com.android.settings.widget.VideoPreferenceController" />
<com.android.settingslib.widget.LayoutPreference
android:key="gesture_prevent_ringing_switch"
android:layout="@layout/styled_switch_bar" />
<PreferenceCategory
android:key="gesture_prevent_ringing_category"
android:title="@string/gesture_prevent_ringing_title" />

View File

@@ -27,13 +27,12 @@
android:selectable="false"
settings:allowDividerBelow="true" />
<com.android.settingslib.widget.MainSwitchPreference
android:key="zen_automatic_rule_switch" />
<com.android.settingslib.widget.ActionButtonsPreference
android:key="zen_action_buttons" />
<com.android.settingslib.widget.LayoutPreference
android:key="zen_automatic_rule_switch"
android:layout="@layout/styled_switch_bar" />
<!-- During events for -->
<DropDownPreference
android:key="calendar"

View File

@@ -27,13 +27,12 @@
android:selectable="false"
settings:allowDividerBelow="true"/>
<com.android.settingslib.widget.MainSwitchPreference
android:key="zen_automatic_rule_switch" />
<com.android.settingslib.widget.ActionButtonsPreference
android:key="zen_action_buttons"/>
<com.android.settingslib.widget.LayoutPreference
android:key="zen_automatic_rule_switch"
android:layout="@layout/styled_switch_bar" />
<!-- Days -->
<Preference
android:key="days"