What's new in Android Wear 2.0

What's new in Android Wear 2.0

This deck is showing some of the new features introduced with the version 2.0 of Android Wear, including:
- new notifications design and user interactions
- standalone wearable applications
- new UI elements
- Complications API

D4be3ad792b57408b3ab6fe98caef08e?s=128

danybony

April 06, 2017
Tweet

Transcript

  1. What’s new in Android Wear 2.0 Daniele Bonaldo

  2. Daniele Bonaldo Android Developer

  3. Notifications

  4. Notifications Wear 1.x Wear 2.0 Large icon Content Text Content

    Title Small Icon http://developer.android.com/wear
  5. Collapsed Notifications Inline Action http://developer.android.com/wear

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

  7. Installation on Wear 1.x

  8. Installation on Wear 2.0

  9. Stand-alone apps <application> ... <meta-data android:name="com.google.android.wearable.standalone" android:value="true" /> ... </application>

  10. Stand-alone apps android { publishNonDefault true ... productFlavors { wear1

    { minSdkVersion 23 } wear2 { minSdkVersion 25 } } }
  11. Network connection on Wear 1.x

  12. Network connection on Wear 2.0

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

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

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

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

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

  18. WearableRecyclerView <android.support.v7.widget.RecyclerView
 android:id="@+id/recycler_view"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:scrollbars="vertical" />

  19. WearableRecyclerView <android.support.wearable.view.WearableRecyclerView
 android:id="@+id/recycler_view"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:scrollbars="vertical" />

  20. Linear scroll public class CircularChildLayoutManager extends CurvedChildLayoutManager {
 
 //

    ...
 
 @Override
 public void updateChild(View child, WearableRecyclerView parent) {
 super.updateChild(child, parent);
 
 child.setScaleX(...);
 child.setScaleY(...);
 }
 }
  21. Circular scroll recyclerView.setCircularScrollingGestureEnabled(true);
 recyclerView.setBezelWidth(0.5f);
 recyclerView.setScrollDegreesPerScreen(90);

  22. Navigation Drawer

  23. Action Drawer

  24. Multi-function Buttons

  25. 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);
 }
  26. 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)

  27. Rotatory input TIMER 01:00

  28. 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);
 } // ... }
  29. Complications IWC Portugieser Perpetual Calendar

  30. Android Wear and complications

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

    Complication data
  32. Different types https://developer.android.com/wear

  33. Watch face Data provider Android Wear

  34. AndroidManifest.xml <service android:name=".CustomComplicationProviderService"
 android:label="@string/complications_provider_label"
 android:icon=“@drawable/complications_provider_icon" android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
 
 <intent-filter>
 <action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST"/>


    </intent-filter>
 
 <meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES"
 android:value=“SHORT_TEXT, ICON"/>
 
 <meta-data android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
 android:value=“360"/> 
 </service>
  35. 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) { ... }
  36. 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);
 } }

  37. Watch face Data provider Android Wear

  38. Subdials IWC Portugieser Perpetual Calendar

  39. Windows Rolex Daydate

  40. Additional hands Rolex GMT Master

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

  42. 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
  43. Complication chooser

  44. 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:
  45. 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
 }
  46. ComplicationWatchFaceService.Engine @Override
 public void onDraw(Canvas canvas, Rect bounds) { ...

    if (complicationData.isActive(currentTimeMillis)) {
 // draw the complication
 } ...
 }
  47. 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);
 }
 }
 }
  48. Watch face Data provider Android Wear

  49. 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
  50. Daniele Bonaldo Thank You! Any questions?