[Android] Remove devices ignorelist

Geoffrey Métais git at videolan.org
Fri Mar 1 14:26:37 CET 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar  1 11:56:30 2019 +0100| [eacc222039530d12d8f63e0bcb253100f0cdb5ec] | committer: Geoffrey Métais

Remove devices ignorelist

(cherry picked from commit 440df05e656cd5eb9b6ca46f5c5fe10ab90772ec)

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

 vlc-android/src/org/videolan/vlc/ExternalMonitor.kt       | 14 ++++++--------
 vlc-android/src/org/videolan/vlc/MediaParsingService.kt   |  7 ++-----
 vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java |  8 --------
 3 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
index 245b6ba05..867950f2a 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
@@ -54,6 +54,8 @@ import java.util.*
 
 private const val TAG = "VLC/ExternalMonitor"
 
+ at ExperimentalCoroutinesApi
+ at ObsoleteCoroutinesApi
 @SuppressLint("StaticFieldLeak")
 object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope {
     override val coroutineContext = Dispatchers.Main
@@ -66,13 +68,9 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
         for (action in channel) when (action){
             is MediaMounted -> {
                 if (TextUtils.isEmpty(action.uuid)) return at actor
-                if (!Settings.getInstance(ctx).getBoolean("ignore_${action.uuid}", false)) {
-                    val ml = VLCApplication.getMLInstance()
-                    val knownDevices = ctx.getFromMl { devices }
-                    if (!containsDevice(knownDevices, action.path) && ml.addDevice(action.uuid, action.path, true)) {
-                        notifyStorageChanges(action.path)
-                    }
-                }
+                val ml = VLCApplication.getMLInstance()
+                val knownDevices = ctx.getFromMl { devices }
+                if (ml.addDevice(action.uuid, action.path, true)) notifyNewStorage(action.path)
             }
             is MediaUnmounted -> {
                 delay(100L)
@@ -210,7 +208,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
     }
 
     @Synchronized
-    private fun notifyStorageChanges(path: String?) {
+    private fun notifyNewStorage(path: String?) {
         val activity = if (storageObserver != null) storageObserver!!.get() else null
         activity?.let { UiTools.newStorageDetected(it, path) }
     }
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
index fb037ec76..0b86f4a73 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.kt
@@ -204,15 +204,13 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
     private suspend fun addDevices(context: Context, addExternal: Boolean) {
         val devices = mutableListOf<String>()
         devices.addAll(DirectoryRepository.getInstance(context).getMediaDirectories())
-        val sharedPreferences = Settings.getInstance(context)
         for (device in devices) {
             val isMainStorage = TextUtils.equals(device, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
             val uuid = FileUtils.getFileNameFromPath(device)
             if (TextUtils.isEmpty(device) || TextUtils.isEmpty(uuid) || !device.scanAllowed()) continue
             val isNew = (isMainStorage || addExternal)
                     && medialibrary.addDevice(if (isMainStorage) "main-storage" else uuid, device, !isMainStorage)
-            val isIgnored = sharedPreferences.getBoolean("ignore_$uuid", false)
-            if (!isMainStorage && isNew && !isIgnored && preselectedStorages.isEmpty()) showStorageNotification(device)
+            if (!isMainStorage && isNew && preselectedStorages.isEmpty()) showStorageNotification(device)
         }
     }
 
@@ -261,8 +259,7 @@ class MediaParsingService : Service(), DevicesDiscoveryCb, CoroutineScope {
                 continue
             }
             val isNew = withContext(Dispatchers.IO) { medialibrary.addDevice(uuid, device, true) }
-            val isIgnored = sharedPreferences.getBoolean("ignore_$uuid", false)
-            if (!isIgnored && isNew) showStorageNotification(device)
+            if (isNew) showStorageNotification(device)
         }
         withContext(Dispatchers.IO) { for (device in missingDevices) {
             val uri = Uri.parse(device)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index c1ecf12ec..e006e0247 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -413,10 +413,6 @@ public class UiTools {
                     .setNegativeButton(R.string.ml_external_storage_decline, new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface dialog, int id) {
-                            Settings.INSTANCE.getInstance(activity)
-                                    .edit()
-                                    .putBoolean("ignore_"+ uuid, true)
-                                    .apply();
                             dialog.dismiss();
                         }
                     });
@@ -435,10 +431,6 @@ public class UiTools {
                 .setNegativeButton(R.string.ml_external_storage_decline, new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int id) {
-                        Settings.INSTANCE.getInstance(activity)
-                                .edit()
-                                .putBoolean("ignore_"+ uuid, true)
-                                .apply();
                         dialog.dismiss();
                     }
                 });



More information about the Android mailing list