Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Get storage permissions & remove old packages (#77)
Browse files Browse the repository at this point in the history
* Remove filesystem & mediastore modules (already deprecated)

* Add getReadFilesPermissions & getReadAndWriteFilesPermissions methods

Refactor storage permission checking logic to be more flexible for future usages

* Remove filesystem & mediastore modules (already deprecated)

* Add getReadFilesPermissions & getReadAndWriteFilesPermissions methods

Refactor storage permission checking logic to be more flexible for future usages

* Change permissions check to bitwise operations

* Deprecate canReadFiles & canReadAndWriteFiles in favor of hasAccess

Deprecate getReadFilesPermissions & getReadAndWriteFilesPermissions in favor of getPermissions
Simplify StoragePermissions.getPermissions unit tests

* Add better support for Java usage

* Add Bill of Material (#78)

* Fix module versioning in documentation (#76)

* Add Bill of Material

* Fix build

Exclude BOM from adding metalava as it doesn't have api/current.api

Co-authored-by: Yacine Rezgui <rezgui.y@gmail.com>

* Update API metadata

* Fix documentation code tab snippets

* Avoid wasting useless workflow runs

* Use new StoragePermissions.hasAccess method

* Update guide with new StoragePermissions.hasAccess method

* Upgrade version number

Co-authored-by: Andreas <andreas.everos@gmail.com>
  • Loading branch information
yrezgui and ghostbear committed Jan 19, 2022
1 parent 05a8ee7 commit bd4188e
Show file tree
Hide file tree
Showing 56 changed files with 437 additions and 3,321 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: Build

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]

jobs:
build:
Expand Down
18 changes: 18 additions & 0 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
kotlin("jvm")
id("com.vanniktech.maven.publish")
}

dependencies {
constraints {
api(project(":permissions"))
api(project(":photopicker"))
api(project(":storage"))
api("com.squareup.okio:okio:3.0.0")
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
3 changes: 3 additions & 0 deletions bom/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_ARTIFACT_ID=modernstorage-bom
POM_NAME=ModernStorage Bill of Material
POM_PACKAGING=jar
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ subprojects {
}
}

if (project.hasProperty('POM_ARTIFACT_ID')) {
if (project.hasProperty('POM_ARTIFACT_ID') && project.properties['POM_ARTIFACT_ID'] != "modernstorage-bom") {
apply plugin: 'me.tylerbwong.gradle.metalava'

metalava {
Expand Down
15 changes: 15 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ implementation("com.google.modernstorage:modernstorage-permissions:{{ lib_versio
implementation("com.google.modernstorage:modernstorage-storage:{{ lib_version }}")
```

Alternatively use the Bill of Material to just have to define the version once, and then define which modules you need.

```kotlin
implementation("com.google.modernstorage:modernstorage-bom:{{ lib_version }}")

implementation("com.google.modernstorage:modernstorage-permissions")

implementation("com.google.modernstorage:modernstorage-storage")

// The Bill of Material includes Okio and Photo Picker as well
implementation("com.google.modernstorage:modernstorage-photopicker")

implementation("com.squareup.okio:okio")
```

## Quick start

* Have a look at the [permissions][permissions_guide] and [storage interactions][storage_interactions_guide] guides
Expand Down
12 changes: 8 additions & 4 deletions docs/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ To help you navigate common use cases, check out the below table:
// Check if the app can read image & document files created by itself
val storagePermissions = StoragePermissions(context)

storagePermissions.canReadFiles(
storagePermissions.hasAccess(
action = Action.READ,
types = listOf(FileType.Image, FileType.Document),
createdBy = StoragePermissions.CreatedBy.Self
)

// Check if the app can read video & audio files created by all apps
storagePermissions.canReadFiles(
storagePermissions.hasAccess(
action = Action.READ,
types = listOf(FileType.Video, FileType.Audio),
createdBy = StoragePermissions.CreatedBy.AllApps
)
Expand All @@ -71,13 +73,15 @@ storagePermissions.canReadFiles(
// Check if the app can read & write image & document files created by itself
val storagePermissions = StoragePermissions(context)

storagePermissions.canReadAndWriteFiles(
storagePermissions.hasAccess(
action = Action.READ_AND_WRITE,
types = listOf(FileType.Image, FileType.Video),
createdBy = StoragePermissions.CreatedBy.Self
)

// Check if the app can read & write video & audio files created by all apps
storagePermissions.canReadAndWriteFiles(
storagePermissions.hasAccess(
action = Action.READ_AND_WRITE,
types = listOf(FileType.Audio, FileType.Document),
createdBy = StoragePermissions.CreatedBy.AllApps
)
Expand Down
1 change: 0 additions & 1 deletion docs/photopicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ implementation("com.google.modernstorage:{{ artifact }}:{{ lib_version }}")
=== "Views"

```kotlin
class
// Register a callback for the Activity Result
val photoPicker = registerForActivityResult(PhotoPicker()) { uris ->
// uris contain the list of selected images & video
Expand Down
163 changes: 0 additions & 163 deletions filesystem/api/current.api

This file was deleted.

73 changes: 0 additions & 73 deletions filesystem/build.gradle

This file was deleted.

Empty file removed filesystem/consumer-rules.pro
Empty file.
3 changes: 0 additions & 3 deletions filesystem/gradle.properties

This file was deleted.

21 changes: 0 additions & 21 deletions filesystem/proguard-rules.pro

This file was deleted.

Loading

0 comments on commit bd4188e

Please sign in to comment.