Several changes for using MediaStore

- Change config key name so default downloads to folder 'Download'
- Always use getFile as we do not need existing file deleted
- Fallback to use File based I/O pre API 29 as officially MediaStore
  APIs do not support general purpose usage. And also, it was working
  fine on all devices before. If it ain't broke, don't fix it
- Show full download path in settings to make it more clear to the user
- Close streams after using them
This commit is contained in:
topjohnwu
2020-08-22 04:20:18 -07:00
committed by John Wu
parent 9e81db8692
commit 14a2f63b8b
12 changed files with 90 additions and 84 deletions
@@ -21,7 +21,8 @@ fun ZipInputStream.forEach(callback: (ZipEntry) -> Unit) {
}
}
fun InputStream.writeTo(file: File) = this.copyTo(file.outputStream())
fun InputStream.writeTo(file: File) =
withStreams(this, file.outputStream()) { reader, writer -> reader.copyTo(writer) }
inline fun <In : InputStream, Out : OutputStream> withStreams(
inStream: In,