diff --git a/StoragePlayground/.gitignore b/StoragePlayground/.gitignore
new file mode 100644
index 00000000..aa724b77
--- /dev/null
+++ b/StoragePlayground/.gitignore
@@ -0,0 +1,15 @@
+*.iml
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+local.properties
diff --git a/StoragePlayground/README.md b/StoragePlayground/README.md
new file mode 100644
index 00000000..0e576e60
--- /dev/null
+++ b/StoragePlayground/README.md
@@ -0,0 +1 @@
+# Storage Playground
\ No newline at end of file
diff --git a/StoragePlayground/app/.gitignore b/StoragePlayground/app/.gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/StoragePlayground/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/StoragePlayground/app/build.gradle b/StoragePlayground/app/build.gradle
new file mode 100644
index 00000000..aa1e715e
--- /dev/null
+++ b/StoragePlayground/app/build.gradle
@@ -0,0 +1,80 @@
+plugins {
+ id 'com.android.application'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.samples.storage.playground'
+ compileSdk 33
+
+ defaultConfig {
+ applicationId "com.samples.storage.playground"
+ minSdk 21
+ targetSdk 33
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ vectorDrawables {
+ useSupportLibrary true
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+ buildFeatures {
+ compose true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion compose_compiler_extension_version
+ }
+ packagingOptions {
+ resources {
+ excludes += '/META-INF/{AL2.0,LGPL2.1}'
+ }
+ }
+}
+
+dependencies {
+ def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
+ implementation composeBom
+ androidTestImplementation composeBom
+
+ implementation 'androidx.compose.material3:material3'
+ implementation 'androidx.compose.material:material-icons-extended'
+
+ // Android Studio Preview support
+ implementation 'androidx.compose.ui:ui-tooling-preview'
+ debugImplementation 'androidx.compose.ui:ui-tooling'
+
+ // UI Tests
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
+ debugImplementation 'androidx.compose.ui:ui-test-manifest'
+
+ implementation 'androidx.core:core-ktx:1.9.0'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
+ implementation 'androidx.navigation:navigation-compose:2.5.3'
+ implementation 'androidx.activity:activity-compose:1.6.1'
+
+ implementation 'io.coil-kt:coil-compose:2.2.1'
+ implementation 'io.coil-kt:coil-video:2.2.1'
+
+ implementation(project(":ui-elements"))
+ implementation(project(":demos:photopicker"))
+ implementation(project(":demos:addfiles"))
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/proguard-rules.pro b/StoragePlayground/app/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/StoragePlayground/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/AndroidManifest.xml b/StoragePlayground/app/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..db72b1d3
--- /dev/null
+++ b/StoragePlayground/app/src/main/AndroidManifest.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/Demo.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/Demo.kt
new file mode 100644
index 00000000..a57fa8ab
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/Demo.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground
+
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.AddCircle
+import androidx.compose.material.icons.filled.AddPhotoAlternate
+import androidx.compose.material.icons.filled.AttachFile
+import androidx.compose.material.icons.filled.Edit
+import androidx.compose.material.icons.filled.FolderOpen
+import androidx.compose.material.icons.filled.ImageSearch
+import androidx.compose.material.icons.filled.NoteAdd
+import androidx.compose.material.icons.filled.PhotoLibrary
+import androidx.compose.ui.graphics.vector.ImageVector
+
+data class Demo(val route: String, val label: String, val icon: ImageVector)
+
+object Demos {
+ val PhotoPicker = Demo("photo-picker", "Photo Picker", Icons.Filled.PhotoLibrary)
+
+ val AddMediaFile = Demo("add-media-file", "Add Media File", Icons.Filled.AddPhotoAlternate)
+ val AddFileToDownloads =
+ Demo("add-files-to-downloads", "Add Files To Downloads", Icons.Filled.AddCircle)
+
+ val CreateDocumentFile =
+ Demo("create-document-file", "Create Document File", Icons.Filled.NoteAdd)
+ val ReadDocumentFile = Demo("read-document-file", "Read Document File", Icons.Filled.AttachFile)
+ val EditDocumentFile = Demo("edit-document-file", "Edit Document File", Icons.Filled.Edit)
+ val ListFolderFiles = Demo("list-folder-files", "List Folder Files", Icons.Filled.FolderOpen)
+
+ val ListMediaFiles = Demo("list-media-files", "List Media Files", Icons.Filled.ImageSearch)
+
+ val list = listOf(
+ PhotoPicker,
+
+ AddMediaFile,
+ AddFileToDownloads,
+
+ CreateDocumentFile,
+ ReadDocumentFile,
+ EditDocumentFile,
+ ListFolderFiles,
+
+ ListMediaFiles,
+ )
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/DemoScreen.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/DemoScreen.kt
new file mode 100644
index 00000000..502ab823
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/DemoScreen.kt
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground
+
+import androidx.compose.foundation.clickable
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.items
+import androidx.compose.material3.Divider
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.font.FontFamily
+import androidx.navigation.NavController
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun DemoScreen(navController: NavController) {
+ Scaffold(
+ topBar = {
+ TopAppBar(
+ title = { Text("Storage Playground", fontFamily = FontFamily.Serif) },
+ )
+ },
+ ) { paddingValues ->
+ LazyColumn(Modifier.padding(paddingValues)) {
+ items(Demos.list) { demo ->
+ ListItem(
+ modifier = Modifier.clickable { navController.navigate(demo.route) },
+ headlineText = { Text(demo.label) },
+ leadingContent = { Icon(demo.icon, contentDescription = null) }
+ )
+ Divider()
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/MainActivity.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/MainActivity.kt
new file mode 100644
index 00000000..957c5ecb
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/MainActivity.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground
+
+import android.content.Context
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.ui.Modifier
+import androidx.navigation.compose.NavHost
+import androidx.navigation.compose.composable
+import androidx.navigation.compose.rememberNavController
+import com.samples.storage.playground.addfiles.AddMediaFileScreen
+import com.samples.storage.playground.photopicker.PhotoPickerScreen
+import com.samples.storage.playground.ui.theme.StoragePlaygroundTheme
+
+class MainActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ StoragePlaygroundTheme {
+ // A surface container using the 'background' color from the theme
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colorScheme.background
+ ) {
+ val navController = rememberNavController()
+ val startNavigation = "demos"
+// val startNavigation = Demos.PhotoPicker.route
+
+ NavHost(navController = navController, startDestination = startNavigation) {
+ composable("demos") { DemoScreen(navController) }
+ composable(Demos.PhotoPicker.route) { PhotoPickerScreen(navController) }
+ composable(Demos.AddMediaFile.route) { AddMediaFileScreen(navController) }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/StoragePlaygroundApplication.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/StoragePlaygroundApplication.kt
new file mode 100644
index 00000000..e0c5ba1f
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/StoragePlaygroundApplication.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import android.app.Application
+import coil.ImageLoader
+import coil.ImageLoaderFactory
+import coil.decode.VideoFrameDecoder
+
+class StoragePlaygroundApplication : Application(), ImageLoaderFactory {
+
+ override fun newImageLoader(): ImageLoader {
+ return ImageLoader.Builder(this)
+ .components {
+ add(VideoFrameDecoder.Factory())
+ }
+ .crossfade(true)
+ .build()
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Color.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Color.kt
new file mode 100644
index 00000000..1fecf6ee
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Color.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.ui.theme
+
+import androidx.compose.ui.graphics.Color
+
+val Purple80 = Color(0xFFD0BCFF)
+val PurpleGrey80 = Color(0xFFCCC2DC)
+val Pink80 = Color(0xFFEFB8C8)
+
+val Purple40 = Color(0xFF6650a4)
+val PurpleGrey40 = Color(0xFF625b71)
+val Pink40 = Color(0xFF7D5260)
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Theme.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Theme.kt
new file mode 100644
index 00000000..217e90e0
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Theme.kt
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.ui.theme
+
+import android.app.Activity
+import android.content.Context
+import android.content.ContextWrapper
+import android.os.Build
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.darkColorScheme
+import androidx.compose.material3.dynamicDarkColorScheme
+import androidx.compose.material3.dynamicLightColorScheme
+import androidx.compose.material3.lightColorScheme
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.SideEffect
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalView
+import androidx.core.view.WindowCompat
+
+private val DarkColorScheme = darkColorScheme(
+ primary = Purple80,
+ secondary = PurpleGrey80,
+ tertiary = Pink80
+)
+
+private val LightColorScheme = lightColorScheme(
+ primary = Purple40,
+ secondary = PurpleGrey40,
+ tertiary = Pink40
+
+ /* Other default colors to override
+ background = Color(0xFFFFFBFE),
+ surface = Color(0xFFFFFBFE),
+ onPrimary = Color.White,
+ onSecondary = Color.White,
+ onTertiary = Color.White,
+ onBackground = Color(0xFF1C1B1F),
+ onSurface = Color(0xFF1C1B1F),
+ */
+)
+
+@Composable
+fun StoragePlaygroundTheme(
+ darkTheme: Boolean = isSystemInDarkTheme(),
+ // Dynamic color is available on Android 12+
+ dynamicColor: Boolean = true,
+ content: @Composable () -> Unit
+) {
+ val colorScheme = when {
+ dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
+ val context = LocalContext.current
+ if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
+ }
+ darkTheme -> DarkColorScheme
+ else -> LightColorScheme
+ }
+ val view = LocalView.current
+ val context = LocalContext.current
+ if (!view.isInEditMode) {
+ SideEffect {
+ WindowCompat.getInsetsController(
+ context.findActivity().window,
+ view
+ ).isAppearanceLightStatusBars = !darkTheme
+ }
+ }
+
+ MaterialTheme(
+ colorScheme = colorScheme,
+ typography = Typography,
+ content = content
+ )
+}
+
+private tailrec fun Context.findActivity(): Activity = when (this) {
+ is Activity -> this
+ is ContextWrapper -> this.baseContext.findActivity()
+ else -> throw IllegalArgumentException("Could not find activity!")
+}
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Type.kt b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Type.kt
new file mode 100644
index 00000000..298b4400
--- /dev/null
+++ b/StoragePlayground/app/src/main/java/com/samples/storage/playground/ui/theme/Type.kt
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.ui.theme
+
+import androidx.compose.material3.Typography
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.sp
+
+// Set of Material typography styles to start with
+val Typography = Typography(
+ bodyLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp,
+ lineHeight = 24.sp,
+ letterSpacing = 0.5.sp
+ )
+ /* Other default text styles to override
+ titleLarge = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 22.sp,
+ lineHeight = 28.sp,
+ letterSpacing = 0.sp
+ ),
+ labelSmall = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Medium,
+ fontSize = 11.sp,
+ lineHeight = 16.sp,
+ letterSpacing = 0.5.sp
+ )
+ */
+)
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/StoragePlayground/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
new file mode 100644
index 00000000..d0ed943a
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/drawable/ic_launcher_background.xml b/StoragePlayground/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 00000000..c90a67bb
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 00000000..bc7babb9
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 00000000..bc7babb9
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher.webp
new file mode 100644
index 00000000..c209e78e
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..b2dfe3d1
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher.webp
new file mode 100644
index 00000000..4f0f1d64
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..62b611da
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
new file mode 100644
index 00000000..948a3070
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..1b9a6956
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..28d4b77f
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9287f508
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
new file mode 100644
index 00000000..aa7d6427
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ
diff --git a/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
new file mode 100644
index 00000000..9126ae37
Binary files /dev/null and b/StoragePlayground/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ
diff --git a/StoragePlayground/app/src/main/res/values/colors.xml b/StoragePlayground/app/src/main/res/values/colors.xml
new file mode 100644
index 00000000..5ac36474
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/values/colors.xml
@@ -0,0 +1,26 @@
+
+
+
+
+ #FFBB86FC
+ #FF6200EE
+ #FF3700B3
+ #FF03DAC5
+ #FF018786
+ #FF000000
+ #FFFFFFFF
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/values/strings.xml b/StoragePlayground/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..3641c8ab
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/values/strings.xml
@@ -0,0 +1,19 @@
+
+
+
+ Storage Playground
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/values/themes.xml b/StoragePlayground/app/src/main/res/values/themes.xml
new file mode 100644
index 00000000..d7eb3264
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/values/themes.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/xml/backup_rules.xml b/StoragePlayground/app/src/main/res/xml/backup_rules.xml
new file mode 100644
index 00000000..8ed32df5
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/xml/backup_rules.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/app/src/main/res/xml/data_extraction_rules.xml b/StoragePlayground/app/src/main/res/xml/data_extraction_rules.xml
new file mode 100644
index 00000000..76cd958b
--- /dev/null
+++ b/StoragePlayground/app/src/main/res/xml/data_extraction_rules.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/build.gradle b/StoragePlayground/build.gradle
new file mode 100644
index 00000000..6bf11a25
--- /dev/null
+++ b/StoragePlayground/build.gradle
@@ -0,0 +1,10 @@
+buildscript {
+ ext {
+ compose_compiler_extension_version = '1.3.2'
+ }
+}// Top-level build file where you can add configuration options common to all sub-projects/modules.
+plugins {
+ id 'com.android.application' version '7.3.1' apply false
+ id 'com.android.library' version '7.3.1' apply false
+ id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/.gitignore b/StoragePlayground/demos/addfiles/.gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/build.gradle b/StoragePlayground/demos/addfiles/build.gradle
new file mode 100644
index 00000000..4cd262d1
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/build.gradle
@@ -0,0 +1,69 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.samples.storage.playground.addfiles'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 33
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+ buildFeatures {
+ compose true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion compose_compiler_extension_version
+ }
+}
+
+dependencies {
+ def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
+ implementation composeBom
+ androidTestImplementation composeBom
+
+ implementation 'androidx.compose.material3:material3'
+ implementation 'androidx.compose.material:material-icons-extended'
+
+ // Android Studio Preview support
+ implementation 'androidx.compose.ui:ui-tooling-preview'
+ debugImplementation 'androidx.compose.ui:ui-tooling'
+
+ // UI Tests
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
+ debugImplementation 'androidx.compose.ui:ui-test-manifest'
+
+ implementation 'androidx.core:core-ktx:1.9.0'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
+ implementation 'androidx.navigation:navigation-compose:2.5.3'
+ implementation 'androidx.activity:activity-compose:1.6.1'
+
+ implementation 'io.coil-kt:coil-compose:2.2.1'
+ implementation 'io.coil-kt:coil-video:2.2.1'
+ implementation 'com.squareup.okhttp3:okhttp:4.10.0'
+
+ implementation(project(":ui-elements"))
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/consumer-rules.pro b/StoragePlayground/demos/addfiles/consumer-rules.pro
new file mode 100644
index 00000000..e69de29b
diff --git a/StoragePlayground/demos/addfiles/proguard-rules.pro b/StoragePlayground/demos/addfiles/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/src/main/AndroidManifest.xml b/StoragePlayground/demos/addfiles/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..fb8ae98b
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/src/main/AndroidManifest.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileScreen.kt b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileScreen.kt
new file mode 100644
index 00000000..7273e77a
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileScreen.kt
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.addfiles
+
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Download
+import androidx.compose.material.icons.filled.Folder
+import androidx.compose.material.icons.filled.Tune
+import androidx.compose.material3.CircularProgressIndicator
+import androidx.compose.material3.Divider
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.ExtendedFloatingActionButton
+import androidx.compose.material3.Icon
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.text.font.FontFamily
+import androidx.lifecycle.viewmodel.compose.viewModel
+import androidx.navigation.NavController
+import com.samples.storage.uielements.BackButton
+import com.samples.storage.uielements.OptionListItem
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun AddMediaFileScreen(
+ navController: NavController,
+ viewModel: AddMediaFileViewModel = viewModel()
+) {
+ val state = viewModel.uiState
+
+ Scaffold(
+ topBar = {
+ TopAppBar(
+ title = { Text("Add Media File", fontFamily = FontFamily.Serif) },
+ navigationIcon = {
+ BackButton(navController)
+ }
+ )
+ },
+ floatingActionButton = {
+ ExtendedFloatingActionButton(
+ onClick = viewModel::download,
+ icon = {
+ if (state.status == AddMediaFileViewModel.Status.LOADING) {
+ CircularProgressIndicator()
+ } else {
+ Icon(Icons.Filled.Download, null)
+ }
+ },
+ text = { Text(text = "Download ${state.fileType}") },
+ )
+ }
+ ) { paddingValues ->
+ Column(Modifier.padding(paddingValues)) {
+ OptionListItem(
+ label = "File Type",
+ icon = Icons.Filled.Tune,
+ values = MediaFile.values(),
+ currentValue = state.fileType,
+ onChange = viewModel::onFileTypeChange
+ )
+ Divider()
+ OptionListItem(
+ label = "Storage Destination",
+ icon = Icons.Filled.Folder,
+ values = AddMediaFileViewModel.StorageDestination.values(),
+ currentValue = state.storageDestination,
+ onChange = viewModel::onDestinationChange
+ )
+ Divider()
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileViewModel.kt b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileViewModel.kt
new file mode 100644
index 00000000..88d8b007
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/AddMediaFileViewModel.kt
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.addfiles
+
+import android.app.Application
+import android.content.Context
+import android.media.MediaScannerConnection
+import android.net.Uri
+import android.provider.MediaStore
+import android.util.Log
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.lifecycle.AndroidViewModel
+import androidx.lifecycle.viewModelScope
+import com.samples.storage.playground.addfiles.FileUtils.generateFilename
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.Response
+import java.io.File
+
+class AddMediaFileViewModel(application: Application) : AndroidViewModel(application) {
+ private val client = OkHttpClient()
+ private val context: Context
+ get() = getApplication()
+
+ enum class Status {
+ NOT_STARTED, LOADING, SUCCESS, ERROR
+ }
+
+ enum class StorageDestination {
+ Internal, Shared
+ }
+
+ data class MediaMetadata(
+ val uri: Uri,
+ val filename: String,
+ val size: Long,
+ val mimeType: String,
+ val orientation: String,
+ val width: Long,
+ val height: Long,
+ val durationInMs: Long?
+ )
+
+ data class UiState(
+ val status: Status = Status.NOT_STARTED,
+ val fileType: MediaFile = MediaFile.Image,
+ val storageDestination: StorageDestination = StorageDestination.Shared,
+ val metadata: MediaMetadata? = null
+ )
+
+ var uiState by mutableStateOf(UiState())
+ private set
+
+ fun onFileTypeChange(fileType: MediaFile) {
+ uiState = uiState.copy(fileType = fileType)
+ }
+
+ fun onDestinationChange(storageDestination: StorageDestination) {
+ uiState = uiState.copy(storageDestination = storageDestination)
+ }
+
+ fun download() {
+ uiState = uiState.copy(status = Status.LOADING)
+ val state = uiState.copy()
+
+ viewModelScope.launch(Dispatchers.IO) {
+ val url = state.fileType.random()
+ val request = Request.Builder().url(url).build()
+
+ client.newCall(request).execute().use { response ->
+ if (!response.isSuccessful) {
+ Log.e("AddMediaFileViewModel", "Download failed: $response")
+ withContext(Dispatchers.Main) {
+ uiState = uiState.copy(status = Status.ERROR)
+ }
+
+ return@launch
+ }
+
+ withContext(Dispatchers.Main) {
+ uiState = uiState.copy(status = Status.SUCCESS)
+ }
+
+ try {
+ when (state.storageDestination) {
+ StorageDestination.Internal -> saveToInternalStorage(
+ state.fileType,
+ response
+ )
+ StorageDestination.Shared -> saveToSharedStorage(state.fileType, response)
+ }
+
+ withContext(Dispatchers.Main) {
+ uiState = uiState.copy(status = Status.SUCCESS)
+ }
+
+ } catch (error: Exception) {
+ Log.e("AddMediaFileViewModel", "Copy failed: $error")
+
+ withContext(Dispatchers.Main) {
+ uiState = uiState.copy(status = Status.ERROR)
+ }
+ }
+ }
+ }
+ }
+
+ private fun saveToInternalStorage(fileType: MediaFile, response: Response) {
+ response.use {
+ response.body?.byteStream()?.use { inputStream ->
+ val newFile = File(context.filesDir, generateFilename(fileType.extension))
+ newFile.outputStream().use {
+ inputStream.copyTo(it)
+ }
+
+ Log.d("AddMediaFileViewModel", "File copied (internal): $newFile")
+ }
+ }
+ }
+
+ private fun saveToSharedStorage(fileType: MediaFile, response: Response) {
+ response.use {
+ val newFile = File(
+ fileType.getSharedFolder(),
+ generateFilename(fileType.extension)
+ )
+
+ response.body?.byteStream()?.use { inputStream ->
+ inputStream.use {
+ newFile.outputStream().use { outputStream ->
+ inputStream.copyTo(outputStream)
+ }
+ }
+ }
+
+ MediaScannerConnection.scanFile(
+ context,
+ arrayOf(newFile.path),
+ arrayOf(fileType.mimeType)
+ ) { _, scannedUri ->
+ if (scannedUri == null) {
+ Log.e(
+ "AddMediaFileViewModel",
+ "File ${newFile.path} could not be scanned"
+ )
+ } else {
+ Log.d(
+ "AddMediaFileViewModel",
+ "File ${newFile.path} scanned: $scannedUri"
+ )
+ }
+ }
+ }
+ }
+
+// suspend fun getResourceByUri(context: Context, uri: Uri): MediaMetadata {
+// return withContext(Dispatchers.IO) {
+// // Convert generic media uri to content uri to get FileColumns.MEDIA_TYPE value
+// val contentUri = convertMediaUriToContentUri(uri)
+//
+// val projection = arrayOf(
+// MediaStore.Files.FileColumns._ID,
+// MediaStore.Files.FileColumns.DISPLAY_NAME,
+// MediaStore.Files.FileColumns.SIZE,
+// MediaStore.Files.FileColumns.MEDIA_TYPE,
+// MediaStore.Files.FileColumns.MIME_TYPE,
+// MediaStore.Files.FileColumns.DATA,
+// )
+//
+// val cursor = contentUri?.let {
+// context.contentResolver.query(
+// it,
+// projection,
+// null,
+// null,
+// null
+// )
+// } ?: throw Exception("Uri $uri could not be found")
+//
+// cursor.use {
+// if (!cursor.moveToFirst()) {
+// throw Exception("Uri $uri could not be found")
+// }
+//
+// val idColumn = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns._ID)
+// val displayNameColumn =
+// cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DISPLAY_NAME)
+// val sizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.SIZE)
+// val mediaTypeColumn =
+// cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MEDIA_TYPE)
+// val mimeTypeColumn =
+// cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.MIME_TYPE)
+// val dataColumn = cursor.getColumnIndexOrThrow(MediaStore.Files.FileColumns.DATA)
+//
+// return MediaMetadata(
+// uri = uri,
+// filename = ,
+// size = ,
+// mimeType = ,
+// orientation = ,
+// width = ,
+// height = ,
+// dateTaken = ,
+// durationInMs = ,
+// )
+//
+// FileResource(
+// uri = contentUri,
+// filename = cursor.getString(displayNameColumn),
+// size = cursor.getLong(sizeColumn),
+// type = FileType.getEnum(cursor.getInt(mediaTypeColumn)),
+// mimeType = cursor.getString(mimeTypeColumn),
+// path = cursor.getString(dataColumn),
+// )
+// }
+// }
+// }
+
+ private suspend fun getImageMetadata(uri: Uri): MediaMetadata? {
+ return withContext(Dispatchers.IO) {
+
+ val projection = arrayOf(
+ MediaStore.MediaColumns._ID,
+ MediaStore.MediaColumns.DISPLAY_NAME,
+ MediaStore.MediaColumns.SIZE,
+ MediaStore.MediaColumns.MIME_TYPE,
+ MediaStore.MediaColumns.HEIGHT,
+ MediaStore.MediaColumns.WIDTH,
+ MediaStore.MediaColumns.ORIENTATION,
+ MediaStore.MediaColumns.DURATION,
+ )
+
+ return@withContext null
+
+// return MediaMetadata(
+// uri = uri,
+// filename =,
+// size =,
+// mimeType =,
+// orientation =,
+// width =,
+// height =,
+// dateTaken =,
+// durationInMs =,
+// )
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/FileUtils.kt b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/FileUtils.kt
new file mode 100644
index 00000000..bd839055
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/FileUtils.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.addfiles
+
+object FileUtils {
+ fun generateFilename(extension: String) = "playground-${System.currentTimeMillis()}.$extension"
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/MediaFile.kt b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/MediaFile.kt
new file mode 100644
index 00000000..c4898c48
--- /dev/null
+++ b/StoragePlayground/demos/addfiles/src/main/java/com/samples/storage/playground/addfiles/MediaFile.kt
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.addfiles
+
+import android.net.Uri
+import android.os.Build
+import android.os.Environment
+import android.provider.MediaStore
+import java.io.File
+
+enum class MediaFile {
+ Image {
+ override val extension = "jpg"
+ override val mimeType = "image/jpeg"
+ override val list = listOf(
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Google%2B/Google%2B_%20Instant%20Upload/card.jpg",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Demo%20Slam/Google%20Demo%20Slam_%2020ft%20Search/card.jpg",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Gone%20Google/Go%20Google_%20Google%20Drive/card.jpg",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Zeitgeist/Google%20Zeitgeist%20-%202013%20in%20Searches/card.jpg",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/April%20Fool's%202013/Explore%20Treasure%20Mode%20with%20Google%20Maps/card.jpg"
+ )
+
+ override fun getSharedFolder(): File = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
+
+ override fun getMediaStoreCollection(): Uri {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
+ } else {
+ MediaStore.Images.Media.EXTERNAL_CONTENT_URI
+ }
+ }
+ },
+
+ Video {
+ override val extension = "mp4"
+ override val mimeType = "video/mp4"
+ override val list = listOf(
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Google%2B/Google%2B_%20Instant%20Upload.mp4",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Demo%20Slam/Google%20Demo%20Slam_%2020ft%20Search.mp4",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Gone%20Google/Go%20Google_%20Google%20Drive.mp4",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/Zeitgeist/Google%20Zeitgeist%20-%202013%20in%20Searches.mp4",
+ "https://storage.googleapis.com/android-tv/Sample%20videos/April%20Fool's%202013/Explore%20Treasure%20Mode%20with%20Google%20Maps.mp4"
+ )
+
+ override fun getSharedFolder(): File = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES)
+
+ override fun getMediaStoreCollection(): Uri {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ MediaStore.Video.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
+ } else {
+ MediaStore.Video.Media.EXTERNAL_CONTENT_URI
+ }
+ }
+ };
+
+ abstract val extension: String
+ abstract val mimeType: String
+ abstract val list: List
+
+ fun random() = list.random()
+ abstract fun getSharedFolder(): File
+ abstract fun getMediaStoreCollection(): Uri
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/.gitignore b/StoragePlayground/demos/photopicker/.gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/build.gradle b/StoragePlayground/demos/photopicker/build.gradle
new file mode 100644
index 00000000..f1ac4acb
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/build.gradle
@@ -0,0 +1,68 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.samples.storage.playground.photopicker'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 33
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+ buildFeatures {
+ compose true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion compose_compiler_extension_version
+ }
+}
+
+dependencies {
+ def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
+ implementation composeBom
+ androidTestImplementation composeBom
+
+ implementation 'androidx.compose.material3:material3'
+ implementation 'androidx.compose.material:material-icons-extended'
+
+ // Android Studio Preview support
+ implementation 'androidx.compose.ui:ui-tooling-preview'
+ debugImplementation 'androidx.compose.ui:ui-tooling'
+
+ // UI Tests
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
+ debugImplementation 'androidx.compose.ui:ui-test-manifest'
+
+ implementation 'androidx.core:core-ktx:1.9.0'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
+ implementation 'androidx.navigation:navigation-compose:2.5.3'
+ implementation 'androidx.activity:activity-compose:1.6.1'
+
+ implementation 'io.coil-kt:coil-compose:2.2.1'
+ implementation 'io.coil-kt:coil-video:2.2.1'
+
+ implementation(project(":ui-elements"))
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/consumer-rules.pro b/StoragePlayground/demos/photopicker/consumer-rules.pro
new file mode 100644
index 00000000..e69de29b
diff --git a/StoragePlayground/demos/photopicker/proguard-rules.pro b/StoragePlayground/demos/photopicker/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/src/main/AndroidManifest.xml b/StoragePlayground/demos/photopicker/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..6f11a73b
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerScreen.kt b/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerScreen.kt
new file mode 100644
index 00000000..f154e2f3
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerScreen.kt
@@ -0,0 +1,180 @@
+package com.samples.storage.playground.photopicker
+
+import android.net.Uri
+import androidx.activity.compose.rememberLauncherForActivityResult
+import androidx.activity.result.contract.ActivityResultContracts
+import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.aspectRatio
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.foundation.lazy.grid.GridCells
+import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
+import androidx.compose.foundation.lazy.grid.items
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Add
+import androidx.compose.material.icons.filled.Filter
+import androidx.compose.material.icons.filled.Tune
+import androidx.compose.material3.BottomAppBarDefaults
+import androidx.compose.material3.Divider
+import androidx.compose.material3.DropdownMenu
+import androidx.compose.material3.DropdownMenuItem
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.FloatingActionButton
+import androidx.compose.material3.FloatingActionButtonDefaults
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.Scaffold
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.material3.TopAppBar
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.layout.ContentScale
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.unit.dp
+import androidx.lifecycle.viewmodel.compose.viewModel
+import androidx.navigation.NavController
+import coil.compose.AsyncImage
+import com.samples.storage.playground.photopicker.PhotoPickerViewModel.Companion.MAX_ITEMS_VALUES
+import com.samples.storage.uielements.BackButton
+import kotlin.math.max
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun PhotoPickerScreen(navController: NavController, viewModel: PhotoPickerViewModel = viewModel()) {
+ val state = viewModel.uiState
+
+ val selectItem = rememberLauncherForActivityResult(
+ ActivityResultContracts.PickVisualMedia(),
+ viewModel::onSingleSelect
+ )
+
+ val selectItems = rememberLauncherForActivityResult(
+ // PickMultipleVisualMedia requires to define a maxItems property to be higher than 1
+ ActivityResultContracts.PickMultipleVisualMedia(max(state.maxItems, 2)),
+ viewModel::onMultipleSelect
+ )
+
+ Scaffold(
+ topBar = {
+ TopAppBar(
+ title = { Text("Photo Picker", fontFamily = FontFamily.Serif) },
+ navigationIcon = {
+ BackButton(navController)
+ }
+ )
+ },
+ floatingActionButton = {
+ FloatingActionButton(
+ onClick = {
+ if (state.maxItems == 1) {
+ selectItem.launch(viewModel.createPickVisualMediaRequest())
+ } else {
+ selectItems.launch(viewModel.createPickVisualMediaRequest())
+ }
+ },
+ containerColor = BottomAppBarDefaults.bottomAppBarFabColor,
+ elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation()
+ ) {
+ Icon(Icons.Filled.Add, "Select from gallery")
+ }
+ }
+ ) { paddingValues ->
+ Column(Modifier.padding(paddingValues)) {
+ ListItem(
+ leadingContent = { Icon(Icons.Filled.Filter, contentDescription = null) },
+ headlineText = { Text("File Type Filter") },
+ trailingContent = {
+ FileTypeFilterMenu(
+ state.fileTypeFilter,
+ viewModel::onFileTypeFilterChange
+ )
+ },
+ )
+ Divider()
+ ListItem(
+ leadingContent = { Icon(Icons.Filled.Tune, contentDescription = null) },
+ headlineText = { Text("Max items limit") },
+ trailingContent = { MaxItemsSelect(state.maxItems, viewModel::onMaxItemsChange) },
+ )
+ Divider()
+ PhotoGallery(state.items)
+ }
+ }
+}
+
+@Composable
+fun FileTypeFilterMenu(
+ value: PhotoPickerViewModel.FileTypeFilter,
+ onChange: (value: PhotoPickerViewModel.FileTypeFilter) -> Unit
+) {
+ var expanded by remember { mutableStateOf(false) }
+
+ Box(modifier = Modifier.wrapContentSize(Alignment.TopEnd)) {
+ TextButton(onClick = { expanded = true }) {
+ Text(value.name)
+ }
+
+ DropdownMenu(
+ expanded = expanded,
+ onDismissRequest = { expanded = false }
+ ) {
+ PhotoPickerViewModel.FileTypeFilter.values().forEach {
+ DropdownMenuItem(
+ text = { Text(it.name) },
+ onClick = { onChange(it); expanded = false }
+ )
+ }
+ }
+ }
+}
+
+@Composable
+fun MaxItemsSelect(maxItems: Int, onSelect: (maxItems: Int) -> Unit) {
+ var expanded by remember { mutableStateOf(false) }
+
+ Box(modifier = Modifier.wrapContentSize(Alignment.TopEnd)) {
+ TextButton(onClick = { expanded = true }) {
+ Text(if (maxItems > 1) "$maxItems items max" else "1 item max")
+ }
+
+ DropdownMenu(
+ expanded = expanded,
+ onDismissRequest = { expanded = false }
+ ) {
+ MAX_ITEMS_VALUES.forEach { value ->
+ DropdownMenuItem(
+ text = { Text(if (value > 1) "$value items max" else "1 item max") },
+ onClick = { onSelect(value); expanded = false }
+ )
+ }
+ }
+ }
+}
+
+@Composable
+fun PhotoGallery(items: List) {
+ LazyVerticalGrid(
+ modifier = Modifier.fillMaxSize(),
+ columns = GridCells.Fixed(3),
+ horizontalArrangement = Arrangement.spacedBy(3.dp),
+ verticalArrangement = Arrangement.spacedBy(3.dp)
+ ) {
+ items(items) {
+ AsyncImage(
+ model = it,
+ contentDescription = null,
+ contentScale = ContentScale.Crop,
+ modifier = Modifier.aspectRatio(1f)
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerViewModel.kt b/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerViewModel.kt
new file mode 100644
index 00000000..05c987f5
--- /dev/null
+++ b/StoragePlayground/demos/photopicker/src/main/java/com/samples/storage/playground/photopicker/PhotoPickerViewModel.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.playground.photopicker
+
+import android.annotation.SuppressLint
+import android.net.Uri
+import android.provider.MediaStore
+import androidx.activity.result.PickVisualMediaRequest
+import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.Companion.isPhotoPickerAvailable
+import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageAndVideo
+import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.ImageOnly
+import androidx.activity.result.contract.ActivityResultContracts.PickVisualMedia.VideoOnly
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.setValue
+import androidx.lifecycle.ViewModel
+
+class PhotoPickerViewModel : ViewModel() {
+ companion object {
+ val MAX_ITEMS_VALUES = setOf(1, 3, 5, 10, getMaxItemsLimit())
+
+ @SuppressLint("NewApi")
+ private fun getMaxItemsLimit(): Int {
+ return if (isPhotoPickerAvailable()) {
+ MediaStore.getPickImagesMaxLimit()
+ } else {
+ 100
+ }
+ }
+ }
+
+ enum class FileTypeFilter {
+ ImageAndVideo, Image, Video
+ }
+
+ data class UiState(
+ val maxItems: Int = getMaxItemsLimit(),
+ val fileTypeFilter: FileTypeFilter = FileTypeFilter.ImageAndVideo,
+ val items: List = emptyList()
+ )
+
+ var uiState by mutableStateOf(UiState())
+ private set
+
+ fun onFileTypeFilterChange(fileTypeFilter: FileTypeFilter) {
+ uiState = uiState.copy(fileTypeFilter = fileTypeFilter)
+ }
+
+ fun onMaxItemsChange(maxItems: Int) {
+ uiState = uiState.copy(maxItems = maxItems)
+ }
+
+ fun onSingleSelect(uri: Uri?) {
+ uri?.let {
+ uiState = uiState.copy(items = listOf(it))
+ }
+ }
+
+ fun onMultipleSelect(uris: List) {
+ if (uris.isNotEmpty()) {
+ uiState = uiState.copy(items = uris)
+ }
+ }
+
+ fun createPickVisualMediaRequest(): PickVisualMediaRequest {
+ return when (uiState.fileTypeFilter) {
+ FileTypeFilter.ImageAndVideo -> PickVisualMediaRequest(ImageAndVideo)
+ FileTypeFilter.Image -> PickVisualMediaRequest(ImageOnly)
+ FileTypeFilter.Video -> PickVisualMediaRequest(VideoOnly)
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/gradle.properties b/StoragePlayground/gradle.properties
new file mode 100644
index 00000000..82d6773e
--- /dev/null
+++ b/StoragePlayground/gradle.properties
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Kotlin code style for this project: "official" or "obsolete":
+kotlin.code.style=official
+# Enables namespacing of each library's R class so that its R class includes only the
+# resources declared in the library itself and none from the library's dependencies,
+# thereby reducing the size of the R class for that library
+android.nonTransitiveRClass=true
+# Enables the configuration cache
+org.gradle.unsafe.configuration-cache=true
\ No newline at end of file
diff --git a/StoragePlayground/gradle/wrapper/gradle-wrapper.jar b/StoragePlayground/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..e708b1c0
Binary files /dev/null and b/StoragePlayground/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/StoragePlayground/gradle/wrapper/gradle-wrapper.properties b/StoragePlayground/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..53e63c8d
--- /dev/null
+++ b/StoragePlayground/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#Mon Sep 19 13:55:13 KST 2022
+distributionBase=GRADLE_USER_HOME
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/StoragePlayground/gradlew b/StoragePlayground/gradlew
new file mode 100755
index 00000000..4f906e0c
--- /dev/null
+++ b/StoragePlayground/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/StoragePlayground/gradlew.bat b/StoragePlayground/gradlew.bat
new file mode 100644
index 00000000..107acd32
--- /dev/null
+++ b/StoragePlayground/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/StoragePlayground/settings.gradle b/StoragePlayground/settings.gradle
new file mode 100644
index 00000000..5bfe2296
--- /dev/null
+++ b/StoragePlayground/settings.gradle
@@ -0,0 +1,19 @@
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "Storage Playground"
+include ':ui-elements'
+include ':app'
+include ':demos:addfiles'
+include ':demos:photopicker'
diff --git a/StoragePlayground/ui-elements/.gitignore b/StoragePlayground/ui-elements/.gitignore
new file mode 100644
index 00000000..42afabfd
--- /dev/null
+++ b/StoragePlayground/ui-elements/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/build.gradle b/StoragePlayground/ui-elements/build.gradle
new file mode 100644
index 00000000..1b11ef53
--- /dev/null
+++ b/StoragePlayground/ui-elements/build.gradle
@@ -0,0 +1,63 @@
+plugins {
+ id 'com.android.library'
+ id 'org.jetbrains.kotlin.android'
+}
+
+android {
+ namespace 'com.samples.storage.uielements'
+ compileSdk 33
+
+ defaultConfig {
+ minSdk 21
+ targetSdk 33
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+ buildFeatures {
+ compose true
+ }
+ composeOptions {
+ kotlinCompilerExtensionVersion compose_compiler_extension_version
+ }
+}
+
+dependencies {
+ def composeBom = platform('androidx.compose:compose-bom:2022.10.00')
+ implementation composeBom
+ androidTestImplementation composeBom
+
+ implementation 'androidx.compose.material3:material3'
+ implementation 'androidx.compose.material:material-icons-extended'
+
+ // Android Studio Preview support
+ implementation 'androidx.compose.ui:ui-tooling-preview'
+ debugImplementation 'androidx.compose.ui:ui-tooling'
+
+ // UI Tests
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
+ debugImplementation 'androidx.compose.ui:ui-test-manifest'
+
+ implementation 'androidx.core:core-ktx:1.9.0'
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
+ implementation 'androidx.navigation:navigation-compose:2.5.3'
+ implementation 'androidx.activity:activity-compose:1.6.1'
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+}
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/consumer-rules.pro b/StoragePlayground/ui-elements/consumer-rules.pro
new file mode 100644
index 00000000..e69de29b
diff --git a/StoragePlayground/ui-elements/proguard-rules.pro b/StoragePlayground/ui-elements/proguard-rules.pro
new file mode 100644
index 00000000..481bb434
--- /dev/null
+++ b/StoragePlayground/ui-elements/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/src/main/AndroidManifest.xml b/StoragePlayground/ui-elements/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..6f11a73b
--- /dev/null
+++ b/StoragePlayground/ui-elements/src/main/AndroidManifest.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/BackButton.kt b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/BackButton.kt
new file mode 100644
index 00000000..eee9dae7
--- /dev/null
+++ b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/BackButton.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.uielements
+
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.ArrowBack
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.runtime.Composable
+import androidx.navigation.NavController
+
+@Composable
+fun BackButton(navController: NavController) {
+ if (navController.previousBackStackEntry != null) {
+ IconButton(onClick = { navController.navigateUp() }) {
+ Icon(
+ imageVector = Icons.Filled.ArrowBack,
+ contentDescription = "Back"
+ )
+ }
+ } else {
+ null
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/EnumDropdownMenu.kt b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/EnumDropdownMenu.kt
new file mode 100644
index 00000000..bc474298
--- /dev/null
+++ b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/EnumDropdownMenu.kt
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.uielements
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.material3.DropdownMenu
+import androidx.compose.material3.DropdownMenuItem
+import androidx.compose.material3.Text
+import androidx.compose.material3.TextButton
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
+import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+
+@Composable
+fun EnumDropdownMenu(values: Array, currentValue: T, onChange: (value: T) -> Unit) {
+ var expanded by remember { mutableStateOf(false) }
+
+ Box(modifier = Modifier.wrapContentSize(Alignment.TopEnd)) {
+ TextButton(onClick = { expanded = true }) {
+ Text(currentValue.toString())
+ }
+
+ DropdownMenu(
+ expanded = expanded,
+ onDismissRequest = { expanded = false }
+ ) {
+ values.forEach {
+ DropdownMenuItem(
+ text = { Text(it.toString()) },
+ onClick = { onChange(it); expanded = false }
+ )
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/OptionListItem.kt b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/OptionListItem.kt
new file mode 100644
index 00000000..1355aec0
--- /dev/null
+++ b/StoragePlayground/ui-elements/src/main/java/com/samples/storage/uielements/OptionListItem.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.samples.storage.uielements
+
+import androidx.compose.material3.ExperimentalMaterial3Api
+import androidx.compose.material3.Icon
+import androidx.compose.material3.ListItem
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.graphics.vector.ImageVector
+
+@OptIn(ExperimentalMaterial3Api::class)
+@Composable
+fun OptionListItem(
+ label: String,
+ icon: ImageVector,
+ values: Array,
+ currentValue: T,
+ onChange: (value: T) -> Unit
+) {
+ ListItem(
+ headlineText = { Text(label) },
+ leadingContent = { Icon(icon, contentDescription = null) },
+ trailingContent = {
+ EnumDropdownMenu(
+ values = values,
+ currentValue = currentValue,
+ onChange = onChange
+ )
+ }
+ )
+}
\ No newline at end of file