Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Autofill Framework
uzzu
December 17, 2020
Technology
0
26
Autofill Framework
第2回Android知見共有会 @cookpad
uzzu
December 17, 2020
Tweet
Share
More Decks by uzzu
See All by uzzu
StoreKitのこれまでとこれから / StoreKit 2 from 1
uzzu
2
5.1k
アプリ内課金の最新事情 クライアントサイド編 / In-app Purchase in Cookpad 2019
uzzu
3
3.6k
Billing Client 2.0 acknowledgement
uzzu
0
13k
Promoting IAP対応から学ぶ外部アプリ内課金実装 / Promoting IAP and others
uzzu
2
620
ブログ作り直した / My blog @ Othlo Tech
uzzu
0
69
新規アプリ開発を支えるユーザ・決済基盤
uzzu
2
1.9k
kotlin-mpp-library-tips
uzzu
1
5.7k
Coroutine Kyuin
uzzu
2
200
Introduce Gradle Kotlin DSL (Kotlin lovers edition)
uzzu
0
270
Other Decks in Technology
See All in Technology
How to start with DDD when you have a Monolith
javujavichi
0
310
Data in Google I/O - IO Extended GDG Seoul
kennethanceyer
0
150
サーバレスECにおける Step Functions の使い方 〜ステートマシン全部見せます!〜
miu_crescent
0
190
JUnit5.7, 5.8の新機能紹介 #jjug_ccc #jjug_ccc_b / junit 5.7, 5.8 new features
kyonmm
PRO
2
420
ラブグラフ紹介資料 〜プロダクト解体新書〜 / Lovegraph Product Deck
lovegraph
0
250
開発組織の生産性を可視化する State of DevOpsとFour Keysとは / deep dive into State of DevOps
yfcgpsebp
0
220
サイボウズの アジャイル・クオリティ / Agile Quality at Cybozu
cybozuinsideout
PRO
4
2.3k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
3
9.1k
The application of formal methods in Kafka reliability engineering
line_developers
PRO
1
180
20220622_FinJAWS_あのときにAWSがあったらこうできた
taketakekaho
0
110
miisan's career talk
mii3king
0
220
セキュリティ 開運研修2022 / security 2022
cybozuinsideout
PRO
3
3.8k
Featured
See All Featured
Practical Orchestrator
shlominoach
178
8.6k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_i
23
15k
The Invisible Customer
myddelton
110
11k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
What's new in Ruby 2.0
geeforr
336
30k
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
196
9.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
224
49k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
12
920
Web development in the modern age
philhawksworth
197
9.3k
YesSQL, Process and Tooling at Scale
rocio
157
12k
Building Applications with DynamoDB
mza
83
4.7k
VelocityConf: Rendering Performance Case Studies
addyosmani
316
22k
Transcript
Autofill framework uzzu @ user-payment dept
Agenda ɾAutofill frameworkͬͯԿ ɾಋೖํ๏ ɾͲΜͳײ͡Ͱಈ͔͢ͷ ɾ·ͱΊ
Autofill framework ɾΞϓϦͰҎԼͷೖྗใΛࣗಈೖྗ͢Δࣄ͕Ͱ͖ΔΈ ɹΞΧϯτೝূใɺΫϨδοτΧʔυใɺॅॴɺਓ໊ɺి൪߸ɺ ɹϫϯλΠϜύεϫʔυ ɾAutofill ServiceʹରԠͨ͠ύεϫʔυϚωʔδϟʔͱ࿈ܞͯ͠ೖྗใΛอଘ͢Δࣄ ɹͰ͖Δ (ࠓճলུ) ɹ৽͍͠ύεϫʔυΛύεϫʔυϚωʔδϟͰੜ্ͨ͠Ͱࣗಈೖྗ͢ΔͳͲ
ɾWeb͚ʹDigital Asset LinksΛ༻ҙ͢Δ͜ͱͰWebͷಉαʔϏεͷೝূใΛ ɹΞϓϦͰར༻Ͱ͖Δ ɾminSdkVersion >= 26 (※)
None
͍ํ(1) - ઃఆ • ઃఆ>γεςϜ>ݴޠͱೖྗ>ৄࡉઃఆ>ೖྗΞγελϯ τ>ࣗಈೖྗαʔϏε ͔ΒࣗಈೖྗαʔϏεΛ༗ޮʹ͢ Δ ↑ΤϛϡϨʔλͰಈ࡞֬ೝ͢Δ߹ཁ֬ೝ •
্ͰGoogleΞΧϯτͰϩάΠϯ͓ͯ͘͠ͷΕ ͳ͍
͍ํ(2) - Autofill༗ޮແޮͷ֬ೝ fun Context.isAutofillAvailable(): Boolean { if (Build.VERSION.SDK_INT <
Build.VERSION_CODES.O) { return false } val manager = getSystemService(AutofillManager::class.java) return manager != null && manager.isEnabled }
͍ํ(3) - ࣗಈೖྗͷͨΊͷHintͷઃఆ • ࢦఆจࣈྻ View.AUTOFILL_HINT_* ͳఆ͕ٛ͋ΔͷͰͦͪΒΛࢀߟʹ • ෳ༩͑ΔࣄͰ͖Δ •
ࣗલͷViewʹHintsΛઃఆ͢Δ߹ View#setAutofillHints(vararg String) • ٯʹɺೖྗิͨ͘͠ͳ͍߹ android:importantForAutofill=“no” “auto”, “no”, “yes”, “noExcludedDescendants”, “yesExcludeDescendants” <EditText android:id="@+id/password_field" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword" android:autofillHints="password" />
͍ํ(4) - ࣗಈೖྗͨ͠༰ͷऔಘ • EditText#getText() ͳͲɺݩͷViewͷ࣮ʹ߹ΘͤͯऔಘɺͰجຊతʹOK • View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE ͷ߹ɺೖྗ༰ͷᐆດ ͞ʹҙ
(06/2022, 6/2022, June 2022, …) ->EditTextͳΓΛܧঝͯ͠AutofillValueΛ༻͍ΔࣄͰᐆດ͞Λճආ͢Δ
override fun getAutofillType(): Int { return AUTOFILL_TYPE_DATE } override fun
getAutofillValue(): AutofillValue { val calendar = Calendar.getInstance() calendar.clear() val (year, month) = sanitize(text?.toString()) calendar.set(Calendar.YEAR, year) calendar.set(Calendar.MONTH, month) val unixTime: Long = calendar.timeInMillis return AutofillValue.forDate(unixTime) } override fun autofill(value: AutofillValue) { if (!value.isDate) { return } val calendar = Calendar.getInstance() calendar.timeInMillis = value.dateValue setText(DateFormat.format("MM/yy", calendar)) }
͍ํ(5) - ͋ͱAdvanced ɾࣗಈೖྗΛ࣮ࢪ͠ͳ͍߹AutofillManager#cancel ɾActivity1ͭʹର͠ෳͷFragmentͰը໘ભҠ͠ͳ͕Βೖ ྗ͢Δ߹ɺ࠷ޙʹ AutoFillManager#commit ͢Δ
طͷ(1) - DialogͰͷར༻ • API Level 27ҎલͰDialogͷϏϡʔΛදࣔޙʹαΠ ζมߋΛ͢ΔͱࣗಈೖྗͷରͱΈͳ͞Εͳ͘ͳΔ
طͷ(1) - ճආࡦ • window token ΛৼΓ͢ class Dialog(context: Context)
: Dialog(context) { private var token: IBinder? = null override fun onWindowAttributesChanged(params: WindowManager.LayoutParams) { if (params.token == null && token != null) { params.token = token } super.onWindowAttributesChanged(params) } override fun onAttachedToWindow() { if (context.isDialogResizedWorkAroundRequired() /* API 26ͩͬͨΒ */) { token = requireNotNull(ownerActivity).window.attributes.token } super.onAttachedToWindow() } }
طͷ(2) - RecyclerViewͰͷར༻ • RecyclerViewͰͷར༻࣌ʹҙਤͤ͵ೖྗϑΟʔϧυʹ ࣗಈೖྗ͞Εͯ͠·͏ (View͕࠶ར༻͞ΕΔࣄ͕͋Δͷ͔ͩΒͳΜͱͳ͘ ؾ͔࣋ͪΔ…)
طͷ(2) - ղܾࡦ (minSdkVersion >= 28) • AutofillManager͕IdΛ࠾൪͍ͯ͠ΔͷͰɺ֤ΞΠςϜʹIdΛ࠾൪͢Δ data class
Item( val text: String, // Viewදࣔͷҝͷͳʹ͔ // : val autofillId: Int // Autofill framework༻ͷId ΛՃ ) // RecyclerViewʹՃ͢Δཁૉʹ1ͭͣͭ࠾൪ val autofillId = autofillManager.nextAutofillId • ͦͷޙonBindViewHolderͰViewHolder্Ͱ͍࣋ͬͯΔTextViewʹ View#setAutofillId(autofillId) ͢Δ
·ͱΊ • ϑΟʔϧυʹೖྗ͢Δ࣌ؒΛݮͨ͠ΓɺೖྗϛεΛ࠷খݶʹ͑Δࣄ͕Ͱ͖Δ • Autofill ServiceʹରԠͨ͠ύεϫʔυϚωʔδϟʔͱ࿈ܞͯ͠ೖྗใΛอଘͰ͖Δ • ΣϒαΠτͱͷؔ࿈͚Ͱ AndroidΞϓϦͰͷϩάΠϯ࣌ʹ WebͰͷϩάΠϯใΛࣗಈೖྗͰ͖Δ
• minSdkVersion >=26 Ͱ͋Δ͕ɺطͷʹखؒগͳ͘ରॲ͢ΔͳΒ minSdkVersion >= 28 • androidx.autofill Ͱ͏গ͠Ճػೳ͕͑Δ (ιϑτΣΞΩʔϘʔυɺOTPपΓͷαϙʔτ͕खް͍)͕ ݱࡏ1.1.0-rc01 minSdkVersion >= 30