heihei blog

Write once, recall anytime. 自分のために書く 📝

Notes - Android Jetpack: what’s new in Android Support Library (Google I/O 2018)

f:id:shaunkawano:20180514095248p:plain

はじめに

Notes記事では、英語のセッション動画やポッドキャストの内容を(雑に)英語でメモに書き残すことを行っています。本記事は、あくまで動画を見ながら、参考程度に読んでいただくことを想定しています。Notes記事には雑メモ程度のものだったり、書き起こしのようなものもあります。これから実際の動画を見る際には、本記事の内容が少しでもお役に立てば幸いです。(内容において不備、誤字脱字等ありましたら気軽にご連絡いただけると嬉しいです!m(__)m)

本記事は、Android Jetpack: what’s new in Android Support Library (Google I/O 2018)のNotes記事です。

——

Packaging

Current Package Name

  • com.android.support
    • support-v4
    • support-v13
    • appcompat-v7
    • cardview-v7
    • gridlayout-v7
    • mediarouter-v7
    • palette-v7
    • preference-v7
    • preference-v14
    • recyclerview-v7

Packaging Versioning Releasing

  • Form of foundation to jetpack: Android Extension Libraries = AndroidX

Jetpack

  • Guidance
  • Recommended libraries and tools
  • Has a cute logo

AndroidX

  • Libraries itself
  • Technical guarantees
  • Does not have a cute logo

Finer-grained artifacts

  • Feature-based Maven groupId and artifactId
  • Scoped to individual widgets, use cases
  • Compatible with old artifacts
  • Binary compatible

Refined versioning

  • Reset from 28.0.0 to 1.0.0
  • Strict semantic versioning
    • Major - binary compatibility
    • Minor - feature release
    • Bug fix
  • Per-artifact versioning & release
  • Dependencies defined in POM

Updated packaging

  • Refactored to androidx java packages
    • 1androidx..ClassName`
  • Consistent Maven naming schemes
    • androidx.<feature>:<feature>-<sub-feature>
  • Removed -v7, -v4, etc. naming

Examples

Support Library 28.0.0-alpha1 => AndroidX 1.0.0-alpha1
com.android.support:multidex
=> androidx.multidex:multidex

com.android.databinding:adapters
=> androidx.databinding:databinding-adapters

android.arch.persistence.room:common
=> androidx.room:room-common

com.android.support:support-compat
=> androidx.core:core

com.android.support:cardview-v7
=> androidx.cardview:cardview

Migrating to AndroidX

  • Tooling for automatic source migration
    • Available in Android Studio 3.2 Canary 14+
    • Wait until Canary 15 to start using this
  • Jetifier tool for prebuilt JAR, AAR transformation
    • Available as standalone JAR or Gradle plugin
  • Use Automated refactoring(As of 05/12/18: Available now in Android Studio 3.2 Canary 14)

    • "Refactor to AndroidX…"
  • Support Library 28.0.x

    • Parity with AndroidX 1.0.x libraries
    • Same old android.support java package
    • Same old com.android.support Maven groupId
  • No feature releases after 28.0.0

What's New Features

RecyclerView Selection

  • Touch and mouse-driven
  • Preserves state between Activity lifecycle events
  • Finger-grained control
dependencies {
  implementation "androidx.recyclerview:recyclerview-selection:1.0.0-alpha1"
}
  • Band selection
  • Item selection area
  • Item rejection
  • State management
  • Much more

RecyclerView ListAdapter

  • Operates on immutable lists
  • Simplified way to use DiffUtil
  • Provides animated updates
  • Concurrency support
  • Efficiently animates changes
  • See also AsyncListDiffer

androidx.webkit

  • Provides access to latest WebView platform APIs(android.webkit.*)
  • Relies on updatable WebView APK
    • API 21+ devices only
dependencies {
  implementation "androidx.webkit:webkit:1.0.0-alpha1"
}

Browser library

  • android.support.customtabs -> androidx.browser
  • Custom tabs supported by major browsers
    • Chrome
    • Firefox
    • Samsung Internet
  • Browser actions
    • Allows apps to hook into browser context-click menu
    • Requires browser support: Chrome v66+

HeifWriter

  • Writing to HEIF files from:
    • YUV byte buffers
    • android.view.Surface
    • android.graphics.Btmap
  • API 28+ (backport coming)

Slices

Android's new approach for remote content

  • Templated
  • Interactive
  • Updatable

Backwards-compatible through API 19+(95% of devices)

Goal

  • One reusable API for presenting remote app content in Android
  • Templated and Interactive

Launching in Search

Enhance Suggestions with rich, live app content

  • App names
  • General terms

Reach hundreds of millions of users with Slices backwards-compatibility

dependencies {
  implementation "androidx:slice-builders:1.0.0-alpha1"
  implementation "androidx:slice-view:1.0.0-alpha1"
  implementation "androidx:slice-core:1.0.0-alpha1"
}

Slice Types

  • Shortcut slice
  • Small slice
  • Large slice

Material Components

  • Adding more customization for color, type, and shape
  • New components
  • Animations
  • Express your brand
dependencies {
  implementation "com.google.android.material:material:1.0.0-alpha1"
}

所感・まとめ・個人的に印象に残ったことなど

  • Automatic Source MigrationはCanary 15から
  • Jetifier名前良い..どういう仕組みとか知るためには紹介されていた動画を見る
  • What's new in Android Support Libraryが来年からWhat's new in AndroidXになる!
  • Androidアプリ開発を始めてから今まで、Androidのサポートライブラリ系のパッケージング周りよくわからなかったので、今回androidxに統一されて分かりやすくなるの最高そう!

以上です!