Skip to content

Commit

Permalink
Adds CommitContentSampleIME sample to repo.
Browse files Browse the repository at this point in the history
Change-Id: Ie4fe0cddf0b2980fd4c940a5b0116cb0d64c170a
  • Loading branch information
Jeremy Walker committed Jul 30, 2019
1 parent 079c274 commit 05f09a2
Show file tree
Hide file tree
Showing 33 changed files with 867 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CommitContentSampleIME/.google/packaging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# GOOGLE SAMPLE PACKAGING DATA
#
# This file is used by Google as part of our samples packaging process.
# End users may safely ignore this file. It has no relevance to other systems.
---
status: PUBLISHED
technologies: [Android]
categories: [System]
languages: [Java]
solutions: [Mobile]
github: android/input
level: INTERMEDIATE
icon: screenshots/icon-web.png
apiRefs:
- android:android.widget.EditText
- android:import android.support.v13.view.inputmethod.EditorInfoCompat
- android:import android.support.v13.view.inputmethod.InputConnectionCompat
- android:import android.support.v13.view.inputmethod.InputContentInfoCompat
license: apache2
59 changes: 59 additions & 0 deletions CommitContentSampleIME/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

Android CommitContentSampleIME Sample
===================================

This sample demonstrates how to write an keyboard which sends rich content (such as images) to text
fields using the Commit Content API.

Introduction
------------

Users often want to communicate with emojis, stickers, and other kinds of rich content. In previous
versions of Android, soft keyboards (input method editors or IMEs) could send only unicode emoji to
apps. For rich content (such as images), apps had to either build app-specific APIs that couldn't
be used in other apps or use workarounds like sending images through the Easy Share Action or the
clipboard.

Now in Android 7.1 (API 25), the Android SDK includes the [Commit Content API][1], which provides a
universal way for IMEs to send images and other rich content directly to a text editor in an app.
The API is also available in the v13 Support Library (ver. 25.0), supporting devices as early as
Android 3.2 (API 13).

With this API, you can build messaging apps that accept rich content from any keyboard, as well as
keyboards that can send rich content to any app.

**Note:** This sample does not have a default Activity. After installing it, you will need to enable
this app as a keyboard by navigating to *Settings > Languages & Input > Virtual Keyboard > Manage
Keyboards*. This keyboard can then be accessed by pressing the virtual keyboard icon in the
lower-right hand corner of the display while in a text field.

[1]: https://android-dot-devsite.googleplex.com/preview/image-keyboard.html

Pre-requisites
--------------

- Android SDK 28
- Android Build Tools v28.0.3
- Android Support Repository

Screenshots
-------------

<img src="screenshots/screenshot-1.png" height="400" alt="Screenshot"/>

Getting Started
---------------

This sample uses the Gradle build system. To build this project, use the
"gradlew build" command or use "Import Project" in Android Studio.

Support
-------

- Stack Overflow: http://stackoverflow.com/questions/tagged/android

If you've found an error in this sample, please file an issue:
https://github.com/android/input

Patches are encouraged, and may be submitted by forking this project and
submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
29 changes: 29 additions & 0 deletions CommitContentSampleIME/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.android.commitcontent.ime"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support:support-v13:28.0.0'
testCompile 'junit:junit:4.12'
}
17 changes: 17 additions & 0 deletions CommitContentSampleIME/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/google/home/yukawa/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
33 changes: 33 additions & 0 deletions CommitContentSampleIME/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.commitcontent.ime">

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<service
android:name="com.example.android.commitcontent.ime.ImageKeyboard"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method" />
</service>

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.android.commitcontent.ime.inputcontent"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>

</application>

</manifest>

1 comment on commit 05f09a2

@jen801
Copy link

@jen801 jen801 commented on 05f09a2 Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#33 **

Please sign in to comment.