aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-24 11:29:03 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-24 14:12:40 +0200
commite729c5dc518da23b405c702687fefc5a71f771f7 (patch)
tree2658cc78ff45d0eaea332f9086f8a03535d3c7aa /ui
parentui: account for null data in callback (diff)
downloadwireguard-android-e729c5dc518da23b405c702687fefc5a71f771f7.tar.xz
wireguard-android-e729c5dc518da23b405c702687fefc5a71f771f7.zip
tv: show volume descriptions for file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/TvMainActivity.kt8
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 32fbe38..301ac5f 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 {