whats new in android wear 2.0

107
Peter Friese Developer Advocate, Google What’s New in Android Wear 2.0

Upload: peter-friese

Post on 22-Jan-2018

473 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Whats new in Android Wear 2.0

Peter FrieseDeveloper Advocate, Google

What’s New in Android Wear 2.0

Page 2: Whats new in Android Wear 2.0
Page 3: Whats new in Android Wear 2.0

Android Wear 2.0 Developer Preview

Page 4: Whats new in Android Wear 2.0

Android Wear 2.01. Material Design for Apps

2. Standalone

3. Watch faces

4. Messaging

5. Fitness

Page 5: Whats new in Android Wear 2.0

New User Interface

Page 6: Whats new in Android Wear 2.0

design.google.com

Page 7: Whats new in Android Wear 2.0

Material Design for Wearablesgoogle.com/design/spec-wear

Components and app design patternsVertical layouts Darker colors

Page 8: Whats new in Android Wear 2.0

Vertical layouts

Page 9: Whats new in Android Wear 2.0

Vertical layoutMulti-directional layout

Page 10: Whats new in Android Wear 2.0
Page 11: Whats new in Android Wear 2.0

Darker colors

Page 12: Whats new in Android Wear 2.0

Purple 500

App primary color

Page 13: Whats new in Android Wear 2.0
Page 14: Whats new in Android Wear 2.0

Purple 500

App primary color

Page 15: Whats new in Android Wear 2.0
Page 16: Whats new in Android Wear 2.0
Page 17: Whats new in Android Wear 2.0

google.com/design/spec-wear

Page 18: Whats new in Android Wear 2.0

Components and app design patterns

Page 19: Whats new in Android Wear 2.0
Page 20: Whats new in Android Wear 2.0
Page 21: Whats new in Android Wear 2.0
Page 22: Whats new in Android Wear 2.0
Page 23: Whats new in Android Wear 2.0
Page 24: Whats new in Android Wear 2.0
Page 25: Whats new in Android Wear 2.0

A B C D

Page 26: Whats new in Android Wear 2.0
Page 27: Whats new in Android Wear 2.0
Page 28: Whats new in Android Wear 2.0
Page 29: Whats new in Android Wear 2.0

WearableDrawerLayout

Page 30: Whats new in Android Wear 2.0

<WearableDrawerLayout>

<FrameLayout

android:id=”@+id/content” />

<WearableNavigationDrawer

android:id=”@+id/top_drawer”

android:layout_width=”match_parent”

android:layout_height=”match_parent” />

<WearableActionDrawer

android:id=”@+id/bottom_drawer”

android:layout_width=”match_parent”

android:layout_height=”match_parent” />

</WearableDrawerLayout>

Defining the layout

Page 31: Whats new in Android Wear 2.0

Android Wear 2.0 Support Library

dependencies { ...

compile 'com.google.android.support:wearable:2.0.0-alpha3'}

build.gradle

Page 32: Whats new in Android Wear 2.0

google.com/design/spec-wearg.co/wearpreview

Page 33: Whats new in Android Wear 2.0

Don’t forgetWear apps are “real” appsAlways On Apps

Page 34: Whats new in Android Wear 2.0
Page 35: Whats new in Android Wear 2.0
Page 36: Whats new in Android Wear 2.0

Standalone Apps

Page 37: Whats new in Android Wear 2.0

Cloud and data

Cloud DistributeAuth Notify

Page 38: Whats new in Android Wear 2.0

Direct network access

HTTP REST

Page 39: Whats new in Android Wear 2.0

Direct network access

● Bluetooth to Phone

Bluetooth Proxy

● Wifi

● LTE/Cellular

Wifi,LTE/Cellular

Page 40: Whats new in Android Wear 2.0

Cloud and data

HTTP REST

DataItems

HTTP REST

Page 41: Whats new in Android Wear 2.0

Authentication

Auth DistributeCloud Notify

Page 42: Whats new in Android Wear 2.0

Standalone apps must manage auth Valid auth

DataItems

Valid auth

Page 43: Whats new in Android Wear 2.0

But time awaits no one...Don’t ask for auth if you don’t need it

Or postpone auth, store data locally

Else, focus user ease

Page 44: Whats new in Android Wear 2.0

Use a login activity

Input fields with android:inputType set to textPassword for password keyboard.

Page 45: Whats new in Android Wear 2.0

Google Sign-in and Smart Lock for Passwords offer seamless sign-in.

Google Sign-in

Smart Lock for

Passwords

Page 46: Whats new in Android Wear 2.0

Pass tokens via Data Layer

This is fast and easy for user, but does not work on iOS.

Valid auth

Valid auth

?

Page 47: Whats new in Android Wear 2.0

Coming soon: Pass the user to OAuth flow on phone

OAuth Service

Page 48: Whats new in Android Wear 2.0

Choosing auth methods

Fast and easy for user

Works with iOS Works without phone

Available

Google Sign-in Soon

SmartLock for Passwords Soon

Token over Data Layer Now

OAuth URL Soon

Activity on watch Now

Page 49: Whats new in Android Wear 2.0

Notifications and push

Auth DistributeCloud Notify

Page 50: Whats new in Android Wear 2.0

Cloud messages can go directly to Wear

FCM FCM

● GCM -> FCM

Page 51: Whats new in Android Wear 2.0

Use FCM to send cloud messages to watches

● Payloads can be user visible and/or data

● Works well with Doze

● Cross-platform

Page 52: Whats new in Android Wear 2.0

Android Notifications bridge from phone to watch

Page 53: Whats new in Android Wear 2.0

Disable bridging in AndroidManifest.xml

<manifest package="com.example.standalone"

xmlns:android="http://schemas.android.com/apk/res/android">

<application ...>

<meta-data

android:name="com.google.android.wearable.notificationBridgeMode"

android:value="NO_BRIDGING" />

...

Page 54: Whats new in Android Wear 2.0

Distribution and installation

Auth DistributeCloud Notify

Page 55: Whats new in Android Wear 2.0

No more bundled APKs! Phone APK

Embedded Wear APK

Phone APK

Wear APK

● Smaller phone apks

● Decoupled release process

● Per-architecture apks

Page 56: Whats new in Android Wear 2.0

Watch Feature in Android Manifest.xml

<manifest package="com.example.standalone"

xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature android:name="android.hardware.type.watch"/>

...

</manifest>

Page 57: Whats new in Android Wear 2.0
Page 58: Whats new in Android Wear 2.0
Page 59: Whats new in Android Wear 2.0
Page 60: Whats new in Android Wear 2.0
Page 61: Whats new in Android Wear 2.0

Turn off phone app bundling of wear apps

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

wearApp project(':wear')

compile 'com.google.android.gms:play-services:8.4.0'

}

Page 62: Whats new in Android Wear 2.0

Complications API

Page 63: Whats new in Android Wear 2.0

Introducing complicationsSub Title

Page 64: Whats new in Android Wear 2.0

What’s a complication?In Horology, the study of clocks and watches, a complication refers to any feature in a timepiece beyond the simple display of hours and minutes.Source: Wikipedia

Page 65: Whats new in Android Wear 2.0

Bits Legacy

Page 66: Whats new in Android Wear 2.0

Watch faceData provider

Complications API

Page 67: Whats new in Android Wear 2.0

Watch face

Page 68: Whats new in Android Wear 2.0

Data provider

Page 69: Whats new in Android Wear 2.0

Design Guidelines

Page 70: Whats new in Android Wear 2.0

Short text Icon Ranged value

Long text Large imageSmall image

Page 71: Whats new in Android Wear 2.0

Where to position complications

Page 72: Whats new in Android Wear 2.0

Containing form factors

Page 73: Whats new in Android Wear 2.0

Building a strong relationship with the watch face

Page 74: Whats new in Android Wear 2.0

Multiple complications

Page 75: Whats new in Android Wear 2.0

More opportunity to get creative

Page 76: Whats new in Android Wear 2.0
Page 77: Whats new in Android Wear 2.0

Using the API

Page 78: Whats new in Android Wear 2.0

Watch faceData provider

Page 79: Whats new in Android Wear 2.0

Watch face

Update request

Data provider

ComplicationData ComplicationData

Page 80: Whats new in Android Wear 2.0
Page 81: Whats new in Android Wear 2.0
Page 82: Whats new in Android Wear 2.0
Page 83: Whats new in Android Wear 2.0

watchface complicationid = 2

watchface complicationid = 1

Ranged ValueLong TextShort Text

Icon

Ranged ValueShort TextIcon

Page 84: Whats new in Android Wear 2.0
Page 85: Whats new in Android Wear 2.0

MyWatchFaceConfigActivity.java

Intent intent = ComplicationHelperActivity.createProviderChooserIntent(

getActivity(),

watchfaceComponentName,

watchFaceComplicationId,

new int[] {

ComplicationData.TYPE_RANGED_VALUE,

ComplicationData.TYPE_SHORT_TEXT,

ComplicationData.TYPE_ICON

});

startActivityForResult(intent, REQ_CODE);

Page 86: Whats new in Android Wear 2.0
Page 87: Whats new in Android Wear 2.0
Page 88: Whats new in Android Wear 2.0
Page 89: Whats new in Android Wear 2.0

MyWatchFaceService.Engine

@Override

public void onCreate(SurfaceHolder holder) {

...

setActiveComplications(watchFaceComplicationId1, watchFaceComplicationId2);

}

@Override

public void onComplicationDataUpdate(

int watchFaceComplicationId, ComplicationData data) {

// do something with the data

}

Page 90: Whats new in Android Wear 2.0

MyWatchFaceService.Engine

@Override

public void onDraw(Canvas canvas, Rect bounds) {

...

if (complicationData.isActive(currentTimeMillis) {

// draw the complication

}

...

}

@Override

public void onTapCommand(int tapType, int x, int y, long eventTime) {

// check if a complication was tapped

}

Page 91: Whats new in Android Wear 2.0

The watch face must have permission to show the provider chooser and to receive data.

But these cases don't require permission:Safe system providersProvider and watch face from same appProvider whitelists watch face as safe watch face

Permissions

Page 92: Whats new in Android Wear 2.0

AndroidManifest.xml

<uses-permission

android:name=

"com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>

Page 93: Whats new in Android Wear 2.0

Watch faceData provider

Page 94: Whats new in Android Wear 2.0

MyComplicationProviderService.java

@Override

public void onComplicationUpdate(

int complicationId, int type, ComplicationManager manager) {

if (type == ComplicationData.TYPE_SHORT_TEXT) {

ComplicationData data;

data = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)

.setShortText(ComplicationText.plainText("hello"))

.setIcon(Icon.createWithResource(

getPackageName(), R.drawable.icon))

.build();

manager.updateComplicationData(complicationId, data);

}

}

Page 95: Whats new in Android Wear 2.0

AndroidManifest.xml

<meta-data

android:name="android.support.wearable.complications.SUPPORTED_TYPES"

android:value="RANGED_VALUE,SHORT_TEXT,ICON"/>

<meta-data

android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"

android:value="300"/>

Page 96: Whats new in Android Wear 2.0

TimeDifferenceText

TimeFormatText

Page 97: Whats new in Android Wear 2.0

MyComplicationProviderService.java

data = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)

.setShortText(new ComplicationText.TimeDifferenceBuilder()

.setReferencePeriodStart(startTime)

.setReferencePeriodEnd(endTime)

.setStyle(ComplicationText.DIFFERENCE_STYLE_SHORT_DUAL_UNIT)

.build())

.setEndTime(endTime)

.build();

Page 98: Whats new in Android Wear 2.0
Page 99: Whats new in Android Wear 2.0
Page 100: Whats new in Android Wear 2.0
Page 101: Whats new in Android Wear 2.0
Page 102: Whats new in Android Wear 2.0

Watch faceData provider

Complications API

Page 103: Whats new in Android Wear 2.0

Introducing complicationsSub Title

Page 104: Whats new in Android Wear 2.0

Android Wear 2.01. System UI and Material Design

2. Standalone

3. Watch faces

4. Messaging

5. Fitness

Page 105: Whats new in Android Wear 2.0

g.co/wearpreview

Page 106: Whats new in Android Wear 2.0

g.co/wearpreview

Bugs, API suggestions?Android Wear Developer Preview Issue tracker

g.co/wearpreviewbug

DiscussionAndroid Wear G+ Community

g.co/androidweardev

Page 107: Whats new in Android Wear 2.0

Peter Friese@peterfriese

Thank You!