summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--photopicker/Android.bp40
-rw-r--r--photopicker/AndroidManifest.xml71
-rw-r--r--photopicker/README47
-rw-r--r--photopicker/TEST_MAPPING8
-rw-r--r--photopicker/res/values/core_strings.xml22
-rw-r--r--photopicker/res/values/themes.xml24
-rw-r--r--photopicker/src/com/android/photopicker/MainActivity.kt41
-rw-r--r--photopicker/src/com/android/photopicker/PhotopickerApplication.kt25
-rw-r--r--photopicker/src/com/android/photopicker/core/PhotopickerApp.kt30
-rw-r--r--photopicker/tests/Android.bp26
-rw-r--r--photopicker/tests/AndroidManifest.xml28
-rw-r--r--photopicker/tests/src/com/android/photopicker/MainActivityTest.kt39
-rw-r--r--photopicker/tests/src/com/android/photopicker/core/PhotopickerAppTest.kt47
13 files changed, 448 insertions, 0 deletions
diff --git a/photopicker/Android.bp b/photopicker/Android.bp
new file mode 100644
index 000000000..3e538f2a4
--- /dev/null
+++ b/photopicker/Android.bp
@@ -0,0 +1,40 @@
+package {
+ // See: http://go/android-license-faq
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_library {
+ name: "PhotopickerLib",
+ manifest: "AndroidManifest.xml",
+ srcs: [ "src/**/*.kt"],
+ resource_dirs: ["res"],
+ sdk_version: "module_current",
+ min_sdk_version: "30",
+ static_libs: [
+ "androidx.activity_activity-compose",
+ "androidx.compose.foundation_foundation",
+ "androidx.compose.material3_material3",
+ "androidx.compose.runtime_runtime",
+ "androidx.compose.ui_ui",
+ "androidx.core_core-ktx",
+ ],
+ apex_available: ["//apex_available:platform", "com.android.mediaprovider"],
+}
+
+android_app {
+ name: "Photopicker",
+ manifest: "AndroidManifest.xml",
+ static_libs: [
+ "PhotopickerLib",
+ ],
+ plugins: [],
+ kotlincflags: ["-Xjvm-default=all"],
+ libs: [ ],
+ certificate: "media",
+ privileged: true,
+ sdk_version: "module_current",
+ min_sdk_version: "30",
+ apex_available: ["//apex_available:platform", "com.android.mediaprovider"],
+
+}
+
diff --git a/photopicker/AndroidManifest.xml b/photopicker/AndroidManifest.xml
new file mode 100644
index 000000000..376c14fd8
--- /dev/null
+++ b/photopicker/AndroidManifest.xml
@@ -0,0 +1,71 @@
+<!--
+ Copyright 2024 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
+
+ http://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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="com.android.photopicker">
+
+ <!--
+ This permission identifies Photopicker to MediaProvider and allows access
+ to private system APIs.
+
+ Declared by MediaProvider and requires the 'media' certificate to obtain.
+ -->
+ <uses-permission
+ android:name="com.android.providers.media.permission.MANAGE_CLOUD_MEDIA_PROVIDERS"/>
+
+ <application
+ android:name="com.android.photopicker.PhotopickerApplication"
+ android:label="@string/photopicker_application_label"
+ android:allowBackup="false"
+ android:supportsRtl="true">
+
+ <activity
+ android:name="com.android.photopicker.MainActivity"
+ android:exported="true"
+ android:theme="@style/Theme.Photopicker"
+ android:label="@string/photopicker_application_label"
+ android:excludeFromRecents="true">
+
+ <intent-filter android:priority="105" >
+ <action android:name="android.provider.action.PICK_IMAGES"/>
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="image/*" />
+ <data android:mimeType="video/*" />
+ </intent-filter>
+ <intent-filter android:priority="105" >
+ <action android:name="android.provider.action.PICK_IMAGES"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ </intent-filter>
+ </activity>
+
+ <activity-alias
+ android:name="com.android.photopicker.PhotopickerGetContentActivity"
+ android:targetActivity="com.android.photopicker.MainActivity"
+ android:exported="true"
+ android:excludeFromRecents="true"
+ android:enabled="true">
+ <intent-filter android:priority="105" >
+ <action android:name="android.intent.action.GET_CONTENT"/>
+ <category android:name="android.intent.category.OPENABLE"/>
+ <category android:name="android.intent.category.DEFAULT"/>
+ <data android:mimeType="image/*"/>
+ <data android:mimeType="video/*"/>
+ </intent-filter>
+ </activity-alias>
+
+ </application>
+</manifest>
diff --git a/photopicker/README b/photopicker/README
new file mode 100644
index 000000000..123c9c666
--- /dev/null
+++ b/photopicker/README
@@ -0,0 +1,47 @@
+######################################
+# Android Photopicker README
+######################################
+
+Note: This photopicker app is currently under development, and is not
+(currently) being shipped with mediaprovider. You might be looking for:
+
+/packages/providers/MediaProvider/photopicker
+
+######################################
+# To install for development / testing:
+######################################
+
+Consider using photopicker_utils.sh for deploying/incremental installs/removing.
+
+Build a mediaprovider APEX which includes Photopicker. The initial deployment
+needs to be from the APEX to ensure Photopicker receives its certificate specific
+permissions.
+
+Incremental builds can be done by making the Photopicker target and directly
+installing the resulting APK.
+
+######################################
+# Troubleshooting
+######################################
+
+Launching ACTION_PICK_IMAGES or ACTION_GET_CONTENT should bring you into the new
+PhotopickerActivity. If not, try debugging the intents to see if the activity
+is getting picked up by Android:
+
+adb shell pm query-activities -a "android.intent.action.GET_CONTENT" -t "image/*"
+
+This should give a print out of all activities (and their respective priorities)
+that can handle this intent and com.android.photopicker.MainActivity should be
+in the list. If not, try the installation steps above again. (Be sure to reboot)
+
+
+######################################
+# Testing
+######################################
+To run the tests:
+
+atest PhotopickerTests
+
+Note: PhotopickerTests bundles the application code with the tests, so the
+app does not need to be installed first for the test suite to be run. The test
+suite will bring along all the code it needs.
diff --git a/photopicker/TEST_MAPPING b/photopicker/TEST_MAPPING
new file mode 100644
index 000000000..c04920944
--- /dev/null
+++ b/photopicker/TEST_MAPPING
@@ -0,0 +1,8 @@
+{
+ "presubmit": [
+ {
+ "name": "PhotopickerTests",
+ "options": []
+ }
+ ]
+}
diff --git a/photopicker/res/values/core_strings.xml b/photopicker/res/values/core_strings.xml
new file mode 100644
index 000000000..632d4e036
--- /dev/null
+++ b/photopicker/res/values/core_strings.xml
@@ -0,0 +1,22 @@
+<!--
+ Copyright 2024 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
+
+ http://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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <!-- Label to show to user for this package and for Photo picker. -->
+ <string name="photopicker_application_label" translation_description="Label for the application that handles picking media files to share with other apps. [CHAR_LIMIT=NONE]">Media Picker</string>
+
+</resources>
diff --git a/photopicker/res/values/themes.xml b/photopicker/res/values/themes.xml
new file mode 100644
index 000000000..dd73d405e
--- /dev/null
+++ b/photopicker/res/values/themes.xml
@@ -0,0 +1,24 @@
+<!--
+ Copyright 2024 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
+
+ http://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.
+ -->
+<resources>
+ <style name="Theme.Photopicker" parent="@android:style/Theme.DeviceDefault.DayNight">
+ <item name="android:backgroundDimEnabled">true</item>
+ <item name="android:statusBarColor">@android:color/transparent</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
+ <item name="android:windowIsTranslucent">true</item>
+ <item name="android:windowNoTitle">true</item>
+ </style>
+</resources>
diff --git a/photopicker/src/com/android/photopicker/MainActivity.kt b/photopicker/src/com/android/photopicker/MainActivity.kt
new file mode 100644
index 000000000..40a027b59
--- /dev/null
+++ b/photopicker/src/com/android/photopicker/MainActivity.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.android.photopicker
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import com.android.photopicker.core.PhotopickerApp
+
+/**
+ * This is the main entrypoint into the Android Photopicker.
+ *
+ * This class is responsible for bootstrapping the launched activity, session related dependencies,
+ * and providing the compose ui entrypoint in [[PhotopickerApp]] with everything it needs.
+ */
+class MainActivity : ComponentActivity() {
+ companion object {
+ val TAG: String = "Photopicker"
+ }
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ PhotopickerApp()
+ }
+ }
+}
diff --git a/photopicker/src/com/android/photopicker/PhotopickerApplication.kt b/photopicker/src/com/android/photopicker/PhotopickerApplication.kt
new file mode 100644
index 000000000..65e138985
--- /dev/null
+++ b/photopicker/src/com/android/photopicker/PhotopickerApplication.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.android.photopicker
+
+import android.app.Application
+
+class PhotopickerApplication : Application() {
+ override fun onCreate() {
+ super.onCreate()
+ }
+}
diff --git a/photopicker/src/com/android/photopicker/core/PhotopickerApp.kt b/photopicker/src/com/android/photopicker/core/PhotopickerApp.kt
new file mode 100644
index 000000000..996bbf456
--- /dev/null
+++ b/photopicker/src/com/android/photopicker/core/PhotopickerApp.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.android.photopicker.core
+
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+
+@Composable
+fun PhotopickerApp() {
+ Surface(modifier = Modifier.fillMaxSize()) {
+ Text("Hello World from Photopicker!")
+ }
+}
diff --git a/photopicker/tests/Android.bp b/photopicker/tests/Android.bp
new file mode 100644
index 000000000..f00f92626
--- /dev/null
+++ b/photopicker/tests/Android.bp
@@ -0,0 +1,26 @@
+
+android_test {
+
+ name: "PhotopickerTests",
+ test_suites: ["general-tests"],
+ manifest: "AndroidManifest.xml",
+ srcs: ["src/**/*.kt"],
+ compile_multilib: "both",
+ certificate: "media",
+ sdk_version: "module_current",
+ min_sdk_version: "30",
+ static_libs: [
+ // sources
+ "PhotopickerLib",
+
+ // test dependencies
+ "androidx.test.core",
+ "androidx.test.rules",
+ "androidx.compose.runtime_runtime",
+ "androidx.compose.ui_ui-test-junit4",
+ "androidx.compose.ui_ui-test-manifest",
+ ],
+
+ aaptflags: ["--custom-package com.android.photopicker"],
+
+}
diff --git a/photopicker/tests/AndroidManifest.xml b/photopicker/tests/AndroidManifest.xml
new file mode 100644
index 000000000..86434b2f4
--- /dev/null
+++ b/photopicker/tests/AndroidManifest.xml
@@ -0,0 +1,28 @@
+<!--
+ Copyright 2024 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
+
+ http://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.
+ -->
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.photopicker">
+
+ <application android:debuggable="true">
+ <uses-library android:name="android.test.runner"/>
+ </application>
+
+ <instrumentation
+ android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.photopicker"
+ android:label="Tests for Android Photopicker"/>
+</manifest>
diff --git a/photopicker/tests/src/com/android/photopicker/MainActivityTest.kt b/photopicker/tests/src/com/android/photopicker/MainActivityTest.kt
new file mode 100644
index 000000000..67c0f01ee
--- /dev/null
+++ b/photopicker/tests/src/com/android/photopicker/MainActivityTest.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.android.photopicker
+
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
+import androidx.compose.ui.test.onNodeWithText
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * This test class will run Photopicker's actual MainActivity.
+ */
+@RunWith(AndroidJUnit4::class)
+class MainActivityTest {
+ @get:Rule
+ val composeTestRule = createAndroidComposeRule(activityClass = MainActivity::class.java)
+
+ @Test
+ fun testMainActivity() {
+ composeTestRule.onNodeWithText("Hello World from Photopicker!").assertIsDisplayed()
+ }
+}
diff --git a/photopicker/tests/src/com/android/photopicker/core/PhotopickerAppTest.kt b/photopicker/tests/src/com/android/photopicker/core/PhotopickerAppTest.kt
new file mode 100644
index 000000000..549a08019
--- /dev/null
+++ b/photopicker/tests/src/com/android/photopicker/core/PhotopickerAppTest.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2024 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
+ *
+ * http://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.android.photopicker.core
+
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.compose.ui.test.onNodeWithText
+import androidx.test.ext.junit.runners.AndroidJUnit4
+
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/**
+ * Unit tests for the main PhotopickerApp composable.
+ */
+@RunWith(AndroidJUnit4::class)
+class PhotopickerAppTest {
+
+ @get:Rule
+ val composeTestRule = createComposeRule()
+
+ @Test
+ fun testPhotopickerApp(){
+
+ composeTestRule.setContent{
+ PhotopickerApp()
+ }
+
+ composeTestRule.onNodeWithText("Hello World from Photopicker!").assertIsDisplayed()
+ }
+
+}