mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Add more options to the download options bottom sheet
This commit is contained in:
parent
338e3dafa9
commit
a35ff72f21
@ -8,7 +8,11 @@ import com.github.libretube.constants.IntentData
|
|||||||
import com.github.libretube.db.DatabaseHolder
|
import com.github.libretube.db.DatabaseHolder
|
||||||
import com.github.libretube.db.obj.Download
|
import com.github.libretube.db.obj.Download
|
||||||
import com.github.libretube.db.obj.DownloadItem
|
import com.github.libretube.db.obj.DownloadItem
|
||||||
|
import com.github.libretube.enums.ShareObjectType
|
||||||
|
import com.github.libretube.helpers.NavigationHelper
|
||||||
|
import com.github.libretube.obj.ShareData
|
||||||
import com.github.libretube.services.OfflinePlayerService
|
import com.github.libretube.services.OfflinePlayerService
|
||||||
|
import com.github.libretube.ui.dialogs.ShareDialog
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlin.io.path.deleteIfExists
|
import kotlin.io.path.deleteIfExists
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -20,7 +24,12 @@ class DownloadOptionsBottomSheet(
|
|||||||
private val onDelete: () -> Unit
|
private val onDelete: () -> Unit
|
||||||
) : BaseBottomSheet() {
|
) : BaseBottomSheet() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
val options = listOf(R.string.playOnBackground, R.string.delete).map { getString(it) }
|
val options = listOf(
|
||||||
|
R.string.playOnBackground,
|
||||||
|
R.string.go_to_video,
|
||||||
|
R.string.share,
|
||||||
|
R.string.delete
|
||||||
|
).map { getString(it) }
|
||||||
setSimpleItems(options) { selectedIndex ->
|
setSimpleItems(options) { selectedIndex ->
|
||||||
when (selectedIndex) {
|
when (selectedIndex) {
|
||||||
0 -> {
|
0 -> {
|
||||||
@ -29,6 +38,14 @@ class DownloadOptionsBottomSheet(
|
|||||||
ContextCompat.startForegroundService(requireContext(), playerIntent)
|
ContextCompat.startForegroundService(requireContext(), playerIntent)
|
||||||
}
|
}
|
||||||
1 -> {
|
1 -> {
|
||||||
|
NavigationHelper.navigateVideo(requireContext(), videoId = download.videoId)
|
||||||
|
}
|
||||||
|
2 -> {
|
||||||
|
val shareData = ShareData(currentVideo = download.uploader)
|
||||||
|
ShareDialog(download.videoId, ShareObjectType.VIDEO, shareData)
|
||||||
|
.show(parentFragmentManager, null)
|
||||||
|
}
|
||||||
|
3 -> {
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
.setTitle(R.string.delete)
|
.setTitle(R.string.delete)
|
||||||
.setMessage(R.string.irreversible)
|
.setMessage(R.string.irreversible)
|
||||||
|
@ -463,6 +463,7 @@
|
|||||||
<string name="play_automatically">Play automatically</string>
|
<string name="play_automatically">Play automatically</string>
|
||||||
<string name="play_automatically_summary">Start playing video automatically when selecting</string>
|
<string name="play_automatically_summary">Start playing video automatically when selecting</string>
|
||||||
<string name="fullscreen_gestures">Enter/exit fullscreen gestures</string>
|
<string name="fullscreen_gestures">Enter/exit fullscreen gestures</string>
|
||||||
|
<string name="go_to_video">Go to video</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user