Messaging: Style the SwitchPreferences

Use the newer style of A15

Change-Id: I75a0e54f70f837d21d3aaa746f2e0ec7af226eda
This commit is contained in:
Michael W
2024-12-17 18:44:28 +01:00
parent 1914db5ea4
commit 5ed268cee1
6 changed files with 33 additions and 8 deletions

View File

@@ -81,6 +81,7 @@ android_app {
"com.android.vcard",
"guava",
"libphonenumber",
"com.google.android.material_material",
],
aaptflags: [

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
SPDX-FileCopyrightText: 2023 The Android Open Source Project
SPDX-License-Identifier: Apache-2.0
-->
<com.google.android.material.materialswitch.MaterialSwitch
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/switchWidget"
android:theme="@style/Theme.Material3.DynamicColors.DayNight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false" />

View File

@@ -35,6 +35,7 @@
<item name="android:textColorHighlight">@color/text_highlight_color</item>
<item name="actionBarStyle">@style/BugleActionBar</item>
<item name="alertDialogTheme">@style/AlertDialogTheme</item>
<item name="preferenceTheme">@style/AppPreferenceThemeOverlay</item>
</style>
<style name="LaunchTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
@@ -638,4 +639,13 @@
<item name="android:background">@color/window_background</item>
<item name="dialogCornerRadius">28dp</item>
</style>
<style name="AppPreferenceThemeOverlay" parent="@style/PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/AppSwitchPreference</item>
</style>
<style name="AppSwitchPreference" parent="@style/Preference.SwitchPreferenceCompat.Material">
<item name="widgetLayout">@layout/preference_material_switch</item>
</style>
</resources>

View File

@@ -37,7 +37,7 @@
</intent>
</PreferenceScreen>
<CheckBoxPreference
<SwitchPreferenceCompat
android:key="@string/send_sound_pref_key"
android:title="@string/send_sound_pref_title"
android:defaultValue="@bool/send_sound_pref_default"
@@ -48,7 +48,7 @@
android:title="@string/notifications_pref_title"
android:persistent="true" />
<SwitchPreference
<SwitchPreferenceCompat
android:key="@string/swipe_right_deletes_conversation_key"
android:title="@string/swipe_to_delete_conversation_pref_title"
android:summary="@string/swipe_to_delete_conversation_pref_summary"

View File

@@ -30,13 +30,13 @@
android:key="@string/mms_phone_number_pref_key"
android:title="@string/mms_phone_number_pref_title" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:key="@string/auto_retrieve_mms_pref_key"
android:title="@string/auto_retrieve_mms_pref_title"
android:summary="@string/auto_retrieve_mms_pref_summary"
android:defaultValue="@bool/auto_retrieve_mms_pref_default" />
<CheckBoxPreference
<SwitchPreferenceCompat
android:key="@string/auto_retrieve_mms_when_roaming_pref_key"
android:dependency="@string/auto_retrieve_mms_pref_key"
android:title="@string/auto_retrieve_mms_when_roaming_pref_title"
@@ -49,7 +49,7 @@
android:key="@string/advanced_category_pref_key"
android:title="@string/advanced_category_pref_title">
<CheckBoxPreference
<SwitchPreferenceCompat
android:key="@string/delivery_reports_pref_key"
android:title="@string/delivery_reports_pref_title"
android:summary="@string/delivery_reports_pref_summary"

View File

@@ -30,7 +30,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreference;
import androidx.preference.SwitchPreferenceCompat;
import com.android.messaging.R;
import com.android.messaging.ui.BugleActionBarActivity;
@@ -89,7 +89,7 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
private Preference mSmsEnabledPreference;
private boolean mIsSmsPreferenceClicked;
private String mSwipeRightToDeleteConversationkey;
private SwitchPreference mSwipeRightToDeleteConversationPreference;
private SwitchPreferenceCompat mSwipeRightToDeleteConversationPreference;
public ApplicationSettingsFragment() {
// Required empty constructor
@@ -111,7 +111,7 @@ public class ApplicationSettingsActivity extends BugleActionBarActivity {
mSwipeRightToDeleteConversationkey = getString(
R.string.swipe_right_deletes_conversation_key);
mSwipeRightToDeleteConversationPreference =
(SwitchPreference) findPreference(mSwipeRightToDeleteConversationkey);
(SwitchPreferenceCompat) findPreference(mSwipeRightToDeleteConversationkey);
mIsSmsPreferenceClicked = false;
final PreferenceScreen advancedScreen = (PreferenceScreen) findPreference(