71
Android Wear 2.0 Next Level of Freedom for Your Action Constantine Mars Organizer @ GDG Dnipro Senior Developer @ DataArt

Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Embed Size (px)

Citation preview

Page 1: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Android Wear 2.0Next Level of Freedom for Your Action

Constantine MarsOrganizer @ GDG DniproSenior Developer @ DataArt

Page 2: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

A long time ago…

Page 3: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

A long time ago… in the Lviv, not so far away :)

Page 4: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

A long time ago… in the Lviv, not so far away :)We’ve been talking about...

Page 5: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Freedom of tethering

BLE

WiFi

Cellular

Page 6: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

And chances to get direct access to Play Store

Page 7: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

And today...

Page 8: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016
Page 9: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Developer Preview 3Play Store and MoreAvailable since September 28

Page 10: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Play Store features

● multiple accounts, ● support of alpha and

beta testing● update or uninstall

apps in “My apps” view● install only the watch

app● phone apps are no

longer necessary

Page 11: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

You can now build and publish watch-only apps for users to discover on Google Play

Page 12: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

android {

publishNonDefault true // Allows you to reference product flavors in your phone's build.gradle

defaultConfig

{ minSdkVersion 23 } // This is the minSdkVersion of the Wear 1.0 embedded app

productFlavors {

wear1 { /* Use the defaultConfig value */ }

wear2 { minSdkVersion 24 }

}

}

Flavors for supporting both 2.0 and 1.x

Page 13: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

dependencies {

...

wearApp project(path: ':wear', configuration: 'wear1Release')

}

Package only when build variant requires it

Page 14: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

If no need in 1.x - simply publish MultiAPK

Page 15: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

HardwareKey platform features and supported watches

Page 16: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Officially supported watches

LG Watch Urbane 2nd Edition Huawei Watch

Page 17: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Officially supported watches

LG Watch Urbane 2nd Edition Huawei Watch

Display: 1.4 inches, 400 x 400 pixels (~286 ppi)

CPU:Quad-core 1.2 GHz Cortex-A7

GPU: Adreno 305, Chipset: Qualcomm Snapdragon 400

Memory: 4 GB, 512 MB RAM

Comm: Wi-Fi 802.11 b/g, Bluetooth v4.1 LE

Network: No cellular connectivity

Battery: 300 mAh (48h)

Display: 1.38 inches, 480 x 480 pixels (~348 ppi)

CPU: Quad-core 1.2 GHz Cortex-A7

GPU: Adreno 305, Chipset: Qualcomm Snapdragon 400

Memory: 4 GB, 768 MB RAM

Comm: Wi-Fi 802.11 b/g, Bluetooth v4.1 LE, GPS, NFC

Network: GSM, HSPA, LTE

Battery: 570 mAh (60h)

Page 18: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

ComplicationsPersonal expression and utility

Page 19: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Personal expression and utility

Modern by LG Ranger by Zuhanden GoogleFit Today

Page 20: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Or simply an personal expression :)

HeyKittyKitty by WatchMaster

Page 21: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Complications

“any feature in a timepiece beyond the simple display

of hours and minutes” (Wikipedia)

Page 22: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Complication types

-Short text-Long text-Range of values-Icon (small picture)-Image (big picture)

Page 23: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Complications coding

Page 24: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

New in Preview 3

com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA

Request permission to access Complication Data

Page 25: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Runtime permissions. Wearable version:)

Now required for accessing Complication Providers from WatchFace apps

Page 26: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Each position need to be identified

private static final int LEFT_DIAL_COMPLICATION = 0;

private static final int RIGHT_DIAL_COMPLICATION = 1;

public static final int[] COMPLICATION_IDS = {LEFT_DIAL_COMPLICATION,

RIGHT_DIAL_COMPLICATION};

Complication ID

Page 27: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Each position must be mapped with array of supported types

// Left and right dial supported types.

public static final int[][] COMPLICATION_SUPPORTED_TYPES = {

{ComplicationData.TYPE_SHORT_TEXT},

{ComplicationData.TYPE_SHORT_TEXT}

};

Complication supported types

Page 28: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Data Providers and system trigger .onComplicationDataUpdate() sometimes

/* Called when there is updated data for a complication id. */

@Override

public void onComplicationDataUpdate(

int complicationId, ComplicationData complicationData) {

Log.d(TAG, "onComplicationDataUpdate() id: " + complicationId);

mActiveComplicationDataSparseArray.put(complicationId, complicationData);

invalidate();

}

ComplicationData receiving

Page 29: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

.onDraw() is the moment of drawing. ComplicationData where stored earlier

@Override

public void onDraw(Canvas canvas, Rect bounds) {

ComplicationData complicationData;

for (int i = 0; i < COMPLICATION_IDS.length; i++) {

complicationData = mActiveComplicationDataSparseArray

.get(COMPLICATION_IDS[i]);

// ...

Complications rendering

Page 30: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Complication may be deactivated or contain wrong data type

if ((complicationData != null)

&& (complicationData.isActive(currentTimeMillis))

&& (complicationData.getType() ==

ComplicationData.TYPE_SHORT_TEXT)) {

ComplicationText mainText = complicationData.getShortText();

CharSequence complicationMessage =

mainText.getText(getApplicationContext(),

currentTimeMillis);

Complications rendering

Page 31: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Actual drawing is trivial

canvas.drawText(

complicationMessage,

0,

complicationMessage.length(),

complicationsX,

mComplicationsY,

mComplicationPaint);

Complications rendering

Page 32: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Data Providers

Page 33: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Android Wear role in data exchange

Page 34: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Data Providers

Page 35: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Data Providers coding

Page 36: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

<service android:name=".RandomNumberProviderService"

android:label="@string/complications_provider_random_number"

android:icon="@drawable/ic_watch_white">

Data Provider Service attributesExtend ComplicationProviderService

Page 37: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

<intent-filter>

<action

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

TE_REQUEST"/>

</intent-filter>

<meta-data

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

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

Data Provider declaration

Page 38: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Update period

<meta-data

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

android:value="120"/>

Data Provider declaration

Page 39: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

@Override

public void onComplicationActivated( int complicationId, int dataType,

ComplicationManager complicationManager) { … }

@Override

public void onComplicationUpdate( int complicationId, int dataType,

ComplicationManager complicationManager) { … }

@Override

public void onComplicationDeactivated(int complicationId) { … }

Data Provider methods

Page 40: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

@Override

public void onComplicationUpdate(int complicationId, int dataType,

ComplicationManager complicationManager) {

// Retrieve or generate your data

int randomNumber = (int) Math.floor(Math.random() * 10);

String randomNumberText =

String.format(Locale.getDefault(), "%d!", randomNumber);

Exposing data to complicationsCalled according to update period time

Page 41: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

ComplicationData complicationData = null;

switch (dataType) {

case ComplicationData.TYPE_SHORT_TEXT:

complicationData = new ComplicationData.Builder(

ComplicationData.TYPE_SHORT_TEXT)

.setShortText(ComplicationText.plainText(randomNumberText))

.build();

break;

Exposing data to complications

Page 42: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

@Override

public void onComplicationUpdate( int complicationId, int dataType,

ComplicationManager complicationManager) {

if (complicationData != null) {

complicationManager.updateComplicationData(

complicationId,

complicationData);

}

Exposing data to complications

Page 43: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

WatchFaceService.Engine.setDefaultComplicationProvider()

Default Providers

Page 44: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Notifications updated

Page 45: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Notifications in Android Wear 1.X

Page 46: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Android Wear 2.0 NotificationsMaterial Design for Wearables, Dark Theme

Page 47: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Notifications preview

Page 48: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Notifications messaging style

Page 49: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Notifications coding

Page 50: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Notification noti = new NotificationCompat.Builder()

.setContentTitle(messages.length + " new messages with " + sender)

.setContentText("subject")

.setSmallIcon(R.drawable.new_message)

// 2) set the style to MessagingStyle

.setStyle(new NotificationCompat.MessagingStyle(

getResources().getString(R.string.reply_name))

.addMessage(messages[0])

.addMessage(messages[1]);

Notifications with modern MessagingStyle

set MessagingStyle

Page 51: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

NotificationCompat.Action action =

new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,

getString(R.string.label), replyPendingIntent)

.addRemoteInput(remoteInput)

.setAllowGeneratedReplies(true)

.build();

Notifications with SmartReply

Allow SmartReply

Starting with Preview 3 SmartReply uses standalone machine, located on watch

Page 52: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

NotificationCompat.Action action =

new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,

getString(R.string.label), replyPendingIntent)

.addRemoteInput(remoteInput)

.extend(new NotificationCompat.Action.WearableExtender()

.setHintDisplayActionInline(true))

.build();

Inline Action, available directly from stream

Set inline action

Page 53: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

(Not new) Input Methods

Page 54: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

New input methods

Page 55: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Voice input, Emoji

Page 56: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Keyboard, Handwriting

Page 57: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Wait, a Keyboard???LG Watch Urbane 2nd Edition

Display: 1.38 inches, 480 x 480 pixels (~348 ppi)

CPU: Quad-core 1.2 GHz Cortex-A7

GPU: Adreno 305, Chipset: Qualcomm Snapdragon 400

Memory: 4 GB, 768 MB RAM

Comm: Wi-Fi 802.11 b/g, Bluetooth v4.1, LE, GPS, NFC

Network: GSM, HSPA, LTE

Battery: 570 mAh (60h)

Size x2 bigger than first phones

Page 58: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Material Design for Wearables

Page 59: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

1D Layout

Do Don’t

Page 60: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

UI Anatomy

Page 61: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Navigation Drawer

Page 62: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Action Drawer

Page 63: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Dark Theme

Page 64: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Brightness values

1 App color - Default color

2 Dark background - 15%

3 Lighter background - 30%

4 UI element - 40%

5 Lighter UI element - 65%

6 Accent - 100%

Page 65: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Applications list

Page 66: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

WearableRecyclerViewSince Preview 3 - .setCircularScrollingGestureEnabled(true) available

Page 67: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Some new Google Fit features for Android Wear

Page 68: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Upcoming APIs

Beat to Beat API Goals API Profile API

Page 69: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Real Time Gym Activity Recognition

Page 70: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

#gdgceesummit

Recognized exercises

Page 71: Android Wear 2.0 - New Level of Freedom for Your Action - GDG CEE Leads Summit 2016

Q&A?

Thank you!

Constantine Mars

@ConstantineMars+ConstantineMars