3. Android Wear
• Android SDK
• Specific wear APIs in external libraries (support:wearable,
play-services-wearable)
• All devices are compa>ble with API 23 (minSdkVersion 23)
• Only a few devices are compa>ble with API > 23 ("Android Wear
2.0")
4. Crea%ng a wear app
h"ps://developer.android.com/training/building-wearables.html
5. Crea%ng a wear app
• Ac$vity
• AndroidManifest.xml
• LayoutInflater
• You know the stuff...
6. Crea%ng a watch face
h"ps://developer.android.com/training/wearables/watch-faces/index.html
7. Crea%ng a watch face
1. Create a class that extends
CanvasWatchFaceService.Engine
2. Create a Service that extends CanvasWatchFaceService and
override onCreateEngine
Prefer OpenGL ES instead of the Canvas API ?
Use Gles2WatchFaceService instead
67. #9: Experiment in an
Android (not wear) custom
View
<com.nilhcem.experiments.ui.widget.WearFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.nilhcem.experiments.ui.ExperimentalView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.nilhcem.experiments.ui.widget.WearFrameLayout>
68. #10: Use ValueAnimator
for onDraw anima7ons
private ValueAnimator animator;
private final Handler handler = new Handler();
public void onTapCommand(int tapType, int x, int y, long e) {
if (tapType == TAP_TYPE_TAP) {
animator = ValueAnimator.ofInt(0, Math.round(MAX_RADIUS));
animator.setDuration(600L);
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.start();
invalidate();
}
}
public void onDraw(Canvas canvas, Rect bounds) {
if (animator != null && animator.isRunning()) {
int value = (Integer) animator.getAnimatedValue();
canvas.drawCircle(centerX, centerY, value, paint);
// Invalidate at a 30fps ratio
handler.postDelayed(() -> invalidate()), 1000L / 30);
}
}
72. #13: Vector Drawables
• M (x,y): Absolute move to (x,y)
• m (x,y): Rela5ve move to (x,y)
• L or l (x,y): Line to (x,y)
• C or c (x1,y1,x2,y2): Curve from (x1,y1) to (x2,y2)
• Q or q (x1,y1,x,y): Quadra5c curve to (x,y) using (x1,y1) as the control point
• Z or z: Close path
h#ps://www.w3.org/TR/SVG/paths.html
74. #14: Port your app to
Tizen
• HTML5 Canvas api
• Low-Bit Ambient mode
• Burn-in support
• onTimeTick() becomes
window.addEventListener("time
tick", drawWatchContent);
76. From a hoodie to a watch face
nilhcem.com/android-wear/watchfaces-
design
• Android Wear 1 + 2 support
• Square / Circular shapes
• Chin support
• Textures + Xfer modes