am f082f898: Merge "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)." into lmp-docs automerge: 8884eda

automerge: de9bd40

* commit 'de9bd40e21696ceeffc67ec24e6e43975461bc60':
  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).
This commit is contained in:
Luan Nguyen
2015-01-21 23:31:44 +00:00
committed by android-build-merger
2 changed files with 27 additions and 57 deletions

View File

@@ -192,13 +192,14 @@ as described in <a href="#Drawing">Drawing Your Watch Face</a>.</p>
<h3 id="Timer">Initialize the custom timer</h3> <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 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 interactive mode. This enables you to create custom animations and other visual effects.
ambient mode, you should disable the timer to let the CPU sleep and update the watch face </p>
only when the time changes. For more information, see
<a href="{@docRoot}training/wearables/watch-faces/performance.html">Optimizing Performance and <p class="note"><strong>Note:</strong> In ambient mode, the system does not reliably call the
Battery Life</a>.</p> 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 <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 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> <li>The device is in interactive mode.</li>
</ul> </ul>
<p>The timer should not run under any other conditions, since this watch face does not <p>The <code>AnalogWatchFaceService</code> class schedules the next timer tick if required as
draw the second hand in ambient mode to conserve power. The <code>AnalogWatchFaceService</code> follows:</p>
class schedules the next timer tick if required as follows:</p>
<pre> <pre>
private void updateTimer() { 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, <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. To update your watch face It is usually sufficient to update your watch face once per minute in this mode. To update your
more often while in interactive mode, you provide a custom timer as described in watch face while in interactive mode, you must provide a custom timer as described in
<a href="#Timer">Initialize the custom timer</a>.</p> <a href="#Timer">Initialize the custom timer</a>.</p>
<p>Most watch face implementations just invalidate the canvas to redraw the watch face when <p>In ambient mode, most watch face implementations simply invalidate the canvas to redraw the watch
the time changes:</p> face in the <code>Engine.onTimeTick()</code> method:</p>
<pre> <pre>
&#64;Override &#64;Override
@@ -402,20 +402,17 @@ method for the system to redraw the watch face.</p>
&#64;Override &#64;Override
public void onAmbientModeChanged(boolean inAmbientMode) { public void onAmbientModeChanged(boolean inAmbientMode) {
boolean wasInAmbientMode = isInAmbientMode();
super.onAmbientModeChanged(inAmbientMode); super.onAmbientModeChanged(inAmbientMode);
if (inAmbientMode != wasInAmbientMode) { if (mLowBitAmbient) {
if (mLowBitAmbient) { boolean antiAlias = !inAmbientMode;
boolean antiAlias = !inAmbientMode; mHourPaint.setAntiAlias(antiAlias);
mHourPaint.setAntiAlias(antiAlias); mMinutePaint.setAntiAlias(antiAlias);
mMinutePaint.setAntiAlias(antiAlias); mSecondPaint.setAntiAlias(antiAlias);
mSecondPaint.setAntiAlias(antiAlias); mTickPaint.setAntiAlias(antiAlias);
mTickPaint.setAntiAlias(antiAlias);
}
invalidate();
updateTimer();
} }
invalidate();
updateTimer();
} }
</pre> </pre>
@@ -478,7 +475,7 @@ public void onDraw(Canvas canvas, Rect bounds) {
float hrLength = centerX - 80; float hrLength = centerX - 80;
// Only draw the second hand in interactive mode. // Only draw the second hand in interactive mode.
if (!mAmbient) { if (!isInAmbientMode()) {
float secX = (float) Math.sin(secRot) * secLength; float secX = (float) Math.sin(secRot) * secLength;
float secY = (float) -Math.cos(secRot) * secLength; float secY = (float) -Math.cos(secRot) * secLength;
canvas.drawLine(centerX, centerY, centerX + secX, centerY + canvas.drawLine(centerX, centerY, centerX + secX, centerY +

View File

@@ -64,42 +64,15 @@ Project</a>.</p>
<h3 id="Dependencies">Dependencies</h3> <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 <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 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 <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 and the wearable with the <a href="{@docRoot}training/wearables/data-layer/index.html">Wearable
Data Layer API</a>.</p> 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> <h3 id="Reference">Wearable Support Library API Reference</h3>
<p>The reference documentation provides detailed information about the classes you use to <p>The reference documentation provides detailed information about the classes you use to