This commit is contained in:
Pupil
2020-02-09 17:35:34 +09:00
parent 748495ca64
commit 7455e68a45
3 changed files with 10 additions and 11 deletions

View File

@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":36,"versionName":"5.3-beta1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":36,"versionName":"5.3-beta2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

View File

@@ -101,7 +101,7 @@ class SettingsFragment :
}.show() }.show()
} }
"delete_downloads" -> { "delete_downloads" -> {
val dir = getDownloadDirectory(context)!! val dir = getDownloadDirectory(context)
AlertDialog.Builder(context).apply { AlertDialog.Builder(context).apply {
setTitle(R.string.warning) setTitle(R.string.warning)
@@ -150,7 +150,7 @@ class SettingsFragment :
"backup" -> { "backup" -> {
File(ContextCompat.getDataDir(context), "favorites.json").copyTo( File(ContextCompat.getDataDir(context), "favorites.json").copyTo(
context, context,
getDownloadDirectory(context)?.createFile("null", "favorites.json")!! getDownloadDirectory(context).createFile("null", "favorites.json")!!
) )
Snackbar.make(this@SettingsFragment.listView, R.string.settings_backup_snackbar, Snackbar.LENGTH_LONG) Snackbar.make(this@SettingsFragment.listView, R.string.settings_backup_snackbar, Snackbar.LENGTH_LONG)
@@ -192,8 +192,7 @@ class SettingsFragment :
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
when (key) { when (key) {
"dl_location" -> { "dl_location" -> {
findPreference<Preference>(key)?.summary = findPreference<Preference>(key)?.summary = getDownloadDirectory(context!!).uri.path
FileUtils.getPath(context, getDownloadDirectory(context!!)?.uri)
} }
} }
} }
@@ -230,7 +229,7 @@ class SettingsFragment :
onPreferenceClickListener = this@SettingsFragment onPreferenceClickListener = this@SettingsFragment
} }
"delete_downloads" -> { "delete_downloads" -> {
val dir = getDownloadDirectory(context)!! val dir = getDownloadDirectory(context)
summary = getDirSize(dir) summary = getDirSize(dir)
onPreferenceClickListener = this@SettingsFragment onPreferenceClickListener = this@SettingsFragment
@@ -242,7 +241,7 @@ class SettingsFragment :
onPreferenceClickListener = this@SettingsFragment onPreferenceClickListener = this@SettingsFragment
} }
"dl_location" -> { "dl_location" -> {
summary = FileUtils.getPath(context, getDownloadDirectory(context)?.uri) summary = getDownloadDirectory(context).uri.path
onPreferenceClickListener = this@SettingsFragment onPreferenceClickListener = this@SettingsFragment
} }

View File

@@ -29,21 +29,21 @@ import java.nio.charset.Charset
import java.util.* import java.util.*
fun getCachedGallery(context: Context, galleryID: Int) = fun getCachedGallery(context: Context, galleryID: Int) =
getDownloadDirectory(context)?.findFile(galleryID.toString()) ?: getDownloadDirectory(context).findFile(galleryID.toString()) ?:
DocumentFile.fromFile(File(context.cacheDir, "imageCache/$galleryID")) DocumentFile.fromFile(File(context.cacheDir, "imageCache/$galleryID"))
fun getDownloadDirectory(context: Context) : DocumentFile? { fun getDownloadDirectory(context: Context) : DocumentFile {
val uri = PreferenceManager.getDefaultSharedPreferences(context).getString("dl_location", null).let { val uri = PreferenceManager.getDefaultSharedPreferences(context).getString("dl_location", null).let {
if (it != null) if (it != null)
Uri.parse(it) Uri.parse(it)
else else
return null Uri.fromFile(context.getExternalFilesDir(null))
} }
return if (uri.toString().startsWith("file")) return if (uri.toString().startsWith("file"))
DocumentFile.fromFile(File(uri.path!!)) DocumentFile.fromFile(File(uri.path!!))
else else
DocumentFile.fromTreeUri(context, uri) DocumentFile.fromTreeUri(context, uri) ?: DocumentFile.fromFile(context.getExternalFilesDir(null)!!)
} }
fun convertUpdateUri(context: Context, uri: Uri) : Uri = fun convertUpdateUri(context: Context, uri: Uri) : Uri =