Ver Fonte

Use Material3 switches in XML layouts

(cherry picked from commit da7a64b40dda3368565b329e519da3283c797131)
arkon há 2 anos atrás
pai
commit
e0d23cd688

+ 1 - 1
app/src/main/res/layout/pref_settings.xml

@@ -17,7 +17,7 @@
         app:tint="?attr/colorOnBackground" />
 
     <!-- Matches ID used in SwitchPreferenceCompat -->
-    <androidx.appcompat.widget.SwitchCompat
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/switchWidget"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />

+ 1 - 1
app/src/main/res/layout/pref_widget_switch_material.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<com.google.android.material.switchmaterial.SwitchMaterial
+<com.google.android.material.materialswitch.MaterialSwitch
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/switchWidget"
     android:layout_width="wrap_content"

+ 12 - 12
app/src/main/res/layout/reader_color_filter_settings.xml

@@ -11,12 +11,12 @@
 
         <!-- Brightness -->
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/custom_brightness"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_custom_brightness"
             app:layout_constraintTop_toTopOf="parent" />
 
@@ -61,12 +61,12 @@
 
         <!-- Color filter -->
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/switch_color_filter"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_custom_color_filter"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintStart_toStartOf="parent"
@@ -237,22 +237,22 @@
 
         <!-- Grayscale -->
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/grayscale"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_grayscale"
             android:textColor="?android:attr/textColorSecondary"
             app:layout_constraintTop_toBottomOf="@id/color_filter_mode" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/inverted_colors"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_inverted_colors"
             android:textColor="?android:attr/textColorSecondary"
             app:layout_constraintTop_toBottomOf="@id/grayscale" />

+ 21 - 21
app/src/main/res/layout/reader_general_settings.xml

@@ -17,68 +17,68 @@
             android:entries="@array/reader_themes"
             app:title="@string/pref_reader_theme" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/show_page_number"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_show_page_number"
             android:textColor="?android:attr/textColorSecondary" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/fullscreen"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_fullscreen"
             android:textColor="?android:attr/textColorSecondary" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/cutout_short"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_cutout_short"
             android:textColor="?android:attr/textColorSecondary"
             android:visibility="gone"
             tools:visibility="visible" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/keepscreen"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_keep_screen_on"
             android:textColor="?android:attr/textColorSecondary" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/long_tap"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_read_with_long_tap"
             android:textColor="?android:attr/textColorSecondary" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/always_show_chapter_transition"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_always_show_chapter_transition"
             android:textColor="?android:attr/textColorSecondary" />
 
-        <com.google.android.material.switchmaterial.SwitchMaterial
+        <com.google.android.material.materialswitch.MaterialSwitch
             android:id="@+id/page_transitions"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:paddingStart="16dp"
-            android:paddingEnd="16dp"
+            android:paddingHorizontal="16dp"
+            android:paddingVertical="16dp"
             android:text="@string/pref_page_transitions"
             android:textColor="?android:attr/textColorSecondary" />
 

+ 15 - 15
app/src/main/res/layout/reader_pager_settings.xml

@@ -37,12 +37,12 @@
         android:entries="@array/image_scale_type"
         app:title="@string/pref_image_scale_type" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/landscape_zoom"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_landscape_zoom"
         android:textColor="?android:attr/textColorSecondary" />
 
@@ -53,39 +53,39 @@
         android:entries="@array/zoom_start"
         app:title="@string/pref_zoom_start" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/crop_borders"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_crop_borders"
         android:textColor="?android:attr/textColorSecondary" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/navigate_pan"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_navigate_pan"
         android:textColor="?android:attr/textColorSecondary" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/dual_page_split"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_dual_page_split"
         android:textColor="?android:attr/textColorSecondary" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/dual_page_invert"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_dual_page_invert"
         android:textColor="?android:attr/textColorSecondary"
         android:visibility="gone"

+ 9 - 9
app/src/main/res/layout/reader_webtoon_settings.xml

@@ -37,30 +37,30 @@
         android:entries="@array/webtoon_side_padding"
         app:title="@string/pref_webtoon_side_padding" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/crop_borders_webtoon"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_crop_borders"
         android:textColor="?android:attr/textColorSecondary" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/dual_page_split"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_dual_page_split"
         android:textColor="?android:attr/textColorSecondary" />
 
-    <com.google.android.material.switchmaterial.SwitchMaterial
+    <com.google.android.material.materialswitch.MaterialSwitch
         android:id="@+id/dual_page_invert"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
+        android:paddingHorizontal="16dp"
+        android:paddingVertical="16dp"
         android:text="@string/pref_dual_page_invert"
         android:textColor="?android:attr/textColorSecondary"
         android:visibility="gone"

+ 2 - 0
app/src/main/res/values/themes.xml

@@ -77,6 +77,8 @@
         <item name="bottomNavigationStyle">@style/Widget.Tachiyomi.BottomNavigationView</item>
         <item name="navigationRailStyle">@style/Widget.Tachiyomi.NavigationRailView</item>
         <item name="switchStyle">@style/Widget.Tachiyomi.Switch</item>
+        <item name="materialSwitchStyle">@style/Widget.Material3.CompoundButton.MaterialSwitch</item>
+        <item name="switchPreferenceCompatStyle">@style/Widget.Tachiyomi.Switch</item>
         <item name="sliderStyle">@style/Widget.Tachiyomi.Slider</item>
         <item name="materialCardViewStyle">@style/Widget.Material3.CardView.Elevated</item>
 

+ 1 - 1
gradle/libs.versions.toml

@@ -57,7 +57,7 @@ natural-comparator = "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
 
 markwon = "io.noties.markwon:core:4.6.2"
 
-material = "com.google.android.material:material:1.7.0-alpha01"
+material = "com.google.android.material:material:1.7.0-alpha02"
 androidprocessbutton = "com.github.dmytrodanylyk.android-process-button:library:1.0.4"
 flexible-adapter-core = "com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533"
 flexible-adapter-ui = "com.github.arkon.FlexibleAdapter:flexible-adapter-ui:c8013533"