mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
refactor: replace View#setVisibility with kotlin visibility extension
This commit is contained in:
parent
3a106c449b
commit
05fa57b912
@ -1,6 +1,6 @@
|
|||||||
package com.github.libretube.api
|
package com.github.libretube.api
|
||||||
|
|
||||||
import java.util.*
|
import java.util.LinkedList
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
class ResettableLazyManager {
|
class ResettableLazyManager {
|
||||||
|
@ -5,10 +5,10 @@ import android.util.Log
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
import android.view.MenuInflater
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import androidx.core.view.forEach
|
import androidx.core.view.forEach
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.size
|
import androidx.core.view.size
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
@ -107,7 +107,7 @@ object NavBarHelper {
|
|||||||
).icon = menuItem.icon
|
).icon = menuItem.icon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (navBarItems.filter { it.isVisible }.isEmpty()) bottomNav.visibility = View.GONE
|
if (navBarItems.none { it.isVisible }) bottomNav.isGone = true
|
||||||
|
|
||||||
return getStartFragmentId(bottomNav.context)
|
return getStartFragmentId(bottomNav.context)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import androidx.media3.exoplayer.trackselection.DefaultTrackSelector
|
|||||||
import androidx.media3.ui.CaptionStyleCompat
|
import androidx.media3.ui.CaptionStyleCompat
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.obj.ChapterSegment
|
import com.github.libretube.api.obj.ChapterSegment
|
||||||
import com.github.libretube.api.obj.PreviewFrames
|
|
||||||
import com.github.libretube.api.obj.Segment
|
import com.github.libretube.api.obj.Segment
|
||||||
import com.github.libretube.api.obj.Streams
|
import com.github.libretube.api.obj.Streams
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
@ -39,7 +38,6 @@ import com.github.libretube.db.DatabaseHolder
|
|||||||
import com.github.libretube.enums.PlayerEvent
|
import com.github.libretube.enums.PlayerEvent
|
||||||
import com.github.libretube.enums.SbSkipOptions
|
import com.github.libretube.enums.SbSkipOptions
|
||||||
import com.github.libretube.extensions.updateParameters
|
import com.github.libretube.extensions.updateParameters
|
||||||
import com.github.libretube.obj.PreviewFrame
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.math.absoluteValue
|
import kotlin.math.absoluteValue
|
||||||
|
@ -15,7 +15,6 @@ import com.github.libretube.R
|
|||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
import com.github.libretube.ui.adapters.IconsSheetAdapter
|
import com.github.libretube.ui.adapters.IconsSheetAdapter
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
import java.lang.IllegalArgumentException
|
|
||||||
|
|
||||||
object ThemeHelper {
|
object ThemeHelper {
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.github.libretube.services
|
|||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.IBinder
|
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import com.github.libretube.constants.IntentData
|
|||||||
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
|
||||||
import com.github.libretube.db.DatabaseHolder.Database
|
import com.github.libretube.db.DatabaseHolder.Database
|
||||||
import com.github.libretube.db.obj.WatchPosition
|
import com.github.libretube.db.obj.WatchPosition
|
||||||
import com.github.libretube.enums.SbSkipOptions
|
|
||||||
import com.github.libretube.extensions.parcelableExtra
|
import com.github.libretube.extensions.parcelableExtra
|
||||||
import com.github.libretube.extensions.setMetadata
|
import com.github.libretube.extensions.setMetadata
|
||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
|
@ -7,7 +7,6 @@ import android.content.res.Configuration
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import androidx.activity.addCallback
|
import androidx.activity.addCallback
|
||||||
@ -16,6 +15,7 @@ import androidx.appcompat.widget.SearchView
|
|||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
@ -311,7 +311,10 @@ class MainActivity : BaseActivity() {
|
|||||||
|
|
||||||
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
override fun onQueryTextSubmit(query: String?): Boolean {
|
override fun onQueryTextSubmit(query: String?): Boolean {
|
||||||
navController.navigate(R.id.searchResultFragment, bundleOf(IntentData.query to query))
|
navController.navigate(
|
||||||
|
R.id.searchResultFragment,
|
||||||
|
bundleOf(IntentData.query to query)
|
||||||
|
)
|
||||||
searchView.clearFocus()
|
searchView.clearFocus()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -337,7 +340,10 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (navController.currentDestination?.id != R.id.searchFragment) {
|
if (navController.currentDestination?.id != R.id.searchFragment) {
|
||||||
navController.navigate(R.id.searchFragment, bundleOf(IntentData.query to newText))
|
navController.navigate(
|
||||||
|
R.id.searchFragment,
|
||||||
|
bundleOf(IntentData.query to newText)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
searchViewModel.setQuery(newText)
|
searchViewModel.setQuery(newText)
|
||||||
}
|
}
|
||||||
@ -482,7 +488,7 @@ class MainActivity : BaseActivity() {
|
|||||||
supportFragmentManager.fragments.forEach { fragment ->
|
supportFragmentManager.fragments.forEach { fragment ->
|
||||||
(fragment as? PlayerFragment)?.binding?.apply {
|
(fragment as? PlayerFragment)?.binding?.apply {
|
||||||
mainContainer.isClickable = false
|
mainContainer.isClickable = false
|
||||||
linLayout.visibility = View.VISIBLE
|
linLayout.isVisible = true
|
||||||
playerMotionLayout.setTransitionDuration(250)
|
playerMotionLayout.setTransitionDuration(250)
|
||||||
playerMotionLayout.transitionToEnd()
|
playerMotionLayout.transitionToEnd()
|
||||||
playerMotionLayout.getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
playerMotionLayout.getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.libretube.ui.activities
|
package com.github.libretube.ui.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@ -97,7 +96,9 @@ class RouterActivity : BaseActivity() {
|
|||||||
private fun handleSendText(uri: Uri) {
|
private fun handleSendText(uri: Uri) {
|
||||||
Log.i(TAG(), uri.toString())
|
Log.i(TAG(), uri.toString())
|
||||||
|
|
||||||
val intent = this.packageManager.getLaunchIntentForPackage(this.packageName)!!.resolveType(uri)
|
val intent = this.packageManager.getLaunchIntentForPackage(
|
||||||
|
this.packageName
|
||||||
|
)!!.resolveType(uri)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finishAndRemoveTask()
|
finishAndRemoveTask()
|
||||||
|
@ -2,10 +2,7 @@ package com.github.libretube.ui.activities
|
|||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.os.bundleOf
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.R
|
|
||||||
import com.github.libretube.constants.IntentData
|
|
||||||
import com.github.libretube.databinding.VideoTagRowBinding
|
import com.github.libretube.databinding.VideoTagRowBinding
|
||||||
import com.github.libretube.ui.viewholders.VideoTagsViewHolder
|
import com.github.libretube.ui.viewholders.VideoTagsViewHolder
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@ package com.github.libretube.ui.adapters
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.MarginLayoutParams
|
import android.view.ViewGroup.MarginLayoutParams
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@ -79,10 +80,10 @@ class CommentsAdapter(
|
|||||||
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
||||||
likesTextView.text = comment.likeCount.formatShort()
|
likesTextView.text = comment.likeCount.formatShort()
|
||||||
|
|
||||||
if (comment.verified) verifiedImageView.visibility = View.VISIBLE
|
if (comment.verified) verifiedImageView.isVisible = true
|
||||||
if (comment.pinned) pinnedImageView.visibility = View.VISIBLE
|
if (comment.pinned) pinnedImageView.isVisible = true
|
||||||
if (comment.hearted) heartedImageView.visibility = View.VISIBLE
|
if (comment.hearted) heartedImageView.isVisible = true
|
||||||
if (comment.repliesPage != null) repliesCount.visibility = View.VISIBLE
|
if (comment.repliesPage != null) repliesCount.isVisible = true
|
||||||
if (comment.replyCount > 0L) {
|
if (comment.replyCount > 0L) {
|
||||||
repliesCount.text = comment.replyCount.formatShort()
|
repliesCount.text = comment.replyCount.formatShort()
|
||||||
}
|
}
|
||||||
@ -93,7 +94,7 @@ class CommentsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isRepliesAdapter) {
|
if (isRepliesAdapter) {
|
||||||
repliesCount.visibility = View.GONE
|
repliesCount.isGone = true
|
||||||
|
|
||||||
// highlight the comment that is being replied to
|
// highlight the comment that is being replied to
|
||||||
if (comment == comments.firstOrNull()) {
|
if (comment == comments.firstOrNull()) {
|
||||||
|
@ -4,9 +4,10 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.constants.IntentData
|
import com.github.libretube.constants.IntentData
|
||||||
@ -64,11 +65,11 @@ class DownloadsAdapter(
|
|||||||
context.getString(R.string.unknown)
|
context.getString(R.string.unknown)
|
||||||
}
|
}
|
||||||
if (downloadSize > currentSize) {
|
if (downloadSize > currentSize) {
|
||||||
downloadOverlay.visibility = View.VISIBLE
|
downloadOverlay.isVisible = true
|
||||||
resumePauseBtn.setImageResource(R.drawable.ic_download)
|
resumePauseBtn.setImageResource(R.drawable.ic_download)
|
||||||
fileSize.text = "${currentSize.formatAsFileSize()} / $totalSizeInfo"
|
fileSize.text = "${currentSize.formatAsFileSize()} / $totalSizeInfo"
|
||||||
} else {
|
} else {
|
||||||
downloadOverlay.visibility = View.GONE
|
downloadOverlay.isGone = true
|
||||||
fileSize.text = totalSizeInfo
|
fileSize.text = totalSizeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import android.app.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.api.PlaylistsHelper
|
import com.github.libretube.api.PlaylistsHelper
|
||||||
import com.github.libretube.api.obj.StreamItem
|
import com.github.libretube.api.obj.StreamItem
|
||||||
@ -67,7 +67,7 @@ class PlaylistAdapter(
|
|||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
videoTitle.text = streamItem.title
|
videoTitle.text = streamItem.title
|
||||||
videoInfo.text = streamItem.uploaderName
|
videoInfo.text = streamItem.uploaderName
|
||||||
channelImage.visibility = View.GONE
|
channelImage.isGone = true
|
||||||
|
|
||||||
thumbnailDuration.setFormattedDuration(streamItem.duration!!, streamItem.isShort)
|
thumbnailDuration.setFormattedDuration(streamItem.duration!!, streamItem.isShort)
|
||||||
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.github.libretube.ui.adapters
|
package com.github.libretube.ui.adapters
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.databinding.PlaylistBookmarkRowBinding
|
import com.github.libretube.databinding.PlaylistBookmarkRowBinding
|
||||||
@ -87,7 +87,7 @@ class PlaylistBookmarkAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bookmarkPlaylist.visibility = View.VISIBLE
|
bookmarkPlaylist.isVisible = true
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
NavigationHelper.navigatePlaylist(
|
NavigationHelper.navigatePlaylist(
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.github.libretube.ui.adapters
|
package com.github.libretube.ui.adapters
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.databinding.SuggestionRowBinding
|
import com.github.libretube.databinding.SuggestionRowBinding
|
||||||
import com.github.libretube.db.DatabaseHolder.Database
|
import com.github.libretube.db.DatabaseHolder.Database
|
||||||
@ -33,7 +33,7 @@ class SearchHistoryAdapter(
|
|||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
suggestionText.text = historyQuery
|
suggestionText.text = historyQuery
|
||||||
|
|
||||||
deleteHistory.visibility = View.VISIBLE
|
deleteHistory.isVisible = true
|
||||||
|
|
||||||
deleteHistory.setOnClickListener {
|
deleteHistory.setOnClickListener {
|
||||||
historyList -= historyQuery
|
historyList -= historyQuery
|
||||||
|
@ -5,10 +5,10 @@ import android.os.Bundle
|
|||||||
import android.text.InputFilter
|
import android.text.InputFilter
|
||||||
import android.text.format.Formatter
|
import android.text.format.Formatter
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@ -112,7 +112,7 @@ class DownloadDialog(
|
|||||||
.filter { !it.url.isNullOrEmpty() && !it.name.isNullOrEmpty() }
|
.filter { !it.url.isNullOrEmpty() && !it.name.isNullOrEmpty() }
|
||||||
.sortedBy { it.name }
|
.sortedBy { it.name }
|
||||||
|
|
||||||
if (subtitles.isEmpty()) binding.subtitleSpinner.visibility = View.GONE
|
if (subtitles.isEmpty()) binding.subtitleSpinner.isGone = true
|
||||||
|
|
||||||
// initialize the video sources
|
// initialize the video sources
|
||||||
val videoArrayAdapter = ArrayAdapter(
|
val videoArrayAdapter = ArrayAdapter(
|
||||||
|
@ -3,7 +3,6 @@ package com.github.libretube.ui.dialogs
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
@ -87,7 +86,7 @@ class ShareDialog(
|
|||||||
}
|
}
|
||||||
binding.timeStamp.setText((shareData.currentPosition ?: 0L).toString())
|
binding.timeStamp.setText((shareData.currentPosition ?: 0L).toString())
|
||||||
if (binding.timeCodeSwitch.isChecked) {
|
if (binding.timeCodeSwitch.isChecked) {
|
||||||
binding.timeStampLayout.visibility = View.VISIBLE
|
binding.timeStampLayout.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import android.graphics.Color
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import com.github.libretube.db.DatabaseHolder.Database
|
import com.github.libretube.db.DatabaseHolder.Database
|
||||||
import com.github.libretube.helpers.ThemeHelper
|
import com.github.libretube.helpers.ThemeHelper
|
||||||
@ -19,11 +21,19 @@ fun View.setWatchProgressLength(videoId: String, duration: Long) {
|
|||||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
matchConstraintPercentWidth = 0f
|
matchConstraintPercentWidth = 0f
|
||||||
}
|
}
|
||||||
var backgroundColor = MaterialColors.getColor(this, com.google.android.material.R.attr.colorPrimaryDark)
|
var backgroundColor = MaterialColors.getColor(
|
||||||
|
this,
|
||||||
|
com.google.android.material.R.attr.colorPrimaryDark
|
||||||
|
)
|
||||||
// increase the brightness for better contrast in light mode
|
// increase the brightness for better contrast in light mode
|
||||||
if (!ThemeHelper.isDarkMode(context)) backgroundColor = ColorUtils.blendARGB(backgroundColor, Color.WHITE, 0.4f)
|
if (!ThemeHelper.isDarkMode(
|
||||||
|
context
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
backgroundColor = ColorUtils.blendARGB(backgroundColor, Color.WHITE, 0.4f)
|
||||||
|
}
|
||||||
setBackgroundColor(backgroundColor)
|
setBackgroundColor(backgroundColor)
|
||||||
visibility = View.GONE
|
isGone = true
|
||||||
|
|
||||||
val progress = try {
|
val progress = try {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
@ -41,5 +51,5 @@ fun View.setWatchProgressLength(videoId: String, duration: Long) {
|
|||||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
matchConstraintPercentWidth = progress / duration.toFloat()
|
matchConstraintPercentWidth = progress / duration.toFloat()
|
||||||
}
|
}
|
||||||
visibility = View.VISIBLE
|
isVisible = true
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.github.libretube.ui.extensions
|
package com.github.libretube.ui.extensions
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.SubscriptionHelper
|
import com.github.libretube.api.SubscriptionHelper
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
@ -28,9 +29,9 @@ fun TextView.setupSubscriptionButton(
|
|||||||
if (subscribed == true) {
|
if (subscribed == true) {
|
||||||
this@setupSubscriptionButton.text = context.getString(R.string.unsubscribe)
|
this@setupSubscriptionButton.text = context.getString(R.string.unsubscribe)
|
||||||
} else {
|
} else {
|
||||||
notificationBell?.visibility = View.GONE
|
notificationBell?.isGone = true
|
||||||
}
|
}
|
||||||
this@setupSubscriptionButton.visibility = View.VISIBLE
|
this@setupSubscriptionButton.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,14 +40,14 @@ fun TextView.setupSubscriptionButton(
|
|||||||
if (subscribed == true) {
|
if (subscribed == true) {
|
||||||
SubscriptionHelper.handleUnsubscribe(context, channelId, channelName) {
|
SubscriptionHelper.handleUnsubscribe(context, channelId, channelName) {
|
||||||
this.text = context.getString(R.string.subscribe)
|
this.text = context.getString(R.string.subscribe)
|
||||||
notificationBell?.visibility = View.GONE
|
notificationBell?.isGone = true
|
||||||
subscribed = false
|
subscribed = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
SubscriptionHelper.subscribe(channelId)
|
SubscriptionHelper.subscribe(channelId)
|
||||||
text = context.getString(R.string.unsubscribe)
|
text = context.getString(R.string.unsubscribe)
|
||||||
notificationBell?.visibility = View.VISIBLE
|
notificationBell?.isVisible = true
|
||||||
subscribed = true
|
subscribed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||||
import androidx.constraintlayout.motion.widget.TransitionAdapter
|
import androidx.constraintlayout.motion.widget.TransitionAdapter
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -204,7 +205,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun initializeTransitionLayout() {
|
private fun initializeTransitionLayout() {
|
||||||
mainActivity.binding.container.visibility = View.VISIBLE
|
mainActivity.binding.container.isVisible = true
|
||||||
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
||||||
|
|
||||||
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
||||||
@ -259,14 +260,14 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateThumbnailAsync(thumbnailUrl: String) {
|
private fun updateThumbnailAsync(thumbnailUrl: String) {
|
||||||
binding.progress.visibility = View.VISIBLE
|
binding.progress.isVisible = true
|
||||||
binding.thumbnail.visibility = View.GONE
|
binding.thumbnail.isGone = true
|
||||||
|
|
||||||
ImageHelper.getAsync(requireContext(), thumbnailUrl) {
|
ImageHelper.getAsync(requireContext(), thumbnailUrl) {
|
||||||
binding.thumbnail.setImageBitmap(it)
|
binding.thumbnail.setImageBitmap(it)
|
||||||
binding.miniPlayerThumbnail.setImageBitmap(it)
|
binding.miniPlayerThumbnail.setImageBitmap(it)
|
||||||
binding.thumbnail.visibility = View.VISIBLE
|
binding.thumbnail.isVisible = true
|
||||||
binding.progress.visibility = View.GONE
|
binding.progress.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,19 +349,19 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwipe(distanceY: Float) {
|
override fun onSwipe(distanceY: Float) {
|
||||||
binding.volumeControls.visibility = View.VISIBLE
|
binding.volumeControls.isVisible = true
|
||||||
updateVolume(distanceY)
|
updateVolume(distanceY)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwipeEnd() {
|
override fun onSwipeEnd() {
|
||||||
binding.volumeControls.visibility = View.GONE
|
binding.volumeControls.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateVolume(distance: Float) {
|
private fun updateVolume(distance: Float) {
|
||||||
val bar = binding.volumeProgressBar
|
val bar = binding.volumeProgressBar
|
||||||
binding.volumeControls.apply {
|
binding.volumeControls.apply {
|
||||||
if (visibility == View.GONE) {
|
if (visibility == View.GONE) {
|
||||||
visibility = View.VISIBLE
|
isVisible = true
|
||||||
// Volume could be changed using other mediums, sync progress
|
// Volume could be changed using other mediums, sync progress
|
||||||
// bar with new value.
|
// bar with new value.
|
||||||
bar.progress = audioHelper.getVolumeWithScale(bar.max)
|
bar.progress = audioHelper.getVolumeWithScale(bar.max)
|
||||||
|
@ -7,6 +7,8 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@ -164,7 +166,7 @@ class ChannelFragment : Fragment() {
|
|||||||
isLoading = false
|
isLoading = false
|
||||||
binding.channelRefresh.isRefreshing = false
|
binding.channelRefresh.isRefreshing = false
|
||||||
|
|
||||||
binding.channelScrollView.visibility = View.VISIBLE
|
binding.channelScrollView.isVisible = true
|
||||||
binding.channelName.text = response.name
|
binding.channelName.text = response.name
|
||||||
if (response.verified) {
|
if (response.verified) {
|
||||||
binding.channelName.setCompoundDrawablesWithIntrinsicBounds(
|
binding.channelName.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
@ -179,7 +181,7 @@ class ChannelFragment : Fragment() {
|
|||||||
response.subscriberCount.formatShort()
|
response.subscriberCount.formatShort()
|
||||||
)
|
)
|
||||||
if (response.description.orEmpty().isBlank()) {
|
if (response.description.orEmpty().isBlank()) {
|
||||||
binding.channelDescription.visibility = View.GONE
|
binding.channelDescription.isGone = true
|
||||||
} else {
|
} else {
|
||||||
binding.channelDescription.text = response.description.orEmpty().trim()
|
binding.channelDescription.text = response.description.orEmpty().trim()
|
||||||
}
|
}
|
||||||
@ -209,7 +211,7 @@ class ChannelFragment : Fragment() {
|
|||||||
binding.tabChips.children.forEach { chip ->
|
binding.tabChips.children.forEach { chip ->
|
||||||
val resourceTab = possibleTabs.firstOrNull { it.chipId == chip.id }
|
val resourceTab = possibleTabs.firstOrNull { it.chipId == chip.id }
|
||||||
resourceTab?.let { resTab ->
|
resourceTab?.let { resTab ->
|
||||||
if (tabs.any { it.name == resTab.identifierName }) chip.visibility = View.VISIBLE
|
if (tabs.any { it.name == resTab.identifierName }) chip.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -65,7 +66,7 @@ class CommentsMainFragment : Fragment() {
|
|||||||
|
|
||||||
commentsAdapter = CommentsAdapter(
|
commentsAdapter = CommentsAdapter(
|
||||||
this,
|
this,
|
||||||
viewModel.videoId!!,
|
viewModel.videoId ?: return,
|
||||||
viewModel.commentsPage.value?.comments.orEmpty().toMutableList(),
|
viewModel.commentsPage.value?.comments.orEmpty().toMutableList(),
|
||||||
handleLink = viewModel.handleLink
|
handleLink = viewModel.handleLink
|
||||||
) {
|
) {
|
||||||
@ -74,7 +75,7 @@ class CommentsMainFragment : Fragment() {
|
|||||||
binding.commentsRV.adapter = commentsAdapter
|
binding.commentsRV.adapter = commentsAdapter
|
||||||
|
|
||||||
if (viewModel.commentsPage.value?.comments.orEmpty().isEmpty()) {
|
if (viewModel.commentsPage.value?.comments.orEmpty().isEmpty()) {
|
||||||
binding.progress.visibility = View.VISIBLE
|
binding.progress.isVisible = true
|
||||||
viewModel.fetchComments()
|
viewModel.fetchComments()
|
||||||
} else {
|
} else {
|
||||||
binding.commentsRV.scrollToPosition(viewModel.currentCommentsPosition)
|
binding.commentsRV.scrollToPosition(viewModel.currentCommentsPosition)
|
||||||
@ -83,9 +84,9 @@ class CommentsMainFragment : Fragment() {
|
|||||||
// listen for new comments to be loaded
|
// listen for new comments to be loaded
|
||||||
viewModel.commentsPage.observe(viewLifecycleOwner) {
|
viewModel.commentsPage.observe(viewLifecycleOwner) {
|
||||||
if (it == null) return@observe
|
if (it == null) return@observe
|
||||||
binding.progress.visibility = View.GONE
|
binding.progress.isGone = true
|
||||||
if (it.disabled) {
|
if (it.disabled) {
|
||||||
binding.errorTV.visibility = View.VISIBLE
|
binding.errorTV.isVisible = true
|
||||||
return@observe
|
return@observe
|
||||||
}
|
}
|
||||||
(parentFragment as CommentsSheet).updateFragmentInfo(
|
(parentFragment as CommentsSheet).updateFragmentInfo(
|
||||||
@ -94,7 +95,7 @@ class CommentsMainFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
if (it.comments.isEmpty()) {
|
if (it.comments.isEmpty()) {
|
||||||
binding.errorTV.text = getString(R.string.no_comments_available)
|
binding.errorTV.text = getString(R.string.no_comments_available)
|
||||||
binding.errorTV.visibility = View.VISIBLE
|
binding.errorTV.isVisible = true
|
||||||
return@observe
|
return@observe
|
||||||
}
|
}
|
||||||
commentsAdapter.updateItems(
|
commentsAdapter.updateItems(
|
||||||
|
@ -5,6 +5,8 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -94,10 +96,10 @@ class CommentsRepliesFragment : Fragment() {
|
|||||||
nextPage: String,
|
nextPage: String,
|
||||||
repliesAdapter: CommentsAdapter
|
repliesAdapter: CommentsAdapter
|
||||||
) {
|
) {
|
||||||
binding.progress.visibility = View.VISIBLE
|
binding.progress.isVisible = true
|
||||||
fetchReplies(videoId, nextPage) {
|
fetchReplies(videoId, nextPage) {
|
||||||
repliesAdapter.updateItems(it.comments)
|
repliesAdapter.updateItems(it.comments)
|
||||||
binding.progress.visibility = View.GONE
|
binding.progress.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import android.os.IBinder
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper
|
import androidx.recyclerview.widget.ItemTouchHelper
|
||||||
@ -80,8 +82,8 @@ class DownloadsFragment : Fragment() {
|
|||||||
downloads.clear()
|
downloads.clear()
|
||||||
downloads.addAll(dbDownloads)
|
downloads.addAll(dbDownloads)
|
||||||
|
|
||||||
binding.downloadsEmpty.visibility = View.GONE
|
binding.downloadsEmpty.isGone = true
|
||||||
binding.downloads.visibility = View.VISIBLE
|
binding.downloads.isVisible = true
|
||||||
|
|
||||||
binding.downloads.layoutManager = LinearLayoutManager(context)
|
binding.downloads.layoutManager = LinearLayoutManager(context)
|
||||||
|
|
||||||
@ -139,8 +141,8 @@ class DownloadsFragment : Fragment() {
|
|||||||
super.onItemRangeRemoved(positionStart, itemCount)
|
super.onItemRangeRemoved(positionStart, itemCount)
|
||||||
val binding = _binding ?: return
|
val binding = _binding ?: return
|
||||||
if (binding.downloads.adapter?.itemCount == 0) {
|
if (binding.downloads.adapter?.itemCount == 0) {
|
||||||
binding.downloads.visibility = View.GONE
|
binding.downloads.isGone = true
|
||||||
binding.downloadsEmpty.visibility = View.VISIBLE
|
binding.downloadsEmpty.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,13 +187,13 @@ class DownloadsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DownloadStatus.Completed -> {
|
DownloadStatus.Completed -> {
|
||||||
downloadOverlay.visibility = View.GONE
|
downloadOverlay.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadStatus.Stopped -> Unit
|
DownloadStatus.Stopped -> Unit
|
||||||
|
|
||||||
is DownloadStatus.Progress -> {
|
is DownloadStatus.Progress -> {
|
||||||
downloadOverlay.visibility = View.VISIBLE
|
downloadOverlay.isVisible = true
|
||||||
resumePauseBtn.setImageResource(R.drawable.ic_pause)
|
resumePauseBtn.setImageResource(R.drawable.ic_pause)
|
||||||
if (progressBar.isIndeterminate) return
|
if (progressBar.isIndeterminate) return
|
||||||
progressBar.incrementProgressBy(status.progress.toInt())
|
progressBar.incrementProgressBy(status.progress.toInt())
|
||||||
|
@ -201,8 +201,8 @@ class HomeFragment : Fragment() {
|
|||||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||||
super.onItemRangeRemoved(positionStart, itemCount)
|
super.onItemRangeRemoved(positionStart, itemCount)
|
||||||
if (itemCount == 0) {
|
if (itemCount == 0) {
|
||||||
binding.playlistsRV.visibility = View.GONE
|
binding.playlistsRV.isGone = true
|
||||||
binding.playlistsTV.visibility = View.GONE
|
binding.playlistsTV.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.ViewGroup.MarginLayoutParams
|
import android.view.ViewGroup.MarginLayoutParams
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@ -65,7 +66,7 @@ class LibraryFragment : Fragment() {
|
|||||||
val watchHistoryEnabled =
|
val watchHistoryEnabled =
|
||||||
PreferenceHelper.getBoolean(PreferenceKeys.WATCH_HISTORY_TOGGLE, true)
|
PreferenceHelper.getBoolean(PreferenceKeys.WATCH_HISTORY_TOGGLE, true)
|
||||||
if (!watchHistoryEnabled) {
|
if (!watchHistoryEnabled) {
|
||||||
binding.watchHistory.visibility = View.GONE
|
binding.watchHistory.isGone = true
|
||||||
} else {
|
} else {
|
||||||
binding.watchHistory.setOnClickListener {
|
binding.watchHistory.setOnClickListener {
|
||||||
findNavController().navigate(R.id.watchHistoryFragment)
|
findNavController().navigate(R.id.watchHistoryFragment)
|
||||||
@ -78,7 +79,7 @@ class LibraryFragment : Fragment() {
|
|||||||
|
|
||||||
val navBarItems = NavBarHelper.getNavBarItems(requireContext())
|
val navBarItems = NavBarHelper.getNavBarItems(requireContext())
|
||||||
if (navBarItems.filter { it.isVisible }.any { it.itemId == R.id.downloadsFragment }) {
|
if (navBarItems.filter { it.isVisible }.any { it.itemId == R.id.downloadsFragment }) {
|
||||||
binding.downloads.visibility = View.GONE
|
binding.downloads.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchPlaylists()
|
fetchPlaylists()
|
||||||
@ -156,10 +157,10 @@ class LibraryFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
binding.nothingHere.visibility = View.GONE
|
binding.nothingHere.isGone = true
|
||||||
binding.playlistRecView.adapter = playlistsAdapter
|
binding.playlistRecView.adapter = playlistsAdapter
|
||||||
} else {
|
} else {
|
||||||
binding.nothingHere.visibility = View.VISIBLE
|
binding.nothingHere.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun initializeTransitionLayout() {
|
private fun initializeTransitionLayout() {
|
||||||
mainActivity.binding.container.visibility = View.VISIBLE
|
mainActivity.binding.container.isVisible = true
|
||||||
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
||||||
|
|
||||||
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
||||||
@ -381,7 +381,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
BackgroundHelper.stopBackgroundPlay(requireContext())
|
BackgroundHelper.stopBackgroundPlay(requireContext())
|
||||||
killPlayerFragment()
|
killPlayerFragment()
|
||||||
}
|
}
|
||||||
playerBinding.autoPlay.visibility = View.VISIBLE
|
playerBinding.autoPlay.isVisible = true
|
||||||
|
|
||||||
binding.playImageView.setOnClickListener {
|
binding.playImageView.setOnClickListener {
|
||||||
when {
|
when {
|
||||||
@ -407,7 +407,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
CommentsSheet().show(childFragmentManager)
|
CommentsSheet().show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
playerBinding.queueToggle.visibility = View.VISIBLE
|
playerBinding.queueToggle.isVisible = true
|
||||||
playerBinding.queueToggle.setOnClickListener {
|
playerBinding.queueToggle.setOnClickListener {
|
||||||
PlayingQueueSheet().show(childFragmentManager, null)
|
PlayingQueueSheet().show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
@ -532,10 +532,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
windowInsetsControllerCompat.isAppearanceLightStatusBars = false
|
windowInsetsControllerCompat.isAppearanceLightStatusBars = false
|
||||||
|
|
||||||
binding.mainContainer.isClickable = true
|
binding.mainContainer.isClickable = true
|
||||||
binding.linLayout.visibility = View.GONE
|
binding.linLayout.isGone = true
|
||||||
commentsViewModel.setCommentSheetExpand(null)
|
commentsViewModel.setCommentSheetExpand(null)
|
||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
||||||
playerBinding.exoTitle.visibility = View.VISIBLE
|
playerBinding.exoTitle.isVisible = true
|
||||||
|
|
||||||
updateFullscreenOrientation()
|
updateFullscreenOrientation()
|
||||||
viewModel.isFullscreen.value = true
|
viewModel.isFullscreen.value = true
|
||||||
@ -558,9 +558,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.mainContainer.isClickable = false
|
binding.mainContainer.isClickable = false
|
||||||
binding.linLayout.visibility = View.VISIBLE
|
binding.linLayout.isVisible = true
|
||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
|
||||||
playerBinding.exoTitle.visibility = View.INVISIBLE
|
playerBinding.exoTitle.isInvisible = true
|
||||||
|
|
||||||
if (!PlayerHelper.autoRotationEnabled) {
|
if (!PlayerHelper.autoRotationEnabled) {
|
||||||
// switch back to portrait mode if autorotation disabled
|
// switch back to portrait mode if autorotation disabled
|
||||||
@ -582,14 +582,14 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
if (binding.descLinLayout.isVisible) {
|
if (binding.descLinLayout.isVisible) {
|
||||||
// hide the description and chapters
|
// hide the description and chapters
|
||||||
binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start()
|
binding.playerDescriptionArrow.animate().rotation(0F).setDuration(250).start()
|
||||||
binding.descLinLayout.visibility = View.GONE
|
binding.descLinLayout.isGone = true
|
||||||
|
|
||||||
// limit the title height to two lines
|
// limit the title height to two lines
|
||||||
binding.playerTitle.maxLines = 2
|
binding.playerTitle.maxLines = 2
|
||||||
} else {
|
} else {
|
||||||
// show the description and chapters
|
// show the description and chapters
|
||||||
binding.playerDescriptionArrow.animate().rotation(180F).setDuration(250).start()
|
binding.playerDescriptionArrow.animate().rotation(180F).setDuration(250).start()
|
||||||
binding.descLinLayout.visibility = View.VISIBLE
|
binding.descLinLayout.isVisible = true
|
||||||
|
|
||||||
// show the whole title
|
// show the whole title
|
||||||
binding.playerTitle.maxLines = Int.MAX_VALUE
|
binding.playerTitle.maxLines = Int.MAX_VALUE
|
||||||
@ -688,7 +688,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
private fun playVideo() {
|
private fun playVideo() {
|
||||||
// reset the player view
|
// reset the player view
|
||||||
playerBinding.exoProgress.clearSegments()
|
playerBinding.exoProgress.clearSegments()
|
||||||
playerBinding.sbToggle.visibility = View.GONE
|
playerBinding.sbToggle.isGone = true
|
||||||
|
|
||||||
// reset the comments to become reloaded later
|
// reset the comments to become reloaded later
|
||||||
commentsViewModel.reset()
|
commentsViewModel.reset()
|
||||||
@ -743,7 +743,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
// hide the button to skip SponsorBlock segments manually
|
// hide the button to skip SponsorBlock segments manually
|
||||||
binding.sbSkipBtn.visibility = View.GONE
|
binding.sbSkipBtn.isGone = true
|
||||||
|
|
||||||
// set media sources for the player
|
// set media sources for the player
|
||||||
initStreamSources()
|
initStreamSources()
|
||||||
@ -799,7 +799,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
playerBinding.exoProgress.setSegments(segments)
|
playerBinding.exoProgress.setSegments(segments)
|
||||||
playerBinding.sbToggle.visibility = View.VISIBLE
|
playerBinding.sbToggle.isVisible = true
|
||||||
updateDisplayedDuration()
|
updateDisplayedDuration()
|
||||||
}
|
}
|
||||||
segments.firstOrNull { it.category == SPONSOR_HIGHLIGHT_CATEGORY }?.let {
|
segments.firstOrNull { it.category == SPONSOR_HIGHLIGHT_CATEGORY }?.let {
|
||||||
@ -1041,7 +1041,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
binding.autoplayCountdown.setHideSelfListener {
|
binding.autoplayCountdown.setHideSelfListener {
|
||||||
// could fail if the video already got closed before
|
// could fail if the video already got closed before
|
||||||
runCatching {
|
runCatching {
|
||||||
binding.autoplayCountdown.visibility = View.GONE
|
binding.autoplayCountdown.isGone = true
|
||||||
binding.player.useController = true
|
binding.player.useController = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1154,13 +1154,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
private fun initializeChapters() {
|
private fun initializeChapters() {
|
||||||
if (chapters.isEmpty()) {
|
if (chapters.isEmpty()) {
|
||||||
binding.chaptersRecView.visibility = View.GONE
|
binding.chaptersRecView.isGone = true
|
||||||
playerBinding.chapterLL.visibility = View.INVISIBLE
|
playerBinding.chapterLL.isInvisible = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// show the chapter layouts
|
// show the chapter layouts
|
||||||
binding.chaptersRecView.visibility = View.VISIBLE
|
binding.chaptersRecView.isVisible = true
|
||||||
playerBinding.chapterLL.visibility = View.VISIBLE
|
playerBinding.chapterLL.isVisible = true
|
||||||
|
|
||||||
// enable chapters in the video description
|
// enable chapters in the video description
|
||||||
binding.chaptersRecView.layoutManager =
|
binding.chaptersRecView.layoutManager =
|
||||||
@ -1525,7 +1525,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
||||||
enableTransition(R.id.yt_transition, false)
|
enableTransition(R.id.yt_transition, false)
|
||||||
}
|
}
|
||||||
binding.linLayout.visibility = View.GONE
|
binding.linLayout.isGone = true
|
||||||
|
|
||||||
updateCaptionsLanguage(null)
|
updateCaptionsLanguage(null)
|
||||||
} else {
|
} else {
|
||||||
@ -1542,7 +1542,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||||
enableTransition(R.id.yt_transition, true)
|
enableTransition(R.id.yt_transition, true)
|
||||||
}
|
}
|
||||||
binding.linLayout.visibility = View.VISIBLE
|
binding.linLayout.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCaptionsLanguage(captionLanguage)
|
updateCaptionsLanguage(captionLanguage)
|
||||||
@ -1582,7 +1582,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
.build()
|
.build()
|
||||||
|
|
||||||
private fun setupSeekbarPreview() {
|
private fun setupSeekbarPreview() {
|
||||||
playerBinding.seekbarPreview.visibility = View.GONE
|
playerBinding.seekbarPreview.isGone = true
|
||||||
playerBinding.exoProgress.addListener(
|
playerBinding.exoProgress.addListener(
|
||||||
SeekbarPreviewListener(
|
SeekbarPreviewListener(
|
||||||
OnlineTimeFrameReceiver(requireContext(), streams.previewFrames),
|
OnlineTimeFrameReceiver(requireContext(), streams.previewFrames),
|
||||||
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -90,7 +91,7 @@ class PlaylistFragment : Fragment() {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.playlistRecView.layoutManager = LinearLayoutManager(context)
|
binding.playlistRecView.layoutManager = LinearLayoutManager(context)
|
||||||
binding.playlistProgress.visibility = View.VISIBLE
|
binding.playlistProgress.isVisible = true
|
||||||
|
|
||||||
isBookmarked = runBlocking(Dispatchers.IO) {
|
isBookmarked = runBlocking(Dispatchers.IO) {
|
||||||
DatabaseHolder.Database.playlistBookmarkDao().includes(playlistId!!)
|
DatabaseHolder.Database.playlistBookmarkDao().includes(playlistId!!)
|
||||||
@ -118,7 +119,7 @@ class PlaylistFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchPlaylist() {
|
private fun fetchPlaylist() {
|
||||||
binding.playlistScrollview.visibility = View.GONE
|
binding.playlistScrollview.isGone = true
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
||||||
val response = try {
|
val response = try {
|
||||||
@ -132,12 +133,12 @@ class PlaylistFragment : Fragment() {
|
|||||||
val binding = _binding ?: return@repeatOnLifecycle
|
val binding = _binding ?: return@repeatOnLifecycle
|
||||||
|
|
||||||
playlistFeed = response.relatedStreams.toMutableList()
|
playlistFeed = response.relatedStreams.toMutableList()
|
||||||
binding.playlistScrollview.visibility = View.VISIBLE
|
binding.playlistScrollview.isVisible = true
|
||||||
nextPage = response.nextpage
|
nextPage = response.nextpage
|
||||||
playlistName = response.name
|
playlistName = response.name
|
||||||
isLoading = false
|
isLoading = false
|
||||||
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
||||||
binding.playlistProgress.visibility = View.GONE
|
binding.playlistProgress.isGone = true
|
||||||
binding.playlistName.text = response.name
|
binding.playlistName.text = response.name
|
||||||
|
|
||||||
binding.playlistName.setOnClickListener {
|
binding.playlistName.setOnClickListener {
|
||||||
|
@ -5,6 +5,8 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
@ -63,8 +65,8 @@ class SearchFragment : Fragment() {
|
|||||||
|
|
||||||
private fun showData(query: String?) {
|
private fun showData(query: String?) {
|
||||||
// fetch search suggestions if enabled or show the search history
|
// fetch search suggestions if enabled or show the search history
|
||||||
binding.historyEmpty.visibility = View.GONE
|
binding.historyEmpty.isGone = true
|
||||||
binding.suggestionsRecycler.visibility = View.VISIBLE
|
binding.suggestionsRecycler.isVisible = true
|
||||||
if (query.isNullOrEmpty()) {
|
if (query.isNullOrEmpty()) {
|
||||||
showHistory()
|
showHistory()
|
||||||
} else if (PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_SUGGESTIONS, true)) {
|
} else if (PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_SUGGESTIONS, true)) {
|
||||||
@ -106,8 +108,8 @@ class SearchFragment : Fragment() {
|
|||||||
(activity as MainActivity).searchView
|
(activity as MainActivity).searchView
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
binding.suggestionsRecycler.visibility = View.GONE
|
binding.suggestionsRecycler.isGone = true
|
||||||
binding.historyEmpty.visibility = View.VISIBLE
|
binding.historyEmpty.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
@ -75,7 +76,7 @@ class TrendsFragment : Fragment() {
|
|||||||
|
|
||||||
val binding = _binding ?: return@repeatOnLifecycle
|
val binding = _binding ?: return@repeatOnLifecycle
|
||||||
binding.homeRefresh.isRefreshing = false
|
binding.homeRefresh.isRefreshing = false
|
||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.isGone = true
|
||||||
|
|
||||||
// show a [SnackBar] if there are no trending videos available
|
// show a [SnackBar] if there are no trending videos available
|
||||||
if (response.isEmpty()) {
|
if (response.isEmpty()) {
|
||||||
|
@ -7,6 +7,8 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.os.postDelayed
|
import androidx.core.os.postDelayed
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
@ -71,8 +73,8 @@ class WatchHistoryFragment : Fragment() {
|
|||||||
.setTitle(R.string.clear_history)
|
.setTitle(R.string.clear_history)
|
||||||
.setMessage(R.string.irreversible)
|
.setMessage(R.string.irreversible)
|
||||||
.setPositiveButton(R.string.okay) { _, _ ->
|
.setPositiveButton(R.string.okay) { _, _ ->
|
||||||
binding.historyScrollView.visibility = View.GONE
|
binding.historyScrollView.isGone = true
|
||||||
binding.historyEmpty.visibility = View.VISIBLE
|
binding.historyEmpty.isVisible = true
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
Database.watchHistoryDao().deleteAll()
|
Database.watchHistoryDao().deleteAll()
|
||||||
}
|
}
|
||||||
@ -110,8 +112,8 @@ class WatchHistoryFragment : Fragment() {
|
|||||||
|
|
||||||
binding.watchHistoryRecView.layoutManager = LinearLayoutManager(context)
|
binding.watchHistoryRecView.layoutManager = LinearLayoutManager(context)
|
||||||
binding.watchHistoryRecView.adapter = watchHistoryAdapter
|
binding.watchHistoryRecView.adapter = watchHistoryAdapter
|
||||||
binding.historyEmpty.visibility = View.GONE
|
binding.historyEmpty.isGone = true
|
||||||
binding.historyScrollView.visibility = View.VISIBLE
|
binding.historyScrollView.isVisible = true
|
||||||
|
|
||||||
val itemTouchCallback = object : ItemTouchHelper.SimpleCallback(
|
val itemTouchCallback = object : ItemTouchHelper.SimpleCallback(
|
||||||
0,
|
0,
|
||||||
@ -142,8 +144,8 @@ class WatchHistoryFragment : Fragment() {
|
|||||||
RecyclerView.AdapterDataObserver() {
|
RecyclerView.AdapterDataObserver() {
|
||||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||||
if (watchHistoryAdapter.itemCount == 0) {
|
if (watchHistoryAdapter.itemCount == 0) {
|
||||||
binding.historyScrollView.visibility = View.GONE
|
binding.historyScrollView.isGone = true
|
||||||
binding.historyEmpty.visibility = View.VISIBLE
|
binding.historyEmpty.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package com.github.libretube.ui.listeners
|
package com.github.libretube.ui.listeners
|
||||||
|
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup.MarginLayoutParams
|
import android.view.ViewGroup.MarginLayoutParams
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.ui.TimeBar
|
import androidx.media3.ui.TimeBar
|
||||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||||
import com.github.libretube.ui.interfaces.TimeFrameReceiver
|
import com.github.libretube.ui.interfaces.TimeFrameReceiver
|
||||||
|
import kotlin.math.absoluteValue
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlin.math.absoluteValue
|
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
class SeekbarPreviewListener(
|
class SeekbarPreviewListener(
|
||||||
@ -69,7 +69,7 @@ class SeekbarPreviewListener(
|
|||||||
.translationYBy(30f)
|
.translationYBy(30f)
|
||||||
.setDuration(200)
|
.setDuration(200)
|
||||||
.withEndAction {
|
.withEndAction {
|
||||||
playerBinding.seekbarPreview.visibility = View.GONE
|
playerBinding.seekbarPreview.isGone = true
|
||||||
playerBinding.seekbarPreview.translationY -= 30f
|
playerBinding.seekbarPreview.translationY -= 30f
|
||||||
playerBinding.seekbarPreview.alpha = 1f
|
playerBinding.seekbarPreview.alpha = 1f
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import android.os.Handler
|
|||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.core.os.postDelayed
|
import androidx.core.os.postDelayed
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.databinding.AutoplayCountdownBinding
|
import com.github.libretube.databinding.AutoplayCountdownBinding
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class AutoplayCountdownView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun startCountdown(onEnd: () -> Unit) {
|
fun startCountdown(onEnd: () -> Unit) {
|
||||||
this.visibility = View.VISIBLE
|
this.isVisible = true
|
||||||
onCountdownEnd = {
|
onCountdownEnd = {
|
||||||
hideSelf.invoke()
|
hideSelf.invoke()
|
||||||
onEnd.invoke()
|
onEnd.invoke()
|
||||||
|
@ -275,7 +275,7 @@ open class CustomExoPlayerView(
|
|||||||
if (PlayerHelper.doubleTapToSeek) return
|
if (PlayerHelper.doubleTapToSeek) return
|
||||||
|
|
||||||
listOf(binding.forwardBTN, binding.rewindBTN).forEach {
|
listOf(binding.forwardBTN, binding.rewindBTN).forEach {
|
||||||
it.visibility = View.VISIBLE
|
it.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ open class CustomExoPlayerView(
|
|||||||
// start callback to hide the button
|
// start callback to hide the button
|
||||||
runnableHandler.removeCallbacksAndMessages(HIDE_REWIND_BUTTON_TOKEN)
|
runnableHandler.removeCallbacksAndMessages(HIDE_REWIND_BUTTON_TOKEN)
|
||||||
runnableHandler.postDelayed(700, HIDE_REWIND_BUTTON_TOKEN) {
|
runnableHandler.postDelayed(700, HIDE_REWIND_BUTTON_TOKEN) {
|
||||||
rewindBTN.visibility = View.GONE
|
rewindBTN.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ open class CustomExoPlayerView(
|
|||||||
// start callback to hide the button
|
// start callback to hide the button
|
||||||
runnableHandler.removeCallbacksAndMessages(HIDE_FORWARD_BUTTON_TOKEN)
|
runnableHandler.removeCallbacksAndMessages(HIDE_FORWARD_BUTTON_TOKEN)
|
||||||
runnableHandler.postDelayed(700, HIDE_FORWARD_BUTTON_TOKEN) {
|
runnableHandler.postDelayed(700, HIDE_FORWARD_BUTTON_TOKEN) {
|
||||||
forwardBTN.visibility = View.GONE
|
forwardBTN.isGone = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ open class CustomExoPlayerView(
|
|||||||
textView: TextView,
|
textView: TextView,
|
||||||
isRewind: Boolean
|
isRewind: Boolean
|
||||||
) {
|
) {
|
||||||
container.visibility = View.VISIBLE
|
container.isVisible = true
|
||||||
// the direction of the action
|
// the direction of the action
|
||||||
val direction = if (isRewind) -1 else 1
|
val direction = if (isRewind) -1 else 1
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ open class CustomExoPlayerView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBrightness(distance: Float) {
|
private fun updateBrightness(distance: Float) {
|
||||||
gestureViewBinding.brightnessControlView.visibility = View.VISIBLE
|
gestureViewBinding.brightnessControlView.isVisible = true
|
||||||
val bar = gestureViewBinding.brightnessProgressBar
|
val bar = gestureViewBinding.brightnessProgressBar
|
||||||
|
|
||||||
if (bar.progress == 0) {
|
if (bar.progress == 0) {
|
||||||
@ -477,7 +477,7 @@ open class CustomExoPlayerView(
|
|||||||
val bar = gestureViewBinding.volumeProgressBar
|
val bar = gestureViewBinding.volumeProgressBar
|
||||||
gestureViewBinding.volumeControlView.apply {
|
gestureViewBinding.volumeControlView.apply {
|
||||||
if (visibility == View.GONE) {
|
if (visibility == View.GONE) {
|
||||||
visibility = View.VISIBLE
|
isVisible = true
|
||||||
// Volume could be changed using other mediums, sync progress
|
// Volume could be changed using other mediums, sync progress
|
||||||
// bar with new value.
|
// bar with new value.
|
||||||
bar.progress = audioHelper.getVolumeWithScale(bar.max)
|
bar.progress = audioHelper.getVolumeWithScale(bar.max)
|
||||||
@ -679,8 +679,8 @@ open class CustomExoPlayerView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwipeEnd() {
|
override fun onSwipeEnd() {
|
||||||
gestureViewBinding.brightnessControlView.visibility = View.GONE
|
gestureViewBinding.brightnessControlView.isGone = true
|
||||||
gestureViewBinding.volumeControlView.visibility = View.GONE
|
gestureViewBinding.volumeControlView.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onZoom() {
|
override fun onZoom() {
|
||||||
|
@ -11,7 +11,6 @@ import androidx.media3.common.Player
|
|||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.ui.DefaultTimeBar
|
import androidx.media3.ui.DefaultTimeBar
|
||||||
import com.github.libretube.api.obj.Segment
|
import com.github.libretube.api.obj.Segment
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
|
||||||
import com.github.libretube.extensions.dpToPx
|
import com.github.libretube.extensions.dpToPx
|
||||||
import com.github.libretube.helpers.PreferenceHelper
|
import com.github.libretube.helpers.PreferenceHelper
|
||||||
import com.github.libretube.helpers.ThemeHelper
|
import com.github.libretube.helpers.ThemeHelper
|
||||||
|
Loading…
Reference in New Issue
Block a user