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

Commit 05f09a2

Browse files
author
Jeremy Walker
committed
Adds CommitContentSampleIME sample to repo.
Change-Id: Ie4fe0cddf0b2980fd4c940a5b0116cb0d64c170a
1 parent 079c274 commit 05f09a2

33 files changed

+867
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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: [System]
10+
languages: [Java]
11+
solutions: [Mobile]
12+
github: android/input
13+
level: INTERMEDIATE
14+
icon: screenshots/icon-web.png
15+
apiRefs:
16+
- android:android.widget.EditText
17+
- android:import android.support.v13.view.inputmethod.EditorInfoCompat
18+
- android:import android.support.v13.view.inputmethod.InputConnectionCompat
19+
- android:import android.support.v13.view.inputmethod.InputContentInfoCompat
20+
license: apache2

CommitContentSampleIME/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
Android CommitContentSampleIME Sample
3+
===================================
4+
5+
This sample demonstrates how to write an keyboard which sends rich content (such as images) to text
6+
fields using the Commit Content API.
7+
8+
Introduction
9+
------------
10+
11+
Users often want to communicate with emojis, stickers, and other kinds of rich content. In previous
12+
versions of Android, soft keyboards (input method editors or IMEs) could send only unicode emoji to
13+
apps. For rich content (such as images), apps had to either build app-specific APIs that couldn't
14+
be used in other apps or use workarounds like sending images through the Easy Share Action or the
15+
clipboard.
16+
17+
Now in Android 7.1 (API 25), the Android SDK includes the [Commit Content API][1], which provides a
18+
universal way for IMEs to send images and other rich content directly to a text editor in an app.
19+
The API is also available in the v13 Support Library (ver. 25.0), supporting devices as early as
20+
Android 3.2 (API 13).
21+
22+
With this API, you can build messaging apps that accept rich content from any keyboard, as well as
23+
keyboards that can send rich content to any app.
24+
25+
**Note:** This sample does not have a default Activity. After installing it, you will need to enable
26+
this app as a keyboard by navigating to *Settings > Languages & Input > Virtual Keyboard > Manage
27+
Keyboards*. This keyboard can then be accessed by pressing the virtual keyboard icon in the
28+
lower-right hand corner of the display while in a text field.
29+
30+
[1]: https://android-dot-devsite.googleplex.com/preview/image-keyboard.html
31+
32+
Pre-requisites
33+
--------------
34+
35+
- Android SDK 28
36+
- Android Build Tools v28.0.3
37+
- Android Support Repository
38+
39+
Screenshots
40+
-------------
41+
42+
<img src="screenshots/screenshot-1.png" height="400" alt="Screenshot"/>
43+
44+
Getting Started
45+
---------------
46+
47+
This sample uses the Gradle build system. To build this project, use the
48+
"gradlew build" command or use "Import Project" in Android Studio.
49+
50+
Support
51+
-------
52+
53+
- Stack Overflow: http://stackoverflow.com/questions/tagged/android
54+
55+
If you've found an error in this sample, please file an issue:
56+
https://github.com/android/input
57+
58+
Patches are encouraged, and may be submitted by forking this project and
59+
submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 28
5+
defaultConfig {
6+
applicationId "com.example.android.commitcontent.ime"
7+
minSdkVersion 16
8+
targetSdkVersion 28
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
compile fileTree(include: ['*.jar'], dir: 'libs')
23+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
24+
exclude group: 'com.android.support', module: 'support-annotations'
25+
})
26+
compile 'com.android.support:appcompat-v7:28.0.0'
27+
compile 'com.android.support:support-v13:28.0.0'
28+
testCompile 'junit:junit:4.12'
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/google/home/yukawa/Android/Sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.android.commitcontent.ime">
3+
4+
<application
5+
android:allowBackup="false"
6+
android:icon="@mipmap/ic_launcher"
7+
android:roundIcon="@mipmap/ic_launcher_round"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
12+
<service
13+
android:name="com.example.android.commitcontent.ime.ImageKeyboard"
14+
android:permission="android.permission.BIND_INPUT_METHOD">
15+
<intent-filter>
16+
<action android:name="android.view.InputMethod" />
17+
</intent-filter>
18+
<meta-data android:name="android.view.im" android:resource="@xml/method" />
19+
</service>
20+
21+
<provider
22+
android:name="android.support.v4.content.FileProvider"
23+
android:authorities="com.example.android.commitcontent.ime.inputcontent"
24+
android:exported="false"
25+
android:grantUriPermissions="true">
26+
<meta-data
27+
android:name="android.support.FILE_PROVIDER_PATHS"
28+
android:resource="@xml/file_paths" />
29+
</provider>
30+
31+
</application>
32+
33+
</manifest>

0 commit comments

Comments
 (0)