mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 16:18:55 +01:00 
			
		
		
		
	Handle a few more possible external directories before Lollipop
This commit is contained in:
		@@ -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
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user