diff options
author | Luan Nguyen <luann@google.com> | 2015-01-20 08:41:51 -0800 |
---|---|---|
committer | Luan Nguyen <luann@google.com> | 2015-01-21 08:00:45 -0800 |
commit | 46e804d2a730042fbf4824459cdcf2592d310abd (patch) | |
tree | eb1d769997d79639d03fe5e31eadfd95bdff5547 /docs | |
parent | de0a87007b987a76af2ddd526dd473ad83fbb74b (diff) | |
download | frameworks_base-46e804d2a730042fbf4824459cdcf2592d310abd.zip frameworks_base-46e804d2a730042fbf4824459cdcf2592d310abd.tar.gz frameworks_base-46e804d2a730042fbf4824459cdcf2592d310abd.tar.bz2 |
docs: Fix conditional in ambient mode check method (18832168).
Fix issue with non existent variable (18832287).
Fix issue with outdated instructions (18832293).
Fix issue with misleading time tick (18832171).
bug: 18832168
bug: 18832171
bug: 18832287
bug: 18832293
Change-Id: I4f071846589ba7edda500342ccd5fac6ecca3161
Diffstat (limited to 'docs')
-rw-r--r-- | docs/html/training/wearables/watch-faces/drawing.jd | 51 | ||||
-rw-r--r-- | docs/html/training/wearables/watch-faces/service.jd | 33 |
2 files changed, 27 insertions, 57 deletions
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 |