diff --git a/app/release/output.json b/app/release/output.json index b6ccf614..29ec4809 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -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":{}}] \ No newline at end of file +[{"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":{}}] \ No newline at end of file diff --git a/app/src/main/java/xyz/quaver/pupil/ui/fragment/SettingsFragment.kt b/app/src/main/java/xyz/quaver/pupil/ui/fragment/SettingsFragment.kt index bbb31331..e7c76069 100644 --- a/app/src/main/java/xyz/quaver/pupil/ui/fragment/SettingsFragment.kt +++ b/app/src/main/java/xyz/quaver/pupil/ui/fragment/SettingsFragment.kt @@ -101,7 +101,7 @@ class SettingsFragment : }.show() } "delete_downloads" -> { - val dir = getDownloadDirectory(context)!! + val dir = getDownloadDirectory(context) AlertDialog.Builder(context).apply { setTitle(R.string.warning) @@ -150,7 +150,7 @@ class SettingsFragment : "backup" -> { File(ContextCompat.getDataDir(context), "favorites.json").copyTo( 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) @@ -192,8 +192,7 @@ class SettingsFragment : override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { "dl_location" -> { - findPreference(key)?.summary = - FileUtils.getPath(context, getDownloadDirectory(context!!)?.uri) + findPreference(key)?.summary = getDownloadDirectory(context!!).uri.path } } } @@ -230,7 +229,7 @@ class SettingsFragment : onPreferenceClickListener = this@SettingsFragment } "delete_downloads" -> { - val dir = getDownloadDirectory(context)!! + val dir = getDownloadDirectory(context) summary = getDirSize(dir) onPreferenceClickListener = this@SettingsFragment @@ -242,7 +241,7 @@ class SettingsFragment : onPreferenceClickListener = this@SettingsFragment } "dl_location" -> { - summary = FileUtils.getPath(context, getDownloadDirectory(context)?.uri) + summary = getDownloadDirectory(context).uri.path onPreferenceClickListener = this@SettingsFragment } diff --git a/app/src/main/java/xyz/quaver/pupil/util/file.kt b/app/src/main/java/xyz/quaver/pupil/util/file.kt index 9edef922..137cc8d4 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/file.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/file.kt @@ -29,21 +29,21 @@ import java.nio.charset.Charset import java.util.* fun getCachedGallery(context: Context, galleryID: Int) = - getDownloadDirectory(context)?.findFile(galleryID.toString()) ?: + getDownloadDirectory(context).findFile(galleryID.toString()) ?: 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 { if (it != null) Uri.parse(it) else - return null + Uri.fromFile(context.getExternalFilesDir(null)) } return if (uri.toString().startsWith("file")) DocumentFile.fromFile(File(uri.path!!)) else - DocumentFile.fromTreeUri(context, uri) + DocumentFile.fromTreeUri(context, uri) ?: DocumentFile.fromFile(context.getExternalFilesDir(null)!!) } fun convertUpdateUri(context: Context, uri: Uri) : Uri =