From c777560e5404ef3772d532b5bd1ac42dda5de943 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 30 Jul 2022 14:00:14 +0200 Subject: [PATCH 1/2] layout improvements --- app/src/main/res/layout/fragment_search.xml | 2 +- app/src/main/res/layout/fragment_subscriptions.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index b39ba3a3a..ddc946bc5 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -49,7 +49,7 @@ android:background="@android:color/transparent" android:hint="@string/search_hint" android:imeOptions="actionSearch" - android:inputType="text" + android:inputType="textFilter|textNoSuggestions" android:maxLines="1" android:padding="12dp" /> diff --git a/app/src/main/res/layout/fragment_subscriptions.xml b/app/src/main/res/layout/fragment_subscriptions.xml index 1ecc39cf8..3bdce219d 100644 --- a/app/src/main/res/layout/fragment_subscriptions.xml +++ b/app/src/main/res/layout/fragment_subscriptions.xml @@ -122,6 +122,7 @@ android:layout_gravity="end" android:drawablePadding="5dp" android:paddingHorizontal="10dp" + android:layout_marginBottom="5dp" android:text="@string/most_recent" android:textSize="16sp" app:drawableEndCompat="@drawable/ic_arrow_downward" /> From aa4817f0a83be4b130a92dde1f1ebff1825f64c1 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 30 Jul 2022 15:54:47 +0200 Subject: [PATCH 2/2] improve live video handling --- .../libretube/fragments/PlayerFragment.kt | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) 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 3ca26ffe6..edce28e5b 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -770,12 +770,6 @@ class PlayerFragment : Fragment() { // save related streams for autoplay relatedStreams = response.relatedStreams - // duration that's not greater than 0 indicates that the video is live - if (!(response.duration!! > 0)) { - isLive = true - handleLiveVideo() - } - runOnUiThread { // set media sources for the player setResolutionAndSubtitles(response) @@ -800,21 +794,14 @@ class PlayerFragment : Fragment() { run() } - private fun handleLiveVideo() { - playerBinding.exoTime.visibility = View.GONE - playerBinding.liveLL.visibility = View.VISIBLE - refreshLiveStatus() - } - private fun refreshLiveStatus() { // switch back to normal speed when on the end of live stream - Log.e(exoPlayer.duration.toString(), exoPlayer.currentPosition.toString()) - if (isLive && (exoPlayer.duration - exoPlayer.currentPosition < 10000)) { + if (exoPlayer.duration - exoPlayer.currentPosition < 7000) { exoPlayer.setPlaybackSpeed(1F) playerBinding.speedText.text = "1x" playerBinding.liveSeparator.visibility = View.GONE playerBinding.liveDiff.text = "" - } else if (isLive) { + } else { Log.e(TAG, "changing the time") // live stream but not watching at the end/live position playerBinding.liveSeparator.visibility = View.VISIBLE @@ -977,6 +964,15 @@ class PlayerFragment : Fragment() { } } + private fun handleLiveVideo() { + playerBinding.exoTime.visibility = View.GONE + playerBinding.liveLL.visibility = View.VISIBLE + playerBinding.liveIndicator.setOnClickListener { + exoPlayer.seekTo(exoPlayer.duration - 1000) + } + refreshLiveStatus() + } + private fun initializePlayerView(response: Streams) { binding.apply { playerViewsInfo.text = @@ -994,6 +990,12 @@ class PlayerFragment : Fragment() { playerDescription.text = response.description } + // duration that's not greater than 0 indicates that the video is live + if (!(response.duration!! > 0)) { + isLive = true + handleLiveVideo() + } + playerBinding.exoTitle.text = response.title if (seekBarPreview) enableSeekbarPreview()