$30 off During Our Annual Pro Sale. View Details »

Waiting for slices

Waiting for slices

ymnder

May 22, 2018
Tweet

More Decks by ymnder

Other Decks in Programming

Transcript

  1. Waiting for slices
    CA.apk#6 @Shibuya 2018/05/22 @ymnd

    View Slide

  2. ࠓ೔ͷ͓඼ॻ͖
    ᶃ What are Slices

    ᶄ Where are Slices

    ᶅ How wonderful are Slices

    ᶆ How install Slices
    2

    View Slide

  3. ࠓ೔͓࿩͠ͳ͍͜ͱ
    • Slicesͷ಺෦࣮૷
    • SliceManager: handle interactions
    • SliceProvider: provide content(ContentProvider)
    • SliceAction: action
    • SliceView: view for displaying slice
    • TemplateSliceBuilder: base UI builder
    • ͲͷΑ͏ʹSlices͕ಈ͍͍ͯΔ͔

    View Slide

  4. ࠓ೔ͷ͓඼ॻ͖
    ᶃ What are Slices

    ᶄ Where are Slices

    ᶅ How wonderful are Slices

    ᶆ How install Slices
    4

    View Slide

  5. What are Slices?

    View Slide

  6. Slices are UI templates that can
    display rich, dynamic, and
    interactive content from your app
    from within the Google Search
    app and later in other places like
    the Google Assistant.

    View Slide

  7. ᶃWhat are Slices
    • remotableͰcontrolableͳૢ࡞Λఏڙ͢Δinline UI
    • ϦϞʔτίϯςϯπʹର͢Δ৽͍͠Ξϓϩʔν
    • ଞͷΞϓϦʹϛχΞϓϦΛࠩ͠ࠐΊΔΠϝʔδ

    View Slide

  8. ᶃWhat are Slices
    • templated
    • ๛෋ͳίϯϙʔωϯτΛ༻ҙ͍ͯ͠Δ
    • ࣗ෼Ͱॊೈʹ૊Έ্͛ΒΕΔ
    • interactive
    • ੩తͳσʔλ͚ͩͰͳ͍
    • ϦΞϧλΠϜͳσʔλΛऔಘՄೳ
    • actionɺtoggleɺsliderɺscroll
    • updatable
    • bundled with jetpack
    • surfaceɺtemplatesɺcontrols(ex. text input)ͷߋ৽༧ఆ

    View Slide

  9. ᶃWhat are Slices
    • Widgetͱ͸ҧ͏ͷʁ
    • RemoteViewͰ࣮૷͞Ε͍ͯͳ͍
    • SliceViewͱ͍͏࢓૊ΈΛ৽ͨʹ༻ҙ͍ͯ͠Δ
    • ϨΠΞ΢τ͸xmlͰͳ͘ίϯϙʔωϯτͰ૊Ή

    View Slide

  10. ࠓ೔ͷ͓඼ॻ͖
    ᶃ What are Slices

    ᶄ Where are Slices

    ᶅ How wonderful are Slices

    ᶆ How install Slices
    10

    View Slide

  11. ᶄWhere are Slices
    • Google Search App: Auto Complete
    • Google Assistant
    • and more…?

    View Slide

  12. ᶄWhere are Slices: Search App
    • App Name
    • ΞϓϦ໊ʹͻ͔͚ͬͯදࣔ͢Δ
    • permissionͱActivity΁ͷURIͷඥ෇͚͕ඞཁ

    View Slide

  13. ᶄWhere are Slices: Search App
    • General Terms
    • ؔ܎͢ΔΫΤϦʹ൓Ԡͤ͞Δ
    • deeplink / specific feature
    • FirebaseAppIndexingͰindexΛͭ͘Δ

    View Slide

  14. ࠓ೔ͷ͓඼ॻ͖
    ᶃ What are Slices

    ᶄ Where are Slices

    ᶅ How wonderful are Slices

    ᶆ How install Slices
    14

    View Slide

  15. ᶅHow wonderful are Slices
    • ϢʔβʔͷೳಈతͳߦಈʹϑοΫͰ͖Δ
    • ݕࡧ΍ΞγελϯτػೳͰ݁ՌΛಘΒΕͨͱ͖
    • ࣗ෼ͷΞϓϦͷ֎ͰίϯςϯπʹϦʔνͰ͖Δ
    • ΞϓϦͷίΞػೳΛϛχΞϓϦͱͯ͠ఏڙͰ͖Δ
    • ʢ࢖ΘΕ͍ͯΔؒ͸ΞϓϦ͸ফ͞Εͳ͍ʣ

    View Slide

  16. ᶅHow wonderful are Slices: template
    • templateΛ࢖ͬͯॊೈʹUIΛ૊Έ্͛ΒΕΔ

    View Slide

  17. ᶅHow wonderful are Slices: template

    fun createSliceWithHeader(sliceUri: Uri) =
    ListBuilder(context, sliceUri, ListBuilder.INFINITY)
    .setAccentColor(0xff0F9D) // Specify color for tinting icons
    .setHeader {
    it.apply {
    setTitle("Get a ride")
    setSubtitle("Ride in 4 min")
    setSummary("Work in 1 hour 45 min | Home in 12 min")
    }
    }.addRow {
    it.apply {
    setTitle("Home")
    setSubtitle("12 miles | 12 min | $9.00")
    addEndItem(
    IconCompat.createWithResource(context, R.drawable.ic_home), SliceHints.ICON_IMAGE
    )
    }
    }

    View Slide

  18. ࠓ೔ͷ͓඼ॻ͖
    ᶃ What are Slices

    ᶄ Where are Slices

    ᶅ How wonderful are Slices

    ᶆ How install Slices
    18

    View Slide

  19. ᶆHow install Slices
    • minSdk is 19+!!!!!
    • gradleʹ͸ҎԼΛهड़ʢα൛Ͱ͢ʣ
    dependencies {
    implementation 'androidx.slice:slice-core:1.0.0-alpha1'
    implementation 'androidx.slice:slice-builders:1.0.0-alpha1'
    implementation 'androidx.slice:slice-view:1.0.0-alpha1'
    }

    View Slide

  20. ᶆHow install Slices
    ᶃ manifestʹproviderΛఆٛ
    ᶄ SliceProviderΛ࣮૷ɿURIܗࣜͰ෼ذɺUIΛߏங
    ᶅ SliceͷUIΛߏஙɿBuilderؔ਺
    ᶆ BroadcasrReceiverͰΠϕϯτϋϯυϦϯά
    • PendingIntentΛ࢖͍ɺSlices͔ΒActionΛ௨஌͢Δ
    • ΞϓϦͰActionΛड͚औΓߋ৽͢Δ
    ᶇ ࣮ػςετ
    • ݱঢ়Ͱ͸SliceViewerͱ͍͏DebugAppΛ࢖͏

    View Slide

  21. ࣍ʹԿΛ͢Δ͔
    • Code labΛ΍Δ
    • Slicesͷ࣮૷աఔΛҰ௨Γֶ΂Δ
    • DocumentΛಡΉ
    • templateͷ૊ΈํͳͲ͕ॆ࣮͍ͯ͠Δ
    • App ActionsΛֶͿ
    • ActionsΛػೳڧԽ͢ΔͨΊͷ࢓૊Έͱͯ͠ͷSlices
    • ಺෦࣮૷ΛಡΉ
    • ͨʔʔʔͷ͠ʔʔʔʔɿϒϩάॻ͔ͳ͖Ό

    View Slide

  22. ࢀߟϦϯΫ
    • http://g.co/Slices
    • https://codelabs.developers.google.com/codelabs/android-
    slices-basic/index.html?index=..%2F..%2Findex#0
    • https://blog.novoda.com/android-p-slices-missing-
    documentation-part-1/
    • https://techblog.picappinc.jp/google-i-
    o%E3%81%A7%E3%83%86%E3%83%B3%E3%82%B7%E3%8
    3%A7%E3%83%B3%E4%B8%8A%E3%81%8C%E3%81%A3%
    E3%81%9Fslices%E3%81%AE%E8%A9%B1-4425de150b7b
    • http://konifar-zatsu.hatenadiary.jp/entry/2018/05/16/155727

    View Slide

  23. whoami
    • twitter:@ymnd, github:@ymnder
    • Application Engineer
    • Android ೔ܦిࢠ൛ΞϓϦ
    • Android ࢴ໘ϏϡʔΞʔΞϓϦ
    • ٕज़ϒϩά΍ͬͯ·͢ → https://hack.nikkei.com/blog/
    23

    View Slide

  24. Slices΍͍͖ͬͯ

    View Slide