Date post: | 17-Jan-2017 |
Category: |
Software |
Upload: | constantine-mars |
View: | 58 times |
Download: | 0 times |
Android Wear 2.0 New level of freedom for your action
Докладчик: Constantine MarsSenior Developer @ DataArt,Co-Organizer @ GDG Dnipro+ConstantineMars
David Singleton, VP Engineering at Google
So… What’s coming in Android Wear 2.0?
Problem No.1: Tethering
Freedom from tetheringmeans “freedom without phone”
Officially supported by:● LGE Watch Urbane
2nd Edition● Huawei Watch
Android Wear 2.0 Preview is available for
Upcoming: access Market directly from watch
What makes custom Watch Faces different but at the same time similar?
Complications- “any feature in a timepiece beyond the simple display of hours and
minutes” (Wikipedia)
● Short text● Long text● Range of values● Icon (small picture)● Image (big picture)
Complication types:
Complications coding
Each complication should have unique id
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};
// Left and right dial supported types.
public static final int[][] COMPLICATION_SUPPORTED_TYPES = {
{ComplicationData.TYPE_SHORT_TEXT},
{ComplicationData.TYPE_SHORT_TEXT}
};
ComplicationData type stores complication info (text, icon, type)
onComplicationDataUpdate() is initiated by Data Provider
private SparseArray<ComplicationData> mActiveComplicationDataSparseArray;
…
@Override
public void onComplicationDataUpdate(
int complicationId, ComplicationData complicationData) {
Log.d(TAG, "onComplicationDataUpdate() id: " + complicationId);
// Adds/updates active complication data in the array.
mActiveComplicationDataSparseArray.put(complicationId, complicationData);
invalidate();
}
Rendering complications
private void drawComplications(Canvas canvas, long currentTimeMillis) { // onDraw()
for (int i = 0; i < COMPLICATION_IDS.length; i++) {
ComplicationData complicationData = mActiveComplicationDataSparseArray.get(COMPLICATION_IDS[i]);
if ((complicationData != null) && (complicationData.isActive(currentTimeMillis))
&& (complicationData.getType() == ComplicationData.TYPE_SHORT_TEXT)) {
ComplicationText mainText = complicationData.getShortText();
canvas.drawText( mainText, 0, mainText.length(),
complicationsX, mComplicationsY, mComplicationPaint);
Data Providerswill stand behind the scenes as sources of data for
complications
One complication may use different providers as the data source
DataProviders coding
Extend ComplicationProviderServiceand declare it in AndroidManifest.xml
android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST
android:icon
android.support.wearable.complications.UPDATE_PERIOD_SECONDS
android.support.wearable.complications.PROVIDER_CONFIG_ACTION
<meta-data
android:name="android.support.wearable.complications.SUPPORTED_TYPES"
android:value="SHORT_TEXT"/>
ComplicationProviderServiceinternals
onComplicationActivated()
onComplicationUpdate()
onComplicationDeactivated()
Exposing data from providerin onComplicationUpdate()
@Override
public void onComplicationUpdate(int complicationId, int dataType, ComplicationManager complicationManager) {
int randomNumber = (int) Math.floor(Math.random() * 10);
String randomNumberText = String.format(Locale.getDefault(), "%d!", randomNumber);
switch (dataType) {
case ComplicationData.TYPE_SHORT_TEXT:
ComplicationData complicationData = new ComplicationData.Builder(ComplicationData.TYPE_SHORT_TEXT)
.setShortText(ComplicationText.plainText(randomNumberText))
.build();
break;
...
Exposing data from providerTrigger update with ComplicationManager.updateComplicationData()
@Override
public void onComplicationUpdate(int complicationId, int dataType, ComplicationManager complicationManager) {
...
if (complicationData != null) {
complicationManager.updateComplicationData(complicationId, complicationData);
}
What whas really distracting in AndroidWear 1.X notifications?
White light when you receive notification
Visual updates to notifications in 2.0Dark theme, Material Design for Android Wear
Large dark notificationEasier to read, but less-distracting in everyday life
Notifications and messages
Notification MessagingStyle
Allow smart replies, based on Google Assistant
NotificationCompat.Action action =
new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
getString(R.string.label), replyPendingIntent)
.addRemoteInput(remoteInput)
// 1) allow generated replies
.setAllowGeneratedReplies(true)
.build();
Use MessagingStyle for notification
Notification noti = new NotificationCompat.Builder()
.setContentTitle(messages.length + " new messages with " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_message)
.setLargeIcon(aBitmap)
// 2) set the style to MessagingStyle
.setStyle(new NotificationCompat.MessagingStyle(resources.getString(R.string.reply_name))
.addMessage(messages[0].getText(), messages[0].getTime(), messages[0].getSender())
.addMessage(messages[1].getText(), messages[1].getTime(), messages[1].getSender()))
Response to notifications in AndroidWear 1.X“Voice input”
More input methodsHandwriting, suggestions, keyboard
1.38-inch full circle P-OLED480 x 480348ppi
How full-size keyboard works on the small screen?
“Magic button” - center of navigation concepts
The most complicated UI pattern of AndroidWear 1.X?- “2D Picker”
The answer to this problem in AndroidWear 2- Recommended pattern is “1D Layouts”
App Layout examples
Material Design: Navigation and Action Drawers
WearableDrawerLayoutand it’s internals
<android.support.wearable.view.drawer.WearableDrawerLayout
...>
<FrameLayout
.../>
<android.support.wearable.view.drawer.WearableNavigationDrawer
.../>
<android.support.wearable.view.drawer.WearableActionDrawer
.../>
</android.support.wearable.view.drawer.WearableDrawerLayout>
Material Design: Navigation and Action Drawers
Material Design: Dark Theme
Android Wear Area at Google I/O
GoogleFit infrastructure
Well known GoogleFit APIs
GoogleFit: upcoming APIs
GoogleFit: upcoming features of existing APIs
GoogleFit - gym activity recognition
GoogleFit live demo on Google I/O
Activity recognition accuracy