From 582bb3e2ca65eea43517047abacabfc7b27d3756 Mon Sep 17 00:00:00 2001 From: len Date: Fri, 3 Mar 2017 18:45:25 +0100 Subject: [PATCH] Handle a few more possible external directories before Lollipop --- .../java/eu/kanade/tachiyomi/util/DiskUtil.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt index cf289506b3..e710bbc0fc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt @@ -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 { - return ContextCompat.getExternalFilesDirs(context, null) + fun getExternalStorages(context: Context): Collection { + val directories = mutableSetOf() + 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 } /**