diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/html/design/wear/watchfaces.jd | 39 | ||||
| -rw-r--r-- | docs/html/training/articles/security-tips.jd | 12 | ||||
| -rw-r--r-- | docs/html/training/wearables/data-layer/messages.jd | 22 | ||||
| -rw-r--r-- | docs/html/training/wearables/watch-faces/configuration.jd | 19 | ||||
| -rw-r--r-- | docs/html/training/wearables/watch-faces/drawing.jd | 51 | ||||
| -rw-r--r-- | docs/html/training/wearables/watch-faces/service.jd | 33 |
6 files changed, 92 insertions, 84 deletions
diff --git a/docs/html/design/wear/watchfaces.jd b/docs/html/design/wear/watchfaces.jd index 99dc3dd..2a00802 100644 --- a/docs/html/design/wear/watchfaces.jd +++ b/docs/html/design/wear/watchfaces.jd @@ -101,7 +101,7 @@ format.</p> <!-- H2: plan for all display modes --> <div style="float:right;margin-top:35px;margin-left:20px"> <img src="{@docRoot}design/media/wear/Render_Interactive.png" - width="200" height="195" alt="" style="margin-right:5px"/><br/> + width="200" height="195" alt="" style="margin-right:5px;margin-top:20px"/><br/> <img src="{@docRoot}design/media/wear/Render_Ambient.png" width="200" height="195" alt="" style="margin-right:5px"/> </div> @@ -118,11 +118,12 @@ mode. Your design can use full color with fluid animation in this mode.</p> <h3>Ambient mode</h3> <p>Ambient mode helps the device conserve power. Your design should make clear to the user that -the screen is in ambient mode by using only grayscale colors. Do not use a lot of white in ambient -mode, since this distracting and hurts battery life on some screens. In this mode, the screen -is only updated once every minute. Only show hours and minutes in ambient mode; do not show -seconds. Your watch face is notified when the device switches to ambient mode, and you should -thoughtfully design for it.</p> +the screen is in ambient mode. The background color scheme is <em>strictly limited</em> to black, +white, and grays. Your watch face may use some color elements on screens that support it +provided it is unambiguous that the device is in ambient mode. You can use color elements for up +to 5 percent of total pixels. In this mode, the screen is only updated once every minute. Only +show hours and minutes in ambient mode; do not show seconds. Your watch face is notified when +the device switches to ambient mode, and you should thoughtfully design for it.</p> @@ -131,23 +132,29 @@ thoughtfully design for it.</p> <p>Android Wear devices feature a variety of screen technologies, each with their own advantages and considerations. One important consideration when designing the ambient mode display for your -watch face is how it affects battery life and screen burn-in on some screens.</p> - -<p>You can configure your watch face to display different ambient designs depending on the kind +watch face is how it affects battery life and screen burn-in on some screens. +You can configure your watch face to display different ambient designs depending on the kind of screen available on the device. Consider the best design for your watch faces on all screens.</p> <div class="layout-content-row" style="margin-top:20px"> <div class="layout-content-col span-9"> - <h3>Low bit</h3> - <p>Pixels on some screens (including OLED and transflective LED) in ambient mode are either - "on" or "off", also known as "low-bit". When designing for low-bit ambient mode, use only black - and white, avoid grayscale colors, and disable antialiasing in your paint styles. Make sure to - test your design on devices with low-bit ambient mode.</p> + <h3>Reduced color space</h3> + <p>Some displays use a reduced color space in ambient mode to save power.</p> + <p>One reduced color space power saving method is to use a "low-bit" mode. In low-bit mode, + the available colors are limited to black, white, blue, red, magenta, green, cyan, and yellow. + When designing for low-bit ambient mode, use a black or a white background. For OLED screens, + you must use a black background. Non-background pixels must be less than 10 percent of total + pixels. You can use low-bit color for up to 5 percent of pixels on screens that support it. + You should also disable antialiasing in your paint styles for this mode. Make sure to test + your design on devices with low-bit ambient mode.</p> + <p>Other displays save power in ambient mode by not producing any color. When designing for + displays which do not use color in ambient mode, the background may be either black or + white.</p> </div> <div class="layout-content-col span-4"> <img src="{@docRoot}design/media/wear/Render_LowBit.png" width="200" - height="" alt="" style="margin-top:-30px;margin-left:13px"> + height="" alt="" style="margin-top:45px;margin-left:13px"> </div> </div> @@ -164,7 +171,7 @@ screens.</p> </div> <div class="layout-content-col span-4"> <img src="{@docRoot}design/media/wear/Render_1Bit.png" width="200" - height="" alt="" style="margin-top:-30px;margin-left:13px"> + height="" alt="" style="margin-top:-10px;margin-left:13px"> </div> </div> diff --git a/docs/html/training/articles/security-tips.jd b/docs/html/training/articles/security-tips.jd index e05b44c..3215a0e 100644 --- a/docs/html/training/articles/security-tips.jd +++ b/docs/html/training/articles/security-tips.jd @@ -445,7 +445,17 @@ locally. Server-side headers like <code>no-cache</code> can also be used to indicate that an application should not cache particular content.</p> - +<p>Devices running platforms older than Android 4.4 (API level 19) +use a version of {@link android.webkit webkit} that has a number of security issues. +As a workaround, if your app is running on these devices, it +should confirm that {@link android.webkit.WebView} objects display only trusted +content. You should also use the updatable security {@link +java.security.Provider Provider} object to make sure your app isn’t exposed to +potential vulnerabilities in SSL, as described in <a +href="{@docRoot}training/articles/security-gms-provider.html">Updating Your +Security Provider to Protect Against SSL Exploits</a>. If your application must +render content from the open web, consider providing your own renderer so +you can keep it up to date with the latest security patches.</p> <h3 id="Credentials">Handling Credentials</h3> diff --git a/docs/html/training/wearables/data-layer/messages.jd b/docs/html/training/wearables/data-layer/messages.jd index 822e395..0ca55ba 100644 --- a/docs/html/training/wearables/data-layer/messages.jd +++ b/docs/html/training/wearables/data-layer/messages.jd @@ -39,16 +39,24 @@ to Google Play services and when to use each in </p> <pre> -Node node; // the connected device to send the message to GoogleApiClient mGoogleApiClient; -public static final START_ACTIVITY_PATH = "/start/MainActivity"; +public static final String START_ACTIVITY_PATH = "/start/MainActivity"; ... - SendMessageResult result = Wearable.MessageApi.sendMessage( - mGoogleApiClient, node, START_ACTIVITY_PATH, null).await(); - if (!result.getStatus().isSuccess()) { - Log.e(TAG, "ERROR: failed to send Message: " + result.getStatus()); - } +private void sendStartActivityMessage(String nodeId) { + Wearable.MessageApi.sendMessage( + mGoogleApiClient, nodeId, START_ACTIVITY_PATH, new byte[0]).setResultCallback( + new ResultCallback<SendMessageResult>() { + @Override + public void onResult(SendMessageResult sendMessageResult) { + if (!sendMessageResult.getStatus().isSuccess()) { + Log.e(TAG, "Failed to send message with status code: " + + sendMessageResult.getStatus().getStatusCode()); + } + } + } + ); +} </pre> <p> diff --git a/docs/html/training/wearables/watch-faces/configuration.jd b/docs/html/training/wearables/watch-faces/configuration.jd index edc7eac..5a4585d 100644 --- a/docs/html/training/wearables/watch-faces/configuration.jd +++ b/docs/html/training/wearables/watch-faces/configuration.jd @@ -92,7 +92,7 @@ and declare the following intent filter in the manifest file of the wearable app <action android:name= "com.example.android.wearable.watchface.CONFIG_DIGITAL" /> <category android:name= - "com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION" /> + <strong>"com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION"</strong> /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> @@ -119,8 +119,21 @@ a handheld device. For example, a configuration activity on a handheld device en present users with elaborate color pickers to select the background color of a watch face.</p> <p>To create a companion configuration activity, add a new activity to your handheld app module and -declare the same intent filter for this activity as the one in <a href="#WearableActivity">Create -a Wearable Configuration Activity</a>.</p> +declare the following intent filter in the manifest file of the handheld app:</p> + +<pre> +<activity + android:name=".DigitalWatchFaceCompanionConfigActivity" + android:label="@string/app_name"> + <intent-filter> + <action android:name= + "com.example.android.wearable.watchface.CONFIG_DIGITAL" /> + <category android:name= + <strong>"com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION"</strong> /> + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> +</activity> +</pre> <p>In your configuration activity, build a UI that provides options to customize all the configurable elements of your watch face. When users make a selection, use the <a diff --git a/docs/html/training/wearables/watch-faces/drawing.jd b/docs/html/training/wearables/watch-faces/drawing.jd index 9afdd80..3c5da34 100644 --- a/docs/html/training/wearables/watch-faces/drawing.jd +++ b/docs/html/training/wearables/watch-faces/drawing.jd @@ -192,13 +192,14 @@ as described in <a href="#Drawing">Drawing Your Watch Face</a>.</p> <h3 id="Timer">Initialize the custom timer</h3> -<p>As a watch face developer, you can decide how often you want to update your watch face by +<p>As a watch face developer, you decide how often you want to update your watch face by providing a custom timer that ticks with the required frequency while the device is in -interactive mode. This enables you to create custom animations and other visual effects. In -ambient mode, you should disable the timer to let the CPU sleep and update the watch face -only when the time changes. For more information, see -<a href="{@docRoot}training/wearables/watch-faces/performance.html">Optimizing Performance and -Battery Life</a>.</p> +interactive mode. This enables you to create custom animations and other visual effects. +</p> + +<p class="note"><strong>Note:</strong> In ambient mode, the system does not reliably call the +custom timer. To update the watch face in ambient mode, see <a href="#TimeTick">Update the watch +face in ambient mode</a>.</p> <p>An example timer definition from the <code>AnalogWatchFaceService</code> class that ticks once every second is shown in <a href="#Variables">Declare variables</a>. In the @@ -210,9 +211,8 @@ conditions apply:</p> <li>The device is in interactive mode.</li> </ul> -<p>The timer should not run under any other conditions, since this watch face does not -draw the second hand in ambient mode to conserve power. The <code>AnalogWatchFaceService</code> -class schedules the next timer tick if required as follows:</p> +<p>The <code>AnalogWatchFaceService</code> class schedules the next timer tick if required as +follows:</p> <pre> private void updateTimer() { @@ -281,15 +281,15 @@ private void unregisterReceiver() { -<h3 id="TimeTick">Invalidate the canvas when the time changes</h3> +<h3 id="TimeTick">Update the watch face in ambient mode</h3> -<p>The system calls the <code>Engine.onTimeTick()</code> method every minute. In ambient mode, -it is usually sufficient to update your watch face once per minute. To update your watch face -more often while in interactive mode, you provide a custom timer as described in +<p>In ambient mode, the system calls the <code>Engine.onTimeTick()</code> method every minute. +It is usually sufficient to update your watch face once per minute in this mode. To update your +watch face while in interactive mode, you must provide a custom timer as described in <a href="#Timer">Initialize the custom timer</a>.</p> -<p>Most watch face implementations just invalidate the canvas to redraw the watch face when -the time changes:</p> +<p>In ambient mode, most watch face implementations simply invalidate the canvas to redraw the watch +face in the <code>Engine.onTimeTick()</code> method:</p> <pre> @Override @@ -402,20 +402,17 @@ method for the system to redraw the watch face.</p> @Override public void onAmbientModeChanged(boolean inAmbientMode) { - boolean wasInAmbientMode = isInAmbientMode(); super.onAmbientModeChanged(inAmbientMode); - if (inAmbientMode != wasInAmbientMode) { - if (mLowBitAmbient) { - boolean antiAlias = !inAmbientMode; - mHourPaint.setAntiAlias(antiAlias); - mMinutePaint.setAntiAlias(antiAlias); - mSecondPaint.setAntiAlias(antiAlias); - mTickPaint.setAntiAlias(antiAlias); - } - invalidate(); - updateTimer(); + if (mLowBitAmbient) { + boolean antiAlias = !inAmbientMode; + mHourPaint.setAntiAlias(antiAlias); + mMinutePaint.setAntiAlias(antiAlias); + mSecondPaint.setAntiAlias(antiAlias); + mTickPaint.setAntiAlias(antiAlias); } + invalidate(); + updateTimer(); } </pre> @@ -478,7 +475,7 @@ public void onDraw(Canvas canvas, Rect bounds) { float hrLength = centerX - 80; // Only draw the second hand in interactive mode. - if (!mAmbient) { + if (!isInAmbientMode()) { float secX = (float) Math.sin(secRot) * secLength; float secY = (float) -Math.cos(secRot) * secLength; canvas.drawLine(centerX, centerY, centerX + secX, centerY + diff --git a/docs/html/training/wearables/watch-faces/service.jd b/docs/html/training/wearables/watch-faces/service.jd index 7ab575e..35366c5 100644 --- a/docs/html/training/wearables/watch-faces/service.jd +++ b/docs/html/training/wearables/watch-faces/service.jd @@ -64,42 +64,15 @@ Project</a>.</p> <h3 id="Dependencies">Dependencies</h3> -<p>For the handheld app, edit the <code>build.gradle</code> file in the <code>mobile</code> module -to add these dependencies:</p> - -<pre> -apply plugin: 'com.android.application' - -android { ... } - -dependencies { - ... - wearApp project(':wear') - compile 'com.google.android.gms:play-services:6.5.+' -} -</pre> - -<p>For the wearable app, edit the <code>build.gradle</code> file in the <code>wear</code> module -to add these dependencies:</p> - -<pre> -apply plugin: 'com.android.application' - -android { ... } - -dependencies { - ... - compile 'com.google.android.support:wearable:1.1.+' - compile 'com.google.android.gms:play-services-wearable:6.5.+' -} -</pre> - <p>The Wearable Support Library provides the necessary classes that you extend to create watch face implementations. The Google Play services client libraries (<code>play-services</code> and <code>play-services-wearable</code>) are required to sync data items between the companion device and the wearable with the <a href="{@docRoot}training/wearables/data-layer/index.html">Wearable Data Layer API</a>.</p> +<p>Android Studio automatically adds the required entries in your <code>build.gradle</code> +files when you create the project in the instructions above.</p> + <h3 id="Reference">Wearable Support Library API Reference</h3> <p>The reference documentation provides detailed information about the classes you use to |
