├── settings.gradle ├── screenshots ├── 1-main.png ├── 2-intent.png ├── 3-message.png └── icon-web.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── Application ├── src │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ └── tile.9.png │ │ ├── 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 │ │ ├── values-v21 │ │ │ ├── base-colors.xml │ │ │ └── base-template-styles.xml │ │ ├── values-v11 │ │ │ └── template-styles.xml │ │ ├── values │ │ │ ├── dimens.xml │ │ │ ├── base-strings.xml │ │ │ ├── colors.xml │ │ │ ├── template-dimens.xml │ │ │ ├── styles.xml │ │ │ ├── template-styles.xml │ │ │ └── strings.xml │ │ ├── values-sw600dp │ │ │ ├── template-dimens.xml │ │ │ └── template-styles.xml │ │ └── layout │ │ │ ├── select_contact.xml │ │ │ ├── contact.xml │ │ │ ├── main.xml │ │ │ └── send_message.xml │ │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── android │ │ │ └── directshare │ │ │ ├── ContactViewBinder.java │ │ │ ├── MainActivity.java │ │ │ ├── Contact.java │ │ │ ├── SampleChooserTargetService.java │ │ │ ├── SelectContactActivity.java │ │ │ └── SendMessageActivity.java │ │ └── AndroidManifest.xml └── build.gradle ├── README.md ├── .google └── packaging.yaml ├── CONTRIBUTING.md ├── gradlew.bat ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | include 'Application' 3 | -------------------------------------------------------------------------------- /screenshots/1-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/screenshots/1-main.png -------------------------------------------------------------------------------- /screenshots/2-intent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/screenshots/2-intent.png -------------------------------------------------------------------------------- /screenshots/3-message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/screenshots/3-message.png -------------------------------------------------------------------------------- /screenshots/icon-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/screenshots/icon-web.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Application/src/main/res/drawable-hdpi/tile.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/drawable-hdpi/tile.9.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-hdpi/logo_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-hdpi/logo_avatar.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-mdpi/logo_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-mdpi/logo_avatar.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xhdpi/logo_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xhdpi/logo_avatar.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xxhdpi/logo_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xxhdpi/logo_avatar.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Application/src/main/res/mipmap-xxxhdpi/logo_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/android-DirectShare/master/Application/src/main/res/mipmap-xxxhdpi/logo_avatar.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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.4-all.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Android DirectShare Sample 3 | ========================== 4 | 5 | This sample has been deprecated/archived meaning it's read-only and it's no longer actively maintained (more details on archiving can be found [here][1]). 6 | 7 | For other related samples, check out the new [SharingShortcuts][2] repo. Thank you! 8 | 9 | [1]: https://help.github.com/en/articles/about-archiving-repositories 10 | [2]: https://github.com/android/storage-samples/tree/master/SharingShortcuts 11 | -------------------------------------------------------------------------------- /.google/packaging.yaml: -------------------------------------------------------------------------------- 1 | 2 | # GOOGLE SAMPLE PACKAGING DATA 3 | # 4 | # This file is used by Google as part of our samples packaging process. 5 | # End users may safely ignore this file. It has no relevance to other systems. 6 | --- 7 | status: PUBLISHED 8 | technologies: [Android] 9 | categories: [Content] 10 | languages: [Java] 11 | solutions: [Mobile] 12 | github: android-DirectShare 13 | level: INTERMEDIATE 14 | icon: screenshots/icon-web.png 15 | apiRefs: 16 | - android:android.service.chooser.ChooserTargetService 17 | - android:android.service.chooser.ChooserTarget 18 | license: apache2 19 | -------------------------------------------------------------------------------- /Application/src/main/res/values-v21/base-colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Application/src/main/res/values-v11/template-styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Application/src/main/res/values-sw600dp/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | @dimen/margin_huge 22 | @dimen/margin_medium 23 | 24 | 25 | -------------------------------------------------------------------------------- /Application/src/main/res/values-sw600dp/template-styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/select_contact.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 26 | -------------------------------------------------------------------------------- /Application/src/main/res/values/base-strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | DirectShare 20 | 21 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Application/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | #3F51B5 19 | #303F9F 20 | #C5CAE9 21 | #00BCD4 22 | #212121 23 | #727272 24 | #FFFFFF 25 | #B6B6B6 26 | 27 | -------------------------------------------------------------------------------- /Application/src/main/res/values/template-dimens.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 4dp 22 | 8dp 23 | 16dp 24 | 32dp 25 | 64dp 26 | 27 | 28 | 29 | @dimen/margin_medium 30 | @dimen/margin_medium 31 | 32 | 33 | -------------------------------------------------------------------------------- /Application/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 24 | 25 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Application/src/main/java/com/example/android/directshare/ContactViewBinder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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 | * A simple utility to bind a {@link TextView} with a {@link Contact}. 23 | */ 24 | public class ContactViewBinder { 25 | 26 | /** 27 | * Binds the {@code textView} with the specified {@code contact}. 28 | * 29 | * @param contact The contact. 30 | * @param textView The TextView. 31 | */ 32 | public static void bind(Contact contact, TextView textView) { 33 | textView.setText(contact.getName()); 34 | textView.setCompoundDrawablesRelativeWithIntrinsicBounds(contact.getIcon(), 0, 0, 0); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/contact.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 31 | -------------------------------------------------------------------------------- /Application/src/main/res/values/template-styles.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 34 | 35 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Application/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 22 | This app demonstrates how to implement Direct Share. Use some other app and share a text. 23 | For your convenience, you can also use the input below to share the text. 24 | 25 | Hello! 26 | Share 27 | Send a message via: 28 | 29 | 30 | 31 | Sending a message 32 | To: 33 | Send 34 | Body: 35 | Edit your message. 36 | Sent a message \"%1$s\" to %2$s. 37 | Text to share 38 | 39 | 40 | -------------------------------------------------------------------------------- /Application/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | buildscript { 3 | repositories { 4 | jcenter() 5 | google() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.0.1' 10 | } 11 | } 12 | 13 | apply plugin: 'com.android.application' 14 | 15 | repositories { 16 | jcenter() 17 | google() 18 | } 19 | 20 | dependencies { 21 | compile "com.android.support:support-v4:27.0.2" 22 | compile "com.android.support:support-v13:27.0.2" 23 | compile "com.android.support:cardview-v7:27.0.2" 24 | compile "com.android.support:appcompat-v7:27.0.2" 25 | } 26 | 27 | // The sample build uses multiple directories to 28 | // keep boilerplate and common code separate from 29 | // the main sample code. 30 | List dirs = [ 31 | 'main', // main sample code; look here for the interesting stuff. 32 | 'common', // components that are reused by multiple samples 33 | 'template'] // boilerplate code that is generated by the sample template process 34 | 35 | android { 36 | compileSdkVersion 27 37 | 38 | buildToolsVersion "27.0.2" 39 | 40 | defaultConfig { 41 | minSdkVersion 23 42 | targetSdkVersion 27 43 | } 44 | 45 | compileOptions { 46 | sourceCompatibility JavaVersion.VERSION_1_7 47 | targetCompatibility JavaVersion.VERSION_1_7 48 | } 49 | 50 | sourceSets { 51 | main { 52 | dirs.each { dir -> 53 | java.srcDirs "src/${dir}/java" 54 | res.srcDirs "src/${dir}/res" 55 | } 56 | } 57 | androidTest.setRoot('tests') 58 | androidTest.java.srcDirs = ['tests/src'] 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your sample apps and patches! Before we can take them, we 6 | have to jump a couple of legal hurdles. 7 | 8 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 9 | 10 | * If you are an individual writing original source code and you're sure you 11 | own the intellectual property, then you'll need to sign an [individual CLA] 12 | (https://cla.developers.google.com). 13 | * If you work for a company that wants to allow you to contribute your work, 14 | then you'll need to sign a [corporate CLA] 15 | (https://cla.developers.google.com). 16 | 17 | Follow either of the two links above to access the appropriate CLA and 18 | instructions for how to sign and return it. Once we receive it, we'll be able to 19 | accept your pull requests. 20 | 21 | ## Contributing A Patch 22 | 23 | 1. Submit an issue describing your proposed change to the repo in question. 24 | 1. The repo owner will respond to your issue promptly. 25 | 1. If your proposed change is accepted, and you haven't already done so, sign a 26 | Contributor License Agreement (see details above). 27 | 1. Fork the desired repo, develop and test your code changes. 28 | 1. Ensure that your code adheres to the existing style in the sample to which 29 | you are contributing. Refer to the 30 | [Android Code Style Guide] 31 | (https://source.android.com/source/code-style.html) for the 32 | recommended coding standards for this organization. 33 | 1. Ensure that your code has an appropriate set of unit tests which all pass. 34 | 1. Submit a pull request. 35 | 36 | -------------------------------------------------------------------------------- /Application/src/main/java/com/example/android/directshare/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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.View; 23 | import android.widget.EditText; 24 | import android.widget.Toolbar; 25 | 26 | /** 27 | * Provides the landing screen of this sample. There is nothing particularly interesting here. All 28 | * the codes related to the Direct Share feature are in {@link SampleChooserTargetService}. 29 | */ 30 | public class MainActivity extends Activity { 31 | 32 | private EditText mEditBody; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.main); 38 | setActionBar((Toolbar) findViewById(R.id.toolbar)); 39 | mEditBody = (EditText) findViewById(R.id.body); 40 | findViewById(R.id.share).setOnClickListener(mOnClickListener); 41 | } 42 | 43 | private View.OnClickListener mOnClickListener = new View.OnClickListener() { 44 | @Override 45 | public void onClick(View v) { 46 | switch (v.getId()) { 47 | case R.id.share: 48 | share(); 49 | break; 50 | } 51 | } 52 | }; 53 | 54 | /** 55 | * Emits a sample share {@link Intent}. 56 | */ 57 | private void share() { 58 | Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 59 | sharingIntent.setType("text/plain"); 60 | sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, mEditBody.getText().toString()); 61 | startActivity(Intent.createChooser(sharingIntent, getString(R.string.send_intent_title))); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Application/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 16 | 20 | 21 | 30 | 31 | 37 | 38 | 42 | 43 | 52 | 53 |