diff --git a/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt b/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt
index 00ad42411..12cb149a4 100644
--- a/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt
+++ b/app/src/main/java/com/github/libretube/activities/SettingsActivity.kt
@@ -15,9 +15,6 @@ class SettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
ThemeHelper.updateTheme(this)
- // apply the theme for the preference dialogs
- setTheme(R.style.MaterialAlertDialog)
-
super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
diff --git a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
index c481eaba1..ceeb221bf 100644
--- a/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AdvancedSettings.kt
@@ -2,12 +2,12 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
+import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-class AdvancedSettings : PreferenceFragmentCompat() {
+class AdvancedSettings : MaterialPreferenceFragment() {
val TAG = "AdvancedSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
index c61c5b682..827613604 100644
--- a/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/AppearanceSettings.kt
@@ -7,15 +7,15 @@ import android.provider.Settings
import android.widget.Toast
import androidx.preference.ListPreference
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
import com.github.libretube.dialogs.RequireRestartDialog
import com.github.libretube.util.ThemeHelper
+import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.color.DynamicColors
-class AppearanceSettings : PreferenceFragmentCompat() {
+class AppearanceSettings : MaterialPreferenceFragment() {
private val TAG = "AppearanceSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
diff --git a/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt b/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt
index c40ed8427..bf5e39ce0 100644
--- a/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/GeneralSettings.kt
@@ -2,13 +2,13 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.ListPreference
-import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
import com.github.libretube.dialogs.RequireRestartDialog
+import com.github.libretube.views.MaterialPreferenceFragment
-class GeneralSettings : PreferenceFragmentCompat() {
+class GeneralSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt b/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt
index 969fed55e..12c57e1e5 100644
--- a/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/HistorySettings.kt
@@ -2,12 +2,12 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
+import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-class HistorySettings : PreferenceFragmentCompat() {
+class HistorySettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.history_settings, rootKey)
diff --git a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
index 5bf938c33..06c50c185 100644
--- a/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/InstanceSettings.kt
@@ -11,7 +11,6 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
@@ -22,8 +21,9 @@ import com.github.libretube.dialogs.LogoutDialog
import com.github.libretube.util.ImportHelper
import com.github.libretube.util.PermissionHelper
import com.github.libretube.util.RetrofitInstance
+import com.github.libretube.views.MaterialPreferenceFragment
-class InstanceSettings : PreferenceFragmentCompat() {
+class InstanceSettings : MaterialPreferenceFragment() {
val TAG = "InstanceSettings"
/**
diff --git a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt
index befc17f81..413c94cb0 100644
--- a/app/src/main/java/com/github/libretube/preferences/MainSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/MainSettings.kt
@@ -3,18 +3,18 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.BuildConfig
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
import com.github.libretube.dialogs.UpdateDialog
import com.github.libretube.update.UpdateChecker
+import com.github.libretube.views.MaterialPreferenceFragment
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
-class MainSettings : PreferenceFragmentCompat() {
+class MainSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt b/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt
index 54d8379d3..bea9048aa 100644
--- a/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/NotificationSettings.kt
@@ -2,14 +2,14 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.ListPreference
-import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import androidx.work.ExistingPeriodicWorkPolicy
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
import com.github.libretube.util.NotificationHelper
+import com.github.libretube.views.MaterialPreferenceFragment
-class NotificationSettings : PreferenceFragmentCompat() {
+class NotificationSettings : MaterialPreferenceFragment() {
val TAG = "SettingsFragment"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
index 8d22b72ef..ae1df72ec 100644
--- a/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/PlayerSettings.kt
@@ -3,13 +3,13 @@ package com.github.libretube.preferences
import android.os.Bundle
import androidx.preference.ListPreference
import androidx.preference.Preference
-import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
+import com.github.libretube.views.MaterialPreferenceFragment
import java.util.*
-class PlayerSettings : PreferenceFragmentCompat() {
+class PlayerSettings : MaterialPreferenceFragment() {
val TAG = "PlayerSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
index 1feb8b1de..6654bc8ba 100644
--- a/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
+++ b/app/src/main/java/com/github/libretube/preferences/SponsorBlockSettings.kt
@@ -1,11 +1,11 @@
package com.github.libretube.preferences
import android.os.Bundle
-import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R
import com.github.libretube.activities.SettingsActivity
+import com.github.libretube.views.MaterialPreferenceFragment
-class SponsorBlockSettings : PreferenceFragmentCompat() {
+class SponsorBlockSettings : MaterialPreferenceFragment() {
private val TAG = "SponsorBlockSettings"
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt b/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt
new file mode 100644
index 000000000..1bce4578a
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/views/MaterialPreferenceFragment.kt
@@ -0,0 +1,47 @@
+package com.github.libretube.views
+
+import android.os.Bundle
+import androidx.preference.ListPreference
+import androidx.preference.Preference
+import androidx.preference.PreferenceFragmentCompat
+import com.github.libretube.R
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
+
+/**
+ * PreferenceFragmentCompat using the [MaterialAlertDialogBuilder] instead of the old dialog builder
+ */
+open class MaterialPreferenceFragment : PreferenceFragmentCompat() {
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {}
+
+ override fun onDisplayPreferenceDialog(preference: Preference) {
+ when (preference) {
+ /**
+ * Show a [MaterialAlertDialogBuilder] when the preference is a [ListPreference]
+ */
+ is ListPreference -> {
+ // get the index of the previous selected item
+ val prefIndex = preference.entryValues.indexOf(preference.value)
+ MaterialAlertDialogBuilder(requireContext())
+ .setTitle(preference.title)
+ .setSingleChoiceItems(preference.entries, prefIndex) { dialog, index ->
+
+ // get the new ListPreference value
+ val newValue = preference.entryValues[index].toString()
+
+ // save the new value and call the onPreferenceChange Method
+ preference.value = newValue
+ preference.callChangeListener(newValue)
+
+ // dismiss the dialog
+ dialog.dismiss()
+ }
+ .setNegativeButton(R.string.cancel, null)
+ .show()
+ }
+ /**
+ * Otherwise show the normal dialog, dialogs for other preference types are not supported yet
+ */
+ else -> super.onDisplayPreferenceDialog(preference)
+ }
+ }
+}
diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml
index 96e6f530b..986b322ef 100644
--- a/app/src/main/res/values/style.xml
+++ b/app/src/main/res/values/style.xml
@@ -15,13 +15,6 @@
-
-