Notes from Google I/O 15

Overview
The notes here are mostly focused on Android, as it is written by an Android developer. The biggest improvements for Android are in terms of quality and performance tooling, and the M preview announcement.

As usual with conferences where there are many sessions/talk happening concurrently, one cannot attend all sessions/talks onsite. So, some of the sections below related to talks are empty, indicating a wishlist of talks to watch later. Feel free to augment.

Onsite experience
The Sandbox talks were only up to 20 minutes long, to allow 10 minutes time to get to the next session, or should I say wait in line. The space was in a somewhat open setting but still enclosed by some wooden structures which let people look through. The allocated spaces for theses were way too small, and overcrowding was a problem at most interesting sessions. Most Sandbox talks will be (re-)recorded, even though it was not apparent. I didn't see any camera at the Sandbox talks, but later learned they will be re-recorded as DevBytes (shorter and no Q&A). It does seem like a long time until all the sessions will be published under "100 days of Google Dev". I only went to a couple of bigger sessions since the most interesting ones were live streamed and available for everybody to watch from home. Even there overcrowding was an issue. One had to stand in line for quite a while. A 2.5 minute highlight reel of on-site experience.

Main videos
At https://events.google.com/io2015/videos you can filter for Android and switch between Sessions and DevBytes.
 * Keynote
 * What's new in Android
 * What’s New in Android Development Tools (to add)

What's new in Android

 * Samples now on Github: https://github.com/googlesamples
 * GCM Network Manager allows to specify criteria when to perform network-oriented tasks (OneOffTask, PeriodicTask), part of Google Play Services :(, uses JobScheduler internally for L+ devices
 * Data Binding -> session: Data driven Android UI development
 * Android Design Support Library -> Sandbox talk: Bringing Material Design to Life on Android
 * CoordinatorLayout, Snackbar, TabLayout, NavigationView, ..., FAB (FloatingActionButton),
 * RecyclerView: Swipe to dismiss, drag&drop
 * WebView: PostMessage, ..., WebSettings.setOffscreenPreRaster
 * Notifications: Icon (was a bit unclear)
 * Systrace for ART: get runtime stats
 * Adoptable Storage Devices: User can "adopt" insertable SD card as permanent storage; no new APIs; avoid hard-coded paths in code
 * Next: "Developing for Android" series: medium.com/google-developers

Android M Preview
No official name for M yet. Preview is available for a few Nexus devices only (Nexus 5, 6, 9, Player). There will be 3+ previews this time to incorporate feedback, roughly once near the end of each month. Some of my favorites:
 * App permissions
 * Individual and delayed Permission requests (instead of asking the user for all permissions at install time, the app asks when a new permission is needed, can be revoked later); M+ devices only, older devices revert to old behavior to ask the user at install time; permission categories have changed


 * "Now on Tap"
 * Long-press home button to get a single Google Now suggestion at the bottom of screen (so, not full screen anymore) based on what's on your screen right now.


 * "Doze" mode
 * low-power mode while the device rests


 * USB Type C connector support

Links:
 * Android M Developer Preview Site: http://developer.android.com/preview/overview.html
 * Android M Preview Flashable Images: http://developer.android.com/preview/download.html

Talks about Android App Testing
I'm excited about the quality tool improvements announced at this IO. Overview of talks:
 * Android Studio:
 * (session) What's New in Android Development Tools
 * Unit Testing on Android
 * Android Testing Library:
 * Android Testing Support Library
 * Espresso: UI Testing for Android
 * Cloud Test Lab:
 * Mobile App Quality Leaps to the Cloud
 * Google Play Testing:
 * Smarter Approaches to App Testing

Unit testing on Android
For now you need to switch source sets when developing tests in Build variant chooser between instrumentation tests and unit tests. (It's a Gradle plugin limitation). No need to switch when running tests since you can run the from a AS run config or from command line.

Android Testing Support Library: The next generation of Android Testing APIs
AndroidJUnitRunner (aka InstrumentationTestRunner2) ""
 * finally, JUnit4 and lots of annotations for instrumentation tests :)
 * e.g:,  ,  ,  ,  ,   (in addition to the regular JUnit4  ,  ,  )
 * does not inherit from a base class: but you can use,  ,  ,.
 * for functional testing:
 * 
 * Next:
 * Samples: android-testing on GitHub: https://github.com/googlesamples/android-testing
 * Docs: https://developer.android.com/tools/testing-support-library
 * Codelabs: "Unit and UI Testing in Android Studio"

Espresso: UI Testing for Android
What would a user do? 1. Find a View 2. Perform an action 3. Check some state

onView(Matcher) .perform(ViewAction) .check(ViewAssertion);
 * Basic:

Espresso provides lots of Matchers, ViewActions, ViewAssertions, see Espresso cheat sheet.


 * Going Deeper:
 * API for s
 * Advanced Synchronization with

onData(ObjectMatcher) .DataOptions .perform(ViewAction) .check(ViewAssertion);

intenting(IntentMatcher) .respondWith(ActivityResult);
 * Espresso-Intents: like Mockito but for Intents

"Work with WebView using WebDriver Atoms" onWebView .withElement(Atom) .perform(Atom) .check(WebAssertion);
 * Espresso-Web: [yay for us heavy WebView users]


 * Espresso Contrib: stuff that doesn't fit into other buckets, and/or is user contributed (GitHub!)
 * DrawerLayout, RecyclerView, AccessibilityChecks, ...

Same codelab as above: "Unit and UI Testing in Android Studio"

Mobile app quality leaps to the cloud
(caught last part only)

Probably the same as below but instead of using Dev Console this is using Android Studio

Smarter approaches to app testing
Cloud Test Lab in Dev Console: upload apk to alpha/beta channel, then let test run on the top 20 devices Monkey Runner-like test is free, custom tests cost money

Talks about Android Performance
I saw a bunch of very entertaining session by Colt McAnlis. He's also got several "Android Performance Patterns" videos on [goo.gl/4ZJkY1 Youtube] and. Overview of how to use the tools: https://docs.google.com/document/d/1EKVq2FzcLVJFbwUtaC3QRddSwtzs0BSKZahkQyeGyHo/pub?embedded=true#h.zayu98yotlht

Network Performance & Tooling (Colt McAnlis)

 * Network Traffic Tool
 * JobScheduler, SyncAdapters


 * Videos about payload size:
 * CompressorHead
 * GZip is NOT enough (1 hr.)
 * Flatbuffers (5 min.)
 * Posts about payload size:
 * Image Compression for web developers (vary JPEG quality level)
 * Text Compression for web developers

Memory Performance & Tooling (Colt McAnlis)

 * Allocation Tracker, TraceView
 * When loading Bitmap make it scale down instantly
 * use a lib like Glide, Picasso
 * ArrayMap uses less memory than HashMap if few items
 * Video: DevBytes: The Magic of LRU Cache

Rendering Performance & Tooling (Colt McAnlis)
(to watch)

Battery Performance & Tooling (Colt McAnlis)
(to watch)

Android Developer Tools: Deep dive into Performance & Build Tools
(to watch)

Project Volta: Android battery life
(to watch)

Android application architecture
(to watch) This session was offered twice but so full that I couldn't make it. Will watch online.

Building Apps Faster with Android Data Binding
Windows devs had this for years. Finally coming to Android. Bind your data in a layout XML file with the regular layout. Code is generated/optimized at compile time. No reflection/runtime used.

Making apps context aware: Opportunities, tools, lessons and the future
(to watch)

Building location aware apps using the Android Location and Places APIs
With the Places API you can translate easily between lat, lon to place names and types and vv. (Example: Am I at a gym or in a forest?)

Adaptive UI with Material Design
(to watch)

Android Design Support Library: Bringing material design to life
There have been many 3rd party libs for Material Design. Now there's an official one.
 * CoordinatorLayout: coordinates behavior of layout components for nicer animation flows,
 * avoid hiding important elements (example: add a FAB to a CoordinatorLayout, ref. the CoordinatorLayout in a Snackbar, then FAB can move away when Snackbar appears)
 * CoordinatorLayout + app bar:

Other highlights were already listed above. Here are the details:
 * Design library blog post: http://android-developers.blogspot.com/2015/05/android-design-support-library.html
 * Android Support Library: http://developer.android.com/tools/support-library
 * DevBytes: https://www.youtube.com/watch?v=32i7ot0y78U&index=1&list=PLOU2XLYxmsIJDPXCTt5TLDu67271PruEk

Unleashing the power of Android Backup
(to watch)

Anyone can do it! Easy ways to evaluate your App’s Accessibility
(to watch)

Read more

 * "Developing for Android" series

Action Items
(Compiled while I was watching https://plus.google.com/u/1/events/cn2mln1obrhkuhsfin8sobmi0m4?e=-RedirectToSandbox)

Soon
I also found a Backup Test app on the emulator. I used that to backup and restore the Wikipedia app but it failed to successfully restore the backup. Someone needs to look into that more. External Storage: User can "adopt" a micro-SD card to act as internal storage (users could move the app there); no new APIs; avoid hard-coded paths in code There are no real devices to test this with yet; so for Preview testing on emulators these are the magic commands we should use (could use more info here): adb root && sleep 2 adb shell setprop persist.fw.force_adoptable 1 adb reboot
 * Try out app on M preview SDK and M preview (virtual or real) device: https://developer.android.com/preview/setup-sdk.html
 * Check out https://developer.android.com/preview/api-overview.html
 * Test:
 * Android Backup: test on M (app data is backed up automatically starting with M, need to look into excluding files if we need to)
 * Adoptable Storage Devices https://developer.android.com/preview/behavior-changes.html#behavior-adoptable-storage


 * Android Design Support Library (quick wins):
 * Change NavDrawerFragment to NavigationView ✅
 * Change croutons and several toasts to Snackbar ✅
 * Change EditText to TextInputLayout (wraps EditText; hint text floats above when focused or not empty; errors appear below) ✅


 * Consider using new Support annotations: TODO: compile a list that makes sense. A presenter said that some annotations are not necessary for the app dev to add since the base classes in the system libraries already have them. I believe he was referring to @WorkerThread and @RequiresPermission.

Merge around the time when M is released
(or keep a WIP patch around for a couple of months ;; requires targetSdkLevel 23)
 * Add code to request permissions at runtime, see also:
 * IO session "Permissions in M: Best practices for developers"
 * https://developer.android.com/preview/features/runtime-permissions.html

Upcoming support library
[Ok, I didn't actually see this at Google IO onsite, and this exists since Lollipop, but since I ran across this while watching some DevBytes, I wanted to add some notes about that.] VectorDrawables allow icon resources to be packaged as XML (subset of SVG) instead of multiple PNGs. You can't used SVGs directly, but there are tools which let you import SVG files. BTW, there is also an animated variant (like and animated GIF, ehm, SVG). Unfortunately, VectorDrawables are currently only supported on devices running Lollipop or newer. There are already a few libraries trying to fix this and there seems to be a VectorDrawableCompat in the works. :) Let's check that out when it is available. This could make our apk leaner. We could just change our convert-icons script to use one of those tools instead. http://stackoverflow.com/questions/26548354/vectordrawable-is-it-available-somehow-to-pre-lollipop-versions-of-android https://github.com/android/platform_frameworks_support/blob/master/v7/vectordrawable/src/android/support/v7/graphics/drawable/VectorDrawableCompat.java How would it would deal with RTL you ask? There is a flag we could set in the VectorDrawable XML: android:autoMirrored. :D You can also set a android:tint in the root node of VectorDrawable XML to easily customize the SVG for our color palette / theme.
 * VectorDrawables

Maybe later

 * Consider RecyclerViews instead of ListViews: if we want swipe to dismiss or drag & drop; initially for new functionality, no need to change if ListView is working for us
 * Consider CoordinatorLayout ✅ for FAB
 * DirectShare: implement ... ChooserService
 * Consider Voice Interactions
 * More control over word break in TextView
 * new Icon class promises to reduce memory use (Icon.createWithBitmap)
 * App linking: consider adding statements.json to web site and auto-verify flag to AndroidManifest.xml
 * http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE prevents screen to be accessible for screenshots and to Now on Tap Assistant, but user could also disable Now on Tap Assistant

...