Git Product home page Git Product logo

modernstorage's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modernstorage's Issues

Add media files in a specific folder

Currently, we can only add media files at the root folder of each media collection, and not a sub folder. We should allow to specify the location

Delete media files

Currently, we can only add files and not delete them. This feature request should include deleting media files created by 3rd party apps

Verify authority when interacting with MediaStore URIs

Verify authority (MediaStore.AUTHORITY) when interacting with MediaStore APIs that require media URIs else return Result.failure.

  • MediaStoreRepository.getPathByUri
  • MediaStoreRepository.addMediaFromStream
  • MediaStoreRepository.scanUri
  • MediaStoreRepository.getResourceByUri
  • MediaStoreRepository.scanUri
  • MediaStoreRepository.scanUri
  • MediaStoreRepository.scanUri

Edit media files

Currently, we can only add files and not edit them. This feature request should include editing media files created by 3rd party apps

Request: add easy way to prepare a DocumentFile by file-path

Because Google said that the current API (of DocumentFile.fromFile) doesn't provide it, and that it doesn't plan on adding such a thing either:
https://issuetracker.google.com/issues/179478996#comment11

My request was that given a file-path, I should be able to reach it via DocumentFile (assuming I have access to the file, and that indeed it's a file on the device file system), and perform all operations on it like any other DocumentFile instance.

SQLiteConstraintException in createMediaStoreUri

Describe the bug

I'm using modernstorage to save a file from the web to my Downloads folder.
In certain situations, the following error occurs:

java.util.concurrent.ExecutionException: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: files._data (code 2067 SQLITE_CONSTRAINT_UNIQUE)
        at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)
        at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)
        at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:321)
        at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: files._data (code 2067 SQLITE_CONSTRAINT_UNIQUE)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:178)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
        at android.content.ContentResolver.insert(ContentResolver.java:2149)
        at android.content.ContentResolver.insert(ContentResolver.java:2111)
        at com.google.modernstorage.storage.SharedFileSystem.createMediaStoreUri(SharedFileSystem.kt:266)

To Reproduce

As I managed to find out, this happens if you download a file in the application, then clear the application data and try to download the same file again.

Environment:

  • Android OS version: Android 11
  • Target SDK version: API 31
  • Device: Xiaomi Mi 8 (PE)
  • ModernStorage version: v1.0.0-alpha03

Additional context

Some peaces of code, witch I use:

        val destPath = fileSystem.createMediaStoreUri(
            filename = depFileName,
            directory = getExternalStorageDir().absolutePath
        )?.toPath()
    private fun getExternalStorageDir(): File {
        return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            applicationContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)!!
        } else {
            @Suppress("DEPRECATION")
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
        }
    }

Running sample fails due to 502, remove jcenter?

Describe the bug

I'm trying to run the sample, but in current stable AS I get an issue

Error resolving plugin [id: 'org.jetbrains.dokka', version: '1.4.32']
> Could not resolve all dependencies for configuration 'detachedConfiguration2'.
   > Could not determine artifacts for org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:1.4.32
      > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/dokka/org.jetbrains.dokka.gradle.plugin/1.4.32/org.jetbrains.dokka.gradle.plugin-1.4.32.jar'.
         > Could not HEAD 'https://jcenter.bintray.com/org/jetbrains/dokka/org.jetbrains.dokka.gradle.plugin/1.4.32/org.jetbrains.dokka.gradle.plugin-1.4.32.jar'. Received status code 502 from server: Bad Gateway

I understand we can't do anything about the 502, and it might be temporary, but maybe we can try to remove jcenter/bintray repo?

[filesystem] Make `PlatformContract` methods match `DocumentsContract`

Instead of various methods which are identical, or almost identical, to the DocumentsContract, make PlatformContract define an interface which matches the Android version (with the exception of using java.net.URI rather than android.net.Uri for testing on non-Android devices)

Interface or abstract class? Both could have default implementations that would allow defining helper methods.

Perhaps best would be an interface for DocumentsContract and then a class that uses that interface for defining lower level helper methods that can be used by the filesystem classes without worrying about DocumentsContract at all.

Adding Bazel support in the sample

Adding Bazel support in the sample as an example of how to use the library for the apps that use Bazel.

may be just a wiki or complete bazel setup.
Might be blocked until the library is added to maven

Typo in a repository tag

Discussed in #45

Originally posted by ragunathjawahar August 7, 2021
The repository has a typo in the tag storace-access-framework should this be storage-access-framework?

Failed to resolve: com.google.modernstorage:modernstorage-permissions:1.0.0-alpha06

Error when building app with modernstorage

FAILURE: Build completed with 8 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:dataBindingMergeDependencyArtifactsCvsDebug'.
> Could not resolve all files for configuration ':app:cvsDebugCompileClasspath'.
   > Failed to transform modernstorage-storage-1.0.0-alpha06.aar (com.google.modernstorage:modernstorage-storage:1.0.0-alpha06) to match attributes {artifactType=android-databinding, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
      > Could not find modernstorage-storage-1.0.0-alpha06.aar (com.google.modernstorage:modernstorage-storage:1.0.0-alpha06).
        Searched in the following locations:
            https://plugins.gradle.org/m2/com/google/modernstorage/modernstorage-storage/1.0.0-alpha06/modernstorage-storage-1.0.0-alpha06.aar

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:dataBindingMergeDependencyArtifactsCvsDebug'.
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
	at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
	at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:79)
...

To Reproduce

Steps to reproduce the behavior:

  1. Add
    implementation("com.google.modernstorage:modernstorage-permissions:1.0.0-alpha06")
    implementation("com.google.modernstorage:modernstorage-storage:1.0.0-alpha06")
  2. Build app
  3. Run app
  4. See error

Environment:

  • Android OS version: 13 beta2
  • Target SDK version 31
  • Device: Google Pixel 6
  • ModernStorage version: 1.0.0-alpha06

Additional context

mavenCentral() added in build.gradle

No

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Add ID Column

I believe the MediaStore.Images.Media._ID will be extremely useful on getMediaResourceById and mediaresources when any developers can use it with getContentUri

[Idea] Add proper ProGuard support

Is your feature request related to a problem? Please describe.
Verify if current ProGuard rules are well written (we might have to do nothing)

Copyright profile

It would be valuable to add the copyright profile from the .idea folder to the project so that all files automatically get the correct license headers.

Ensure consistent code style

It would be helpful to add the codestyle files in the .idea folder to the project so that all contributors have the same settings.

Warning in Filesystem unit tests when using AGP 7.0.0-beta05

Describe the bug

Whenever I run the filesystem unit tests, I get an warning in my logs. It doesn't stop the tests to run and they're still succeeding but this warning shouldn't happen. The bug has been introduced when we updated AGP to 7.0.0-beta05 from 4.2.1 (see commit here).

Executing tasks: [:filesystem:cleanTestDebugUnitTest, :filesystem:testDebugUnitTest] in project /Users/yrezgui/modernstorage

unable to enhance gradle daemon classloader with idea_rt.jar
org.gradle.api.InvalidUserCodeException: Querying the mapped value of provider(interface java.util.Set) before task ':filesystem:compileDebugUnitTestKotlin' has completed is not supported

To Reproduce

Steps to reproduce the behavior:

  1. Open project in Android Studio
  2. Run filesystem unit tests
  3. See warning in logs

Expected behavior

Warning shouldn't happen. It's not present when using AGP 4.2.1

Environment:

  • Android Studio version: Arctic Fox beta 05
  • Target SDK version: API 30
  • ModernStorage version: 1.0.0-alpha02

Introducing Kotlin linter checks in github actions

Adding Ktlint linter for kotlin as a static GitHub check will reduce the code review period and improve code style

Found the following errors when checked with Ktlint 0.37.1^v

/home/farees/opensource/modernstorage/media/src/androidTest/java/com/google/modernstorage/media/ExampleInstrumentedTest.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/CustomActivityResultContracts.kt:39:1: Needless blank line(s)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:34:16: Missing spacing after "when"
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:41:16: Missing spacing after "when"
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:47:1: Needless blank line(s)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:59:16: Missing spacing after "when"
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaCollection.kt:66:16: Missing spacing after "when"
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaQuery.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaResource.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaStoreClient.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/MediaStoreClient.kt:19:1: Imports must be ordered in lexicographic order without any empty lines in-between
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/Permission.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/StorageLocation.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/media/src/main/java/com/google/modernstorage/media/StorageLocation.kt:23:1: Missing space after //
/home/farees/opensource/modernstorage/media/src/test/java/com/google/modernstorage/media/ExampleUnitTest.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/sample/src/androidTest/java/com/google/modernstorage/sample/ExampleInstrumentedTest.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/MainActivity.kt:42:1: Unexpected indentation (16) (should be 12)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/MediaStoreFragment.kt:155:11: Missing spacing after "if"
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/MediaStoreFragment.kt:161:1: Unexpected blank line(s) before "}"
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/MediaStoreViewModel.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/MediaStoreViewModel.kt:58:15: Missing spacing after "if"
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:1:1: File must end with a newline (\n)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:21:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:22:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:23:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:24:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:28:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:29:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:30:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/main/java/com/google/modernstorage/sample/mediastore/SampleData.kt:31:1: Exceeded max line length (100) (cannot be auto-corrected)
/home/farees/opensource/modernstorage/sample/src/test/java/com/google/modernstorage/sample/ExampleUnitTest.kt:1:1: File must end with a newline (\n)

IllegalArgumentException: Mutation of _data is not allowed when target Android 14

Describe the bug

I try use modernstorage to file downloading, but when update target to Android 14 start receive this exception

java.lang.IllegalArgumentException: Mutation of _data is not allowed.
                                                                                                	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
                                                                                                	at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
                                                                                                	at android.content.ContentProviderProxy.insert(ContentProviderNative.java:589)
                                                                                                	at android.content.ContentResolver.insert(ContentResolver.java:2209)
                                                                                                	at android.content.ContentResolver.insert(ContentResolver.java:2171)
                                                                                                	at com.google.modernstorage.storage.AndroidFileSystem.createMediaStoreUri(AndroidFileSystem.kt:425)

Environment:

  • Android OS version: Android 14
  • Target SDK version API 34
  • Device: Google Pixel 6a
  • ModernStorage version: v1.0.0-alpha06

Emulate IS_PENDING flag from API 21+

The IS_PENDING flag allows a file to not be visible to others applications until it has been processed like when you're still saving its content (see documentation).

The flag is only available from API 29+ but could possible be emulated on previous Android versions by following this scenario:

  • Save the file content first in the app cache directory
  • Move the file to the right MediaStore collection folder (see getExternalStoragePublicDirectory)
    • The operation should be quick as the file is already on the same storage volume
  • Scan the file in MediaStore

PhotoPicker maxItems not work !!!

Describe the bug

PhotoPicker maxItems not work.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'HomeScreen'
  2. Click on 'Pick Visual Media -> Select Images and/or Video (10 max)'
  3. select image can greater than 10

Expected behavior

Up to 10 images can be selected

Environment:

  • Android OS version: Android 12
  • Target SDK version API 31
  • Device: OnePlus GM1910
  • ModernStorage version: 1.0.0-alpha06

Add BOM in guide

We're adding BOM support in 1.0.0-alpha04 but we need to update the guide to highlight it

Project dead?

This set of APIs seemed really promising but it looks like there hasn't been much development on it for a long time now. Even the homepage said We're looking for a stable release in 2022.

Is there a plan to revive modernstorage?
Hoping for a positive response ๐Ÿคž๐Ÿป๐Ÿ’š

Fully implement Okio Filesystem API

We're currently lacking support for these methods:

  • appendingSink
  • atomicMove
  • createDirectory
  • openReadOnly
  • openReadWrite

Other methods could improve their support (we're not verifying in list or listOrNull if the provided Path is an actual directory Uri but the priority would be first to fully implement the Okio Filesystem API, we can follow up with improvements after.

java.lang.IllegalArgumentException: MIME type

Hi!

Describe the bug

Crash app

To Reproduce

Steps to reproduce the behavior:

  1. Open AddMediaScreen.
  2. Click on "Add Video" or "Add Audio"
 java.lang.IllegalArgumentException: MIME type video/mp4 cannot be inserted into content://media/external/images/media; expected MIME type under image/*
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
        at android.content.ContentProviderProxy.insert(ContentProviderNative.java:549)
        at android.content.ContentResolver.insert(ContentResolver.java:2149)
        at android.content.ContentResolver.insert(ContentResolver.java:2111)
        at com.google.modernstorage.storage.AndroidFileSystem.createMediaStoreUri(AndroidFileSystem.kt:425)
        at com.google.modernstorage.sample.mediastore.MediaStoreViewModel$addMedia$1.invokeSuspend(MediaStoreViewModel.kt:76)

It seems to fix the error you need to change the following:
in MediaStoreViewModel
change field "Collection"
For video ->

collection = MediaStore.Video.Media.getContentUri("external")

For Audio ->

  collection = MediaStore.Audio.Media.getContentUri("external")

[Idea] AndroidX Activity added ActivityResultContracts$PickVisualMedia. modernstorage-photopicker won't be needed anymore.

Version 1.6.0-alpha03

April 27, 2022

androidx.activity:activity:1.6.0-alpha03, androidx.activity:activity-compose:1.6.0-alpha03, and androidx.activity:activity-ktx:1.6.0-alpha03 are released.

  • Note: This version will only compile against the Android 13 Developer Beta 1 SDK.

New Features

  • Added ActivityResultContracts.PickVisualMedia and ActivityResultContracts.PickMultipleVisualMedia for providing a backward compatible contract that uses MediaStore.ACTION_PICK_IMAGES when the Photo Picker is available and Intent.ACTION_OPEN_DOCUMENT when it is not available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.