[Android] Onboarding: Preselect folders for customize opt

Geoffrey Métais git at videolan.org
Wed Feb 27 15:55:33 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 27 12:07:29 2019 +0100| [00b74b9b8a3adfb4ea82013f526d9412ca8ea0f1] | committer: Geoffrey Métais

Onboarding: Preselect folders for customize opt

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

 .../videolan/vlc/gui/onboarding/OnboardingActivity.kt | 19 ++++++++++++-------
 .../src/org/videolan/vlc/util/AndroidDevices.java     |  2 ++
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt b/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
index fc1f1cf5e..fe254f74c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/onboarding/OnboardingActivity.kt
@@ -18,7 +18,6 @@ import org.videolan.vlc.R
 import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate
 import org.videolan.vlc.gui.preferences.PreferencesActivity
 import org.videolan.vlc.gui.view.NonSwipeableViewPager
-import org.videolan.vlc.repository.DirectoryRepository
 import org.videolan.vlc.startMedialibrary
 import org.videolan.vlc.util.*
 
@@ -42,12 +41,6 @@ class OnboardingActivity : AppCompatActivity(), ViewPager.OnPageChangeListener,
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
-        launch {
-            if (viewModel.scanStorages && !viewModel.customizeMediaFolders) {
-                MediaParsingService.preselectedStorages.addAll(DirectoryRepository.getInstance(this at OnboardingActivity).getMediaDirectories())
-            }
-        }
-
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
@@ -200,7 +193,19 @@ class OnboardingActivity : AppCompatActivity(), ViewPager.OnPageChangeListener,
         if (customizeEnabled) {
             indicators[3]?.visibility = View.VISIBLE
             indicators[3]?.animate()?.alpha(0.6f)?.scaleX(0.5f)?.scaleY(0.5f)!!.setListener(null)
+            if (MediaParsingService.preselectedStorages.isEmpty()) launch {
+                    MediaParsingService.preselectedStorages.run {
+                        addAll(AndroidDevices.getExternalStorageDirectories())
+                        AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_URI.path?.let { add(it) }
+                        AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_DCIM_DIRECTORY_URI.path?.let { add(it) }
+                        AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MOVIES_DIRECTORY_URI.path?.let { add(it) }
+                        AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_MUSIC_DIRECTORY_URI.path?.let { add(it) }
+                        AndroidDevices.MediaFolders.EXTERNAL_PUBLIC_PODCAST_DIRECTORY_URI.path?.let { add(it) }
+                        AndroidDevices.MediaFolders.WHATSAPP_VIDEOS_FILE_URI.path?.let { add(it) }
+                    }
+            }
         } else {
+            MediaParsingService.preselectedStorages.clear()
             indicators[3]?.animate()?.scaleY(0f)?.scaleX(0f)?.alpha(0f)?.setListener(object : Animator.AnimatorListener {
                 override fun onAnimationRepeat(animation: Animator?) {}
 
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 80276dccd..6baa8f8fb 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -216,12 +216,14 @@ public class AndroidDevices {
         public final static File EXTERNAL_PUBLIC_MUSIC_DIRECTORY_FILE = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
         public final static File EXTERNAL_PUBLIC_PODCAST_DIRECTORY_FILE = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS);
         public final static File EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_FILE = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+        public final static File EXTERNAL_PUBLIC_DCIM_DIRECTORY_FILE = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
         public final static File WHATSAPP_VIDEOS_FILE = new File(EXTERNAL_PUBLIC_DIRECTORY+"/WhatsApp/Media/WhatsApp Video/");
 
         public final static Uri EXTERNAL_PUBLIC_MOVIES_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_MOVIES_DIRECTORY_FILE);
         public final static Uri EXTERNAL_PUBLIC_MUSIC_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_MUSIC_DIRECTORY_FILE);
         public final static Uri EXTERNAL_PUBLIC_PODCAST_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_PODCAST_DIRECTORY_FILE);
         public final static Uri EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_DOWNLOAD_DIRECTORY_FILE);
+        public final static Uri EXTERNAL_PUBLIC_DCIM_DIRECTORY_URI = getFolderUri(EXTERNAL_PUBLIC_DCIM_DIRECTORY_FILE);
         public final static Uri WHATSAPP_VIDEOS_FILE_URI = getFolderUri(WHATSAPP_VIDEOS_FILE);
 
         private static Uri getFolderUri(File file) {



More information about the Android mailing list