ラップトップ上ブラウザから引いて見ると。

With 3D Globe Mode on Google Maps desktop, Greenland's projection is no longer the size of Africa.
Just zoom all the way out at https://t.co/mIZTya01K3 😎🌍 pic.twitter.com/CIkkS7It8d
— Google Maps (@googlemaps) 2018年8月2日
いつのまにw
ラップトップ上ブラウザから引いて見ると。

With 3D Globe Mode on Google Maps desktop, Greenland's projection is no longer the size of Africa.
Just zoom all the way out at https://t.co/mIZTya01K3 😎🌍 pic.twitter.com/CIkkS7It8d
— Google Maps (@googlemaps) 2018年8月2日
いつのまにw
Android KTX は、次期 androidx のパッケージとも深い関わりをもっているようです。
androidx: Hello World!
You may notice that Android KTX uses package names that begin with androidx. This is a new package name prefix that we will be using in future versions of Android Support Library. We hope the division between android.* and androidx.* makes it more obvious which APIs are bundled with the platform, and which are static libraries for app developers that work across different versions of Android.
Android Developers Blog: Introducing Android KTX: Even Sweeter Kotlin Development for Android
また、パッケージ名に関してのマッピングも公式からアナウンスされ始めています。

AndroidX refactoring | Android Developers
そんな Android KTX に関係するいくつかの動画がアップされています。
Android Jetpack: sweetening Kotlin development with Android KTX (Google I/O 2018) - YouTube
Google I/O 2018: Stage 2 - YouTube
前回は、よく分からんオネーチャンが喋ってましたが、 今回は、Jake Wharton さんが遂に表に登場しました。
彼のトークやスライドは開発に有効に利用できることばかりです。
Kotlin の Extension Function の勉強にもなりますので、登場したコードを書き出しておきます。
並び順は、
「よくあるコード」(before)
「Android KTX のコード(拡張関数)」(KTX)
「KTXを利用したコード」(after)
です。
// before
val userLayout: ViewGroup = findViewById(R.id.users)
for (index in 0 until userLayout.childCount) {
val view = userLayout.getChildAt(index)
// Do something with index and view...
}
// KTX
fun ViewGroup.forEachIndexed(action: (Int, View) -> Unit) {
for (index in 0 until childCount) {
action(index, getChildAt(index))
}
}
// after
val userLayout: ViewGroup = findViewById(R.id.users)
userLayout.forEachIndexed { index, view ->
// Do something with index and view...
}
// before
// In an Activity, on API 23+...
val notifications = getSystemService(NotificationManager::class.java)
// or all API levels...
val notifications = ContextCompat.getSystemService(this,
NotificationManager::class.java)
// KTX
inline fun <reified T> Context.systemService() =
ContextCompat.getSystemService(this, T::class.java)
// after
val notifications = systemService<NotificationManager>()
// before
avatarView.setPadding(
10, avatarView.paddingTop, 10, avatarView.paddingBottom)
// KTX
inline fun View.updatePadding(
left: Int = paddingLeft,
top: Int = paddingTop,
right: Int = paddingRight,
bottom: Int = paddingBottom
) {
setPaddinng(left, top, right, bottom)
}
// after
avatarView.updatePadding(left = 10, right = 10)
// before
val rect = avaterView.clipBounds
val left = rect.left
val top = rect.top
val right = rect.right
val bottom = rect.bottom
// Use left, top, right, bottom...
// KTX
inline operator fun Rect.component1() = left
inline operator fun Rect.component2() = top
inline operator fun Rect.component3() = right
inline operator fun Rect.component3() = bottom
// after
val (left, top, right, bottom) = avatarView.clipBounds
// Use left, top, right, bottom...
val (left, top, right) = avatarView.clipBounds
// Use left, top, right...
val (left, _, right) = avatarView.clipBounds
// Use left, right...
// before
val onlyDigits = true
for (c in phoneNumber) {
if (!c.isDigit()) {
onlyDigits = false
break
}
}
// before
val onlyDigits = phoneNumber.all { it.isDigit() }
// before
val onlyDigits = TextUtils.isDigitsOnly(phoneNumber)
// KTX
inline fun CharSequence.isDigitsOnly() = TextUtils.isDigitsOnly(this)
// after
val onlyDigits = phoneNumber.isDigitsOnly()
とりあえずは、前半のコードを書き出しておいて、次回へ
(つづく...)
便利そうなのでました!
Android Developers Blog: Announcing new SDK versioning in Google Play services and Firebase
com.google.android.gms:play-services-*
com.google.firebase:firebase-*
に関しては、それぞれが独立したバージョンで記述してよい。
なので、以下のような「バージョンをを揃える」記述は不要。
buildscript {
ext {
play_version = '15.0.0'
}
}
dependencies {
// DON'T DO THIS!!
// The following use of the above buildscript property is no longer valid.
implementation "com.google.android.gms:play-services-auth:${play_version}"
implementation "com.google.firebase:firebase-auth:${play_version}"
implementation "com.google.firebase:firebase-firestore:${play_version}"
}
利用方法は以下2パターン。
classpath 'com.google.gms:google-services:3.3.0'
// 最終行
apply plugin: 'com.google.gms.google-services'
かまたは、
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.0'
// 最終行
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'
とのこと。
エラー。
ビルドできず。
The library com.google.android.gms:play-services-measurement-base
is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]],
but resolves to 15.0.2. Disable the plugin and check your dependencies tree
using ./gradlew :app:dependencies.
記述にはない「play-services-measurement-base」が
内部的に呼ばれてこけている。
メッセージに書いてある
./gradlew :app:dependencies
は実行すらできない。
それぞれは、Andrid Studioの自動チェックで最新のはずなのだが。

目視でGoogleリポジトリを確認。


AndroidStudioの自動チェックで最新版の「15.0.0」だと思っていたが
実は、古いバージョンのままだった。
実際は「15.0.2」が最新。

これに書き換えたらいけた。
しかし、AndroidStudioの自動最新バージョンチェック機能らしきは、
機能してなくね?
かまたは、微妙に古くね?
「Preference」-「Editor」-「Inspections」 にある
「Lint」-「Newer Library Versions Available」

OFFになってるが。
Description
Newer Library Versions Available This detector checks with a central repository to see if there are newer versions available for the dependencies used by this project. This is similar to the GradleDependency check, which checks for newer versions available in the Android SDK tools and libraries, but this works with any MavenCentral dependency, and connects to the library every time, which makes it more flexible but also much slower.
「毎回チェックするのでとろい」ということで
デフォルトでOFFになっているのか。
毎回でなく適時、意図的に実行したい場合は、
「Analyze」-「Run Inspection by Name」からいきましょう。

グレーのハイライトと同時にツールチップで最新版である
「15.0.2」
をサジェストしてくれました!
Google Play Console にアップすると怒られて受け付けてくれません。
"New permissions added
WARNING
Users that have the APK with version code 19 may need to accept one or more of the android.permission.READ_PHONE_STATE and android.permission.WRITE_EXTERNAL_STORAGE permissions, which may result in them not upgrading to this version of the app."
android.permission.READ_PHONE_STATE てどんな許可内容だったか。
端末のステータスとIDの読み取り
端末の電話機能へのアクセスをアプリに許可します。これにより、電話番号、端末ID、通話中かどうか、通話相手の電話番号をアプリから特定できるようになります。
危険なパーミッションです。
「通話機能の必要ないアプリでも Play Service を利用していれば弾かれる」というような状況のようです。
android - Why has the READ_PHONE_STATE permission been added? - Stack Overflow
以下で回避できるようです。できました。
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:node="remove" />
なんなんでしょうね。
このような混乱はきっとこの先も増えていきそうです。
ーーー
2018-04-04: 追記
修正されているようです。
Release Notes | Google APIs for Android | Google Developers
ふと、こういう書き込みを見つけた。


国税庁 - 仮想通貨に関する所得の計算方法等について(情報)
雑所得扱いとなる申告が怖くて面倒くさいので利確できない
↓
BTC下がる
↓
利益がある限り利確できない
↓
BTC下がる
↓
利益がなくなる
そんなビットコインに対しての日本人の状況。

ビットコイン、取引シェア日本4割 個人の投機大半 :日本経済新聞
2017-12-22 18:36 現在まさしくその流れ。

日本人はほんとに養分となってしまうのか。
がんばれ日本! 負けるな日本!