mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
Merge pull request #4743 from Bnyro/master
fix: remove fragment constructors from video and channel options bott…
This commit is contained in:
commit
c11cb94f6d
@ -1,10 +1,13 @@
|
|||||||
package com.github.libretube.api.obj
|
package com.github.libretube.api.obj
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
import com.github.libretube.db.obj.LocalPlaylistItem
|
import com.github.libretube.db.obj.LocalPlaylistItem
|
||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
@Parcelize
|
||||||
data class StreamItem(
|
data class StreamItem(
|
||||||
val url: String? = null,
|
val url: String? = null,
|
||||||
val type: String? = null,
|
val type: String? = null,
|
||||||
@ -20,7 +23,7 @@ data class StreamItem(
|
|||||||
val uploaded: Long? = null,
|
val uploaded: Long? = null,
|
||||||
val shortDescription: String? = null,
|
val shortDescription: String? = null,
|
||||||
val isShort: Boolean = false
|
val isShort: Boolean = false
|
||||||
) {
|
): Parcelable {
|
||||||
fun toLocalPlaylistItem(playlistId: String): LocalPlaylistItem {
|
fun toLocalPlaylistItem(playlistId: String): LocalPlaylistItem {
|
||||||
return LocalPlaylistItem(
|
return LocalPlaylistItem(
|
||||||
playlistId = playlistId.toInt(),
|
playlistId = playlistId.toInt(),
|
||||||
|
@ -28,4 +28,5 @@ object IntentData {
|
|||||||
const val loginTask = "loginTask"
|
const val loginTask = "loginTask"
|
||||||
const val logoutTask = "logoutTask"
|
const val logoutTask = "logoutTask"
|
||||||
const val color = "color"
|
const val color = "color"
|
||||||
|
const val streamItem = "streamItem"
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package com.github.libretube.ui.adapters
|
|||||||
|
|
||||||
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.constants.IntentData
|
||||||
import com.github.libretube.databinding.LegacySubscriptionChannelBinding
|
import com.github.libretube.databinding.LegacySubscriptionChannelBinding
|
||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.helpers.ImageHelper
|
import com.github.libretube.helpers.ImageHelper
|
||||||
@ -40,8 +42,12 @@ class LegacySubscriptionAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
ChannelOptionsBottomSheet(subscription.url.toID(), subscription.name)
|
val channelOptionsSheet = ChannelOptionsBottomSheet()
|
||||||
.show((root.context as BaseActivity).supportFragmentManager)
|
channelOptionsSheet.arguments = bundleOf(
|
||||||
|
IntentData.channelId to subscription.url.toID(),
|
||||||
|
IntentData.channelName to subscription.name
|
||||||
|
)
|
||||||
|
channelOptionsSheet.show((root.context as BaseActivity).supportFragmentManager)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,14 @@ import android.content.Context
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
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
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.VideoRowBinding
|
import com.github.libretube.databinding.VideoRowBinding
|
||||||
import com.github.libretube.enums.PlaylistType
|
import com.github.libretube.enums.PlaylistType
|
||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
@ -23,6 +25,7 @@ import com.github.libretube.ui.base.BaseActivity
|
|||||||
import com.github.libretube.ui.extensions.setFormattedDuration
|
import com.github.libretube.ui.extensions.setFormattedDuration
|
||||||
import com.github.libretube.ui.extensions.setWatchProgressLength
|
import com.github.libretube.ui.extensions.setWatchProgressLength
|
||||||
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
|
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet
|
||||||
|
import com.github.libretube.ui.sheets.VideoOptionsBottomSheet.Companion.VIDEO_OPTIONS_SHEET_REQUEST_KEY
|
||||||
import com.github.libretube.ui.viewholders.PlaylistViewHolder
|
import com.github.libretube.ui.viewholders.PlaylistViewHolder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -80,14 +83,16 @@ class PlaylistAdapter(
|
|||||||
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
||||||
}
|
}
|
||||||
val videoId = streamItem.url!!.toID()
|
val videoId = streamItem.url!!.toID()
|
||||||
|
|
||||||
|
val activity = (root.context as BaseActivity)
|
||||||
|
val fragmentManager = activity.supportFragmentManager
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
VideoOptionsBottomSheet(streamItem) {
|
fragmentManager.setFragmentResultListener(VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
.show(
|
val sheet = VideoOptionsBottomSheet()
|
||||||
(root.context as BaseActivity).supportFragmentManager,
|
sheet.arguments = bundleOf(IntentData.streamItem to streamItem)
|
||||||
VideoOptionsBottomSheet::class.java.name
|
sheet.show(fragmentManager, VideoOptionsBottomSheet::class.java.name)
|
||||||
)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,34 +53,34 @@ class PlaylistsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val fragmentManager = (root.context as BaseActivity).supportFragmentManager
|
val fragmentManager = (root.context as BaseActivity).supportFragmentManager
|
||||||
fragmentManager.setFragmentResultListener(
|
|
||||||
PLAYLISTS_ADAPTER_REQUEST_KEY,
|
|
||||||
(root.context as BaseActivity)
|
|
||||||
) { _, resultBundle ->
|
|
||||||
val newPlaylistDescription =
|
|
||||||
resultBundle.getString(IntentData.playlistDescription)
|
|
||||||
val newPlaylistName =
|
|
||||||
resultBundle.getString(IntentData.playlistName)
|
|
||||||
val isPlaylistToBeDeleted =
|
|
||||||
resultBundle.getBoolean(IntentData.playlistTask)
|
|
||||||
|
|
||||||
newPlaylistDescription?.let {
|
|
||||||
playlistDescription.text = it
|
|
||||||
playlist.shortDescription = it
|
|
||||||
}
|
|
||||||
|
|
||||||
newPlaylistName?.let {
|
|
||||||
playlistTitle.text = it
|
|
||||||
playlist.name = it
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPlaylistToBeDeleted) {
|
|
||||||
// try to refresh the playlists in the library on deletion success
|
|
||||||
onDelete(position, root.context as BaseActivity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
|
fragmentManager.setFragmentResultListener(
|
||||||
|
PLAYLISTS_ADAPTER_REQUEST_KEY,
|
||||||
|
(root.context as BaseActivity)
|
||||||
|
) { _, resultBundle ->
|
||||||
|
val newPlaylistDescription =
|
||||||
|
resultBundle.getString(IntentData.playlistDescription)
|
||||||
|
val newPlaylistName =
|
||||||
|
resultBundle.getString(IntentData.playlistName)
|
||||||
|
val isPlaylistToBeDeleted =
|
||||||
|
resultBundle.getBoolean(IntentData.playlistTask)
|
||||||
|
|
||||||
|
newPlaylistDescription?.let {
|
||||||
|
playlistDescription.text = it
|
||||||
|
playlist.shortDescription = it
|
||||||
|
}
|
||||||
|
|
||||||
|
newPlaylistName?.let {
|
||||||
|
playlistTitle.text = it
|
||||||
|
playlist.name = it
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPlaylistToBeDeleted) {
|
||||||
|
// try to refresh the playlists in the library on deletion success
|
||||||
|
onDelete(position, root.context as BaseActivity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val playlistOptionsDialog = PlaylistOptionsBottomSheet(
|
val playlistOptionsDialog = PlaylistOptionsBottomSheet(
|
||||||
playlistId = playlist.id!!,
|
playlistId = playlist.id!!,
|
||||||
playlistName = playlist.name!!,
|
playlistName = playlist.name!!,
|
||||||
|
@ -2,11 +2,13 @@ package com.github.libretube.ui.adapters
|
|||||||
|
|
||||||
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.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.obj.ContentItem
|
import com.github.libretube.api.obj.ContentItem
|
||||||
import com.github.libretube.api.obj.StreamItem
|
import com.github.libretube.api.obj.StreamItem
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.ChannelRowBinding
|
import com.github.libretube.databinding.ChannelRowBinding
|
||||||
import com.github.libretube.databinding.PlaylistsRowBinding
|
import com.github.libretube.databinding.PlaylistsRowBinding
|
||||||
import com.github.libretube.databinding.VideoRowBinding
|
import com.github.libretube.databinding.VideoRowBinding
|
||||||
@ -96,14 +98,16 @@ class SearchAdapter(
|
|||||||
NavigationHelper.navigateVideo(root.context, item.url)
|
NavigationHelper.navigateVideo(root.context, item.url)
|
||||||
}
|
}
|
||||||
val videoId = item.url.toID()
|
val videoId = item.url.toID()
|
||||||
|
|
||||||
|
val activity = (root.context as BaseActivity)
|
||||||
|
val fragmentManager = activity.supportFragmentManager
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
VideoOptionsBottomSheet(item.toStreamItem()) {
|
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
.show(
|
val sheet = VideoOptionsBottomSheet()
|
||||||
(root.context as BaseActivity).supportFragmentManager,
|
sheet.arguments = bundleOf(IntentData.streamItem to item)
|
||||||
VideoOptionsBottomSheet::class.java.name
|
sheet.show(fragmentManager, SearchAdapter::class.java.name)
|
||||||
)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
channelContainer.setOnClickListener {
|
channelContainer.setOnClickListener {
|
||||||
@ -134,8 +138,12 @@ class SearchAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
ChannelOptionsBottomSheet(item.url.toID(), item.name)
|
val channelOptionsSheet = ChannelOptionsBottomSheet()
|
||||||
.show((root.context as BaseActivity).supportFragmentManager)
|
channelOptionsSheet.arguments = bundleOf(
|
||||||
|
IntentData.channelId to item.url.toID(),
|
||||||
|
IntentData.channelName to item.name
|
||||||
|
)
|
||||||
|
channelOptionsSheet.show((root.context as BaseActivity).supportFragmentManager)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@ package com.github.libretube.ui.adapters
|
|||||||
|
|
||||||
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.api.obj.Subscription
|
import com.github.libretube.api.obj.Subscription
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.ChannelSubscriptionRowBinding
|
import com.github.libretube.databinding.ChannelSubscriptionRowBinding
|
||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.helpers.ImageHelper
|
import com.github.libretube.helpers.ImageHelper
|
||||||
@ -47,8 +49,12 @@ class SubscriptionChannelAdapter(
|
|||||||
NavigationHelper.navigateChannel(root.context, subscription.url)
|
NavigationHelper.navigateChannel(root.context, subscription.url)
|
||||||
}
|
}
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
ChannelOptionsBottomSheet(subscription.url.toID(), subscription.name)
|
val channelOptionsSheet = ChannelOptionsBottomSheet()
|
||||||
.show((root.context as BaseActivity).supportFragmentManager)
|
channelOptionsSheet.arguments = bundleOf(
|
||||||
|
IntentData.channelId to subscription.url.toID(),
|
||||||
|
IntentData.channelName to subscription.name
|
||||||
|
)
|
||||||
|
channelOptionsSheet.show((root.context as BaseActivity).supportFragmentManager)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context
|
|||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
@ -13,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
import androidx.recyclerview.widget.RecyclerView.LayoutManager
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.obj.StreamItem
|
import com.github.libretube.api.obj.StreamItem
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
import com.github.libretube.databinding.AllCaughtUpRowBinding
|
import com.github.libretube.databinding.AllCaughtUpRowBinding
|
||||||
import com.github.libretube.databinding.TrendingRowBinding
|
import com.github.libretube.databinding.TrendingRowBinding
|
||||||
@ -103,9 +105,7 @@ class VideosAdapter(
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: VideosViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: VideosViewHolder, position: Int) {
|
||||||
val video = streamItems[position]
|
val video = streamItems[position]
|
||||||
|
|
||||||
val videoId = video.url?.toID()
|
val videoId = video.url?.toID()
|
||||||
val videoName = video.title
|
|
||||||
|
|
||||||
videoId?.let {
|
videoId?.let {
|
||||||
(holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress)
|
(holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress)
|
||||||
@ -116,6 +116,9 @@ class VideosAdapter(
|
|||||||
holder.videoRowBinding ?: holder.trendingRowBinding
|
holder.videoRowBinding ?: holder.trendingRowBinding
|
||||||
?: holder.allCaughtUpBinding
|
?: holder.allCaughtUpBinding
|
||||||
)!!.root.context
|
)!!.root.context
|
||||||
|
val activity = (context as BaseActivity)
|
||||||
|
val fragmentManager = activity.supportFragmentManager
|
||||||
|
|
||||||
val uploadDate =
|
val uploadDate =
|
||||||
video.uploaded?.takeIf { it > 0 }?.let { TextUtils.formatRelativeDate(context, it) }
|
video.uploaded?.takeIf { it > 0 }?.let { TextUtils.formatRelativeDate(context, it) }
|
||||||
|
|
||||||
@ -146,17 +149,14 @@ class VideosAdapter(
|
|||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
NavigationHelper.navigateVideo(root.context, video.url)
|
NavigationHelper.navigateVideo(root.context, video.url)
|
||||||
}
|
}
|
||||||
root.setOnLongClickListener {
|
|
||||||
if (videoId == null || videoName == null) return@setOnLongClickListener true
|
|
||||||
|
|
||||||
VideoOptionsBottomSheet(video) {
|
root.setOnLongClickListener {
|
||||||
|
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
.show(
|
val sheet = VideoOptionsBottomSheet()
|
||||||
(root.context as BaseActivity).supportFragmentManager,
|
sheet.arguments = bundleOf(IntentData.streamItem to video)
|
||||||
VideoOptionsBottomSheet::class.java.name
|
sheet.show(fragmentManager, VideosAdapter::class.java.name)
|
||||||
)
|
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,14 +191,12 @@ class VideosAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
if (videoId == null || videoName == null) return@setOnLongClickListener true
|
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||||
VideoOptionsBottomSheet(video) {
|
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
.show(
|
val sheet = VideoOptionsBottomSheet()
|
||||||
(root.context as BaseActivity).supportFragmentManager,
|
sheet.arguments = bundleOf(IntentData.streamItem to video)
|
||||||
VideoOptionsBottomSheet::class.java.name
|
sheet.show(fragmentManager, VideosAdapter::class.java.name)
|
||||||
)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package com.github.libretube.ui.adapters
|
|||||||
|
|
||||||
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.constants.IntentData
|
||||||
import com.github.libretube.databinding.VideoRowBinding
|
import com.github.libretube.databinding.VideoRowBinding
|
||||||
import com.github.libretube.db.DatabaseHolder
|
import com.github.libretube.db.DatabaseHolder
|
||||||
import com.github.libretube.db.obj.WatchHistoryItem
|
import com.github.libretube.db.obj.WatchHistoryItem
|
||||||
@ -67,14 +69,16 @@ class WatchHistoryAdapter(
|
|||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
NavigationHelper.navigateVideo(root.context, video.videoId)
|
NavigationHelper.navigateVideo(root.context, video.videoId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val activity = (root.context as BaseActivity)
|
||||||
|
val fragmentManager = activity.supportFragmentManager
|
||||||
root.setOnLongClickListener {
|
root.setOnLongClickListener {
|
||||||
VideoOptionsBottomSheet(video.toStreamItem()) {
|
fragmentManager.setFragmentResultListener(VideoOptionsBottomSheet.VIDEO_OPTIONS_SHEET_REQUEST_KEY, activity) { _, _ ->
|
||||||
notifyItemChanged(position)
|
notifyItemChanged(position)
|
||||||
}
|
}
|
||||||
.show(
|
val sheet = VideoOptionsBottomSheet()
|
||||||
(root.context as BaseActivity).supportFragmentManager,
|
sheet.arguments = bundleOf(IntentData.streamItem to video)
|
||||||
VideoOptionsBottomSheet::class.java.name
|
sheet.show(fragmentManager, WatchHistoryAdapter::class.java.name)
|
||||||
)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,9 +397,8 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
|
|||||||
|
|
||||||
override fun onLongTap() {
|
override fun onLongTap() {
|
||||||
val current = PlayingQueue.getCurrent() ?: return
|
val current = PlayingQueue.getCurrent() ?: return
|
||||||
VideoOptionsBottomSheet(
|
VideoOptionsBottomSheet()
|
||||||
current
|
.apply { arguments = bundleOf(IntentData.shareData to current) }
|
||||||
)
|
|
||||||
.show(childFragmentManager)
|
.show(childFragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +21,16 @@ import kotlinx.coroutines.withContext
|
|||||||
*
|
*
|
||||||
* Needs the [channelId] to load the content from the right video.
|
* Needs the [channelId] to load the content from the right video.
|
||||||
*/
|
*/
|
||||||
class ChannelOptionsBottomSheet(
|
class ChannelOptionsBottomSheet : BaseBottomSheet() {
|
||||||
private val channelId: String,
|
private lateinit var channelId: String
|
||||||
channelName: String?
|
private var channelName: String? = null
|
||||||
) : BaseBottomSheet() {
|
|
||||||
private val shareData = ShareData(currentChannel = channelName)
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
channelId = arguments?.getString(IntentData.channelId)!!
|
||||||
|
channelName = arguments?.getString(IntentData.channelName)
|
||||||
|
|
||||||
// List that stores the different menu options. In the future could be add more options here.
|
// List that stores the different menu options. In the future could be add more options here.
|
||||||
val optionsList = mutableListOf(
|
val optionsList = mutableListOf(
|
||||||
getString(R.string.share),
|
getString(R.string.share),
|
||||||
@ -42,7 +44,7 @@ class ChannelOptionsBottomSheet(
|
|||||||
val bundle = bundleOf(
|
val bundle = bundleOf(
|
||||||
IntentData.id to channelId,
|
IntentData.id to channelId,
|
||||||
IntentData.shareObjectType to ShareObjectType.CHANNEL,
|
IntentData.shareObjectType to ShareObjectType.CHANNEL,
|
||||||
IntentData.shareData to shareData
|
IntentData.shareData to ShareData(currentChannel = channelName)
|
||||||
)
|
)
|
||||||
val newShareDialog = ShareDialog()
|
val newShareDialog = ShareDialog()
|
||||||
newShareDialog.arguments = bundle
|
newShareDialog.arguments = bundle
|
||||||
|
@ -40,9 +40,7 @@ class StatsSheet(
|
|||||||
)
|
)
|
||||||
binding.audioInfo.setText(
|
binding.audioInfo.setText(
|
||||||
"${player.audioFormat?.codecs.orEmpty()} ${
|
"${player.audioFormat?.codecs.orEmpty()} ${
|
||||||
TextUtils.formatBitrate(
|
TextUtils.formatBitrate(player.audioFormat?.bitrate)
|
||||||
player.audioFormat?.bitrate
|
|
||||||
)
|
|
||||||
}"
|
}"
|
||||||
)
|
)
|
||||||
binding.videoQuality.setText(
|
binding.videoQuality.setText(
|
||||||
|
@ -2,6 +2,7 @@ package com.github.libretube.ui.sheets
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.fragment.app.setFragmentResult
|
||||||
import androidx.navigation.fragment.NavHostFragment
|
import androidx.navigation.fragment.NavHostFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.obj.StreamItem
|
import com.github.libretube.api.obj.StreamItem
|
||||||
@ -11,6 +12,7 @@ import com.github.libretube.db.DatabaseHelper
|
|||||||
import com.github.libretube.db.DatabaseHolder
|
import com.github.libretube.db.DatabaseHolder
|
||||||
import com.github.libretube.db.obj.WatchPosition
|
import com.github.libretube.db.obj.WatchPosition
|
||||||
import com.github.libretube.enums.ShareObjectType
|
import com.github.libretube.enums.ShareObjectType
|
||||||
|
import com.github.libretube.extensions.parcelable
|
||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.helpers.BackgroundHelper
|
import com.github.libretube.helpers.BackgroundHelper
|
||||||
import com.github.libretube.helpers.NavigationHelper
|
import com.github.libretube.helpers.NavigationHelper
|
||||||
@ -32,12 +34,12 @@ import kotlinx.coroutines.withContext
|
|||||||
*
|
*
|
||||||
* Needs the [streamItem] to load the content from the right video.
|
* Needs the [streamItem] to load the content from the right video.
|
||||||
*/
|
*/
|
||||||
class VideoOptionsBottomSheet(
|
class VideoOptionsBottomSheet : BaseBottomSheet() {
|
||||||
private val streamItem: StreamItem,
|
private lateinit var streamItem: StreamItem
|
||||||
private val onVideoChanged: () -> Unit = {}
|
|
||||||
) : BaseBottomSheet() {
|
|
||||||
private val shareData = ShareData(currentVideo = streamItem.title)
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
streamItem = arguments?.parcelable(IntentData.streamItem)!!
|
||||||
|
|
||||||
val videoId = streamItem.url?.toID() ?: return
|
val videoId = streamItem.url?.toID() ?: return
|
||||||
// List that stores the different menu options. In the future could be add more options here.
|
// List that stores the different menu options. In the future could be add more options here.
|
||||||
val optionsList = mutableListOf(
|
val optionsList = mutableListOf(
|
||||||
@ -64,7 +66,7 @@ class VideoOptionsBottomSheet(
|
|||||||
|
|
||||||
if (streamItem.duration == null ||
|
if (streamItem.duration == null ||
|
||||||
watchPositionEntry == null ||
|
watchPositionEntry == null ||
|
||||||
watchPositionEntry.position < streamItem.duration * 1000 * 0.9
|
watchPositionEntry.position < streamItem.duration!! * 1000 * 0.9
|
||||||
) {
|
) {
|
||||||
optionsList += getString(R.string.mark_as_watched)
|
optionsList += getString(R.string.mark_as_watched)
|
||||||
}
|
}
|
||||||
@ -101,7 +103,7 @@ class VideoOptionsBottomSheet(
|
|||||||
val bundle = bundleOf(
|
val bundle = bundleOf(
|
||||||
IntentData.id to videoId,
|
IntentData.id to videoId,
|
||||||
IntentData.shareObjectType to ShareObjectType.VIDEO,
|
IntentData.shareObjectType to ShareObjectType.VIDEO,
|
||||||
IntentData.shareData to shareData
|
IntentData.shareData to ShareData(currentVideo = streamItem.title)
|
||||||
)
|
)
|
||||||
val newShareDialog = ShareDialog()
|
val newShareDialog = ShareDialog()
|
||||||
newShareDialog.arguments = bundle
|
newShareDialog.arguments = bundle
|
||||||
@ -134,7 +136,7 @@ class VideoOptionsBottomSheet(
|
|||||||
?.firstOrNull() as? SubscriptionsFragment
|
?.firstOrNull() as? SubscriptionsFragment
|
||||||
fragment?.feedAdapter?.removeItemById(videoId)
|
fragment?.feedAdapter?.removeItemById(videoId)
|
||||||
}
|
}
|
||||||
onVideoChanged()
|
setFragmentResult(VIDEO_OPTIONS_SHEET_REQUEST_KEY, bundleOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
getString(R.string.mark_as_unwatched) -> {
|
getString(R.string.mark_as_unwatched) -> {
|
||||||
@ -142,11 +144,15 @@ class VideoOptionsBottomSheet(
|
|||||||
DatabaseHolder.Database.watchPositionDao().deleteByVideoId(videoId)
|
DatabaseHolder.Database.watchPositionDao().deleteByVideoId(videoId)
|
||||||
DatabaseHolder.Database.watchHistoryDao().deleteByVideoId(videoId)
|
DatabaseHolder.Database.watchHistoryDao().deleteByVideoId(videoId)
|
||||||
}
|
}
|
||||||
onVideoChanged()
|
setFragmentResult(VIDEO_OPTIONS_SHEET_REQUEST_KEY, bundleOf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val VIDEO_OPTIONS_SHEET_REQUEST_KEY = "video_options_sheet_request_key"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user