[Android] StorageProvider: use "no subfolder" instead of misleading "empty" string
Nicolas Pomepuy
git at videolan.org
Tue Jan 21 17:19:09 CET 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jan 21 11:13:42 2020 +0100| [22123d1db7ed1fe4815735686c02e1522aab40f2] | committer: Geoffrey Métais
StorageProvider: use "no subfolder" instead of misleading "empty" string
Fixes #1158
> https://code.videolan.org/videolan/vlc-android/commit/22123d1db7ed1fe4815735686c02e1522aab40f2
---
resources/src/main/res/values/strings.xml | 2 +-
.../src/org/videolan/vlc/providers/BrowserProvider.kt | 14 ++++++++++----
.../src/org/videolan/vlc/providers/StorageProvider.kt | 14 ++++++++++++--
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/resources/src/main/res/values/strings.xml b/resources/src/main/res/values/strings.xml
index 4ef834d3f..a88d4b2df 100644
--- a/resources/src/main/res/values/strings.xml
+++ b/resources/src/main/res/values/strings.xml
@@ -124,7 +124,7 @@
<string name="noplaylist">No playlist found.</string>
<string name="mediafiles">Media files</string>
<string name="notavailable">not available</string>
- <string name="nosubdirectory">No subdirectories.</string>
+ <string name="nosubfolder">No subfolder</string>
<string name="directorynotfound">The directory path \'%1$s\' was not found.</string>
<string name="nohistory">You have no playback history yet.</string>
<string name="validation">Are you sure?</string>
diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index ee1a6b3f9..1751e70a2 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -41,10 +41,16 @@ import org.videolan.medialibrary.interfaces.media.MediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Storage
import org.videolan.resources.util.HeaderProvider
-import org.videolan.tools.*
+import org.videolan.tools.AppScope
+import org.videolan.tools.CoroutineContextProvider
+import org.videolan.tools.DependencyProvider
+import org.videolan.tools.Settings
import org.videolan.tools.livedata.LiveDataset
import org.videolan.vlc.R
-import org.videolan.vlc.util.*
+import org.videolan.vlc.util.ModelsHelper
+import org.videolan.vlc.util.VLCInstance
+import org.videolan.vlc.util.isBrowserMedia
+import org.videolan.vlc.util.isMedia
import java.util.*
const val TAG = "VLC/BrowserProvider"
@@ -240,9 +246,9 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
}
private val sb = StringBuilder()
- private fun getDescription(folderCount: Int, mediaFileCount: Int): String {
+ open fun getDescription(folderCount: Int, mediaFileCount: Int): String {
val res = context.resources
- sb.setLength(0)
+ sb.clear()
if (folderCount > 0) {
sb.append(res.getQuantityString(R.plurals.subfolders_quantity, folderCount, folderCount))
if (mediaFileCount > 0) sb.append(", ")
diff --git a/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt b/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
index e0af65e2d..da9409ad9 100644
--- a/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/StorageProvider.kt
@@ -26,10 +26,10 @@ import android.text.TextUtils
import org.videolan.libvlc.interfaces.IMedia
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.Storage
-import org.videolan.vlc.R
-import org.videolan.vlc.repository.DirectoryRepository
import org.videolan.resources.AndroidDevices
import org.videolan.tools.livedata.LiveDataset
+import org.videolan.vlc.R
+import org.videolan.vlc.repository.DirectoryRepository
import java.io.File
import java.util.*
@@ -59,6 +59,16 @@ class StorageProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>,
dataset.value = storagesList
}
+ private val sb = StringBuilder()
+ override fun getDescription(folderCount: Int, mediaFileCount: Int): String {
+ val res = context.resources
+ sb.clear()
+ if (folderCount > 0) {
+ sb.append(res.getQuantityString(R.plurals.subfolders_quantity, folderCount, folderCount))
+ } else sb.append(res.getString(R.string.nosubfolder))
+ return sb.toString()
+ }
+
override suspend fun findMedia(media: IMedia) = media.takeIf { it.isStorage() }?.let { Storage(it.uri) }
override fun computeHeaders(value: List<MediaLibraryItem>) {}
More information about the Android
mailing list