From 44ca4cbbaade6fb14ec86e648aa0d29bc4069c14 Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:41:24 +0530 Subject: [PATCH 1/6] Made improvement to player double-tap further. --- .../libretube/ui/views/CustomExoPlayerView.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index bc46f7f9c0..7d402f3b4c 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -8,6 +8,7 @@ import android.graphics.Color import android.os.Handler import android.os.Looper import android.util.AttributeSet +import android.util.Log import android.view.MotionEvent import android.view.View import android.widget.FrameLayout @@ -118,6 +119,8 @@ internal class CustomExoPlayerView( // don't let the player view hide its controls automatically controllerShowTimeoutMs = -1 + // don't let the player view show its controls automatically + controllerAutoShow = false // locking the player binding.lockPlayer.setOnClickListener { @@ -172,6 +175,11 @@ internal class CustomExoPlayerView( // keep screen on if the video is playing keepScreenOn = player.isPlaying == true + + if (player.playbackState == Player.STATE_ENDED && !autoplayEnabled) { + showController() + cancelHideControllerTask() + } } } }) @@ -603,8 +611,9 @@ internal class CustomExoPlayerView( * Add extra margin to the top bar to not overlap the status bar */ private fun updateTopBarMargin() { - val isFullscreen = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || - playerViewModel?.isFullscreen?.value == true + val isFullscreen = + resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || + playerViewModel?.isFullscreen?.value == true binding.topBar.updateLayoutParams { topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() } @@ -615,6 +624,7 @@ internal class CustomExoPlayerView( } override fun onDoubleTapCenterScreen() { + Log.d("LibreTubeTags", "onDoubleTapCenterScreen") player?.let { player -> if (player.isPlaying) { player.pause() From c8c214d9befd7ee90af5db8e68dcf08f22487a03 Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:45:13 +0530 Subject: [PATCH 2/6] Minor fixes. --- .../java/com/github/libretube/ui/views/CustomExoPlayerView.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 7d402f3b4c..cf0e1328f4 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -624,7 +624,6 @@ internal class CustomExoPlayerView( } override fun onDoubleTapCenterScreen() { - Log.d("LibreTubeTags", "onDoubleTapCenterScreen") player?.let { player -> if (player.isPlaying) { player.pause() From 274f523b7f5201790aa8ef2525a059562cf5d46c Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 7 Feb 2023 21:47:11 +0530 Subject: [PATCH 3/6] fix ktlint --- .../java/com/github/libretube/ui/views/CustomExoPlayerView.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index cf0e1328f4..557442136e 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -8,7 +8,6 @@ import android.graphics.Color import android.os.Handler import android.os.Looper import android.util.AttributeSet -import android.util.Log import android.view.MotionEvent import android.view.View import android.widget.FrameLayout @@ -613,7 +612,7 @@ internal class CustomExoPlayerView( private fun updateTopBarMargin() { val isFullscreen = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || - playerViewModel?.isFullscreen?.value == true + playerViewModel?.isFullscreen?.value == true binding.topBar.updateLayoutParams { topMargin = (if (isFullscreen) 10 else 0).dpToPx().toInt() } From ff7b5b98627e6b5b26c8693fd02c4fe58bb4f058 Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Mon, 13 Feb 2023 22:32:35 +0530 Subject: [PATCH 4/6] Filter out null comments returned from Piped API. --- .../java/com/github/libretube/services/DownloadService.kt | 2 +- .../libretube/ui/extensions/FilterNonEmptyComments.kt | 7 +++++++ .../libretube/ui/fragments/CommentsRepliesFragment.kt | 2 ++ .../github/libretube/ui/fragments/SearchResultFragment.kt | 2 +- .../com/github/libretube/ui/models/CommentsViewModel.kt | 4 +++- .../libretube/ui/preferences/BackupRestoreSettings.kt | 4 ++-- 6 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/ui/extensions/FilterNonEmptyComments.kt diff --git a/app/src/main/java/com/github/libretube/services/DownloadService.kt b/app/src/main/java/com/github/libretube/services/DownloadService.kt index 36219d1cfc..eefe9affd4 100644 --- a/app/src/main/java/com/github/libretube/services/DownloadService.kt +++ b/app/src/main/java/com/github/libretube/services/DownloadService.kt @@ -8,9 +8,9 @@ import android.os.Binder import android.os.IBinder import android.util.SparseBooleanArray import androidx.core.app.NotificationCompat +import androidx.core.app.ServiceCompat import androidx.core.util.set import androidx.core.util.valueIterator -import androidx.core.app.ServiceCompat import com.github.libretube.R import com.github.libretube.api.CronetHelper import com.github.libretube.api.RetrofitInstance diff --git a/app/src/main/java/com/github/libretube/ui/extensions/FilterNonEmptyComments.kt b/app/src/main/java/com/github/libretube/ui/extensions/FilterNonEmptyComments.kt new file mode 100644 index 0000000000..5f4aa0b0e8 --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/extensions/FilterNonEmptyComments.kt @@ -0,0 +1,7 @@ +package com.github.libretube.ui.extensions + +import com.github.libretube.api.obj.Comment + +fun List.filterNonEmptyComments(): List { + return filter { !it.commentText.isNullOrEmpty() } +} diff --git a/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt index 7e29f24baf..343163f27d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/CommentsRepliesFragment.kt @@ -17,6 +17,7 @@ import com.github.libretube.constants.IntentData import com.github.libretube.databinding.FragmentCommentsBinding import com.github.libretube.extensions.TAG import com.github.libretube.ui.adapters.CommentsAdapter +import com.github.libretube.ui.extensions.filterNonEmptyComments import com.github.libretube.ui.models.CommentsViewModel import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -97,6 +98,7 @@ class CommentsRepliesFragment : Fragment() { Log.e(TAG(), "IOException, you might not have internet connection") return@launch } + repliesPage.comments = repliesPage.comments.filterNonEmptyComments() withContext(Dispatchers.Main) { onFinished.invoke(repliesPage) } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt index 860b019cda..64840a23c9 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SearchResultFragment.kt @@ -19,9 +19,9 @@ import com.github.libretube.extensions.hideKeyboard import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.ui.adapters.SearchAdapter import com.github.libretube.ui.base.BaseFragment +import java.io.IOException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -import java.io.IOException import retrofit2.HttpException class SearchResultFragment : BaseFragment() { diff --git a/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt b/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt index 4d142fc799..33d6c2fb17 100644 --- a/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt +++ b/app/src/main/java/com/github/libretube/ui/models/CommentsViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel import com.github.libretube.api.RetrofitInstance import com.github.libretube.api.obj.CommentsPage import com.github.libretube.extensions.TAG +import com.github.libretube.ui.extensions.filterNonEmptyComments import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -33,6 +34,7 @@ class CommentsViewModel : ViewModel() { return@launch } nextPage = response.nextpage + response.comments = response.comments.filterNonEmptyComments() commentsPage.postValue(response) isLoading = false } @@ -49,7 +51,7 @@ class CommentsViewModel : ViewModel() { return@launch } val updatedPage = commentsPage.value?.apply { - comments += response.comments + comments += response.comments.filterNonEmptyComments() } nextPage = response.nextpage commentsPage.postValue(updatedPage) diff --git a/app/src/main/java/com/github/libretube/ui/preferences/BackupRestoreSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/BackupRestoreSettings.kt index 9deee4061b..119c71ced7 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/BackupRestoreSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/BackupRestoreSettings.kt @@ -11,10 +11,10 @@ import com.github.libretube.helpers.ImportHelper import com.github.libretube.obj.BackupFile import com.github.libretube.ui.base.BasePreferenceFragment import com.github.libretube.ui.dialogs.BackupDialog -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch import java.time.LocalDateTime import java.time.format.DateTimeFormatter +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch class BackupRestoreSettings : BasePreferenceFragment() { private val backupDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm:ss") From b36daf1152f081813c431297c2fe42384e3e141a Mon Sep 17 00:00:00 2001 From: faisalcodes Date: Tue, 14 Feb 2023 01:10:41 +0530 Subject: [PATCH 5/6] Fixes: Labels under icons are not visible --- .../libretube/ui/fragments/PlayerFragment.kt | 4 ++++ app/src/main/res/drawable/ic_download.xml | 14 +++++++++----- app/src/main/res/layout/fragment_player.xml | 19 ++++++++++--------- app/src/main/res/values/style.xml | 14 +++++++++----- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 6849876a8c..5c4fdaa8c0 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -1432,6 +1432,10 @@ class PlayerFragment : Fragment(R.layout.fragment_player), OnlinePlayerOptions { binding.linLayout.visibility = View.VISIBLE updateCaptionsLanguage(captionLanguage) + + binding.optionsLL.post { + binding.optionsLL.requestLayout() + } } } diff --git a/app/src/main/res/drawable/ic_download.xml b/app/src/main/res/drawable/ic_download.xml index 30044b1893..de7af3886d 100644 --- a/app/src/main/res/drawable/ic_download.xml +++ b/app/src/main/res/drawable/ic_download.xml @@ -2,9 +2,13 @@ android:width="24dp" android:height="24dp" android:tint="?attr/colorControlNormal" - android:viewportWidth="48" - android:viewportHeight="48"> - + android:viewportWidth="24" + android:viewportHeight="24"> + diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 01fb7a38f6..233d085dfc 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -128,8 +128,9 @@ - - - - -