Use the brand new material switches for preferences (#6475)
This commit is contained in:
parent
10c70dd5f1
commit
d51e937e96
|
@ -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'
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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" />
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue