mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 08:31:50 +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
|
package eu.kanade.tachiyomi.util
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.support.v4.content.ContextCompat
|
import android.support.v4.content.ContextCompat
|
||||||
import android.support.v4.os.EnvironmentCompat
|
import android.support.v4.os.EnvironmentCompat
|
||||||
@ -73,8 +74,9 @@ object DiskUtil {
|
|||||||
/**
|
/**
|
||||||
* Returns the root folders of all the available external storages.
|
* Returns the root folders of all the available external storages.
|
||||||
*/
|
*/
|
||||||
fun getExternalStorages(context: Context): List<File> {
|
fun getExternalStorages(context: Context): Collection<File> {
|
||||||
return ContextCompat.getExternalFilesDirs(context, null)
|
val directories = mutableSetOf<File>()
|
||||||
|
directories += ContextCompat.getExternalFilesDirs(context, null)
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
val file = File(it.absolutePath.substringBefore("/Android/"))
|
val file = File(it.absolutePath.substringBefore("/Android/"))
|
||||||
@ -85,6 +87,15 @@ object DiskUtil {
|
|||||||
null
|
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