Use internal directory for cache in android R by default ( #284 )

This commit is contained in:
世界 2020-12-10 21:00:01 +08:00
parent 08b97917a7
commit 0954be4d5d
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package tw.nekomimi.nekogram.utils
import android.content.Context
import android.os.Build
import android.os.Environment
import android.os.storage.StorageManager
import org.telegram.messenger.ApplicationLoader
@ -44,7 +45,12 @@ object EnvUtil {
if (NekoConfig.cachePath == null) {
NekoConfig.setCachePath(ApplicationLoader.applicationContext.getExternalFilesDir(null)!!.path)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// https://github.com/NekoX-Dev/NekoX/issues/284
NekoConfig.setCachePath(File(ApplicationLoader.getDataDirFixed(), "cache/media").path)
} else {
NekoConfig.setCachePath(ApplicationLoader.applicationContext.getExternalFilesDir(null)!!.path)
}
}