[Android] TV: Delay runtime permission dialog

Geoffrey Métais git at videolan.org
Tue Sep 12 17:59:02 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 12 17:57:22 2017 +0200| [aff4b12c1ca571f3301c559f658d31f02081c58e] | committer: Geoffrey Métais

TV: Delay runtime permission dialog

Workaround to prevent background corruption

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

 .../src/org/videolan/vlc/gui/tv/MainTvActivity.java       | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index d8f7d591f..3c23884d6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -129,7 +129,14 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
             return;
         }
 
-        Permissions.checkReadStoragePermission(this, false);
+        // Delay access permission dialog prompt to avoid background corruption
+        if (!Permissions.canReadStorage())
+            mHandler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    Permissions.checkReadStoragePermission(MainTvActivity.this, false);
+                }
+            }, 1000);
 
         mContext = this;
         setContentView(R.layout.tv_main);
@@ -200,6 +207,8 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
     @Override
     protected void onStart() {
         super.onStart();
+        if (!mBackgroundManager.isAttached())
+            mBackgroundManager.attach(getWindow());
         if (mSelectedItem != null)
             TvUtil.updateBackground(mBackgroundManager, mSelectedItem);
     }
@@ -212,6 +221,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
                     RecommendationsService.class);
             startService(recommendationIntent);
         }
+        TvUtil.releaseBackgroundManager(mBackgroundManager);
     }
 
     @Override
@@ -223,8 +233,6 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
             setmedialibraryListeners();
         } else
             setupMediaLibraryReceiver();
-        if (!mBackgroundManager.isAttached())
-            mBackgroundManager.attach(getWindow());
     }
 
     @Override
@@ -235,7 +243,6 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
         if (mService != null)
             mService.removeCallback(this);
         mMediaLibrary.removeMediaUpdatedCb();
-        TvUtil.releaseBackgroundManager(mBackgroundManager);
     }
 
     @Override



More information about the Android mailing list