[Android] Fix snackbar position on tablets

Nicolas Pomepuy git at videolan.org
Thu Dec 23 09:45:07 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Dec  3 08:45:06 2021 +0100| [e8425c721086e02def4258d2dc0b2b58a5cff591] | committer: Nicolas Pomepuy

Fix snackbar position on tablets

> https://code.videolan.org/videolan/vlc-android/commit/e8425c721086e02def4258d2dc0b2b58a5cff591
---

 .../src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt            | 2 +-
 application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
index 95dcfa4a1..105261d90 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt
@@ -507,7 +507,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener {
         val song = settings.getString(KEY_CURRENT_AUDIO, null) ?: return at launchWhenStarted
         val media = getFromMl { getMedia(song.toUri()) } ?: return at launchWhenStarted
         val title = media.title
-        resumeCard = Snackbar.make(appBarLayout, getString(R.string.resume_card_message, title), Snackbar.LENGTH_LONG)
+        resumeCard = Snackbar.make(getSnackAnchorView() ?: appBarLayout, getString(R.string.resume_card_message, title), Snackbar.LENGTH_LONG)
                 .setAction(R.string.play) { PlaybackService.loadLastAudio(it.context) }
         resumeCard.show()
     }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
index d3232a656..98e27903e 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -81,7 +81,7 @@ class MainActivity : ContentActivity(),
 
     override fun getSnackAnchorView(overAudioPlayer:Boolean): View? {
         val view = super.getSnackAnchorView(overAudioPlayer)
-        return if (view?.id == android.R.id.content) {if(overAudioPlayer) findViewById(android.R.id.content) else findViewById(R.id.appbar)} else view
+        return if (view?.id == android.R.id.content && getScreenWidth() < 600.dp) {if(overAudioPlayer) findViewById(android.R.id.content) else findViewById(R.id.appbar)} else view
     }
 
     @SuppressLint("SetTextI18n")



More information about the Android mailing list