Android12 が来たので新機能を使ってみました。

Android12
Android12

👉 Android 12の新機能・変更点まとめ 
👉 「Android 12」のリリース時期、新機能は?--これまでの情報まとめ - CNET Japan 

画面一部だけ拡大(虫眼鏡)

android12 画面の拡大
👉 【Android12】画面の一部だけを拡大する方法 

クイック設定パネル

オン・オフの状況など見た目がわかりやすくなりました。
android12 クイック設定パネル

“おおよそ“の位置情報に対応

Android12 位置設定

スクショのマークアップツールの進化

android12 スクショツール

ごみ箱管理機能

Android12 ゴミ箱管理機能

クイックタップ

スマホの背面をダブルタップすることでスクショなど動作を設定することができます。
Android12 クイックタップ

デジタルアシスタントアプリの設定

Android12 デジタルアシスタント

全画面スクリーンショット

設定画面で撮ってみました。
縦方向に全画面で撮れてます。
全画面スクリーンショット

Android12 capture screenshot



電池持ちも大きく向上

Android12 バッテリー

片手モード

android12 片手モード
Android12 片手モード

画面自動回転が顔検出に対応。

横になってる時の回転防止。
ansroid12 画面の自動回転 顔検出
👉 設定「画面の自動回転」は OFF で良い。 

イースターエッグ

Android12 Easter Egg




👉 Nonograms (お絵かきロジック/ ピクロス) - Android 10 Easter Egg パズルゲーム 

マイクとカメラの盗撮・盗聴を防止 *
大きなメディアプレイヤー
Wi-Fiパスワードをニアバイシェアで共有
ピクチャ・イン・ピクチャの改善
新しい会話ウィジェットの追加
ホーム画面に新しいグリッドが追加
布団の中でも画面が眩しくない「明るさを下げる」新機能

(更新中...)

👉 【Android12】画面の一部だけを拡大する方法 | #android ファショ通 
👉 java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. | #android ファショ通 


【Kotlin】Flow flatMap* を ネストするか チェインするか【coroutine】

kotlin coroutin flow のオペレータをネストするかチェインするかの話です。

👉 Kotlin flow: Nesting vs Chaining • Vasya Drobushkov 

Flow 間のデータ受け渡し


observeUser()
  .flatMap { user ->
    api.load(user.id)
      .flatMapLatest { data -> api.send(user.id, data) }
  }
  .collect()


observeUser()
  .flatMap { user ->
    api.load(user.id)
  }
  .flatMap { data -> api.send(user.id, data) } // ! user is not accessible
  .collect()

An important observation is that nesting unlike chaining creates scope. And one of the simplest things one can do with the scope is to share some data inside it.

重要なことは、チェインとは異なり、ネストによってスコープが作成されることです。そして、スコープで実行できる最も簡単なことの1つは、スコープ内のデータを共有することです。

キャンセルの伝達


observeUser()
  .flatMapLatest { user ->
    api.load(user.id)
      .flatMapLatest { observeLocation() }
  }
  .collect()


observeUser()
  .flatMapLatest { user ->
    api.load(user.id)
  }
  .flatMapLatest { observeLocation() }
  .collect()

Here we again used nesting, while we don’t need to pass any data to the observeLocation stream. Additionally, instead of flatMap we’ve used flatMapLatest (in RxJava it is called switchMap) - if the new value will be sent by upstream the downstream will be canceled and a new one created. This ensures that if the user was changed (e.g. account switched) we’ll trigger the server once again to determine whether we need to observe location.

observeLocation ストリームには何のデータも渡す必要はありません。RxJavaではswitchMapと呼ばれる flatMapLatest を使用しています。新しい値がアップストリームで送信されると、ダウンストリームはキャンセルされ、新しい値が作成されます。これにより、ユーザーが変更された場合(例えば、アカウントが変更された場合)、位置情報をobserveする必要があるかどうかを判断するために、もう一度サーバーを起動することができます。

because in the case with nesting we’ve defined the scope that has lifecycle attached to the observeUser stream: when the user is changed - everything inside flatMapLatest will be canceled. And in the case of chaining, we have observeLocation outside of user scope - so when the user changed, the location stream is not canceled.

ネスティングの場合は、observUserストリームにライフサイクルが付随するスコープを定義しているため、ユーザーが変更されると、flatMapLatest内のすべてがキャンセルされます。また、チェイニングの場合は、ユーザースコープの外側にobserveLocationを設定していますので、ユーザーが変更されてもlocationストリームはキャンセルされません。

まとめ

flatMapLatest を使う場合は、入れ子のほうが意図に沿いやすいように思えるが、コード自体の見通しは悪い。

頭のどこかに「ネストかチェインか」は置いておくべきでしょう。

👉 【MVVM】 Kotlin Flow で使える5つの利用パターン | #android ファショ通 


MAD SCORECARD プラグインで自分の環境を書き出して公開してみれ

GitHub で公開されているリポジトリを眺めていると!!!

AndroidStudio4-1-1
👉 skydoves/Pokedex: 🗡️ Android Pokedex using Hilt, Motion, Coroutines, Flow, Jetpack (Room, ViewModel) based on MVVM architecture. 

Android Studio 4.1.1

だと!!!

同様に、自分の環境でも、MAD SCORECARD プラグインを入れて書き出してみると、

AndroidStudio-2020-3-1

AndroidStudio 2020-3-1

3.1

あれ、安定版最新のはずなのに古い?

Canary で同様に書き出す。

1.1

あれ、なんなんすかね? これは。

 

Android Studio のバージョン番号体系の更新

記述方法が変わっていた模様です。

Android Studio のバージョン番号体系の更新

 

まとめ

2021-09-14 現在の Android Studio 最新バージョンは以下。

Arctic Fox (安定版)
→ 2020.3.1 Patch 2

Bumblebee (開発版)
→ 2021.1.1 Canary 11

さあ、みんなも MAD SCORECARD を書き出してシェアしたり公開してみよう!!

MAD SCORECARD plugin

MAD のスコアは? 👉 Android デベロッパー  |  Android Developers