From 2651f0e95b32a942a4856fffb3f2f42272c61ba6 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Tue, 9 Aug 2022 14:18:16 +0200 Subject: [PATCH] remove seekbar preview --- .../libretube/activities/MainActivity.kt | 6 ++- .../libretube/fragments/PlayerFragment.kt | 38 ++----------------- .../libretube/preferences/PreferenceKeys.kt | 1 - app/src/main/res/xml/player_settings.xml | 7 ---- 4 files changed, 8 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index 71459065f..0fa212023 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -66,7 +66,11 @@ class MainActivity : BaseActivity() { else ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT // start service that gets called on closure - startService(Intent(this, ClosingService::class.java)) + try { + startService(Intent(this, ClosingService::class.java)) + } catch (e: Exception) { + e.printStackTrace() + } CronetHelper.initCronet(this.applicationContext) ConnectionHelper.imageLoader = ImageLoader.Builder(this.applicationContext) 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 40ce6833d..9d09776d2 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -161,7 +161,6 @@ class PlayerFragment : BaseFragment() { private var videoFormatPreference = "webm" private var defRes = "" private var bufferingGoal = 50000 - private var seekBarPreview = false private var defaultSubtitleCode = "" private var sponsorBlockEnabled = true private var sponsorBlockNotifications = true @@ -310,11 +309,6 @@ class PlayerFragment : BaseFragment() { "50" ).toInt() * 1000 - seekBarPreview = PreferenceHelper.getBoolean( - PreferenceKeys.SEEKBAR_PREVIEW, - false - ) - sponsorBlockEnabled = PreferenceHelper.getBoolean( "sb_enabled_key", true @@ -599,12 +593,12 @@ class PlayerFragment : BaseFragment() { // probably a youtube shorts video if (videoSize.height > videoSize.width) ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT // a video with normal aspect ratio - else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + else ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE } "auto" -> ActivityInfo.SCREEN_ORIENTATION_SENSOR - "landscape" -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + "landscape" -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE "portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT - else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE + else -> ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE } mainActivity.requestedOrientation = orientation } @@ -915,7 +909,6 @@ class PlayerFragment : BaseFragment() { playerBinding.exoTitle.text = response.title - if (seekBarPreview) enableSeekbarPreview() enableDoubleTapToSeek() // init the chapters recyclerview @@ -1173,31 +1166,6 @@ class PlayerFragment : BaseFragment() { } } - // enable seek bar preview - private fun enableSeekbarPreview() { - playerBinding.exoProgress.addListener(object : TimeBar.OnScrubListener { - override fun onScrubStart(timeBar: TimeBar, position: Long) { - exoPlayer.pause() - } - - override fun onScrubMove(timeBar: TimeBar, position: Long) { - val minTimeDiff = 10 * 1000 // 10s - // get the difference between the new and the old position - val diff = abs(exoPlayer.currentPosition - position) - // seek only when the difference is greater than 10 seconds - if (diff >= minTimeDiff) exoPlayer.seekTo(position) - } - - override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) { - exoPlayer.seekTo(position) - exoPlayer.play() - Handler(Looper.getMainLooper()).postDelayed({ - exoPlayerView.hideController() - }, 200) - } - }) - } - private fun initializeChapters() { if (chapters.isNotEmpty()) { // enable chapters in the video description diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt index 1c0b8af8f..15ec07613 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/preferences/PreferenceKeys.kt @@ -54,7 +54,6 @@ object PreferenceKeys { const val PLAYER_VIDEO_FORMAT = "player_video_format" const val DEFAULT_RESOLUTION = "default_res" const val BUFFERING_GOAL = "buffering_goal" - const val SEEKBAR_PREVIEW = "seekbar_preview" const val PLAYER_AUDIO_FORMAT = "player_audio_format" const val PLAYER_AUDIO_QUALITY = "player_audio_quality" const val DEFAULT_SUBTITLE = "default_subtitle" diff --git a/app/src/main/res/xml/player_settings.xml b/app/src/main/res/xml/player_settings.xml index c5cc0e11e..9e72d25dc 100644 --- a/app/src/main/res/xml/player_settings.xml +++ b/app/src/main/res/xml/player_settings.xml @@ -102,13 +102,6 @@ app:key="pause_screen_off" app:title="@string/pauseOnScreenOff" /> - -