├── direct-share-done
├── app
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── xml
│ │ │ │ ├── file_paths.xml
│ │ │ │ └── shortcuts.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── activity_select_contact.xml
│ │ │ │ ├── item_contact.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_send_message.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── android
│ │ │ │ └── directshare
│ │ │ │ ├── Contact.kt
│ │ │ │ ├── SelectContactActivity.kt
│ │ │ │ ├── SharingShortcutsManager.kt
│ │ │ │ ├── SendMessageActivity.kt
│ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── build.gradle
├── gradlew.bat
└── gradlew
├── direct-share-start
├── app
│ ├── .gitignore
│ ├── src
│ │ └── main
│ │ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── logo_avatar.png
│ │ │ ├── xml
│ │ │ │ ├── file_paths.xml
│ │ │ │ └── shortcuts.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ └── layout
│ │ │ │ ├── activity_select_contact.xml
│ │ │ │ ├── item_contact.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_send_message.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── android
│ │ │ │ └── directshare
│ │ │ │ ├── Contact.kt
│ │ │ │ ├── SelectContactActivity.kt
│ │ │ │ ├── SharingShortcutsManager.kt
│ │ │ │ ├── SendMessageActivity.kt
│ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── build.gradle
├── gradlew.bat
└── gradlew
├── settings.gradle
├── screenshots
├── app.gif
├── 1_main.png
├── 2_sharing_text.png
├── 6_android_P_bc.png
├── 5_android_P_no_bc.png
├── 7_android_L_sharing.png
├── 3_launcher_shortcuts.png
└── 4_sharing_no_content_preview.png
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── gradle.properties
├── CONTRIBUTING.md
├── .github
└── workflows
│ └── build_test.yml
├── gradlew.bat
├── gradlew
└── LICENSE
/direct-share-done/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/direct-share-start/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/direct-share-done/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/direct-share-start/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':direct-share-start:app', ':direct-share-done:app'
2 |
--------------------------------------------------------------------------------
/screenshots/app.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/app.gif
--------------------------------------------------------------------------------
/screenshots/1_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/1_main.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea*
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 |
--------------------------------------------------------------------------------
/screenshots/2_sharing_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/2_sharing_text.png
--------------------------------------------------------------------------------
/screenshots/6_android_P_bc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/6_android_P_bc.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/screenshots/5_android_P_no_bc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/5_android_P_no_bc.png
--------------------------------------------------------------------------------
/screenshots/7_android_L_sharing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/7_android_L_sharing.png
--------------------------------------------------------------------------------
/screenshots/3_launcher_shortcuts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/3_launcher_shortcuts.png
--------------------------------------------------------------------------------
/screenshots/4_sharing_no_content_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/screenshots/4_sharing_no_content_preview.png
--------------------------------------------------------------------------------
/direct-share-done/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/direct-share-start/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-hdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-hdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-mdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-mdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-hdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-hdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-mdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-mdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xxhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xxhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/mipmap-xxxhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-done/app/src/main/res/mipmap-xxxhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xxhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xxhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/mipmap-xxxhdpi/logo_avatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android/codelab-android-direct-share/HEAD/direct-share-start/app/src/main/res/mipmap-xxxhdpi/logo_avatar.png
--------------------------------------------------------------------------------
/direct-share-done/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | .build
12 | .captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/direct-share-start/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | .build
12 | .captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 15 12:33:15 CET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
7 |
--------------------------------------------------------------------------------
/direct-share-done/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 15 09:30:55 CET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/direct-share-start/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 15 09:30:55 CET 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Direct Share to an Android app
2 |
3 | This folder contains the source code for the [Direct Share to an Android app codelab](https://codelabs.developers.google.com/codelabs/android-direct-share/#0).
4 |
5 | ## License
6 |
7 | Copyright 2019 Google LLC
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License");
10 | you may not use this file except in compliance with the License.
11 | You may obtain a copy of the License at
12 |
13 | https://www.apache.org/licenses/LICENSE-2.0
14 |
15 | Unless required by applicable law or agreed to in writing, software
16 | distributed under the License is distributed on an "AS IS" BASIS,
17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | See the License for the specific language governing permissions and
19 | limitations under the License.
20 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
22 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
22 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | android.useAndroidX=true
17 | android.enableJetifier=true
18 |
--------------------------------------------------------------------------------
/direct-share-done/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | android.useAndroidX=true
17 | android.enableJetifier=true
18 |
--------------------------------------------------------------------------------
/direct-share-start/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # Kotlin code style for this project: "official" or "obsolete":
15 | kotlin.code.style=official
16 | android.useAndroidX=true
17 | android.enableJetifier=true
18 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/xml/shortcuts.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/xml/shortcuts.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #3F51B5
20 | #303F9F
21 | #C5CAE9
22 | #00BCD4
23 | #212121
24 | #727272
25 | #FFFFFF
26 | #B6B6B6
27 |
28 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #3F51B5
20 | #303F9F
21 | #C5CAE9
22 | #00BCD4
23 | #212121
24 | #727272
25 | #FFFFFF
26 | #B6B6B6
27 |
28 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to Contribute
2 |
3 | We'd love to accept your patches and contributions to this project. There are
4 | just a few small guidelines you need to follow.
5 |
6 | ## Contributor License Agreement
7 |
8 | Contributions to this project must be accompanied by a Contributor License
9 | Agreement. You (or your employer) retain the copyright to your contribution;
10 | this simply gives us permission to use and redistribute your contributions as
11 | part of the project. Head over to to see
12 | your current agreements on file or to sign a new one.
13 |
14 | You generally only need to submit a CLA once, so if you've already submitted one
15 | (even if it was for a different project), you probably don't need to do it
16 | again.
17 |
18 | ## Code reviews
19 |
20 | All submissions, including submissions by project members, require review. We
21 | use GitHub pull requests for this purpose. Consult
22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23 | information on using pull requests.
24 |
25 | ## Community Guidelines
26 |
27 | This project follows [Google's Open Source Community
28 | Guidelines](https://opensource.google.com/conduct/).
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/layout/activity_select_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
28 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/layout/activity_select_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
28 |
--------------------------------------------------------------------------------
/direct-share-done/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
18 |
19 | buildscript {
20 | repositories {
21 | google()
22 | mavenCentral()
23 | }
24 | dependencies {
25 | classpath "com.android.tools.build:gradle:${versions.android_gradle_plugin}"
26 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin_version}"
27 | // NOTE: Do not place your application dependencies here; they belong
28 | // in the individual module build.gradle files
29 | }
30 | }
31 |
32 | task clean(type: Delete) {
33 | delete rootProject.buildDir
34 | }
35 |
--------------------------------------------------------------------------------
/direct-share-start/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
18 |
19 | buildscript {
20 | repositories {
21 | google()
22 | mavenCentral()
23 | }
24 | dependencies {
25 | classpath "com.android.tools.build:gradle:${versions.android_gradle_plugin}"
26 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin_version}"
27 | // NOTE: Do not place your application dependencies here; they belong
28 | // in the individual module build.gradle files
29 | }
30 | }
31 |
32 | task clean(type: Delete) {
33 | delete rootProject.buildDir
34 | }
35 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | 4dp
21 | 8dp
22 | 16dp
23 | 32dp
24 | 64dp
25 |
26 | 16dp
27 |
28 | @dimen/margin_medium
29 | @dimen/margin_medium
30 |
31 | 24dp
32 | 8dp
33 |
34 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | 4dp
21 | 8dp
22 | 16dp
23 | 32dp
24 | 64dp
25 |
26 | 16dp
27 |
28 | @dimen/margin_medium
29 | @dimen/margin_medium
30 |
31 | 24dp
32 | 8dp
33 |
34 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
25 |
26 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/layout/item_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
32 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/layout/item_contact.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
32 |
--------------------------------------------------------------------------------
/.github/workflows/build_test.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | # Controls when the action will run. Triggers the workflow on push or pull request
4 | # events but only for the master branch
5 | on:
6 | push:
7 | branches: [ master ]
8 | pull_request:
9 | branches: [ master ]
10 |
11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
12 | jobs:
13 |
14 | # Build will compile APK, test APK and run tests, lint, etc.
15 | build:
16 |
17 | # The type of runner that the job will run on
18 | runs-on: ubuntu-latest
19 | timeout-minutes: 45
20 | env:
21 | TERM: dumb
22 |
23 | # Steps represent a sequence of tasks that will be executed as part of the job
24 | steps:
25 |
26 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27 | - uses: actions/checkout@v2
28 |
29 | - name: set up JDK
30 | uses: actions/setup-java@v1
31 | with:
32 | java-version: 11
33 |
34 | - name: Build and check all modules
35 | run: ./gradlew assembleDebug assembleDebugAndroidTest lintDebug testDebug
36 |
37 | - name: Upload build reports (direct-share-start)
38 | if: always()
39 | uses: actions/upload-artifact@v1
40 | with:
41 | name: build-reports-direct-share-start
42 | path: direct-share-start/app/build/reports
43 |
44 | - name: Upload build reports (direct-share-done)
45 | if: always()
46 | uses: actions/upload-artifact@v1
47 | with:
48 | name: build-reports-direct-share-done
49 | path: direct-share-done/app/build/reports
50 |
51 | # Project have not tests; omitting steps for publishing test artifacts
52 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Direct Share
21 |
22 |
23 |
24 | Send message
25 |
26 | This app demonstrates how to implement Direct Share. Use some other app and share a text.
27 | For your convenience, you can also use the input below to share the text.
28 |
29 | Text to share
30 | Hello!
31 | Share
32 |
33 |
34 |
35 | Sending a message
36 | To:
37 | Send
38 | Body:
39 | Edit your message
40 | Sent a message \"%1$s\" to %2$s
41 |
42 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | Direct Share
21 |
22 |
23 |
24 | Send message
25 |
26 | This app demonstrates how to implement Direct Share. Use some other app and share a text.
27 | For your convenience, you can also use the input below to share the text.
28 |
29 | Text to share
30 | Hello!
31 | Share
32 |
33 |
34 |
35 | Sending a message
36 | To:
37 | Send
38 | Body:
39 | Edit your message
40 | Sent a message \"%1$s\" to %2$s
41 |
42 |
--------------------------------------------------------------------------------
/direct-share-done/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 | apply plugin: 'kotlin-android'
19 |
20 | android {
21 | compileSdkVersion versions.compileSdk
22 | defaultConfig {
23 | applicationId names.applicationId
24 | minSdkVersion versions.minSdk
25 | targetSdkVersion versions.targetSdk
26 | versionCode 1
27 | versionName "1.0"
28 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation "androidx.core:core-ktx:${versions.androidxCore}"
34 | implementation "androidx.appcompat:appcompat:${versions.appcompat}"
35 | implementation "androidx.sharetarget:sharetarget:${versions.shareTarget}"
36 | implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
37 |
38 | testImplementation "junit:junit:${versions.junit}"
39 | androidTestImplementation "androidx.test:runner:${versions.test_runner}"
40 | androidTestImplementation "androidx.test.espresso:espresso-core:${versions.espresso}"
41 | }
42 |
--------------------------------------------------------------------------------
/direct-share-start/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | apply plugin: 'com.android.application'
18 | apply plugin: 'kotlin-android'
19 |
20 | android {
21 | compileSdkVersion versions.compileSdk
22 | defaultConfig {
23 | applicationId names.applicationId
24 | minSdkVersion versions.minSdk
25 | targetSdkVersion versions.targetSdk
26 | versionCode 1
27 | versionName "1.0"
28 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation "androidx.core:core-ktx:${versions.androidxCore}"
34 | implementation "androidx.appcompat:appcompat:${versions.appcompat}"
35 | implementation "androidx.sharetarget:sharetarget:${versions.shareTarget}"
36 | implementation "androidx.recyclerview:recyclerview:${versions.recyclerView}"
37 |
38 | testImplementation "junit:junit:${versions.junit}"
39 | androidTestImplementation "androidx.test:runner:${versions.test_runner}"
40 | androidTestImplementation "androidx.test.espresso:espresso-core:${versions.espresso}"
41 | }
42 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
28 |
29 |
33 |
34 |
44 |
45 |
53 |
54 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
22 |
23 |
28 |
29 |
33 |
34 |
44 |
45 |
53 |
54 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/java/com/example/android/directshare/Contact.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.widget.TextView
20 |
21 | /**
22 | * Provides the list of dummy contacts.
23 | * This sample implements this as constants, but real-life apps should use a database and such.
24 | */
25 | data class Contact(val name: String) {
26 |
27 | val icon = R.mipmap.logo_avatar
28 |
29 | companion object {
30 | /**
31 | * Representative invalid contact ID.
32 | */
33 | val invalidId = -1
34 |
35 | /**
36 | * The contact ID.
37 | */
38 | val id = "contact_id"
39 |
40 | /**
41 | * The list of dummy contacts.
42 | */
43 | val contacts = arrayOf(
44 | Contact("Tereasa"),
45 | Contact("Chang"),
46 | Contact("Kory"),
47 | Contact("Clare"),
48 | Contact("Landon"),
49 | Contact("Kyle"),
50 | Contact("Deana"),
51 | Contact("Daria"),
52 | Contact("Melisa"),
53 | Contact("Sammie")
54 | )
55 |
56 | /**
57 | * Finds a [Contact] specified by a contact ID.
58 | *
59 | * @param id The contact ID. This needs to be a valid ID.
60 | * @return A [Contact]
61 | */
62 | fun byId(id: Int) = contacts[id]
63 | }
64 | }
65 |
66 | fun Contact.bind(textView: TextView) {
67 | with(textView) {
68 | text = name
69 | setCompoundDrawablesRelativeWithIntrinsicBounds(icon, 0, 0, 0)
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/java/com/example/android/directshare/Contact.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.widget.TextView
20 |
21 | /**
22 | * Provides the list of dummy contacts.
23 | * This sample implements this as constants, but real-life apps should use a database and such.
24 | */
25 | data class Contact(val name: String) {
26 |
27 | val icon = R.mipmap.logo_avatar
28 |
29 | companion object {
30 | /**
31 | * Representative invalid contact ID.
32 | */
33 | val invalidId = -1
34 |
35 | /**
36 | * The contact ID.
37 | */
38 | val id = "contact_id"
39 |
40 | /**
41 | * The list of dummy contacts.
42 | */
43 | val contacts = arrayOf(
44 | Contact("Tereasa"),
45 | Contact("Chang"),
46 | Contact("Kory"),
47 | Contact("Clare"),
48 | Contact("Landon"),
49 | Contact("Kyle"),
50 | Contact("Deana"),
51 | Contact("Daria"),
52 | Contact("Melisa"),
53 | Contact("Sammie")
54 | )
55 |
56 | /**
57 | * Finds a [Contact] specified by a contact ID.
58 | *
59 | * @param id The contact ID. This needs to be a valid ID.
60 | * @return A [Contact]
61 | */
62 | fun byId(id: Int) = contacts[id]
63 | }
64 | }
65 |
66 | fun Contact.bind(textView: TextView) {
67 | with(textView) {
68 | text = name
69 | setCompoundDrawablesRelativeWithIntrinsicBounds(icon, 0, 0, 0)
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/direct-share-done/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/direct-share-start/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/java/com/example/android/directshare/SelectContactActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.app.Activity
20 | import android.content.Intent
21 | import android.os.Bundle
22 | import android.view.LayoutInflater
23 | import android.view.ViewGroup
24 | import android.widget.TextView
25 | import androidx.recyclerview.widget.LinearLayoutManager
26 | import androidx.recyclerview.widget.RecyclerView
27 |
28 | /**
29 | * The dialog for selecting a contact to share the text with. This dialog is shown when the user
30 | * taps on this sample's icon rather than any of the Direct Share contacts.
31 | */
32 | class SelectContactActivity : Activity() {
33 |
34 | private val contactAdapter = object : RecyclerView.Adapter() {
35 |
36 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactViewHolder {
37 | val textView = LayoutInflater.from(parent.context)
38 | .inflate(R.layout.item_contact, parent, false) as TextView
39 | return ContactViewHolder(textView)
40 | }
41 |
42 | override fun onBindViewHolder(holder: ContactViewHolder, position: Int) {
43 | val contact = Contact.contacts[position]
44 | contact.bind(holder.itemView as TextView)
45 | holder.itemView.setOnClickListener {
46 | val data = Intent()
47 | data.putExtra(Contact.id, position)
48 | setResult(Activity.RESULT_OK, data)
49 | finish()
50 | }
51 | }
52 |
53 | override fun getItemCount() = Contact.contacts.size
54 | }
55 |
56 | override fun onCreate(savedInstanceState: Bundle?) {
57 | super.onCreate(savedInstanceState)
58 | setContentView(R.layout.activity_select_contact)
59 |
60 | if (ACTION_SELECT_CONTACT != intent.action) {
61 | finish()
62 | return
63 | }
64 |
65 | // Set up the list of contacts
66 | findViewById(R.id.recycler_view).apply {
67 | adapter = contactAdapter
68 | layoutManager = LinearLayoutManager(this@SelectContactActivity)
69 | }
70 | }
71 |
72 | companion object {
73 | /**
74 | * The action string for Intents.
75 | */
76 | const val ACTION_SELECT_CONTACT =
77 | "com.example.android.directshare.intent.action.SELECT_CONTACT"
78 | }
79 | }
80 |
81 | private class ContactViewHolder(textView: TextView) : RecyclerView.ViewHolder(textView)
82 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/java/com/example/android/directshare/SelectContactActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.app.Activity
20 | import android.content.Intent
21 | import android.os.Bundle
22 | import android.view.LayoutInflater
23 | import android.view.ViewGroup
24 | import android.widget.TextView
25 | import androidx.recyclerview.widget.LinearLayoutManager
26 | import androidx.recyclerview.widget.RecyclerView
27 |
28 | /**
29 | * The dialog for selecting a contact to share the text with. This dialog is shown when the user
30 | * taps on this sample's icon rather than any of the Direct Share contacts.
31 | */
32 | class SelectContactActivity : Activity() {
33 |
34 | private val contactAdapter = object : RecyclerView.Adapter() {
35 |
36 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactViewHolder {
37 | val textView = LayoutInflater.from(parent.context)
38 | .inflate(R.layout.item_contact, parent, false) as TextView
39 | return ContactViewHolder(textView)
40 | }
41 |
42 | override fun onBindViewHolder(holder: ContactViewHolder, position: Int) {
43 | val contact = Contact.contacts[position]
44 | contact.bind(holder.itemView as TextView)
45 | holder.itemView.setOnClickListener {
46 | val data = Intent()
47 | data.putExtra(Contact.id, position)
48 | setResult(Activity.RESULT_OK, data)
49 | finish()
50 | }
51 | }
52 |
53 | override fun getItemCount() = Contact.contacts.size
54 | }
55 |
56 | override fun onCreate(savedInstanceState: Bundle?) {
57 | super.onCreate(savedInstanceState)
58 | setContentView(R.layout.activity_select_contact)
59 |
60 | if (ACTION_SELECT_CONTACT != intent.action) {
61 | finish()
62 | return
63 | }
64 |
65 | // Set up the list of contacts
66 | findViewById(R.id.recycler_view).apply {
67 | adapter = contactAdapter
68 | layoutManager = LinearLayoutManager(this@SelectContactActivity)
69 | }
70 | }
71 |
72 | companion object {
73 | /**
74 | * The action string for Intents.
75 | */
76 | const val ACTION_SELECT_CONTACT =
77 | "com.example.android.directshare.intent.action.SELECT_CONTACT"
78 | }
79 | }
80 |
81 | private class ContactViewHolder(textView: TextView) : RecyclerView.ViewHolder(textView)
82 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/res/layout/activity_send_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
31 |
32 |
38 |
39 |
50 |
51 |
52 |
53 |
62 |
63 |
75 |
76 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/res/layout/activity_send_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
31 |
32 |
38 |
39 |
50 |
51 |
52 |
53 |
62 |
63 |
75 |
76 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
41 |
42 |
43 |
48 |
49 |
50 |
51 |
52 |
53 |
57 |
60 |
61 |
62 |
66 |
67 |
72 |
77 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
22 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
50 |
51 |
52 |
53 |
54 |
55 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
70 |
71 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/java/com/example/android/directshare/SharingShortcutsManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.content.Context
20 | import android.content.Intent
21 | import androidx.core.app.Person
22 | import androidx.core.content.pm.ShortcutInfoCompat
23 | import androidx.core.content.pm.ShortcutManagerCompat
24 | import androidx.core.graphics.drawable.IconCompat
25 | import java.util.ArrayList
26 | import java.util.HashSet
27 |
28 | /**
29 | * Provides the Sharing Shortcuts items to the system.
30 | *
31 | * Use the ShortcutManagerCompat to make it work on older Android versions
32 | * without any extra work needed.
33 | *
34 | * Interactions with the ShortcutManager API can happen on any thread.
35 | */
36 | class SharingShortcutsManager {
37 |
38 | /**
39 | * Category name defined in res/xml/shortcuts.xml that accepts data of type text/plain
40 | * and will trigger [SendMessageActivity]
41 | */
42 | val categoryTextShareTarget = "com.example.android.directshare.category.TEXT_SHARE_TARGET"
43 |
44 | /**
45 | * Define maximum number of shortcuts.
46 | * Don't add more than [ShortcutManagerCompat.getMaxShortcutCountPerActivity].
47 | */
48 | private val maxShortcuts = 4
49 |
50 | /**
51 | * Publish the list of dynamic shortcuts that will be used in Direct Share.
52 | *
53 | * For each shortcut, we specify the categories that it will be associated to
54 | * the intent that will trigger when opened as a static launcher shortcut,
55 | * and the Shortcut ID between other things.
56 | *
57 | * The Shortcut ID that we specify in the [ShortcutInfoCompat.Builder] constructor will
58 | * be received in the intent as [Intent.EXTRA_SHORTCUT_ID].
59 | *
60 | * In this code sample, this method is completely static. We are always setting the same sharing
61 | * shortcuts. In a real-world example, we would replace existing shortcuts depending on
62 | * how the user interacts with the app as often as we want to.
63 | */
64 | fun pushDirectShareTargets(context: Context) {
65 | val shortcuts = ArrayList()
66 |
67 | // Category that our sharing shortcuts will be assigned to
68 | val contactCategories = setOf(categoryTextShareTarget)
69 |
70 | // Adding maximum number of shortcuts to the list
71 | for (id in 0 until maxShortcuts) {
72 | val contact = Contact.byId(id)
73 |
74 | // Item that will be sent if the shortcut is opened as a static launcher shortcut
75 | val staticLauncherShortcutIntent = Intent(Intent.ACTION_DEFAULT)
76 |
77 | // Creates a new Sharing Shortcut and adds it to the list
78 | // The id passed in the constructor will become EXTRA_SHORTCUT_ID in the received Intent
79 | shortcuts.add(
80 | ShortcutInfoCompat.Builder(context, Integer.toString(id))
81 | .setShortLabel(contact.name)
82 | // Icon that will be displayed in the share target
83 | .setIcon(IconCompat.createWithResource(context, contact.icon))
84 | .setIntent(staticLauncherShortcutIntent)
85 | // Make this sharing shortcut cached by the system
86 | // Even if it is unpublished, it can still appear on the sharesheet
87 | .setLongLived(true)
88 | .setCategories(contactCategories)
89 | // Person objects are used to give better suggestions
90 | .setPerson(
91 | Person.Builder()
92 | .setName(contact.name)
93 | .build()
94 | )
95 | .build()
96 | )
97 | }
98 |
99 | ShortcutManagerCompat.addDynamicShortcuts(context, shortcuts)
100 | }
101 |
102 | /**
103 | * Remove all dynamic shortcuts
104 | */
105 | fun removeAllDirectShareTargets(context: Context) {
106 | ShortcutManagerCompat.removeAllDynamicShortcuts(context)
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/direct-share-start/app/src/main/java/com/example/android/directshare/SharingShortcutsManager.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.content.Context
20 | import android.content.Intent
21 | import androidx.core.app.Person
22 | import androidx.core.content.pm.ShortcutInfoCompat
23 | import androidx.core.content.pm.ShortcutManagerCompat
24 | import androidx.core.graphics.drawable.IconCompat
25 | import java.util.ArrayList
26 | import java.util.HashSet
27 |
28 | /**
29 | * Provides the Sharing Shortcuts items to the system.
30 | *
31 | * Use the ShortcutManagerCompat to make it work on older Android versions
32 | * without any extra work needed.
33 | *
34 | * Interactions with the ShortcutManager API can happen on any thread.
35 | */
36 | class SharingShortcutsManager {
37 |
38 | /**
39 | * Category name defined in res/xml/shortcuts.xml that accepts data of type text/plain
40 | * and will trigger [SendMessageActivity]
41 | */
42 | val categoryTextShareTarget = "com.example.android.directshare.category.TEXT_SHARE_TARGET"
43 |
44 | /**
45 | * Define maximum number of shortcuts.
46 | * Don't add more than [ShortcutManagerCompat.getMaxShortcutCountPerActivity].
47 | */
48 | private val maxShortcuts = 4
49 |
50 | /**
51 | * Publish the list of dynamic shortcuts that will be used in Direct Share.
52 | *
53 | * For each shortcut, we specify the categories that it will be associated to
54 | * the intent that will trigger when opened as a static launcher shortcut,
55 | * and the Shortcut ID between other things.
56 | *
57 | * The Shortcut ID that we specify in the [ShortcutInfoCompat.Builder] constructor will
58 | * be received in the intent as [Intent.EXTRA_SHORTCUT_ID].
59 | *
60 | * In this code sample, this method is completely static. We are always setting the same sharing
61 | * shortcuts. In a real-world example, we would replace existing shortcuts depending on
62 | * how the user interacts with the app as often as we want to.
63 | */
64 | fun pushDirectShareTargets(context: Context) {
65 | val shortcuts = ArrayList()
66 |
67 | // Category that our sharing shortcuts will be assigned to
68 | // // TODO STEP 5 - Create categories matching the ones declared in the share-targets
69 | // val contactCategories = setOf(categoryTextShareTarget)
70 | // // TODO END STEP 5
71 |
72 | // // TODO STEP 6 - Prepare the sharing shortcuts
73 | // // Adding maximum number of shortcuts to the list
74 | // for (id in 0 until maxShortcuts) {
75 | // val contact = Contact.byId(id)
76 | //
77 | // // Item that will be sent if the shortcut is opened as a static launcher shortcut
78 | // val staticLauncherShortcutIntent = Intent(Intent.ACTION_DEFAULT)
79 | //
80 | // // Creates a new Sharing Shortcut and adds it to the list
81 | // // The id passed in the constructor will become EXTRA_SHORTCUT_ID in the received Intent
82 | // shortcuts.add(
83 | // ShortcutInfoCompat.Builder(context, Integer.toString(id))
84 | // .setShortLabel(contact.name)
85 | // // Icon that will be displayed in the share target
86 | // .setIcon(IconCompat.createWithResource(context, contact.icon))
87 | // .setIntent(staticLauncherShortcutIntent)
88 | // // Make this sharing shortcut cached by the system
89 | // // Even if it is unpublished, it can still appear on the sharesheet
90 | // .setLongLived(true)
91 | // .setCategories(contactCategories)
92 | // // Person objects are used to give better suggestions
93 | // .setPerson(
94 | // Person.Builder()
95 | // .setName(contact.name)
96 | // .build()
97 | // )
98 | // .build()
99 | // )
100 | // }
101 | // // TODO END STEP 6
102 |
103 | // // TODO STEP 7 - Publish the sharing shortcuts
104 | // ShortcutManagerCompat.addDynamicShortcuts(context, shortcuts)
105 | // // TODO END STEP 7
106 | }
107 |
108 | /**
109 | * Remove all dynamic shortcuts
110 | */
111 | fun removeAllDirectShareTargets(context: Context) {
112 | ShortcutManagerCompat.removeAllDynamicShortcuts(context)
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/direct-share-done/app/src/main/java/com/example/android/directshare/SendMessageActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.example.android.directshare
18 |
19 | import android.app.Activity
20 | import android.content.Intent
21 | import android.os.Build
22 | import android.os.Bundle
23 | import android.widget.Button
24 | import android.widget.TextView
25 | import android.widget.Toast
26 |
27 | /**
28 | * Provides the UI for sharing a text with a [Contact].
29 | */
30 | class SendMessageActivity : Activity() {
31 |
32 | /**
33 | * The request code for [SelectContactActivity]. This is used when the user doesn't
34 | * select any of Direct Share icons.
35 | */
36 | private val requestSelectContact = 1
37 |
38 | /**
39 | * The text to share.
40 | */
41 | private var textToShare: String? = null
42 |
43 | /**
44 | * The ID of the contact to share the text with.
45 | */
46 | private var contactId: Int = 0
47 |
48 | // View references.
49 | private lateinit var textContactName: TextView
50 | private lateinit var textMessageBody: TextView
51 |
52 | override fun onCreate(savedInstanceState: Bundle?) {
53 | super.onCreate(savedInstanceState)
54 | setContentView(R.layout.activity_send_message)
55 | setTitle(R.string.sending_message)
56 |
57 | // View references.
58 | textContactName = findViewById(R.id.contact_name)
59 | textMessageBody = findViewById(R.id.message_body)
60 |
61 | // Handle the share Intent.
62 | val handled = handleIntent(intent)
63 | if (!handled) {
64 | finish()
65 | return
66 | }
67 |
68 | // Bind event handlers.
69 | findViewById