From c4ccc5d3513772fceb0ae8857d567bddcc5bcb49 Mon Sep 17 00:00:00 2001 From: int3debug <164035730+int3debug@users.noreply.github.com> Date: Fri, 9 Aug 2024 00:34:26 +0200 Subject: [PATCH] feat(ui): settings for thumbnail on seekbar (#1256) --- .../cloudstream3/ui/player/AbstractPlayerFragment.kt | 7 +++++-- .../cloudstream3/ui/player/PreviewGenerator.kt | 9 ++++++++- .../cloudstream3/ui/settings/SettingsPlayer.kt | 5 +++-- app/src/main/res/drawable/preview_seekbar_24.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/settings_player.xml | 6 ++++++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/drawable/preview_seekbar_24.xml diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt index 88c34c87..ee987f44 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt @@ -25,10 +25,13 @@ import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.media3.common.PlaybackException -import androidx.media3.common.util.UnstableApi import androidx.media3.exoplayer.ExoPlayer import androidx.media3.session.MediaSession -import androidx.media3.ui.* +import androidx.media3.ui.AspectRatioFrameLayout +import androidx.media3.ui.DefaultTimeBar +import androidx.media3.ui.PlayerView +import androidx.media3.ui.SubtitleView +import androidx.media3.ui.TimeBar import androidx.preference.PreferenceManager import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat import com.github.rubensousa.previewseekbar.PreviewBar diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt index 2d1feaab..ae800dbd 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt @@ -8,6 +8,9 @@ import android.os.Build import android.util.Log import androidx.annotation.WorkerThread import androidx.core.graphics.scale +import androidx.preference.PreferenceManager +import com.lagradost.cloudstream3.AcraApplication +import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout @@ -62,8 +65,12 @@ interface IPreviewGenerator { companion object { fun new(): IPreviewGenerator { + val userDisabled = AcraApplication.context?.let { ctx -> + PreferenceManager.getDefaultSharedPreferences(ctx)?.getBoolean( + ctx.getString(R.string.preview_seekbar_key), true) == false + } ?: false /** because TV has low ram + not show we disable this for now */ - return if (isLayout(TV)) { + return if (isLayout(TV) || userDisabled) { empty() } else { PreviewGenerator() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayer.kt index 21707ca7..1753032a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsPlayer.kt @@ -45,7 +45,8 @@ class SettingsPlayer : PreferenceFragmentCompat() { ), TV or EMULATOR ) - + + getPref(R.string.preview_seekbar_key)?.hideOn(TV) getPref(R.string.pref_category_android_tv_key)?.hideOn(PHONE) getPref(R.string.video_buffer_length_key)?.setOnPreferenceClickListener { @@ -243,4 +244,4 @@ class SettingsPlayer : PreferenceFragmentCompat() { } } } -} \ No newline at end of file +} diff --git a/app/src/main/res/drawable/preview_seekbar_24.xml b/app/src/main/res/drawable/preview_seekbar_24.xml new file mode 100644 index 00000000..657f6247 --- /dev/null +++ b/app/src/main/res/drawable/preview_seekbar_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b3f0cfd2..8156abbf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -811,4 +811,7 @@ Release Date (Old to New) hide_player_control_names_key Hide names of the player\'s controls + preview_seekbar_key + Seekbar preview + Enable preview thumbnail on seekbar \ No newline at end of file diff --git a/app/src/main/res/xml/settings_player.xml b/app/src/main/res/xml/settings_player.xml index 0039af3a..73f9bb5b 100644 --- a/app/src/main/res/xml/settings_player.xml +++ b/app/src/main/res/xml/settings_player.xml @@ -104,6 +104,12 @@ app:defaultValue="false" android:summary="@string/auto_rotate_video_desc" app:key="@string/auto_rotate_video_key" /> +