Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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.8k
Other Decks in Technology
See All in Technology
Screen Lens - 今見てる画面を翻訳する
komagata
0
260
Deploying a Full-Stack Bun-Native Framework on Cloudflare Workers
7nohe
0
150
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
1
1.5k
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
170
あるけみー式LTスライド作成術
alchemy1115
1
200
AIで仕事のやり方を変える
matsu7874
3
1.1k
GoCon2026 - Open Source, Open World
sanposhiho
4
3.4k
「図書館」という名前のままでいいのか -Code4Lib JAPANカンファレンス2026 アンカンファレンス報告- / Code4Lib JAPAN Conference 2026: Unconference Report
ykiyota
0
170
ASTを使って影響範囲を特定する
nealle
0
170
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
160
Where Is JetBrains AI Heading- — Central CLI, Air Alpha, and the Agentic Development Stack
x5gtrn
PRO
0
160
Claude Code本って、 読む必要あるの?
oikon48
2
420
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
141
7.7k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
Side Projects
sachag
456
43k
Designing for Timeless Needs
cassininazir
1
470
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
270
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
520
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
Mobile First: as difficult as doing things right
swwweet
225
10k
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をやりとりするだけなので、 入力側は既存の画像選択機能が利用できるかも • 今後、画像入力が増えることを期待