SimpleStorage
SimpleStorage copied to clipboard
Updated PR based on #142
I ended up rewriting all the still relevant changes with #142 as base branch. Somehow all the commits you did to the branch are now included in the PR too and I couldn't quite figure out how to fix that, as I'm not sooo well versed with git yet.
Once again, the list of the changes I made:
Internal
- Updated
com.vanniktech:gradle-maven-publish-pluginto 0.28.0,org.jetbrains.dokka:dokka-gradle-pluginto 1.9.20, gradle to 8.8 - Fixed build file deprecations and did some polishing there
- Removed redundant proguard files,
ExampleUnitTests,buildFeatures { viewBinding = true }from the storage build file,deps.coroutines.core - Put kotlin files into
kotlinsource sets and the sample java files into ajavasource set, respectively - Made
FileWrapperimplementations value classes, which enables the compiler to optimize away lots of the overhead introduced by the wrapper class reference - Added some documentation to
SingleFileResult.ValidatingandSingleFileResult.Preparing - Added a
@FloatRange(0.0, 100.0)annotation toInProgress.progressfields which clarifies its value range - Ran AndroidStudio code reformatting on sample and storage modules
Breaking
- Made all storage dependencies
implementations instead ofapis, except fordeps.documentfile - Removed the
SingleFileResult.CountingFiles,SingleFileResult.Starting,SingleFolderResult.Starting, which weren't ever emitted - Changed
SingleFileResult.Completedto the following for type clarity
sealed interface Completed : SingleFileResult {
@JvmInline
value class MediaFile(val value: com.anggrayudi.storage.media.MediaFile) : Completed
@JvmInline
value class DocumentFile(val value: androidx.documentfile.provider.DocumentFile) : Completed
companion object {
internal fun get(file: Any): Completed =
when (file) {
is com.anggrayudi.storage.media.MediaFile -> MediaFile(file)
is androidx.documentfile.provider.DocumentFile -> DocumentFile(file)
else -> throw IllegalArgumentException("File must be either of type ${com.anggrayudi.storage.media.MediaFile::class.java.name} or ${androidx.documentfile.provider.DocumentFile::class.java.name}")
}
}
}
- Same for the type of
ZipDecompressionResult.Completed.zipFile: DecompressedZipFile
sealed interface DecompressedZipFile {
@JvmInline
value class MediaFile(val value: com.anggrayudi.storage.media.MediaFile) : DecompressedZipFile
@JvmInline
value class DocumentFile(val value: androidx.documentfile.provider.DocumentFile) :
DecompressedZipFile
}
- Made the 3 MediaDirectory enums implement a common interface:
sealed interface MediaDirectory {
val folderName: String
/**
* Created on 06/09/20
* @author Anggrayudi H
*/
enum class Image(override val folderName: String) : MediaDirectory {
PICTURES(Environment.DIRECTORY_PICTURES),
DCIM(Environment.DIRECTORY_DCIM)
}
/**
* Created on 06/09/20
* @author Anggrayudi H
*/
enum class Video(override val folderName: String) : MediaDirectory {
MOVIES(Environment.DIRECTORY_MOVIES),
DCIM(Environment.DIRECTORY_DCIM)
}
/**
* Created on 06/09/20
* @author Anggrayudi H
*/
enum class Audio(override val folderName: String) : MediaDirectory {
MUSIC(Environment.DIRECTORY_MUSIC),
PODCASTS(Environment.DIRECTORY_PODCASTS),
RINGTONES(Environment.DIRECTORY_RINGTONES),
ALARMS(Environment.DIRECTORY_ALARMS),
NOTIFICATIONS(Environment.DIRECTORY_NOTIFICATIONS)
}
}
- Removed the
MediaFile.AccessCallbackinterface, and instead introduced a MediaFilevar onWriteAccessDenied: OnWriteAccessDenied? = nullconstructor parameter withtypealias OnWriteAccessDenied = (mediaFile: MediaFile, sender: IntentSender) -> Unit