Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Image Keyboardをいらすとやで作ってみた
Search
Naoto Nakazato
February 02, 2017
Technology
770
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Image Keyboardをいらすとやで作ってみた
Image Keyboardをいらすとやで作ってみた
http://qiita.com/oxsoft/items/4a10fafee7f31d0ccbdb
Naoto Nakazato
February 02, 2017
More Decks by Naoto Nakazato
See All by Naoto Nakazato
RxJavaを1年使って見えてきたこと
oxsoft
1
2.7k
Other Decks in Technology
See All in Technology
【Google Cloud Next Tokyo'26】Gemini Enterprise と Oracle AI Database で実現する、業務データ活用を実現する AI エージェント実装
shisyu_gaku
0
230
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
140
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.2k
事業価値と Engineering 2026年度版
recruitengineers
PRO
45
22k
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
350
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
20260608_Codexの可能性_ノンプログラマー向け_大城追記
doradora09
PRO
0
780
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
53k
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
130
PLATEAU で バーチャル花火大会
tatsuya1970
0
110
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
550
OSPN.JPバージョンアップ作業進捗のご報告 / 20260801-osc26kyoto
akkiesoft
0
420
Featured
See All Featured
Fireside Chat
paigeccino
42
4k
Become a Pro
speakerdeck
PRO
31
6.2k
KATA
mclloyd
PRO
35
15k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
64
56k
The Curious Case for Waylosing
cassininazir
1
450
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
630
Testing 201, or: Great Expectations
jmmastey
46
8.2k
We Are The Robots
honzajavorek
0
290
GraphQLとの向き合い方2022年版
quramy
50
15k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
280
Transcript
Image Keyboardを いらすとやで作ってみた @oxsoft
自己紹介 • Naoto Nakazato • Yahoo Japan Corporation • Yahoo!知恵袋
• アカウント ◦ Twitter: @oxsoft ◦ Facebook: naoto.nakazato ◦ GitHub: oxsoft ◦ Qiita: oxsoft ◦ 今回のQiita記事: http://qiita.com/oxsoft/items/4a10fafee7f31d0ccbdb
Image Keyboard Supportしてますか? • キーボードから画像が入力できるようになる機能 • Android 7.1の新機能として App Shortcutsとともに紹介されることが多い
• でも実はサポートライブラリを入れれば使える dependencies { // ... compile 'com.android.support:support-v13:25.1.0' }
Image Keyboard Support • 実はGboardはGIFアニメが入力できる • AlloはImage Keyboardに対応している • FB
Messengerも対応している? • これからスタンプ的な感じで流行りそう
いらすとやで作ってみる https://github.com/oxsoft/Irasutoya
キーボードServiceの作成 public class MainService extends InputMethodService { @Override public View
onCreateInputView() { View inputView = getLayoutInflater().inflate(R.layout.view_keyboard, null); // inputViewの設定 return inputView; } @Override public void onStartInputView(EditorInfo editorInfo, boolean restarting) { // 入力欄に応じた処理 } }
入力欄がサポートしているかチェック @Override public void onStartInputView(EditorInfo editorInfo, boolean restarting) { String[]
mimeTypes = EditorInfoCompat.getContentMimeTypes(editorInfo); boolean pngSupported = false; for (String mimeType : mimeTypes) { if (ClipDescription.compareMimeTypes(mimeType, "image/png")) { pngSupported = true; } } // サポートしていない場合はその旨を表示 unsupported.setVisibility(pngSupported ? View.GONE : View.VISIBLE); }
ContentProviderを用意(FileProviderを使う) <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.sample.content" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider> File file = getFileStreamPath("画像のファイル名"); Uri uri = FileProvider.getUriForFile(this, "com.sample.content", file); AndroidManifest.xml 保存した画像のURIを取得
画像のuriを入力欄に送信 private void commitPngImage(Uri contentUri, String imageDescription, Uri linkUri) {
InputContentInfoCompat inputContentInfo = new InputContentInfoCompat(contentUri, new ClipDescription(imageDescription, new String[]{"image/png"}), linkUri); InputConnection inputConnection = getCurrentInputConnection(); EditorInfo editorInfo = getCurrentInputEditorInfo(); int flags = 0; if (android.os.Build.VERSION.SDK_INT >= 25) { flags |= InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION; } InputConnectionCompat.commitContent(inputConnection, editorInfo, inputContentInfo, flags, null); }
まとめ • 意外と簡単に作れた • Uriをやりとりするだけなので、 入力側は既存の画像選択機能が利用できるかも • 今後、画像入力が増えることを期待