Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 072e40e

Browse files
authored
New Scoped Storage sample (#131)
* Remove existing scoped storage sample * Add files generated by Android Studio * Add list of storage demos (placeholder for now) * Add AddMediaFile draft demo * Update UI when adding an image * Add sample media files * Display add media thumbnail Use landscapist-glide Reformat code Update AGP & compose * Extract HomeScreen to a dedicated file * Add back button in demo * Remove Download Media demo (covered by Add Media demo) * Add CaptureMediaFile demo Rename added files Extract strings to strings.xml * Add document sample files * Add AddFileToDownloads demo * Fix demo title * Add ListMediaFiles demo * Update FileResource to not be tight to MediaStore Move FilePreviewCard composables to common package * Add SelectDocumentFile demo * Remove unused variable * Add ModifyMediaRequest ActivityResultContract * Remove LaunchedEffect logging Reduce loading time when fetching MediaStore results * Switch GitHub action to use JDK 11 * Add copyright header
1 parent 432c05f commit 072e40e

94 files changed

Lines changed: 2795 additions & 2243 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/android.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ jobs:
2828

2929
steps:
3030
- uses: actions/checkout@v1
31-
- name: set up JDK 1.8
31+
- name: set up JDK 11
3232
uses: actions/setup-java@v1
3333
with:
34-
java-version: 1.8
34+
java-version: 11
3535
- name: Build project
3636
run: .github/scripts/gradlew_recursive.sh assembleDebug
3737
- name: Zip artifacts

ScopedStorage/.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
*.iml
22
.gradle
33
/local.properties
4-
.idea
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
510
.DS_Store
611
/build
712
/captures

ScopedStorage/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

ScopedStorage/app/build.gradle

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 The Android Open Source Project
2+
* Copyright 2021 The Android Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,25 +17,23 @@
1717
plugins {
1818
id 'com.android.application'
1919
id 'kotlin-android'
20-
id 'kotlin-parcelize'
20+
id "org.jetbrains.kotlin.plugin.parcelize"
2121
}
2222

2323
android {
24-
compileSdkVersion 30
25-
buildToolsVersion "30.0.3"
24+
compileSdk 31
2625

2726
defaultConfig {
28-
applicationId "com.samples.storage"
29-
minSdkVersion 21
30-
targetSdkVersion 30
27+
applicationId "com.samples.storage.scopedstorage"
28+
minSdk 21
29+
targetSdk 31
3130
versionCode 1
3231
versionName "1.0"
3332

3433
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
35-
}
36-
37-
buildFeatures {
38-
viewBinding true
34+
vectorDrawables {
35+
useSupportLibrary true
36+
}
3937
}
4038

4139
buildTypes {
@@ -50,28 +48,40 @@ android {
5048
}
5149
kotlinOptions {
5250
jvmTarget = '1.8'
51+
useIR = true
52+
}
53+
buildFeatures {
54+
compose true
55+
}
56+
composeOptions {
57+
kotlinCompilerExtensionVersion compose_version
58+
}
59+
packagingOptions {
60+
resources {
61+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
62+
}
5363
}
5464
}
5565

5666
dependencies {
57-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
67+
5868
implementation 'androidx.core:core-ktx:1.6.0'
5969
implementation 'androidx.appcompat:appcompat:1.3.1'
6070
implementation 'com.google.android.material:material:1.4.0'
61-
implementation 'androidx.activity:activity-ktx:1.3.1'
62-
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
63-
implementation 'androidx.fragment:fragment-ktx:1.3.6'
64-
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
65-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
66-
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
67-
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
68-
implementation 'androidx.recyclerview:recyclerview:1.2.1'
69-
implementation 'androidx.documentfile:documentfile:1.0.1'
70-
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
71-
implementation 'com.github.bumptech.glide:glide:4.12.0'
72-
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
71+
implementation "androidx.compose.ui:ui:$compose_version"
72+
implementation "androidx.compose.material:material:$compose_version"
73+
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
74+
implementation "androidx.compose.material:material-icons-extended:$compose_version"
75+
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
76+
implementation 'androidx.activity:activity-compose:1.3.1'
77+
78+
implementation "androidx.navigation:navigation-compose:2.4.0-alpha08"
79+
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
80+
implementation "com.github.skydoves:landscapist-glide:1.3.6"
7381

7482
testImplementation 'junit:junit:4.13.2'
7583
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
7684
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
85+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
86+
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
7787
}

ScopedStorage/app/src/main/AndroidManifest.xml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
~ Copyright (C) 2020 The Android Open Source Project
3+
~ Copyright 2021 The Android Open Source Project
44
~
55
~ Licensed under the Apache License, Version 2.0 (the "License");
66
~ you may not use this file except in compliance with the License.
@@ -16,23 +16,30 @@
1616
-->
1717

1818
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19-
package="com.samples.storage">
19+
package="com.samples.storage.scopedstorage">
2020

2121
<!-- Use to download content in the MediaStore demo -->
2222
<uses-permission android:name="android.permission.INTERNET" />
2323

24-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
25-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
24+
<uses-permission
25+
android:name="android.permission.READ_EXTERNAL_STORAGE"
26+
android:maxSdkVersion="28" />
27+
<uses-permission
28+
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
29+
android:maxSdkVersion="28" />
2630

2731
<application
2832
android:allowBackup="true"
2933
android:icon="@mipmap/ic_launcher"
3034
android:label="@string/app_name"
3135
android:roundIcon="@mipmap/ic_launcher_round"
3236
android:supportsRtl="true"
33-
android:theme="@style/Theme.StorageAPIs"
34-
android:requestLegacyExternalStorage="true">
35-
<activity android:name=".MainActivity">
37+
android:theme="@style/Theme.ScopedStorage">
38+
<activity
39+
android:name=".MainActivity"
40+
android:exported="true"
41+
android:label="@string/app_name"
42+
android:theme="@style/Theme.ScopedStorage.NoActionBar">
3643
<intent-filter>
3744
<action android:name="android.intent.action.MAIN" />
3845

163 KB
Loading
16.9 MB
Binary file not shown.
16.9 KB
Binary file not shown.
173 KB
Binary file not shown.

ScopedStorage/app/src/main/java/com/samples/storage/ActionListAdapter.kt

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)