diff --git a/app/src/main/java/com/github/libretube/MyApp.kt b/app/src/main/java/com/github/libretube/MyApp.kt
index d267bc226..8f214834d 100644
--- a/app/src/main/java/com/github/libretube/MyApp.kt
+++ b/app/src/main/java/com/github/libretube/MyApp.kt
@@ -59,8 +59,6 @@ class MyApp : Application() {
existingPeriodicWorkPolicy = ExistingPeriodicWorkPolicy.KEEP
)
- NotificationHelper(this).checkForNewStreams()
-
/**
* Handler for uncaught exceptions
*/
diff --git a/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt b/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt
new file mode 100644
index 000000000..0ff432fc0
--- /dev/null
+++ b/app/src/main/java/com/github/libretube/extensions/SliderPreference.kt
@@ -0,0 +1,44 @@
+package com.github.libretube.extensions
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import androidx.preference.Preference
+import com.github.libretube.R
+import com.github.libretube.databinding.DialogSliderBinding
+import com.github.libretube.preferences.PreferenceHelper
+import com.google.android.material.dialog.MaterialAlertDialogBuilder
+
+/**
+ * Preference that includes a slider
+ */
+class SliderPreference(
+ context: Context,
+ attributeSet: AttributeSet
+) : Preference(
+ context,
+ attributeSet
+) {
+ override fun onClick() {
+ val sliderBinding = DialogSliderBinding.inflate(
+ LayoutInflater.from(context)
+ )
+ sliderBinding.slider.value = PreferenceHelper.getString(
+ key,
+ "1.0"
+ ).toFloat()
+
+ MaterialAlertDialogBuilder(context)
+ .setTitle(title)
+ .setView(sliderBinding.root)
+ .setNegativeButton(R.string.cancel, null)
+ .setPositiveButton(R.string.okay) { _, _ ->
+ PreferenceHelper.putString(
+ key,
+ sliderBinding.slider.value.toString()
+ )
+ }
+ .show()
+ super.onClick()
+ }
+}
diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
index 8de78a041..16dd19e3b 100644
--- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt
@@ -43,6 +43,7 @@ import com.github.libretube.adapters.TrendingAdapter
import com.github.libretube.api.CronetHelper
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.SubscriptionHelper
+import com.github.libretube.databinding.DialogSliderBinding
import com.github.libretube.databinding.DoubleTapOverlayBinding
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.github.libretube.databinding.FragmentPlayerBinding
@@ -509,17 +510,17 @@ class PlayerFragment : BaseFragment() {
}
override fun onPlaybackSpeedClicked() {
- val playbackSpeeds = context?.resources?.getStringArray(R.array.playbackSpeed)!!
- val playbackSpeedValues =
- context?.resources?.getStringArray(R.array.playbackSpeedValues)!!
-
+ val playbackSpeedBinding = DialogSliderBinding.inflate(layoutInflater)
+ playbackSpeedBinding.slider.value = exoPlayer.playbackParameters.speed
// change playback speed dialog
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.change_playback_speed)
- .setItems(playbackSpeeds) { _, index ->
- // set the new playback speed
- val newPlaybackSpeed = playbackSpeedValues[index].toFloat()
- exoPlayer.setPlaybackSpeed(newPlaybackSpeed)
+ .setView(playbackSpeedBinding.root)
+ .setNegativeButton(R.string.cancel, null)
+ .setPositiveButton(R.string.okay) { _, _ ->
+ exoPlayer.setPlaybackSpeed(
+ playbackSpeedBinding.slider.value
+ )
}
.show()
}
@@ -598,11 +599,7 @@ class PlayerFragment : BaseFragment() {
context.getString(R.string.none)
}
// set the playback speed
- val playbackSpeeds = context.resources.getStringArray(R.array.playbackSpeed)
- val playbackSpeedValues =
- context.resources.getStringArray(R.array.playbackSpeedValues)
- val playbackSpeed = exoPlayer.playbackParameters.speed.toString()
- currentPlaybackSpeed = playbackSpeeds[playbackSpeedValues.indexOf(playbackSpeed)]
+ currentPlaybackSpeed = "${exoPlayer.playbackParameters.speed}x"
// set the quality text
val isAdaptive = exoPlayer.videoFormat?.codecs != null
val quality = exoPlayer.videoSize.height
diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt
index 63ca4b25f..2bdbc6af0 100644
--- a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt
+++ b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt
@@ -32,7 +32,7 @@ object PreferenceHelper {
}
fun putString(key: String?, value: String) {
- editor.putString(key, value)
+ editor.putString(key, value).commit()
}
fun getString(key: String?, defValue: String?): String {
diff --git a/app/src/main/res/layout/dialog_slider.xml b/app/src/main/res/layout/dialog_slider.xml
new file mode 100644
index 000000000..7e190af0f
--- /dev/null
+++ b/app/src/main/res/layout/dialog_slider.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml
index 9efa17ea4..634032d6c 100644
--- a/app/src/main/res/values/array.xml
+++ b/app/src/main/res/values/array.xml
@@ -641,29 +641,6 @@
- .mkv
-
- - 0.25x
- - 0.5x
- - 0.75x
- - 1x
- - 1.25x
- - 1.5x
- - 2x
- - 3x
- - 4x
-
-
- - 0.25
- - 0.5
- - 0.75
- - 1.0
- - 1.25
- - 1.5
- - 2.0
- - 3.0
- - 4.0
-
-
- @string/downloads_directory
- @string/music_directory
diff --git a/app/src/main/res/xml/player_settings.xml b/app/src/main/res/xml/player_settings.xml
index f7f9439dd..64fa9f40f 100644
--- a/app/src/main/res/xml/player_settings.xml
+++ b/app/src/main/res/xml/player_settings.xml
@@ -44,14 +44,11 @@
-
+ app:title="@string/playback_speed" />
-
+ app:title="@string/playback_speed" />