Skip to content

Commit e729c5d

Browse files
committed
tv: show volume descriptions for file picker
Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 4bf34c4 commit e729c5d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ class TvMainActivity : AppCompatActivity() {
204204
val storageManager: StorageManager = getSystemService() ?: return@withContext list
205205
list.addAll(storageManager.storageVolumes.mapNotNull { volume ->
206206
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
207-
volume.directory?.let { KeyedFile(it.canonicalPath) }
207+
volume.directory?.let { KeyedFile(it.canonicalPath, volume.getDescription(this@TvMainActivity)) }
208208
} else {
209-
KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File).canonicalPath)
209+
KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File).canonicalPath, volume.getDescription(this@TvMainActivity))
210210
}
211211
})
212212
} else {
@@ -319,9 +319,9 @@ class TvMainActivity : AppCompatActivity() {
319319
}
320320
}
321321

322-
class KeyedFile(pathname: String) : File(pathname), Keyed<String> {
322+
class KeyedFile(pathname: String, private val forcedKey: String? = null) : File(pathname), Keyed<String> {
323323
override val key: String
324-
get() = if (isDirectory) "$name/" else name
324+
get() = forcedKey ?: if (isDirectory) "$name/" else name
325325
}
326326

327327
companion object {

0 commit comments

Comments
 (0)