summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebraminio <ebrahim@gnu.org>2023-05-29 15:15:25 +0330
committerGitHub <noreply@github.com>2023-05-29 13:45:25 +0200
commitd51e937e9651bcd5955055bee6abffcdefaa0c66 (patch)
tree290755bf29abd5fb820096db3cf6f341d3da37a2
parent10c70dd5f1bd498de32e323cd2832e247df80db7 (diff)
downloadAntennaPod-d51e937e9651bcd5955055bee6abffcdefaa0c66.zip
Use the brand new material switches for preferences (#6475)
-rw-r--r--app/build.gradle2
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java18
-rw-r--r--build.gradle2
-rw-r--r--core/src/main/res/layout/preference_material_switch.xml10
-rw-r--r--core/src/main/res/values/styles.xml10
5 files changed, 33 insertions, 9 deletions
diff --git a/app/build.gradle b/app/build.gradle
index d8dac6b63..680cecc93 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -122,7 +122,7 @@ dependencies {
implementation "com.joanzapata.iconify:android-iconify-material:$iconifyVersion"
implementation 'com.leinardi.android:speed-dial:3.2.0'
implementation 'com.github.ByteHamster:SearchPreference:v2.0.0'
- implementation 'com.github.skydoves:balloon:1.4.0'
+ implementation 'com.github.skydoves:balloon:1.5.3'
implementation 'com.github.xabaras:RecyclerViewSwipeDecorator:1.3'
implementation 'com.annimon:stream:1.2.2'
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
index ecbc1d873..8314382cb 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java
@@ -131,13 +131,7 @@ public class SleepTimerDialog extends DialogFragment {
changeTimesButton.setOnClickListener(changeTimesBtn -> {
int from = SleepTimerPreferences.autoEnableFrom();
int to = SleepTimerPreferences.autoEnableTo();
- TimeRangeDialog dialog = new TimeRangeDialog(getContext(), from, to);
- dialog.setOnDismissListener(v -> {
- SleepTimerPreferences.setAutoEnableFrom(dialog.getFrom());
- SleepTimerPreferences.setAutoEnableTo(dialog.getTo());
- updateAutoEnableText();
- });
- dialog.show();
+ showTimeRangeDialog(getContext(), from, to);
});
Button disableButton = content.findViewById(R.id.disableSleeptimerButton);
@@ -170,6 +164,16 @@ public class SleepTimerDialog extends DialogFragment {
return builder.create();
}
+ private void showTimeRangeDialog(Context context, int from, int to) {
+ TimeRangeDialog dialog = new TimeRangeDialog(context, from, to);
+ dialog.setOnDismissListener(v -> {
+ SleepTimerPreferences.setAutoEnableFrom(dialog.getFrom());
+ SleepTimerPreferences.setAutoEnableTo(dialog.getTo());
+ updateAutoEnableText();
+ });
+ dialog.show();
+ }
+
private void updateAutoEnableText() {
String text;
int from = SleepTimerPreferences.autoEnableFrom();
diff --git a/build.gradle b/build.gradle
index 1a16e1dac..2e306e860 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,7 +31,7 @@ project.ext {
recyclerViewVersion = "1.2.1"
viewPager2Version = "1.1.0-beta01"
workManagerVersion = "2.7.1"
- googleMaterialVersion = "1.6.0"
+ googleMaterialVersion = "1.7.0"
// Third-party
commonslangVersion = "3.6"
diff --git a/core/src/main/res/layout/preference_material_switch.xml b/core/src/main/res/layout/preference_material_switch.xml
new file mode 100644
index 000000000..b39e6b00f
--- /dev/null
+++ b/core/src/main/res/layout/preference_material_switch.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Derived from https://github.com/androidx/androidx/blob/8cb282cc/preference/preference/res/layout/preference_widget_switch_compat.xml -->
+<com.google.android.material.materialswitch.MaterialSwitch
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/switchWidget"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@null"
+ android:clickable="false"
+ android:focusable="false" />
diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml
index 0ebf2aaf7..f1dcd3200 100644
--- a/core/src/main/res/values/styles.xml
+++ b/core/src/main/res/values/styles.xml
@@ -27,6 +27,7 @@
<item name="android:splitMotionEvents">false</item>
<item name="android:fitsSystemWindows">false</item>
<item name="android:windowContentTransitions">true</item>
+ <item name="preferenceTheme">@style/AppPreferenceThemeOverlay</item>
</style>
<style name="Theme.AntennaPod.Light" parent="Theme.AntennaPod.Dynamic.Light">
@@ -68,6 +69,7 @@
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:navigationBarColor">@color/background_darktheme</item>
+ <item name="preferenceTheme">@style/AppPreferenceThemeOverlay</item>
</style>
<style name="Theme.AntennaPod.Dark" parent="Theme.AntennaPod.Dynamic.Dark">
@@ -299,4 +301,12 @@
<item name="android:paddingEnd">8dp</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>