Merge pull request #1883 from Bnyro/master

Option to open queue from background notification
This commit is contained in:
Bnyro 2022-11-17 17:04:19 +01:00 committed by GitHub
commit 7a19f00a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 13 deletions

View File

@ -8,4 +8,5 @@ object IntentData {
const val timeStamp = "timeStamp"
const val position = "position"
const val fileName = "fileName"
const val openQueueOnce = "openQueue"
}

View File

@ -86,6 +86,7 @@ object PreferenceKeys {
* Background mode
*/
const val BACKGROUND_PLAYBACK_SPEED = "background_playback_speed"
const val NOTIFICATION_OPEN_QUEUE = "notification_open_queue"
/**
* Notifications

View File

@ -319,6 +319,10 @@ class MainActivity : BaseActivity() {
"library" ->
navController.navigate(R.id.libraryFragment)
}
if (intent?.getBooleanExtra(IntentData.openQueueOnce, false) == true) {
PlayingQueueSheet()
.show(supportFragmentManager)
}
}
private fun loadVideo(videoId: String, timeStamp: Long?) {

View File

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.databinding.BottomSheetBinding
import com.github.libretube.obj.BottomSheetItem
@ -47,11 +46,6 @@ open class BaseBottomSheet : ExpandedBottomSheet() {
}
}
fun show(fragmentManager: FragmentManager) = show(
fragmentManager,
null
)
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
dialog?.dismiss()

View File

@ -5,6 +5,7 @@ import android.content.res.Configuration
import android.os.Bundle
import android.view.View
import android.widget.FrameLayout
import androidx.fragment.app.FragmentManager
import com.google.android.material.R
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
@ -27,4 +28,9 @@ open class ExpandedBottomSheet : BottomSheetDialogFragment() {
return dialog
}
fun show(fragmentManager: FragmentManager) = show(
fragmentManager,
null
)
}

View File

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import com.github.libretube.databinding.PlaybackBottomSheetBinding
import com.github.libretube.extensions.round
import com.google.android.exoplayer2.PlaybackParameters
@ -55,9 +54,4 @@ class PlaybackSpeedSheet(
binding.pitch.value.round(2)
)
}
fun show(fragmentManager: FragmentManager) = show(
fragmentManager,
null
)
}

View File

@ -20,6 +20,7 @@ import com.github.libretube.api.obj.Streams
import com.github.libretube.constants.BACKGROUND_CHANNEL_ID
import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PLAYER_NOTIFICATION_ID
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.ui.activities.MainActivity
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.Player
@ -74,7 +75,11 @@ class NowPlayingNotification(
// that's the only way to launch back into the previous activity (e.g. the player view
val intent = Intent(context, MainActivity::class.java).apply {
if (isBackgroundPlayerNotification) {
putExtra(IntentData.videoId, videoId)
if (PreferenceHelper.getBoolean(PreferenceKeys.NOTIFICATION_OPEN_QUEUE, true)) {
putExtra(IntentData.openQueueOnce, true)
} else {
putExtra(IntentData.videoId, videoId)
}
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
}

View File

@ -377,6 +377,7 @@
<string name="hls_instead_of_dash_summary">Use HLS instead of DASH (will be slower, not recommended)</string>
<string name="auto_quality">Auto</string>
<string name="limit_to_runtime">Limit to runtime</string>
<string name="open_queue_from_notification">Open queue from notification</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>

View File

@ -98,6 +98,12 @@
app:valueFrom="0.2"
app:valueTo="4.0" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_grid"
android:title="@string/open_queue_from_notification"
app:key="notification_open_queue" />
</PreferenceCategory>
</PreferenceScreen>