mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 03:21:51 +01:00
Handle a few more possible external directories before Lollipop
This commit is contained in:
parent
5c67161dce
commit
582bb3e2ca
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.os.EnvironmentCompat
|
||||
@ -73,8 +74,9 @@ object DiskUtil {
|
||||
/**
|
||||
* Returns the root folders of all the available external storages.
|
||||
*/
|
||||
fun getExternalStorages(context: Context): List<File> {
|
||||
return ContextCompat.getExternalFilesDirs(context, null)
|
||||
fun getExternalStorages(context: Context): Collection<File> {
|
||||
val directories = mutableSetOf<File>()
|
||||
directories += ContextCompat.getExternalFilesDirs(context, null)
|
||||
.filterNotNull()
|
||||
.mapNotNull {
|
||||
val file = File(it.absolutePath.substringBefore("/Android/"))
|
||||
@ -85,6 +87,15 @@ object DiskUtil {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
val extStorages = System.getenv("SECONDARY_STORAGE")
|
||||
if (extStorages != null) {
|
||||
directories += extStorages.split(":").map(::File)
|
||||
}
|
||||
}
|
||||
|
||||
return directories
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user