Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated PR based on #142 #145

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open

Updated PR based on #142 #145

wants to merge 40 commits into from

Conversation

w2sv
Copy link

@w2sv w2sv commented Jul 8, 2024

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

anggrayudi and others added 30 commits June 18, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants