Commit f7f5ea66 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Move context flags to long as we are reaching the 32 bits limit

parent 372f2eaf
......@@ -150,44 +150,44 @@ const val CURRENT_BROWSER_LIST = "CURRENT_BROWSER_LIST"
const val CURRENT_BROWSER_MAP = "CURRENT_BROWSER_MAP"
// Context options
const val CTX_PLAY_ALL = 1
const val CTX_APPEND = 1 shl 1
const val CTX_PLAY_AS_AUDIO = 1 shl 2
const val CTX_INFORMATION = 1 shl 3
const val CTX_DELETE = 1 shl 4
const val CTX_DOWNLOAD_SUBTITLES = 1 shl 5
const val CTX_PLAY_FROM_START = 1 shl 6
const val CTX_PLAY_GROUP = 1 shl 7
const val CTX_PLAY = 1 shl 8
const val CTX_PLAY_NEXT = 1 shl 9
const val CTX_ADD_TO_PLAYLIST = 1 shl 10
const val CTX_SET_RINGTONE = 1 shl 11
const val CTX_FAV_ADD = 1 shl 12
const val CTX_FAV_EDIT = 1 shl 13
const val CTX_FAV_REMOVE = 1 shl 14
const val CTX_CUSTOM_REMOVE = 1 shl 15
const val CTX_ITEM_DL = 1 shl 16
const val CTX_REMOVE_FROM_PLAYLIST = 1 shl 17
const val CTX_STOP_AFTER_THIS = 1 shl 18
const val CTX_RENAME = 1 shl 19
const val CTX_AUDIO_TRACK = 1 shl 20
const val CTX_SUBS_TRACK = 1 shl 21
const val CTX_PICK_SUBS = 1 shl 22
const val CTX_VIDEO_TRACK = 1 shl 23
const val CTX_DOWNLOAD_SUBTITLES_PLAYER = 1 shl 24
const val CTX_ADD_SCANNED = 1 shl 25
const val CTX_COPY = 1 shl 26
const val CTX_SHARE = 1 shl 27
const val CTX_FIND_METADATA = 1 shl 28
const val CTX_ADD_FOLDER_PLAYLIST = 1 shl 29
const val CTX_ADD_FOLDER_AND_SUB_PLAYLIST = 1 shl 30
const val CTX_PLAY_ALL = 1L
const val CTX_APPEND = 1L shl 1
const val CTX_PLAY_AS_AUDIO = 1L shl 2
const val CTX_INFORMATION = 1L shl 3
const val CTX_DELETE = 1L shl 4
const val CTX_DOWNLOAD_SUBTITLES = 1L shl 5
const val CTX_PLAY_FROM_START = 1L shl 6
const val CTX_PLAY_GROUP = 1L shl 7
const val CTX_PLAY = 1L shl 8
const val CTX_PLAY_NEXT = 1L shl 9
const val CTX_ADD_TO_PLAYLIST = 1L shl 10
const val CTX_SET_RINGTONE = 1L shl 11
const val CTX_FAV_ADD = 1L shl 12
const val CTX_FAV_EDIT = 1L shl 13
const val CTX_FAV_REMOVE = 1L shl 14
const val CTX_CUSTOM_REMOVE = 1L shl 15
const val CTX_ITEM_DL = 1L shl 16
const val CTX_REMOVE_FROM_PLAYLIST = 1L shl 17
const val CTX_STOP_AFTER_THIS = 1L shl 18
const val CTX_RENAME = 1L shl 19
const val CTX_AUDIO_TRACK = 1L shl 20
const val CTX_SUBS_TRACK = 1L shl 21
const val CTX_PICK_SUBS = 1L shl 22
const val CTX_VIDEO_TRACK = 1L shl 23
const val CTX_DOWNLOAD_SUBTITLES_PLAYER = 1L shl 24
const val CTX_ADD_SCANNED = 1L shl 25
const val CTX_COPY = 1L shl 26
const val CTX_SHARE = 1L shl 27
const val CTX_FIND_METADATA = 1L shl 28
const val CTX_ADD_FOLDER_PLAYLIST = 1L shl 29
const val CTX_ADD_FOLDER_AND_SUB_PLAYLIST = 1L shl 30
const val CTX_VIDEO_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_DOWNLOAD_SUBTITLES or CTX_INFORMATION or CTX_PLAY_ALL or CTX_PLAY_AS_AUDIO or CTX_ADD_TO_PLAYLIST or CTX_SHARE
const val CTX_TRACK_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_DELETE or CTX_INFORMATION or CTX_PLAY_ALL or CTX_ADD_TO_PLAYLIST or CTX_SET_RINGTONE or CTX_SHARE
const val CTX_AUDIO_FLAGS = CTX_PLAY or CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION
const val CTX_PLAYLIST_FLAGS = CTX_AUDIO_FLAGS or CTX_DELETE
const val CTX_PLAYLIST_ITEM_FLAGS = CTX_APPEND or CTX_PLAY_NEXT or CTX_ADD_TO_PLAYLIST or CTX_INFORMATION or CTX_DELETE or CTX_SET_RINGTONE or CTX_SHARE
const val CTX_VIDEO_GOUP_FLAGS = CTX_APPEND or CTX_PLAY_GROUP
const val CTX_VIDEO_GROUP_FLAGS = CTX_APPEND or CTX_PLAY_GROUP
const val CTX_FOLDER_FLAGS = CTX_PLAY or CTX_APPEND or CTX_ADD_TO_PLAYLIST
//Moviepedia
......
......@@ -826,4 +826,5 @@
<string name="more">More</string>
<string name="favorites">Favorites</string>
<string name="new_stream">New stream</string>
<string name="add_to_group">Add to group</string>
</resources>
......@@ -360,7 +360,7 @@ open class PlaylistActivity : AudioPlayerContainerActivity(), IEventsHandler<Med
startActivity(i)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (position >= audioBrowserAdapter.itemCount) return
val media = audioBrowserAdapter.getItem(position) as MediaWrapper? ?: return
when (option) {
......
......@@ -167,7 +167,7 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
} else super.onClick(v, position, item)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (option == CTX_PLAY_ALL) MediaUtils.playAll(activity, viewModel.provider as MedialibraryProvider<MediaWrapper>, position, false)
else super.onCtxAction(position, option)
}
......
......@@ -37,6 +37,9 @@ import kotlinx.coroutines.ObsoleteCoroutinesApi
import org.videolan.medialibrary.interfaces.media.Album
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.resources.CTX_PLAY_ALL
import org.videolan.tools.Settings
import org.videolan.tools.putSingle
import org.videolan.vlc.R
import org.videolan.vlc.gui.ContentActivity
import org.videolan.vlc.gui.PlaylistActivity
......@@ -45,9 +48,6 @@ import org.videolan.vlc.gui.view.RecyclerSectionItemDecoration
import org.videolan.vlc.gui.view.RecyclerSectionItemGridDecoration
import org.videolan.vlc.media.MediaUtils
import org.videolan.vlc.providers.medialibrary.MedialibraryProvider
import org.videolan.resources.CTX_PLAY_ALL
import org.videolan.tools.Settings
import org.videolan.tools.putSingle
import org.videolan.vlc.util.getScreenWidth
import org.videolan.vlc.viewmodels.mobile.AlbumSongsViewModel
import org.videolan.vlc.viewmodels.mobile.getViewModel
......@@ -230,7 +230,7 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
MediaUtils.openMedia(v.context, item as MediaWrapper)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (option == CTX_PLAY_ALL) MediaUtils.playAll(activity, viewModel.tracksProvider, position, false)
else super.onCtxAction(position, option)
}
......
......@@ -330,7 +330,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
lists[tab.position].smoothScrollToPosition(0)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
@Suppress("UNCHECKED_CAST")
if (option == CTX_PLAY_ALL) MediaUtils.playAll(activity, viewModel.providers[currentTab] as MedialibraryProvider<MediaWrapper>, position, false)
else super.onCtxAction(position, option)
......
......@@ -192,7 +192,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
}
private val ctxReceiver: CtxActionReceiver = object : CtxActionReceiver {
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (position in 0 until playlistAdapter.itemCount) when (option) {
CTX_SET_RINGTONE -> activity?.setRingtone(playlistAdapter.getItem(position))
CTX_ADD_TO_PLAYLIST -> {
......
......@@ -50,7 +50,6 @@ import org.videolan.vlc.gui.browser.MediaBrowserFragment
import org.videolan.vlc.gui.dialogs.CtxActionReceiver
import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
import org.videolan.vlc.gui.dialogs.showContext
import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.AudioUtil.setRingtone
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.helpers.UiTools.addToPlaylist
......@@ -279,7 +278,7 @@ abstract class BaseAudioBrowser<T : MedialibraryViewModel> : MediaBrowserFragmen
}
override fun onCtxClick(v: View, position: Int, item: MediaLibraryItem) {
val flags: Int = when (item.itemType) {
val flags: Long = when (item.itemType) {
MediaLibraryItem.TYPE_MEDIA -> CTX_TRACK_FLAGS
MediaLibraryItem.TYPE_PLAYLIST -> CTX_PLAYLIST_FLAGS
else -> CTX_AUDIO_FLAGS
......@@ -300,7 +299,7 @@ abstract class BaseAudioBrowser<T : MedialibraryViewModel> : MediaBrowserFragmen
override fun onItemFocused(v: View, item: MediaLibraryItem) {}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (position >= getCurrentAdapter()?.itemCount ?: 0) return
val media = getCurrentAdapter()?.getItem(position) ?: return
when (option) {
......
......@@ -522,11 +522,11 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
if (!isAudio) flags = flags or CTX_PLAY_AS_AUDIO
if (isVideo) flags = flags or CTX_DOWNLOAD_SUBTITLES
}
if (flags != 0) showContext(requireActivity(), this@BaseBrowserFragment, position, item.getTitle(), flags)
if (flags != 0L) showContext(requireActivity(), this@BaseBrowserFragment, position, item.getTitle(), flags)
}
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
val mw = adapter.getItem(position) as? MediaWrapper
?: return
when (option) {
......
......@@ -154,7 +154,7 @@ class ExtensionBrowser : Fragment(), View.OnClickListener, androidx.swiperefresh
showContext(requireActivity(), this, position, mAdapter.getItem(position).title, CTX_PLAY_ALL or CTX_APPEND or CTX_PLAY_AS_AUDIO or CTX_ITEM_DL)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
when (option) {
CTX_PLAY_ALL -> {
val items = mAdapter.all
......
......@@ -130,7 +130,7 @@ open class FileBrowserFragment : BaseBrowserFragment() {
super.onClick(v, position, item)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
val mw = this.adapter.getItem(position) as MediaWrapper?
when (option) {
CTX_FAV_ADD -> lifecycleScope.launch { browserFavRepository.addLocalFavItem(mw!!.uri, mw.title, mw.artworkURL) }
......
......@@ -298,7 +298,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
val mw = item as MediaWrapper
if (mw.uri.scheme == "content" || mw.uri.scheme == OTG_SCHEME) return@launch
var flags = 0
var flags = 0L
val isEmpty = (viewModel as? BrowserModel)?.isFolderEmpty(mw) ?: true
if (!isEmpty) flags = flags or CTX_PLAY
val isFileBrowser = isFile && item.uri.scheme == "file"
......@@ -311,7 +311,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
if (localViewModel.provider.hasMedias(mw)) flags = flags or CTX_ADD_FOLDER_PLAYLIST
if (localViewModel.provider.hasSubfolders(mw)) flags = flags or CTX_ADD_FOLDER_AND_SUB_PLAYLIST
}
if (flags != 0) {
if (flags != 0L) {
showContext(requireActivity(), this@MainBrowserFragment, position, item.getTitle(), flags)
currentCtx = this@MainBrowserContainer
}
......@@ -319,7 +319,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
}
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
val adapter = currentCtx?.requireAdapter() ?: return
val mw = adapter.getItem(position) as? MediaWrapper
?: return
......
......@@ -31,11 +31,14 @@ import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.ObsoleteCoroutinesApi
import kotlinx.coroutines.launch
import org.videolan.libvlc.Dialog
import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.resources.CTX_FAV_ADD
import org.videolan.tools.NetworkMonitor
import org.videolan.tools.isStarted
import org.videolan.vlc.R
import org.videolan.vlc.gui.view.EmptyLoadingState
import org.videolan.vlc.util.DialogDelegate
......@@ -118,7 +121,7 @@ class NetworkBrowserFragment : BaseBrowserFragment(), IDialogManager {
}
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
val mw = this.adapter.getItem(position) as MediaWrapper
when (option) {
CTX_FAV_ADD -> lifecycleScope.launch { browserFavRepository.addNetworkFavItem(mw.uri, mw.title, mw.artworkURL) }
......
......@@ -160,7 +160,7 @@ class StorageBrowserFragment : FileBrowserFragment(), EntryPointsEventsCb, Brows
}
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
val storage = adapter.getItem(position) as Storage
val path = storage.uri.path ?: return
viewModel.deleteCustomDirectory(path)
......
......@@ -80,40 +80,40 @@ class ContextSheet : VLCBottomSheetDialogFragment() {
list = view.findViewById<RecyclerView>(R.id.ctx_list)
list.layoutManager = LinearLayoutManager(requireContext())
list.adapter = ContextAdapter()
val flags = arguments?.getInt(CTX_FLAGS_KEY) ?: 0
val flags = arguments?.getLong(CTX_FLAGS_KEY) ?: 0
options = populateOptions(flags)
}
private fun populateOptions(flags: Int) = mutableListOf<CtxOption>().apply {
if (flags and CTX_PLAY != 0) add(Simple(CTX_PLAY, getString(R.string.play), R.drawable.ic_ctx_play_normal))
if (flags and CTX_PLAY_FROM_START != 0) add(Simple(CTX_PLAY_FROM_START, getString(R.string.play_from_start), R.drawable.ic_ctx_play_from_start_normal))
if (flags and CTX_PLAY_ALL != 0) add(Simple(CTX_PLAY_ALL, getString(R.string.play_all), R.drawable.ic_ctx_play_all_normal))
if (flags and CTX_PLAY_AS_AUDIO != 0) add(Simple(CTX_PLAY_AS_AUDIO, getString(R.string.play_as_audio), R.drawable.ic_ctx_play_as_audio_normal))
if (flags and CTX_PLAY_GROUP != 0) add(Simple(CTX_PLAY_GROUP, getString(R.string.play), R.drawable.ic_ctx_play_normal))
if (flags and CTX_VIDEO_TRACK != 0) add(Simple(CTX_VIDEO_TRACK, getString(R.string.ctx_player_video_track), R.drawable.ic_ctx_information_normal))
if (flags and CTX_AUDIO_TRACK != 0) add(Simple(CTX_AUDIO_TRACK, getString(R.string.ctx_player_audio_track), R.drawable.ic_audiotrack_normal))
if (flags and CTX_SUBS_TRACK != 0) add(Simple(CTX_SUBS_TRACK, getString(R.string.ctx_player_subs_track), R.drawable.ic_subtitle_w))
if (flags and CTX_PICK_SUBS != 0) add(Simple(CTX_PICK_SUBS, getString(R.string.subtitle_select), R.drawable.ic_subtitle_open_w))
if (flags and CTX_APPEND != 0) add(Simple(CTX_APPEND, getString(R.string.append), R.drawable.ic_ctx_append_normal))
if (flags and CTX_INFORMATION != 0) add(Simple(CTX_INFORMATION, getString(R.string.info), R.drawable.ic_ctx_information_normal))
if (flags and CTX_DOWNLOAD_SUBTITLES != 0) add(Simple(CTX_DOWNLOAD_SUBTITLES, getString(R.string.download_subtitles), R.drawable.ic_ctx_download_subtitles_normal))
if (flags and CTX_DOWNLOAD_SUBTITLES_PLAYER != 0) add(Simple(CTX_DOWNLOAD_SUBTITLES_PLAYER, getString(R.string.download_subtitles), R.drawable.ic_downsub_normal))
if (flags and CTX_PLAY_NEXT != 0) add(Simple(CTX_PLAY_NEXT, getString(R.string.insert_next), R.drawable.ic_ctx_play_next_normal))
if (flags and CTX_ADD_TO_PLAYLIST != 0) add(Simple(CTX_ADD_TO_PLAYLIST, getString(R.string.add_to_playlist), R.drawable.ic_ctx_add_to_playlist_normal))
if (flags and CTX_SET_RINGTONE != 0 && AndroidDevices.isPhone) add(Simple(CTX_SET_RINGTONE, getString(R.string.set_song), R.drawable.ic_ctx_set_ringtone_normal))
if (flags and CTX_FAV_ADD != 0) add(Simple(CTX_FAV_ADD, getString(R.string.favorites_add), R.drawable.ic_ctx_fav_add_normal))
if (flags and CTX_ADD_SCANNED != 0) add(Simple(CTX_ADD_SCANNED, getString(R.string.add_to_scanned), R.drawable.ic_ctx_addtoscan_normal))
if (flags and CTX_FAV_EDIT != 0) add(Simple(CTX_FAV_EDIT, getString(R.string.favorites_edit), R.drawable.ic_ctx_fav_edit_normal))
if (flags and CTX_FAV_REMOVE != 0) add(Simple(CTX_FAV_REMOVE, getString(R.string.favorites_remove), R.drawable.ic_ctx_fav_remove_normal))
if (flags and CTX_REMOVE_FROM_PLAYLIST != 0) add(Simple(CTX_REMOVE_FROM_PLAYLIST, getString(R.string.remove), R.drawable.ic_ctx_remove_from_playlist_normal))
if (flags and CTX_STOP_AFTER_THIS != 0) add(Simple(CTX_STOP_AFTER_THIS, getString(R.string.stop_after_this), R.drawable.ic_ctx_stop_after_this))
if (flags and CTX_RENAME != 0) add(Simple(CTX_RENAME, getString(R.string.rename), R.drawable.ic_ctx_edit_normal))
if (flags and CTX_COPY != 0) add(Simple(CTX_COPY, getString(R.string.copy_to_clipboard), R.drawable.ic_ctx_link_normal))
if (flags and CTX_DELETE != 0) add(Simple(CTX_DELETE, getString(R.string.delete), R.drawable.ic_ctx_delete_normal))
if (flags and CTX_SHARE != 0) add(Simple(CTX_SHARE, getString(R.string.share), R.drawable.ic_ctx_share_normal))
if (flags and CTX_FIND_METADATA != 0) add(Simple(CTX_FIND_METADATA, getString(R.string.find_metadata), R.drawable.ic_ctx_delete_normal))
if (flags and CTX_ADD_FOLDER_PLAYLIST != 0) add(Simple(CTX_ADD_FOLDER_PLAYLIST, getString(R.string.this_folder), R.drawable.ic_ctx_add_to_playlist_normal))
if (flags and CTX_ADD_FOLDER_AND_SUB_PLAYLIST != 0) add(Simple(CTX_ADD_FOLDER_AND_SUB_PLAYLIST, getString(R.string.all_subfolders), R.drawable.ic_ctx_add_to_playlist_normal))
private fun populateOptions(flags: Long) = mutableListOf<CtxOption>().apply {
if (flags and CTX_PLAY != 0L) add(Simple(CTX_PLAY, getString(R.string.play), R.drawable.ic_ctx_play_normal))
if (flags and CTX_PLAY_FROM_START != 0L) add(Simple(CTX_PLAY_FROM_START, getString(R.string.play_from_start), R.drawable.ic_ctx_play_from_start_normal))
if (flags and CTX_PLAY_ALL != 0L) add(Simple(CTX_PLAY_ALL, getString(R.string.play_all), R.drawable.ic_ctx_play_all_normal))
if (flags and CTX_PLAY_AS_AUDIO != 0L) add(Simple(CTX_PLAY_AS_AUDIO, getString(R.string.play_as_audio), R.drawable.ic_ctx_play_as_audio_normal))
if (flags and CTX_PLAY_GROUP != 0L) add(Simple(CTX_PLAY_GROUP, getString(R.string.play), R.drawable.ic_ctx_play_normal))
if (flags and CTX_VIDEO_TRACK != 0L) add(Simple(CTX_VIDEO_TRACK, getString(R.string.ctx_player_video_track), R.drawable.ic_ctx_information_normal))
if (flags and CTX_AUDIO_TRACK != 0L) add(Simple(CTX_AUDIO_TRACK, getString(R.string.ctx_player_audio_track), R.drawable.ic_audiotrack_normal))
if (flags and CTX_SUBS_TRACK != 0L) add(Simple(CTX_SUBS_TRACK, getString(R.string.ctx_player_subs_track), R.drawable.ic_subtitle_w))
if (flags and CTX_PICK_SUBS != 0L) add(Simple(CTX_PICK_SUBS, getString(R.string.subtitle_select), R.drawable.ic_subtitle_open_w))
if (flags and CTX_APPEND != 0L) add(Simple(CTX_APPEND, getString(R.string.append), R.drawable.ic_ctx_append_normal))
if (flags and CTX_INFORMATION != 0L) add(Simple(CTX_INFORMATION, getString(R.string.info), R.drawable.ic_ctx_information_normal))
if (flags and CTX_DOWNLOAD_SUBTITLES != 0L) add(Simple(CTX_DOWNLOAD_SUBTITLES, getString(R.string.download_subtitles), R.drawable.ic_ctx_download_subtitles_normal))
if (flags and CTX_DOWNLOAD_SUBTITLES_PLAYER != 0L) add(Simple(CTX_DOWNLOAD_SUBTITLES_PLAYER, getString(R.string.download_subtitles), R.drawable.ic_downsub_normal))
if (flags and CTX_PLAY_NEXT != 0L) add(Simple(CTX_PLAY_NEXT, getString(R.string.insert_next), R.drawable.ic_ctx_play_next_normal))
if (flags and CTX_ADD_TO_PLAYLIST != 0L) add(Simple(CTX_ADD_TO_PLAYLIST, getString(R.string.add_to_playlist), R.drawable.ic_ctx_add_to_playlist_normal))
if (flags and CTX_SET_RINGTONE != 0L && AndroidDevices.isPhone) add(Simple(CTX_SET_RINGTONE, getString(R.string.set_song), R.drawable.ic_ctx_set_ringtone_normal))
if (flags and CTX_FAV_ADD != 0L) add(Simple(CTX_FAV_ADD, getString(R.string.favorites_add), R.drawable.ic_ctx_fav_add_normal))
if (flags and CTX_ADD_SCANNED != 0L) add(Simple(CTX_ADD_SCANNED, getString(R.string.add_to_scanned), R.drawable.ic_ctx_addtoscan_normal))
if (flags and CTX_FAV_EDIT != 0L) add(Simple(CTX_FAV_EDIT, getString(R.string.favorites_edit), R.drawable.ic_ctx_fav_edit_normal))
if (flags and CTX_FAV_REMOVE != 0L) add(Simple(CTX_FAV_REMOVE, getString(R.string.favorites_remove), R.drawable.ic_ctx_fav_remove_normal))
if (flags and CTX_REMOVE_FROM_PLAYLIST != 0L) add(Simple(CTX_REMOVE_FROM_PLAYLIST, getString(R.string.remove), R.drawable.ic_ctx_remove_from_playlist_normal))
if (flags and CTX_STOP_AFTER_THIS != 0L) add(Simple(CTX_STOP_AFTER_THIS, getString(R.string.stop_after_this), R.drawable.ic_ctx_stop_after_this))
if (flags and CTX_RENAME != 0L) add(Simple(CTX_RENAME, getString(R.string.rename), R.drawable.ic_ctx_edit_normal))
if (flags and CTX_COPY != 0L) add(Simple(CTX_COPY, getString(R.string.copy_to_clipboard), R.drawable.ic_ctx_link_normal))
if (flags and CTX_DELETE != 0L) add(Simple(CTX_DELETE, getString(R.string.delete), R.drawable.ic_ctx_delete_normal))
if (flags and CTX_SHARE != 0L) add(Simple(CTX_SHARE, getString(R.string.share), R.drawable.ic_ctx_share_normal))
if (flags and CTX_FIND_METADATA != 0L) add(Simple(CTX_FIND_METADATA, getString(R.string.find_metadata), R.drawable.ic_ctx_delete_normal))
if (flags and CTX_ADD_FOLDER_PLAYLIST != 0L) add(Simple(CTX_ADD_FOLDER_PLAYLIST, getString(R.string.this_folder), R.drawable.ic_ctx_add_to_playlist_normal))
if (flags and CTX_ADD_FOLDER_AND_SUB_PLAYLIST != 0L) add(Simple(CTX_ADD_FOLDER_AND_SUB_PLAYLIST, getString(R.string.all_subfolders), R.drawable.ic_ctx_add_to_playlist_normal))
}
inner class ContextAdapter : RecyclerView.Adapter<ContextAdapter.ViewHolder>() {
......@@ -143,20 +143,20 @@ class ContextSheet : VLCBottomSheetDialogFragment() {
}
}
sealed class CtxOption(val id: Int, val title : String, val icon : Int)
class Simple(id: Int, title : String, icon : Int = 0) : CtxOption(id, title, icon)
sealed class CtxOption(val id: Long, val title: String, val icon: Int)
class Simple(id: Long, title: String, icon: Int = 0) : CtxOption(id, title, icon)
interface CtxActionReceiver {
fun onCtxAction(position: Int, option: Int)
fun onCtxAction(position: Int, option: Long)
}
fun showContext(activity: FragmentActivity, receiver: CtxActionReceiver, position: Int, title: String, flags: Int) {
fun showContext(activity: FragmentActivity, receiver: CtxActionReceiver, position: Int, title: String, flags: Long) {
if (!activity.isStarted()) return
val ctxDialog = ContextSheet()
ctxDialog.arguments = Bundle(3).apply {
putString(CTX_TITLE_KEY, title)
putInt(CTX_POSITION_KEY, position)
putInt(CTX_FLAGS_KEY, flags)
putLong(CTX_FLAGS_KEY, flags)
}
ctxDialog.receiver = receiver
ctxDialog.show(activity.supportFragmentManager, "context")
......
......@@ -42,22 +42,22 @@ import java.util.*
private const val ACTION_AUDIO_DELAY = 2
private const val ACTION_SPU_DELAY = 3
private const val ID_PLAY_AS_AUDIO = 0
private const val ID_SLEEP = 1
private const val ID_JUMP_TO = 2
private const val ID_AUDIO_DELAY = 3
private const val ID_SPU_DELAY = 4
private const val ID_CHAPTER_TITLE = 5
private const val ID_PLAYBACK_SPEED = 6
private const val ID_EQUALIZER = 7
private const val ID_SAVE_PLAYLIST = 8
private const val ID_POPUP_VIDEO = 9
private const val ID_REPEAT = 10
private const val ID_SHUFFLE = 11
private const val ID_PASSTHROUGH = 12
private const val ID_ABREPEAT = 13
private const val ID_OVERLAY_SIZE = 14
private const val ID_VIDEO_STATS = 15
private const val ID_PLAY_AS_AUDIO = 0L
private const val ID_SLEEP = 1L
private const val ID_JUMP_TO = 2L
private const val ID_AUDIO_DELAY = 3L
private const val ID_SPU_DELAY = 4L
private const val ID_CHAPTER_TITLE = 5L
private const val ID_PLAYBACK_SPEED = 6L
private const val ID_EQUALIZER = 7L
private const val ID_SAVE_PLAYLIST = 8L
private const val ID_POPUP_VIDEO = 9L
private const val ID_REPEAT = 10L
private const val ID_SHUFFLE = 11L
private const val ID_PASSTHROUGH = 12L
private const val ID_ABREPEAT = 13L
private const val ID_OVERLAY_SIZE = 14L
private const val ID_VIDEO_STATS = 15L
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
......@@ -67,7 +67,7 @@ class PlayerOptionsDelegate(val activity: AppCompatActivity, val service: Playba
private lateinit var recyclerview: RecyclerView
private lateinit var rootView: FrameLayout
private lateinit var playerOptionType: PlayerOptionType
var flags: Int = 0
var flags: Long = 0L
private val toast by lazy(LazyThreadSafetyMode.NONE) { Toast.makeText(activity, "", Toast.LENGTH_SHORT) }
private val primary = activity is VideoPlayerActivity && activity.displayManager.isPrimary
......@@ -123,17 +123,17 @@ class PlayerOptionsDelegate(val activity: AppCompatActivity, val service: Playba
options.add(PlayerOption(playerOptionType, ID_PASSTHROUGH, R.attr.ic_passthrough, res.getString(R.string.audio_digital_title)))
}
PlayerOptionType.MEDIA_TRACKS -> {
if (flags and CTX_VIDEO_TRACK != 0) options.add(PlayerOption(playerOptionType, CTX_VIDEO_TRACK, R.drawable.ic_video_track_w, res.getString(R.string.ctx_player_video_track)))
if (flags and CTX_AUDIO_TRACK != 0) {
if (flags and CTX_VIDEO_TRACK != 0L) options.add(PlayerOption(playerOptionType, CTX_VIDEO_TRACK, R.drawable.ic_video_track_w, res.getString(R.string.ctx_player_video_track)))
if (flags and CTX_AUDIO_TRACK != 0L) {
options.add(PlayerOption(playerOptionType, CTX_AUDIO_TRACK, R.drawable.ic_audiotrack_w, res.getString(R.string.ctx_player_audio_track)))
options.add(PlayerOption(playerOptionType, ID_AUDIO_DELAY, R.drawable.ic_audiodelay_w, res.getString(R.string.audio_delay)))
}
if (flags and CTX_SUBS_TRACK != 0) {
if (flags and CTX_SUBS_TRACK != 0L) {
options.add(PlayerOption(playerOptionType, CTX_SUBS_TRACK, R.drawable.ic_subtitle_w, res.getString(R.string.ctx_player_subs_track)))
options.add(PlayerOption(playerOptionType, ID_SPU_DELAY, R.drawable.ic_subtitledelay_w, res.getString(R.string.spu_delay)))
}
if (flags and CTX_PICK_SUBS != 0) options.add(PlayerOption(playerOptionType, CTX_PICK_SUBS, R.drawable.ic_subtitle_open_w, res.getString(R.string.subtitle_select)))
if (flags and CTX_DOWNLOAD_SUBTITLES_PLAYER != 0) options.add(PlayerOption(playerOptionType, CTX_DOWNLOAD_SUBTITLES_PLAYER, R.drawable.ic_downsub_w, res.getString(R.string.download_subtitles)))
if (flags and CTX_PICK_SUBS != 0L) options.add(PlayerOption(playerOptionType, CTX_PICK_SUBS, R.drawable.ic_subtitle_open_w, res.getString(R.string.subtitle_select)))
if (flags and CTX_DOWNLOAD_SUBTITLES_PLAYER != 0L) options.add(PlayerOption(playerOptionType, CTX_DOWNLOAD_SUBTITLES_PLAYER, R.drawable.ic_downsub_w, res.getString(R.string.download_subtitles)))
}
}
(recyclerview.adapter as OptionsAdapter).update(options)
......@@ -221,7 +221,7 @@ class PlayerOptionsDelegate(val activity: AppCompatActivity, val service: Playba
}
}
private fun showFragment(id: Int) {
private fun showFragment(id: Long) {
val newFragment: DialogFragment
val tag: String
when (id) {
......@@ -440,7 +440,7 @@ fun Context.setSleep(time: Calendar?) {
PlayerOptionsDelegate.playerSleepTime = time
}
data class PlayerOption(val type: PlayerOptionType, val id: Int, val icon: Int, val title: String)
data class PlayerOption(val type: PlayerOptionType, val id: Long, val icon: Int, val title: String)
enum class PlayerOptionType {
ADVANCED, MEDIA_TRACKS
......
......@@ -54,7 +54,7 @@ class StreamsFragmentDelegate : IStreamsFragmentDelegate, CtxActionReceiver {
this.keyboardListener = keyboardListener
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
when (option) {
CTX_RENAME -> renameStream(position)
CTX_APPEND -> {
......
......@@ -389,7 +389,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
videoListAdapter.notifyItemRangeChanged(0, videoListAdapter.itemCount - 1, UPDATE_SEEN)
}
override fun onCtxAction(position: Int, option: Int) {
override fun onCtxAction(position: Int, option: Long) {
if (position >= videoListAdapter.itemCount) return
val activity = activity ?: return
when (val media = videoListAdapter.getItem(position)) {
......@@ -448,7 +448,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
is Folder, is VideoGroup -> showContext(requireActivity(), this@VideoGridFragment, position, item.title, CTX_FOLDER_FLAGS)
is MediaWrapper -> {
val group = item.type == MediaWrapper.TYPE_GROUP
var flags = if (group) CTX_VIDEO_GOUP_FLAGS else CTX_VIDEO_FLAGS
var flags = if (group) CTX_VIDEO_GROUP_FLAGS else CTX_VIDEO_FLAGS
if (item.time != 0L && !group) flags = flags or CTX_PLAY_FROM_START
showContext(requireActivity(), this@VideoGridFragment, position, item.getTitle(), flags)
}
......
......@@ -1625,7 +1625,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
open fun onAudioSubClick(anchor: View?) {
service?.let { service ->
var flags = 0
var flags = 0L
if (enableSubs) {
flags = flags or CTX_DOWNLOAD_SUBTITLES_PLAYER
if (displayManager.isPrimary) flags = flags or CTX_PICK_SUBS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment