tv: show volume descriptions for file picker
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
4bf34c49b7
commit
e729c5dc51
@ -204,9 +204,9 @@ class TvMainActivity : AppCompatActivity() {
|
|||||||
val storageManager: StorageManager = getSystemService() ?: return@withContext list
|
val storageManager: StorageManager = getSystemService() ?: return@withContext list
|
||||||
list.addAll(storageManager.storageVolumes.mapNotNull { volume ->
|
list.addAll(storageManager.storageVolumes.mapNotNull { volume ->
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
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 {
|
} 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 {
|
} 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
|
override val key: String
|
||||||
get() = if (isDirectory) "$name/" else name
|
get() = forcedKey ?: if (isDirectory) "$name/" else name
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user