This commit is contained in:
Bnyro 2022-09-11 18:03:55 +02:00
parent c4580d2d21
commit 3647f1ed1c
3 changed files with 15 additions and 8 deletions

View File

@ -3,6 +3,7 @@ package com.github.libretube.dialogs
import android.app.Dialog
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.Toast
@ -51,9 +52,11 @@ class VideoOptionsDialog(
try {
val notificationManager =
context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.activeNotifications.forEach {
if (it.id == PLAYER_NOTIFICATION_ID) {
optionsList += context?.getString(R.string.add_to_queue)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
notificationManager.activeNotifications.forEach {
if (it.id == PLAYER_NOTIFICATION_ID) {
optionsList += context?.getString(R.string.add_to_queue)
}
}
}
} catch (e: Exception) {

View File

@ -108,13 +108,9 @@ class SubscriptionsFragment : BaseFragment() {
private fun showSortDialog() {
val sortOptions = resources.getStringArray(R.array.sortOptions)
val sortOptionValues = resources.getStringArray(R.array.sortOptionsValues)
val items = mutableListOf<BottomSheetItem>()
sortOptions.forEach {
items += BottomSheetItem(it)
}
val bottomSheet = BottomSheet().apply {
setItems(items) { index ->
setSimpleItems(sortOptions.toList()) { index ->
binding.sortTV.text = sortOptions[index]
sortOrder = sortOptionValues[index]
showFeed()

View File

@ -48,4 +48,12 @@ class BottomSheet : BottomSheetDialogFragment() {
dialog?.dismiss()
}
}
fun setSimpleItems(titles: List<String>, listener: (index: Int) -> Unit) {
this.items = titles.map { BottomSheetItem(it) }
this.listener = { index ->
listener.invoke(index)
dialog?.dismiss()
}
}
}