Slide 1

Slide 1 text

What’s new in Android Wear 2.0 Daniele Bonaldo

Slide 2

Slide 2 text

Daniele Bonaldo Android Developer

Slide 3

Slide 3 text

Notifications

Slide 4

Slide 4 text

Notifications Wear 1.x Wear 2.0 Large icon Content Text Content Title Small Icon http://developer.android.com/wear

Slide 5

Slide 5 text

Collapsed Notifications Inline Action http://developer.android.com/wear

Slide 6

Slide 6 text

Expanded Notifications Actions drawer http://developer.android.com/wear

Slide 7

Slide 7 text

Installation on Wear 1.x

Slide 8

Slide 8 text

Installation on Wear 2.0

Slide 9

Slide 9 text

Stand-alone apps ... ...

Slide 10

Slide 10 text

Stand-alone apps android { publishNonDefault true ... productFlavors { wear1 { minSdkVersion 23 } wear2 { minSdkVersion 25 } } }

Slide 11

Slide 11 text

Network connection on Wear 1.x

Slide 12

Slide 12 text

Network connection on Wear 2.0

Slide 13

Slide 13 text

Network availability http://developer.android.com/wear

Slide 14

Slide 14 text

Darker theme http://developer.android.com/wear

Slide 15

Slide 15 text

Consider different screen shapes http://developer.android.com/wear

Slide 16

Slide 16 text

Consider different screen shapes http://developer.android.com/wear

Slide 17

Slide 17 text

Display shape resource qualifiers http://developer.android.com/wear

Slide 18

Slide 18 text

WearableRecyclerView

Slide 19

Slide 19 text

WearableRecyclerView

Slide 20

Slide 20 text

Linear scroll public class CircularChildLayoutManager extends CurvedChildLayoutManager {
 
 // ...
 
 @Override
 public void updateChild(View child, WearableRecyclerView parent) {
 super.updateChild(child, parent);
 
 child.setScaleX(...);
 child.setScaleY(...);
 }
 }

Slide 21

Slide 21 text

Circular scroll recyclerView.setCircularScrollingGestureEnabled(true);
 recyclerView.setBezelWidth(0.5f);
 recyclerView.setScrollDegreesPerScreen(90);

Slide 22

Slide 22 text

Navigation Drawer

Slide 23

Slide 23 text

Action Drawer

Slide 24

Slide 24 text

Multi-function Buttons

Slide 25

Slide 25 text

Multi-function Buttons @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) { if (event.getRepeatCount() == 0) { if (keyCode == KeyEvent.KEYCODE_STEM_1) {
 // Do stuff return true;
 } } return super.onKeyDown(keyCode, event);
 }

Slide 26

Slide 26 text

Multi-function Buttons KeyEvent.KEYCODE_STEM_1 KeyEvent.KEYCODE_STEM_2 KeyEvent.KEYCODE_STEM_3 WearableButtons.getButtonCount(context) WearableButtons.getButtonInfo(context, keycode) WearableButtons.getButtonIcon(context, keycode)

Slide 27

Slide 27 text

Rotatory input TIMER 01:00

Slide 28

Slide 28 text

Rotatory input public class CustomView extends View { // ... @Override
 public boolean onGenericMotionEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_SCROLL && RotaryEncoder.isFromRotaryEncoder(event)) { float delta = -RotaryEncoder.getRotaryAxisValue(event) * RotaryEncoder.getScaledScrollFactor(getContext());
 // Update view depending on delta return true; } return super.onGenericMotionEvent(event);
 } // ... }

Slide 29

Slide 29 text

Complications IWC Portugieser Perpetual Calendar

Slide 30

Slide 30 text

Android Wear and complications

Slide 31

Slide 31 text

Watch face Data provider Android Wear Update request Complication data Complication data

Slide 32

Slide 32 text

Different types https://developer.android.com/wear

Slide 33

Slide 33 text

Watch face Data provider Android Wear

Slide 34

Slide 34 text

AndroidManifest.xml 
 
 
 
 
 
 
 
 


Slide 35

Slide 35 text

CustomComplicationProviderService @Override public void onComplicationActivated( int complicationId, int dataType, ComplicationManager manager) { ... }
 @Override
 public void onComplicationUpdate( int complicationId, int dataType, ComplicationManager manager) { ... }
 @Override
 public void onComplicationDeactivated( int complicationId) { ... }

Slide 36

Slide 36 text

CustomComplicationProviderService @Override public void onComplicationUpdate( int complicationId, int dataType, ComplicationManager manager) { if (dataType == ComplicationData.TYPE_SHORT_TEXT) {
 ComplicationData data = new ComplicationData.Builder(dataType)
 .setShortText(ComplicationText.plainText(“Hello!”))
 .setIcon(Icon.createWithResource( getPackageName(), R.drawable.action_item_background))
 .build(); 
 manager.updateComplicationData(complicationId, data);
 } }


Slide 37

Slide 37 text

Watch face Data provider Android Wear

Slide 38

Slide 38 text

Subdials IWC Portugieser Perpetual Calendar

Slide 39

Slide 39 text

Windows Rolex Daydate

Slide 40

Slide 40 text

Additional hands Rolex GMT Master

Slide 41

Slide 41 text

Placeholders https://www.google.com/design/spec-wear/patterns/complications.html

Slide 42

Slide 42 text

complication id = 1 Ranged value Short text Icon complication id = 3 Ranged value Long text Short text Icon complication id = 2 Ranged value Short text Icon

Slide 43

Slide 43 text

Complication chooser

Slide 44

Slide 44 text

WatchFaceConfigActivity Intent intent = ComplicationHelperActivity.createProviderChooserHelperIntent( context,
 watchFaceComponentName,
 complicationId,
 ComplicationData.TYPE_RANGED_VALUE,
 ComplicationData.TYPE_SHORT_TEXT,
 ComplicationData.TYPE_ICON
 );
 
 startActivityForResult(intent, REQUEST_CODE); com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA
 Requires permission:

Slide 45

Slide 45 text

ComplicationWatchFaceService.Engine @Override
 public void onCreate(SurfaceHolder holder) { ...
 setActiveComplications(LEFT_DIAL_COMPLICATION, RIGHT_DIAL_COMPLICATION); }
 
 @Override
 public void onComplicationDataUpdate(
 int complicationId, ComplicationData complicationData) {
 // store the data to display it
 }

Slide 46

Slide 46 text

ComplicationWatchFaceService.Engine @Override
 public void onDraw(Canvas canvas, Rect bounds) { ... if (complicationData.isActive(currentTimeMillis)) {
 // draw the complication
 } ...
 }

Slide 47

Slide 47 text

ComplicationWatchFaceService.Engine @Override
 public void onTapCommand(int tapType, int x, int y, long eventTime) {
 
 ...
 // get the complication data related to the tapped placeholder
 ... 
 if (complicationData.getTapAction() != null) {
 try {
 complicationData.getTapAction().send();
 } catch (PendingIntent.CanceledException e) {
 Log.d(TAG, "On complication tap action error " + e);
 }
 }
 }

Slide 48

Slide 48 text

Watch face Data provider Android Wear

Slide 49

Slide 49 text

More info Building Apps for Wearables https://developer.android.com/training/building-wearables.html Android Wear design specs https://www.google.com/design/spec-wear/android-wear/ introduction.html

Slide 50

Slide 50 text

Daniele Bonaldo Thank You! Any questions?