SimpleStorage icon indicating copy to clipboard operation
SimpleStorage copied to clipboard

Updated PR based on #142

Open w2sv opened this issue 1 year ago • 0 comments

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-plugin to 0.28.0, org.jetbrains.dokka:dokka-gradle-plugin to 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 kotlin source sets and the sample java files into a java source set, respectively
  • Made FileWrapper implementations value classes, which enables the compiler to optimize away lots of the overhead introduced by the wrapper class reference
  • Added some documentation to SingleFileResult.Validating and SingleFileResult.Preparing
  • Added a @FloatRange(0.0, 100.0) annotation to InProgress.progress fields which clarifies its value range
  • Ran AndroidStudio code reformatting on sample and storage modules

Breaking

  • Made all storage dependencies implementations instead of apis, except for deps.documentfile
  • Removed the SingleFileResult.CountingFiles, SingleFileResult.Starting, SingleFolderResult.Starting, which weren't ever emitted
  • Changed SingleFileResult.Completed to 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.AccessCallback interface, and instead introduced a MediaFile var onWriteAccessDenied: OnWriteAccessDenied? = null constructor parameter with typealias OnWriteAccessDenied = (mediaFile: MediaFile, sender: IntentSender) -> Unit

w2sv avatar Jul 08 '24 14:07 w2sv