mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
expand options by default
This commit is contained in:
parent
d852726ecf
commit
8046ba97db
@ -68,8 +68,8 @@ import com.github.libretube.ui.base.BaseFragment
|
|||||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||||
import com.github.libretube.ui.dialogs.ShareDialog
|
import com.github.libretube.ui.dialogs.ShareDialog
|
||||||
|
import com.github.libretube.ui.sheets.BaseBottomSheet
|
||||||
import com.github.libretube.ui.sheets.PlayingQueueSheet
|
import com.github.libretube.ui.sheets.PlayingQueueSheet
|
||||||
import com.github.libretube.ui.views.BottomSheet
|
|
||||||
import com.github.libretube.util.BackgroundHelper
|
import com.github.libretube.util.BackgroundHelper
|
||||||
import com.github.libretube.util.ImageHelper
|
import com.github.libretube.util.ImageHelper
|
||||||
import com.github.libretube.util.NowPlayingNotification
|
import com.github.libretube.util.NowPlayingNotification
|
||||||
@ -1345,7 +1345,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
subtitleCodesList += it.code!!
|
subtitleCodesList += it.code!!
|
||||||
}
|
}
|
||||||
|
|
||||||
BottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(subtitlesNamesList) { index ->
|
.setSimpleItems(subtitlesNamesList) { index ->
|
||||||
val newParams = if (index != 0) {
|
val newParams = if (index != 0) {
|
||||||
// caption selected
|
// caption selected
|
||||||
@ -1376,7 +1376,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
// Dialog for quality selection
|
// Dialog for quality selection
|
||||||
val lastPosition = exoPlayer.currentPosition
|
val lastPosition = exoPlayer.currentPosition
|
||||||
BottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(
|
.setSimpleItems(
|
||||||
videosNameArray.toList()
|
videosNameArray.toList()
|
||||||
) { which ->
|
) { which ->
|
||||||
|
@ -17,7 +17,7 @@ import com.github.libretube.ui.adapters.LegacySubscriptionAdapter
|
|||||||
import com.github.libretube.ui.adapters.SubscriptionChannelAdapter
|
import com.github.libretube.ui.adapters.SubscriptionChannelAdapter
|
||||||
import com.github.libretube.ui.adapters.VideosAdapter
|
import com.github.libretube.ui.adapters.VideosAdapter
|
||||||
import com.github.libretube.ui.base.BaseFragment
|
import com.github.libretube.ui.base.BaseFragment
|
||||||
import com.github.libretube.ui.views.BottomSheet
|
import com.github.libretube.ui.sheets.BaseBottomSheet
|
||||||
import com.github.libretube.util.LayoutHelper
|
import com.github.libretube.util.LayoutHelper
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class SubscriptionsFragment : BaseFragment() {
|
|||||||
private fun showSortDialog() {
|
private fun showSortDialog() {
|
||||||
val sortOptions = resources.getStringArray(R.array.sortOptions)
|
val sortOptions = resources.getStringArray(R.array.sortOptions)
|
||||||
|
|
||||||
val bottomSheet = BottomSheet().apply {
|
val bottomSheet = BaseBottomSheet().apply {
|
||||||
setSimpleItems(sortOptions.toList()) { index ->
|
setSimpleItems(sortOptions.toList()) { index ->
|
||||||
binding.sortTV.text = sortOptions[index]
|
binding.sortTV.text = sortOptions[index]
|
||||||
sortOrder = index
|
sortOrder = index
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
package com.github.libretube.ui.views
|
package com.github.libretube.ui.sheets
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
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 android.widget.FrameLayout
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.libretube.databinding.BottomSheetBinding
|
import com.github.libretube.databinding.BottomSheetBinding
|
||||||
import com.github.libretube.obj.BottomSheetItem
|
import com.github.libretube.obj.BottomSheetItem
|
||||||
import com.github.libretube.ui.adapters.BottomSheetAdapter
|
import com.github.libretube.ui.adapters.BottomSheetAdapter
|
||||||
|
import com.google.android.material.R
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||||
|
|
||||||
open class BottomSheet : BottomSheetDialogFragment() {
|
open class BaseBottomSheet : BottomSheetDialogFragment() {
|
||||||
private lateinit var items: List<BottomSheetItem>
|
private lateinit var items: List<BottomSheetItem>
|
||||||
private lateinit var listener: (index: Int) -> Unit
|
private lateinit var listener: (index: Int) -> Unit
|
||||||
private lateinit var binding: BottomSheetBinding
|
private lateinit var binding: BottomSheetBinding
|
||||||
@ -32,6 +37,21 @@ open class BottomSheet : BottomSheetDialogFragment() {
|
|||||||
binding.optionsRecycler.adapter = BottomSheetAdapter(items, listener)
|
binding.optionsRecycler.adapter = BottomSheetAdapter(items, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
|
||||||
|
|
||||||
|
dialog.setOnShowListener {
|
||||||
|
(it as BottomSheetDialog).let { d ->
|
||||||
|
(d.findViewById<View>(R.id.design_bottom_sheet) as FrameLayout?)?.let {
|
||||||
|
BottomSheetBehavior.from(it).state =
|
||||||
|
BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dialog
|
||||||
|
}
|
||||||
|
|
||||||
fun setItems(items: List<BottomSheetItem>, listener: ((index: Int) -> Unit)?) = apply {
|
fun setItems(items: List<BottomSheetItem>, listener: ((index: Int) -> Unit)?) = apply {
|
||||||
this.items = items
|
this.items = items
|
||||||
this.listener = { index ->
|
this.listener = { index ->
|
@ -13,7 +13,6 @@ import com.github.libretube.extensions.TAG
|
|||||||
import com.github.libretube.extensions.toID
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.obj.ShareData
|
import com.github.libretube.obj.ShareData
|
||||||
import com.github.libretube.ui.dialogs.ShareDialog
|
import com.github.libretube.ui.dialogs.ShareDialog
|
||||||
import com.github.libretube.ui.views.BottomSheet
|
|
||||||
import com.github.libretube.util.BackgroundHelper
|
import com.github.libretube.util.BackgroundHelper
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
@ -28,7 +27,7 @@ class PlaylistOptionsBottomSheet(
|
|||||||
private val playlistId: String,
|
private val playlistId: String,
|
||||||
private val playlistName: String,
|
private val playlistName: String,
|
||||||
private val isOwner: Boolean
|
private val isOwner: Boolean
|
||||||
) : BottomSheet() {
|
) : BaseBottomSheet() {
|
||||||
private val shareData = ShareData(currentPlaylist = playlistName)
|
private val shareData = ShareData(currentPlaylist = playlistName)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// options for the dialog
|
// options for the dialog
|
||||||
|
@ -11,7 +11,6 @@ import com.github.libretube.obj.ShareData
|
|||||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||||
import com.github.libretube.ui.dialogs.ShareDialog
|
import com.github.libretube.ui.dialogs.ShareDialog
|
||||||
import com.github.libretube.ui.views.BottomSheet
|
|
||||||
import com.github.libretube.util.BackgroundHelper
|
import com.github.libretube.util.BackgroundHelper
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
@ -27,7 +26,7 @@ import kotlinx.coroutines.launch
|
|||||||
class VideoOptionsBottomSheet(
|
class VideoOptionsBottomSheet(
|
||||||
private val videoId: String,
|
private val videoId: String,
|
||||||
private val videoName: String
|
private val videoName: String
|
||||||
) : BottomSheet() {
|
) : BaseBottomSheet() {
|
||||||
private val shareData = ShareData(currentVideo = videoName)
|
private val shareData = ShareData(currentVideo = videoName)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// 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.
|
||||||
|
@ -18,6 +18,7 @@ import com.github.libretube.models.interfaces.OnlinePlayerOptions
|
|||||||
import com.github.libretube.models.interfaces.PlayerOptions
|
import com.github.libretube.models.interfaces.PlayerOptions
|
||||||
import com.github.libretube.obj.BottomSheetItem
|
import com.github.libretube.obj.BottomSheetItem
|
||||||
import com.github.libretube.ui.activities.MainActivity
|
import com.github.libretube.ui.activities.MainActivity
|
||||||
|
import com.github.libretube.ui.sheets.BaseBottomSheet
|
||||||
import com.github.libretube.ui.sheets.PlaybackSpeedSheet
|
import com.github.libretube.ui.sheets.PlaybackSpeedSheet
|
||||||
import com.github.libretube.util.DoubleTapListener
|
import com.github.libretube.util.DoubleTapListener
|
||||||
import com.github.libretube.util.PlayerHelper
|
import com.github.libretube.util.PlayerHelper
|
||||||
@ -209,7 +210,7 @@ internal class CustomExoPlayerView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomSheetFragment = BottomSheet().setItems(items, null)
|
val bottomSheetFragment = BaseBottomSheet().setItems(items, null)
|
||||||
bottomSheetFragment.show(childFragmentManager, null)
|
bottomSheetFragment.show(childFragmentManager, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,7 +312,7 @@ internal class CustomExoPlayerView(
|
|||||||
|
|
||||||
override fun onAutoplayClicked() {
|
override fun onAutoplayClicked() {
|
||||||
// autoplay options dialog
|
// autoplay options dialog
|
||||||
BottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(
|
.setSimpleItems(
|
||||||
listOf(
|
listOf(
|
||||||
context.getString(R.string.enabled),
|
context.getString(R.string.enabled),
|
||||||
@ -341,7 +342,7 @@ internal class CustomExoPlayerView(
|
|||||||
AspectRatioFrameLayout.RESIZE_MODE_FILL
|
AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||||
)
|
)
|
||||||
|
|
||||||
BottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(aspectRatioModeNames) { index ->
|
.setSimpleItems(aspectRatioModeNames) { index ->
|
||||||
resizeMode = aspectRatioModes[index]
|
resizeMode = aspectRatioModes[index]
|
||||||
}
|
}
|
||||||
@ -360,7 +361,7 @@ internal class CustomExoPlayerView(
|
|||||||
|
|
||||||
)
|
)
|
||||||
// repeat mode options dialog
|
// repeat mode options dialog
|
||||||
BottomSheet()
|
BaseBottomSheet()
|
||||||
.setSimpleItems(repeatModeNames) { index ->
|
.setSimpleItems(repeatModeNames) { index ->
|
||||||
player?.repeatMode = repeatModes[index]
|
player?.repeatMode = repeatModes[index]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user