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 f149862c1..d5618ef91 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -21,7 +21,6 @@ import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.os.bundleOf -import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.navigation.NavController import androidx.navigation.findNavController diff --git a/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt index 09193e57f..832573fab 100644 --- a/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/HomeFragment.kt @@ -17,7 +17,6 @@ import com.github.libretube.util.LocaleHelper import com.github.libretube.util.RetrofitInstance import retrofit2.HttpException import java.io.IOException -import java.util.* class HomeFragment : Fragment() { private val TAG = "HomeFragment" 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 6fb47e1fc..ce1bf0581 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -75,6 +75,7 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource import com.google.android.exoplayer2.ui.AspectRatioFrameLayout import com.google.android.exoplayer2.ui.PlayerNotificationManager import com.google.android.exoplayer2.ui.StyledPlayerView +import com.google.android.exoplayer2.ui.TimeBar import com.google.android.exoplayer2.upstream.DataSource import com.google.android.exoplayer2.upstream.DefaultDataSource import com.google.android.exoplayer2.upstream.DefaultHttpDataSource @@ -692,6 +693,7 @@ class PlayerFragment : Fragment() { playerBinding.exoTitle.text = response.title + enableSeekbarPreview() enableDoubleTapToSeek() // init the chapters recyclerview @@ -863,8 +865,7 @@ class PlayerFragment : Fragment() { } override fun singleClicked() { - if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController() - else exoPlayerView.showController() + toggleController() } } ) @@ -883,14 +884,39 @@ class PlayerFragment : Fragment() { } override fun singleClicked() { - if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController() - else exoPlayerView.showController() + toggleController() } } ) ) } + // toggle the visibility of the player controller + private fun toggleController() { + if (exoPlayerView.isControllerFullyVisible) exoPlayerView.hideController() + else exoPlayerView.showController() + } + + // 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) { + exoPlayer.seekTo(position) + } + + override fun onScrubStop(timeBar: TimeBar, position: Long, canceled: Boolean) { + exoPlayer.play() + Handler(Looper.getMainLooper()).postDelayed({ + exoPlayerView.hideController() + }, 200) + } + }) + } + private fun initializeChapters(chapters: List) { if (chapters.isNotEmpty()) { binding.chaptersRecView.layoutManager = diff --git a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt index 9cc6cede6..57ac348a5 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlaylistFragment.kt @@ -81,7 +81,8 @@ class PlaylistFragment : Fragment() { // show playlist options binding.optionsMenu.setOnClickListener { - val optionsDialog = PlaylistOptionsDialog(playlistId!!, isOwner, requireContext()) + val optionsDialog = + PlaylistOptionsDialog(playlistId!!, isOwner, requireContext()) optionsDialog.show(childFragmentManager, "PlaylistOptionsDialog") } diff --git a/app/src/main/java/com/github/libretube/obj/Streams.kt b/app/src/main/java/com/github/libretube/obj/Streams.kt index 2ca1f50d5..34613b73e 100644 --- a/app/src/main/java/com/github/libretube/obj/Streams.kt +++ b/app/src/main/java/com/github/libretube/obj/Streams.kt @@ -1,5 +1,7 @@ package com.github.libretube.obj + import com.fasterxml.jackson.annotation.JsonIgnoreProperties + @JsonIgnoreProperties(ignoreUnknown = true) data class Streams( val title: String?, diff --git a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt index fc24e172d..8c087a1e5 100644 --- a/app/src/main/java/com/github/libretube/util/LocaleHelper.kt +++ b/app/src/main/java/com/github/libretube/util/LocaleHelper.kt @@ -57,7 +57,8 @@ object LocaleHelper { private fun detectSIMCountry(context: Context): String? { try { - val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + val telephonyManager = + context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager return telephonyManager.simCountryIso } catch (e: Exception) { e.printStackTrace() @@ -67,7 +68,8 @@ object LocaleHelper { private fun detectNetworkCountry(context: Context): String? { try { - val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + val telephonyManager = + context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager return telephonyManager.networkCountryIso } catch (e: Exception) { e.printStackTrace() diff --git a/app/src/main/res/drawable/ic_discord.xml b/app/src/main/res/drawable/ic_discord.xml index 1f9e2f420..4da87697f 100644 --- a/app/src/main/res/drawable/ic_discord.xml +++ b/app/src/main/res/drawable/ic_discord.xml @@ -4,7 +4,7 @@ android:tint="?android:attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/app/src/main/res/drawable/ic_matrix.xml b/app/src/main/res/drawable/ic_matrix.xml index e06da1bef..f88d58ea5 100644 --- a/app/src/main/res/drawable/ic_matrix.xml +++ b/app/src/main/res/drawable/ic_matrix.xml @@ -4,7 +4,7 @@ android:tint="?android:attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/app/src/main/res/drawable/ic_player.xml b/app/src/main/res/drawable/ic_player.xml index 2a9ce7870..07812f901 100644 --- a/app/src/main/res/drawable/ic_player.xml +++ b/app/src/main/res/drawable/ic_player.xml @@ -6,7 +6,7 @@ android:viewportHeight="244.86"> + android:strokeColor="#000000" /> diff --git a/app/src/main/res/drawable/ic_reddit.xml b/app/src/main/res/drawable/ic_reddit.xml index d7480cdb2..ab73945f7 100644 --- a/app/src/main/res/drawable/ic_reddit.xml +++ b/app/src/main/res/drawable/ic_reddit.xml @@ -4,7 +4,7 @@ android:tint="?android:attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/app/src/main/res/layout/comments_row.xml b/app/src/main/res/layout/comments_row.xml index 53523d9c1..73cdcc092 100644 --- a/app/src/main/res/layout/comments_row.xml +++ b/app/src/main/res/layout/comments_row.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?android:attr/selectableItemBackground" > + android:background="?android:attr/selectableItemBackground"> + app:show_buffering="when_playing"> + android:orientation="horizontal" + android:padding="8dp"> diff --git a/app/src/main/res/layout/replies_row.xml b/app/src/main/res/layout/replies_row.xml index 5eec53aa3..1e14c6c92 100644 --- a/app/src/main/res/layout/replies_row.xml +++ b/app/src/main/res/layout/replies_row.xml @@ -2,7 +2,7 @@ + android:layout_height="wrap_content">