android wear 2.0 - great changes upcoming this fall - gdg devfest ukraine 2016

64
Android Wear 2.0 Great Changes Upcoming this Fall Constantine Mars Organizer @ GDG Dnipro Senior Developer @ DataArt

Upload: constantine-mars

Post on 15-Apr-2017

163 views

Category:

Software


0 download

TRANSCRIPT

Android Wear 2.0Great Changes Upcoming this Fall

Constantine MarsOrganizer @ GDG DniproSenior Developer @ DataArt

David Singleton, VP of Engineering at Google

What you can do with the new generation watches?

And why? :)

HardwareKey platform features and supported watches

#dfua

Goodbye tethering!

BLE

WiFi

Cellular

#dfua

Great chances to get direct access to Play

#dfua

Officially supported watches

LG Watch Urbane 2nd Edition Huawei Watch

#dfua

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)

ComplicationsPersonal expression and utility

#dfua

Personal expression and utility

Modern by LG Ranger by Zuhanden GoogleFit Today

#dfua

Or simply an personal expression :)

HeyKittyKitty by WatchMaster

#dfua

Complications

“any feature in a timepiece beyond the simple display

of hours and minutes” (Wikipedia)

#dfua

Complication types

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

Complications coding

#dfua

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

#dfua

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

#dfua

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

#dfua

.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

#dfua

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

#dfua

Actual drawing is trivial

canvas.drawText(

complicationMessage,

0,

complicationMessage.length(),

complicationsX,

mComplicationsY,

mComplicationPaint);

Complications rendering

Data Providers

#dfua

Android Wear role in data exchange

#dfua

Data Providers

Data Providers coding

#dfua

<service android:name=".RandomNumberProviderService"

android:label="@string/complications_provider_random_number"

android:icon="@drawable/ic_watch_white">

Data Provider Service attributesExtend ComplicationProviderService

#dfua

<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

#dfua

Update period

<meta-data

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

android:value="120"/>

Data Provider declaration

#dfua

@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

#dfua

@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

#dfua

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

#dfua

@Override

public void onComplicationUpdate( int complicationId, int dataType,

ComplicationManager complicationManager) {

if (complicationData != null) {

complicationManager.updateComplicationData(

complicationId,

complicationData);

}

Exposing data to complications

Notifications updated

#dfua

Notifications in Android Wear 1.X

#dfua

Android Wear 2.0 NotificationsMaterial Design for Wearables, Dark Theme

#dfua

Android Wear 2.0 Notifications

#dfua

Notifications preview

#dfua

Notifications messaging style

Notifications coding

#dfua

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

#dfua

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

New Input Methods

#dfua

New input methods

#dfua

Voice input, Emoji

#dfua

Keyboard, Handwriting

#dfua

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

Material Design for Wearables

#dfua

1D Layout

Do Don’t

#dfua

UI Anatomy

#dfua

Navigation Drawer

#dfua

Action Drawer

#dfua

Dark Theme

#dfua

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%

#dfua

Interaction types

Quick look at Google Fit

#dfua

Wearables area at Google I/O

#dfua

Google Fit infrastructure

#dfua

Existing Google Fit APIs

Sensors API Recording API History API

#dfua

Upcoming APIs

Beat to Beat API Goals API Profile API

#dfua

Real Time Gym Activity Recognition

#dfua

Real Time Gym Activity Recognition

Live demo from Google I/O

#dfua

Recognized exercises

QA?

Thank you!

Constantine Mars

@ConstantineMars+ConstantineMars