diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-24 11:29:03 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-24 14:12:40 +0200 |
commit | e729c5dc518da23b405c702687fefc5a71f771f7 (patch) | |
tree | 2658cc78ff45d0eaea332f9086f8a03535d3c7aa /ui/src/main/java | |
parent | 4bf34c49b797dd14c59184381b2d572d08a27fa4 (diff) |
tv: show volume descriptions for file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt index 32fbe387..301ac5f4 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt @@ -204,9 +204,9 @@ class TvMainActivity : AppCompatActivity() { val storageManager: StorageManager = getSystemService() ?: return@withContext list list.addAll(storageManager.storageVolumes.mapNotNull { volume -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - volume.directory?.let { KeyedFile(it.canonicalPath) } + volume.directory?.let { KeyedFile(it.canonicalPath, volume.getDescription(this@TvMainActivity)) } } else { - KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File).canonicalPath) + KeyedFile((StorageVolume::class.java.getMethod("getPathFile").invoke(volume) as File).canonicalPath, volume.getDescription(this@TvMainActivity)) } }) } else { @@ -319,9 +319,9 @@ class TvMainActivity : AppCompatActivity() { } } - class KeyedFile(pathname: String) : File(pathname), Keyed<String> { + class KeyedFile(pathname: String, private val forcedKey: String? = null) : File(pathname), Keyed<String> { override val key: String - get() = if (isDirectory) "$name/" else name + get() = forcedKey ?: if (isDirectory) "$name/" else name } companion object { |