Fixed bug for older devices

Hoping that the viewer crashing bug is fixed
Version 2.11
This commit is contained in:
tom5079
2019-06-23 23:09:01 +09:00
parent e01380090d
commit cdc545ea32
27 changed files with 203 additions and 98 deletions

View File

@@ -1,15 +1,24 @@
package xyz.quaver.pupil.util
import android.content.Context
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import androidx.core.content.ContextCompat
import java.io.File
fun getCachedGallery(context: Context, galleryID: Int): File {
return File(context.getExternalFilesDir("Pupil"), galleryID.toString()).let {
return File(getDownloadDirectory(context), galleryID.toString()).let {
when {
it.exists() -> it
else -> File(context.cacheDir, "imageCache/$galleryID")
}
}
}
fun getDownloadDirectory(context: Context): File? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
context.getExternalFilesDir("Pupil")
else
File(Environment.getExternalStorageDirectory(), "Pupil")
}