[Android] Display a snackbar when stopping playback because of a metered connection
Nicolas Pomepuy
git at videolan.org
Wed May 15 13:56:43 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed May 15 13:35:14 2024 +0200| [c514963e17faf4a47e52906ac132051aa6dbd7aa] | committer: Nicolas Pomepuy
Display a snackbar when stopping playback because of a metered connection
> https://code.videolan.org/videolan/vlc-android/commit/c514963e17faf4a47e52906ac132051aa6dbd7aa
---
.../vlc-android/src/org/videolan/vlc/PlaybackService.kt | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 675b308508..bb79c3a41f 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -782,7 +782,17 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
if (meteredAction != 0 && isSchemeStreaming(currentMediaLocation)) {
if (meteredAction == 1) {
stop()
- Toast.makeText(this, R.string.metered_connection_stopped, Toast.LENGTH_LONG).show()
+ //we also check if the current activity is AudioPlayerContainerActivity to avoid displaying the
+ //snackbar in the VideoPlayerActivity that will be closed by the call to stop()
+ (AppContextProvider.currentActivity as? AudioPlayerContainerActivity)?.let {activity ->
+ UiTools.snackerConfirm(activity, getString(R.string.metered_connection_stopped), overAudioPlayer = activity.isAudioPlayerExpanded, confirmMessage = R.string.preferences) {
+ lifecycleScope.launch {
+ PreferencesActivity.launchWithPref(activity as FragmentActivity, "metered_connection")
+ }
+ }
+ } ?: run {
+ Toast.makeText(this, R.string.metered_connection_stopped, Toast.LENGTH_LONG).show()
+ }
} else {
AppContextProvider.currentActivity?.let {activity ->
UiTools.snackerConfirm(activity, getString(R.string.metered_connection_warning), overAudioPlayer = activity is AudioPlayerContainerActivity && activity.isAudioPlayerExpanded, confirmMessage = R.string.preferences) {
More information about the Android
mailing list