[Android] Fix permission snackbar position

Nicolas Pomepuy git at videolan.org
Wed Dec 1 08:38:46 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Dec  1 09:31:19 2021 +0100| [d149f241a0725e687282f4c880c7525cb7620f79] | committer: Nicolas Pomepuy

Fix permission snackbar position

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

 .../vlc-android/src/org/videolan/vlc/gui/MainActivity.kt       | 10 ++++++++++
 1 file changed, 10 insertions(+)

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 3d6406c33..831975cd3 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt
@@ -29,6 +29,7 @@ import android.os.Bundle
 import android.view.KeyEvent
 import android.view.Menu
 import android.view.MenuItem
+import android.view.View
 import androidx.appcompat.view.ActionMode
 import androidx.fragment.app.Fragment
 import kotlinx.android.synthetic.main.toolbar.*
@@ -77,6 +78,11 @@ class MainActivity : ContentActivity(),
     private lateinit var mediaLibrary: Medialibrary
     private var scanNeeded = false
 
+    override fun getSnackAnchorView(): View? {
+        val view = super.getSnackAnchorView()
+        return if (view?.id == android.R.id.content) findViewById(R.id.appbar) else view
+    }
+
     @SuppressLint("SetTextI18n")
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -94,6 +100,10 @@ class MainActivity : ContentActivity(),
         mediaLibrary = Medialibrary.getInstance()
 
 //        VLCBilling.getInstance(application).retrieveSkus()
+    }
+
+    override fun onResume() {
+        super.onResume()
         //Only the partial permission is granted for Android 11+
         if (!settings.getBoolean(PERMISSION_NEVER_ASK, false) && Permissions.canReadStorage(this) && !Permissions.hasAllAccess(this)) {
             UiTools.snackerMessageInfinite(this, getString(R.string.partial_content))?.setAction(R.string.more) {



More information about the Android mailing list