Merge change 8564 into donut

* changes:
  Merge doc change from cupcake: commit 'a8d035ccf319e1aed685a1e1509681350f737fd1' into manualmerge
This commit is contained in:
Android (Google) Code Review
2009-07-24 20:52:01 -07:00
14 changed files with 501 additions and 231 deletions

View File

@@ -349,7 +349,7 @@ web_docs_sample_code_flags := \
# most current Android platform version included in the SDK package.
framework_docs_SDK_VERSION := 1.5
# release version for SDK (ie "Release x")
framework_docs_SDK_REL_ID := 2
framework_docs_SDK_REL_ID := 3
framework_docs_SDK_CURRENT_DIR := $(framework_docs_SDK_VERSION)_r$(framework_docs_SDK_REL_ID)
framework_docs_LOCAL_DROIDDOC_OPTIONS += \

View File

@@ -150,14 +150,26 @@ folder.</p>
<code>(number of cells * 74) - 2</code><br/>
Following this formula, you should use 72 dp for a height of one cell, 294 dp and for a width of four cells.</p>
</li>
<li>The <code>updatePerdiodMillis</code> attribute defines how often the App Widget framework should
<li>The <code>updatePeriodMillis</code> attribute defines how often the App Widget framework should
request an update from the {@link android.appwidget.AppWidgetProvider} by calling the
{@link android.appwidget.AppWidgetProvider#onUpdate(Context,AppWidgetManager,int[])
onUpdate()} method. The actual update is not guaranteed to occur exactly on time with this value
and we suggest updating as infrequently as possible&mdash;perhaps no more than once an hour to
conserve the battery. You might also allow the user to adjust the frequency in a
configuration&mdash;some people might want a stock ticker to update every 15 minutes, or maybe
only four times a day.</li>
only four times a day.
<p class="note"><strong>Note:</strong> If the device is asleep when it is time for an update
(as defined by <code>updatePeriodMillis</code>), then the device will wake up in order
to perform the update. If you don't update more than once per hour, this probably won't
cause significant problems for the battery life. If, however, you need to update more
frequently and/or you do not need to update while the device is asleep, then you can instead
perform updates based on an alarm that will not wake the device. To do so, set an alarm with
an Intent that your AppWidgetProvider receives, using the {@link android.app.AlarmManager}.
Set the alarm type to either {@link android.app.AlarmManager#ELAPSED_REALTIME} or
{@link android.app.AlarmManager#RTC}, which will only
deliver the alarm when the device is awake. Then set <code>updatePeriodMillis</code> to
zero (<code>"0"</code>).</p>
</li>
<li>The <code>initialLayout</code> attribute points to the layout resource that defines the
App Widget layout.</li>
<li>The <code>configure</code> attribute defines the {@link android.app.Activity} to launch when

View File

@@ -11,21 +11,19 @@ home=true
</div><!-- end homeTitle -->
<div id="announcement-block">
<!-- total max width is 520px -->
<img src="/assets/images/home/IO-logo.png" alt="Google I/O Developer Conference 2009" width="242px" />
<div id="announcement" style="width:270px">
<p>The Google I/O developer conference took place May 27-28 in San Francisco.
If you missed the conference, you can experience the Android sessions
by viewing YouTube videos and presentation slides.</p>
<p><a href="http://code.google.com/events/io/sessions.html#mobile">See the Mobile sessions at Google I/O &raquo;</a></p>
<img src="/assets/images/home/android_adc.png" alt="Android Developer Challenge 2" width="232px" />
<div id="announcement" style="width:275px">
<p>The second Android Developer Challenge has begun! In this contest,
real-world users will help review and score applications and the overall winner will
take away $250,000. The deadline for submitting an application to the contest is August 31, 2009.</p>
<p><a href="http://code.google.com/android/adc/">Learn more about ADC 2 &raquo;</a></p>
</div> <!-- end annoucement -->
</div> <!-- end annoucement-block -->
</div><!-- end topAnnouncement -->
<div id="carousel">
<div id="carouselMain">
<div id="bulletinImg"></div>
<div id="bulletinDesc"></div>
</div>
<div id="carouselMain" style="height:192px"> <!-- this height can be adjusted based on the content height -->
</div>
<div class="clearer"></div>
<div id="carouselWheel">
<div class="app-list-container" align="center">
<a href="javascript:{}" id="arrow-left" onclick="" class="arrow-left-off"></a>
<div id="list-clip">
@@ -33,10 +31,10 @@ home=true
<!-- populated by buildCarousel() -->
</div>
</div><!-- end list-clip -->
<a href="javascript:page_right()" id="arrow-right" onclick="" class="arrow-right-off"></a>
<a href="javascript:{ page_right(); }" id="arrow-right" onclick="" class="arrow-right-on"></a>
<div class="clearer"></div>
</div><!-- end app-list container -->
</div><!-- end carousel -->
</div><!-- end carouselWheel -->
</div><!-- end homeMiddle -->
<div style="clear:both">&nbsp;</div>
@@ -81,8 +79,8 @@ home=true
<td class="imageCell"><a href="http://www.youtube.com/user/androiddevelopers"><img src="{@docRoot}assets/images/video-droid.png" style="padding:0" /></a></td>
<td>
<h2 class="green">Watch</h2>
<object width="150" height="140"><param name="movie" value="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="140"></embed></object>
<p style="margin-top:1em"><a href="http://www.youtube.com/user/androiddevelopers">More Android videos &raquo;</a></p>
<object width="150" height="140"><param name="movie" value="http://www.youtube.com/v/GARMe7Km_gk&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GARMe7Km_gk&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="140"></embed></object>
<p style="margin-top:1em"><a href="{@docRoot}videos/index.html">More Android videos &raquo;</a></p>
</td>
</tr>
@@ -122,10 +120,19 @@ home=true
'sdk': {
'layout':"imgLeft",
'icon':"sdk-small.png",
'name':"SDK 1.5 r2",
'name':"SDK 1.5 r3",
'img':"sdk-large.png",
'title':"Android 1.5 SDK",
'desc': "<p>Android 1.5 SDK is now available. It includes new APIs for Android 1.5, updated developer tools, multiple platform versions, and a Google APIs add-on.</p><p><a href='{@docRoot}sdk/1.5_r2/index.html'>Download Android 1.5 SDK</a></p>"
'desc': "<p>Android 1.5 SDK is now available. It includes new APIs for Android 1.5, updated developer tools, multiple platform versions, and a Google APIs add-on.</p><p><a href='{@docRoot}sdk/1.5_r3/index.html'>Download Android 1.5 SDK &raquo;</a></p>"
},
'io': {
'layout':"imgLeft",
'icon':"io-small.png",
'name':"Google I/O",
'img':"io-large.png",
'title':"Google I/O Developer Conference",
'desc': "<p>The Google I/O developer conference took place May 27-28 in San Francisco. If you missed the conference, you can experience the Android sessions by viewing YouTube videos.</p><p><a href='{@docRoot}videos/index.html'>See the sessions from Google I/O &raquo;</a></p>"
},
'mapskey': {

View File

@@ -11,19 +11,17 @@ home=true
</div><!-- end homeTitle -->
<div id="announcement-block">
<!-- total max width is 520px -->
<img src="/assets/images/home/IO-logo.png" alt="Google I/O Developer Conference 2009" width="242px" />
<div id="announcement" style="width:270px">
<p>Google I/O は、サンフランシスコの Moscone Center で 5 月 2728 日に開催された開発者会議です。このイベントに参加できなかった方は、各アンドロイド向けセッションを、YouTube ビデオやプレゼンテーションのスライド資料で体験する事が可能です。</p>
<p><a href="http://code.google.com/events/io/sessions.html#mobile">Mobile のセッションを参照してください &raquo;</a></p>
<img src="/assets/images/home/android_adc.png" alt="Android Developer Challenge 2" width="232px" />
<div id="announcement" style="width:275px">
<p>第2Android Developer Challengeが、遂に登場しましたこのアプリケーション開発コンテストでは、Androidのユーザなら誰でも簡単に参加でき、一等の賞金は$250,000 です。登録の締切日は8月31日になります。</p>
<p><a href="http://code.google.com/android/adc/">Android Developer Challengeについて詳しくはこちら &raquo;</a></p>
</div> <!-- end annoucement -->
</div> <!-- end annoucement-block -->
</div><!-- end topAnnouncement -->
<div id="carousel">
<div id="carouselMain">
<div id="bulletinImg"></div>
<div id="bulletinDesc"></div>
</div>
<div id="carouselMain" style="height:210px"> <!-- this height can be adjusted based on the content height -->
</div>
<div class="clearer"></div>
<div id="carouselWheel">
<div class="app-list-container" align="center">
<a href="javascript:{}" id="arrow-left" onclick="" class="arrow-left-off"></a>
<div id="list-clip">
@@ -31,10 +29,10 @@ home=true
<!-- populated by buildCarousel() -->
</div>
</div><!-- end list-clip -->
<a href="javascript:page_right()" id="arrow-right" onclick="" class="arrow-right-off"></a>
<a href="javascript:{ page_right(); }" id="arrow-right" onclick="" class="arrow-right-on"></a>
<div class="clearer"></div>
</div><!-- end app-list container -->
</div><!-- end carousel -->
</div><!-- end carouselWheel -->
</div><!-- end homeMiddle -->
<div style="clear:both">&nbsp;</div>
@@ -79,8 +77,8 @@ home=true
<td class="imageCell"><a href="http://www.youtube.com/user/androiddevelopers"><img src="{@docRoot}assets/images/video-droid.png" style="padding:0" /></a></td>
<td>
<h2 class="green">再生</h2>
<object width="150" height="140"><param name="movie" value="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=ja&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/x1ZZ-R3p_w8&hl=ja&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="140"></embed></object>
<p style="margin-top:1em"><a href="http://www.youtube.com/user/androiddevelopers">その他の Android 動画 &raquo;</a></p>
<object width="150" height="140"><param name="movie" value="http://www.youtube.com/v/GARMe7Km_gk&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GARMe7Km_gk&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="150" height="140"></embed></object>
<p style="margin-top:1em"><a href="{@docRoot}videos/index.html">その他の Android 動画 &raquo;</a></p>
</td>
</tr>
@@ -120,10 +118,19 @@ home=true
'sdk': {
'layout':"imgLeft",
'icon':"sdk-small.png",
'name':"SDK 1.5 r2",
'name':"SDK 1.5 r3",
'img':"sdk-large.png",
'title':"Android 1.5 SDK r2",
'desc': "<p>Android 1.5 SDK の最新バージョンが公開されました。このリリースには Android 1.5 用の API、最新版デベロッパーツール、複数プラットフォーム(バージョン)サポート、そして Google API のアドオンが含まれています。</p><p><a href='{@docRoot}sdk/1.5_r2/index.html'>Android 1.5 SDK をダウンロード</a></p>"
'title':"Android 1.5 SDK",
'desc': "<p>Android 1.5 SDK の最新バージョンが公開されました。このリリースには Android 1.5 用の API、最新版デベロッパーツール、複数プラットフォーム(バージョン)サポート、そして Google API のアドオンが含まれています。</p><p><a href='{@docRoot}sdk/1.5_r3/index.html'>Android 1.5 SDK をダウンロード &raquo;</a></p>"
},
'io': {
'layout':"imgLeft",
'icon':"io-small.png",
'name':"Google I/O",
'img':"io-large.png",
'title':"Google I/O Developer Conference",
'desc': "<p>Google I/O は、サンフランシスコの Moscone Center で 5 月 2728 日に開催された開発者会議です。このイベントに参加できなかった方は、各アンドロイド向けセッションを、YouTube ビデオ資料で体験する事が可能<nobr>です</nobr>。</p><p><a href='{@docRoot}videos/index.html'>セッションを参照してください &raquo;</a></p>"
},
'mapskey': {

View File

@@ -5,6 +5,76 @@ page.title=SDK Release Notes
releases. For the latest known issues, please ensure that you're viewing this
page at <a href="http://developer.android.com/sdk/RELEASENOTES.html">http://developer.android.com/sdk/RELEASENOTES.html</a>.</p>
<h2 id="1.5_r3">Android 1.5 SDK, Release 3</h2>
<p>Provides an updated Android 1.5 system image that includes permissions
fixes, as described below, and a new application &mdash; an IME for Japanese
text input. Also provides the same set of developer tools included in the
previous SDK, but with bug fixes and several new features.</p>
<h3>Permissions Fixes</h3>
<p>The latest version of the Android platform, deployable to
Android-powered devices, includes fixes to the permissions-checking
in certain areas of the framework. Specifically, the Android system
now properly checks and enforces several existing permissions where it
did not do so in the previous release. Because of these changes in
enforcement, you are strongly encouraged to test your application
against the new Android 1.5 system image included in this SDK, to ensure
that it functions normally. </p>
<p>In particular, if your application uses any of the system areas listed below,
you should add the required permissions to the application's manifest and then
test the areas of your code that depend on the permission-protected services.
Even if you believe your application does not use the permissions-protected
services, you should compile and test your application under the latest platform
version to ensure that users will not encounter problems when using your
application. </p>
<p>The changes to permissions are as follows:</p>
<ul>
<li>When an application requests access to device camera (through
android.hardware.camera), the <code>CAMERA</code> permission check is now
properly enforced. </li>
<li>When an application requests access to device audio capture (through
android.media.MediaRecorder), the <code>RECORD_AUDIO</code> permission check is
now properly enforced.</li>
</ul>
<p>For more information, see the issue described in the oCert advisory
below:</p>
<p style="margin-left: 2em;"><a href="http://www.ocert.org/advisories/ocert-2009-011.html">http://www.ocert.org/advisories/ocert-2009-011.html</a> </p>
<h3>Resolved Issues, Changes</h3>
<ul>
<li>The SDK includes a new version of the Google APIs add-on. The add-on
provides an updated com.google.android.maps external library that fixes compile
errors related to certain classes such as GeoPoint. For information about the
Google APIs add-on and the library it provides, see:
<p style="margin-left:2em;"><a
href="http://code.google.com/android/add-ons/google-apis">http://code.google.com/android/add-ons/google-apis</a> </p></li>
<li>The SDK add-on architecture now lets device manufacturers specify a USB
Vendor ID in their add-ons.
<li>The <code>android</code> tool provides a new command that scans SDK add-ons
for their USB Vendor IDs and makes them available to adb (OS X and Linux
versions of the SDK only). The command is <code>android update adb</code>. On
Windows versions of the SDK, a custom USB driver is included that supports the
"Google" and "HTC" Vendor IDs, which allow adb to recognize G1 and HTC
Magic devices. For other devices, contact the device manufacturer
to obtain a USB driver, especially if you have an SDK add-on that defines
a new USB Vendor ID.</li>
<li>The telephony, sensor, and geo fix issues in the emulator are now
fixed.</li>
<li>When you use adb to uninstall an upgraded application, the Android system
now properly restores any permissions that had already been granted to the
previous (downgrade) version of the application</li>
</ul>
<h2 id="1.5_r2">Android 1.5 SDK, Release 2</h2>
<p>This SDK release provides the same developer tools as the Android 1.5 SDK,

View File

@@ -125,6 +125,7 @@ application against the Android library that corresponds to the application's
<li>Dialer</li>
<li>Email</li>
<li>Gallery</li>
<li>IME for Japanese text input</li>
<li>Messaging</li>
<li>Music</li>
<li>Settings</li>

View File

@@ -1,4 +1,5 @@
sdk.redirect=1.1_r1
sdk.redirect=true
@jd:body

View File

@@ -25,6 +25,12 @@ release</a>.</p>
<th>Date</td>
<th>Description</td>
</tr>
<tr>
<td><a href="{@docRoot}sdk/1.5_r1/index.html">Android 1.5 SDK, Release 2</a></td>
<td style="text-align:center;">Android 1.5<br>Android 1.1</td>
<td><em>May 2009</em></td>
<td>Replaced by Android 1.5 SDK, Release 3. <em><a href="RELEASENOTES.html#1.5_r2">Release notes</a></em></td>
</tr>
<tr>
<td><a href="{@docRoot}sdk/1.5_r1/index.html">Android 1.5 SDK, Release 1</a></td>
<td style="text-align:center;">Android 1.5<br>Android 1.1</td>

View File

@@ -1,191 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0;url=/sdk/android-1.5-highlights.html">
<link href="/assets/android-developer-docs.css" rel="stylesheet" type="text/css" />
</head>
<body class="gc-documentation">
<a name="top"></a>
<div id="header">
<div id="headerLeft">
<a href="/index.html" tabindex="-1"><img
src="/assets/images/bg_logo.png" alt="Android Developers" /></a>
<ul class="sdk">
<li id="home-link"><a href="/index.html">
<span>Home</span></a></li>
<li id="sdk-link"><a href="/sdk/1.5_r1/index.html"><span>SDK</span></a></li>
<li id="guide-link"><a href="/guide/index.html"
onClick="return loadLast('guide')"><span>Dev Guide</span></a></li>
<li id="reference-link"><a href="/reference/packages.html"
onClick="return loadLast('reference')"><span>Reference</span></a></li>
<li><a href="http://android-developers.blogspot.com"><span>Blog</span></a></li>
<li id="community-link"><a href="/community/index.html"><span>Community</span></a></li>
</ul>
</div>
<div id="headerRight">
<div id="headerLinks">
<!-- <img src="/assets/images/icon_world.jpg" alt="" /> -->
<span class="text">
<!-- &nbsp;<a href="#">English</a> | -->
<a href="http://www.android.com">Android.com</a>
</span>
</div>
<div id="search" >
<div id="searchForm">
<form accept-charset="utf-8" class="gsc-search-box"
onsubmit="return submit_search()">
<table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
<tr>
<td class="gsc-input">
<input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
title="search developer docs" name="q"
value="search developer docs"
onFocus="search_focus_changed(this, true)"
onBlur="search_focus_changed(this, false)"
onkeydown="return search_changed(event, true, '/')"
onkeyup="return search_changed(event, false, '/')" />
<div id="search_filtered_div" class="no-display">
<table id="search_filtered" cellspacing=0>
</table>
</div>
</td>
<td class="gsc-search-button">
<input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
</td>
<td class="gsc-clear-button">
<div title="clear results" class="gsc-clear-button">&nbsp;</div>
</td>
</tr></tbody>
</table>
</form>
</div><!-- searchForm -->
</div><!-- search -->
</div><!-- headerRight -->
</div><!-- header -->
<div class="g-section g-tpl-240" id="body-content">
<div class="g-unit g-first not-resizable" id="side-nav">
<div id="devdoc-nav">
<ul>
<li>
<h2>Current SDK Release</h2>
<ul>
<li><a href="/sdk/1.5_r2/index.html">Download</a></li>
<li><a href="/sdk/1.5_r2/installing.html">Installing</a></li>
<li><a href="/sdk/1.5_r2/upgrading.html">Upgrading</a></li>
<li><a href="/sdk/1.5_r2/requirements.html">System Requirements</a></li>
</ul>
<ul>
<li><a href="/sdk/terms.html">SDK Terms and Conditions</a></li>
<li><a href="/sdk/RELEASENOTES.html">SDK Release Notes</a></li>
</ul>
<li>
<h2>System Image Version Notes</h2>
<ul>
<li><a href="/sdk/android-1.5.html">Android 1.5 Version Notes</a></li>
<li><a href="/sdk/android-1.1.html">Android 1.1 Version Notes</a></li>
</ul>
</li>
<li>
<h2>Previous SDK Releases</h2>
<ul>
<li><a href="/sdk/1.1_r1/index.html">Android 1.1 SDK, r1</a></li>
<li><a href="/sdk/1.0_r2/index.html">Android 1.0 SDK, r2</a></li>
<li><a href="/sdk/older_releases.html">Other Releases</a></li>
</ul>
</li>
</ul>
<script type="text/javascript">
<!--
buildToggleLists();
//-->
</script>
</div>
</div> <!-- end side-nav -->
<div class="g-unit">
<div id="jd-content">
<p>Redirecting to
<a href="/sdk/android-1.5-highlights.html">
/sdk/android-1.5-highlights.html
</a></p>
</div><!-- end jd-content -->
</div><!-- end doc-content -->
</div> <!-- end body-content -->
</body>
</html>

View File

@@ -0,0 +1,6 @@
sdk.redirect=true
sdk.redirect.path=android-1.5-highlights.html
@jd:body

View File

@@ -1,5 +1,5 @@
sdk.redirect=true
@jd:body

View File

@@ -1,4 +1,4 @@
<?cs if:!sdk.redirect ?>
<ul>
<li><?cs
if:android.whichdoc != "online" ?>
@@ -51,7 +51,7 @@
<span class="es">Notas de la versión de System Image</span>
<span class="fr">Notes de version de l'image système</span>
<span class="it">Note sulla versione dell'immagine <br />di sistema</span>
<span class="ja"> <br /></span>
<span class="ja"> <br /></span>
<span class="zh-CN"></span>
<span class="zh-TW"></span>
</h2>
@@ -92,3 +92,4 @@
changeNavLang(getLangPref());
//-->
</script>
<?cs /if ?>

View File

@@ -0,0 +1,12 @@
http://developer.android.com/ja/sdk/1.5_r3/installing.html
http://developer.android.com/ja/community/index.html
http://developer.android.com/ja/index.html
http://developer.android.com/ja/guide/publishing/versioning.html
http://developer.android.com/ja/guide/publishing/app-signing.html
http://developer.android.com/ja/guide/publishing/preparing.html
http://developer.android.com/ja/guide/tutorials/hello-world.html
http://developer.android.com/ja/guide/topics/fundamentals.html
http://developer.android.com/ja/guide/index.html
http://developer.android.com/ja/guide/basics/what-is-android.html
http://developer.android.com/ja/guide/developing/other-ide.html
http://developer.android.com/ja/guide/developing/eclipse-adt.html

338
docs/html/videos/index.jd Normal file
View File

@@ -0,0 +1,338 @@
videos=true
page.title=Videos
@jd:body
<script src="http://swfobject.googlecode.com/svn/trunk/swfobject/swfobject.js" type="text/javascript"></script>
<script src="{@docRoot}assets/jquery-history.js" type="text/javascript"></script>
<script type="text/javascript">
// for debugging in FF, so other browsers ignore the console commands.
var console;
if (!console) console = { 'log': function() {} };
/* This 'playlist' object defines the playlist IDs for each tab.
* Each name inside 'playlist' corresponds to class names for the tab that the playlists belong to (eg: "googleioTab" and "googleioBox" divs).
* Each string in 'ids' is the ID of a YouTube playlist that belongs in the corresponding tab.
*/
var playlists = {
'googleio' : {
'ids': ["734A052F802C96B9"]
},
'about' : {
'ids': ["D7C64411AF40DEA5","611F8C5DBF49CEC6"]
},
'developertips' : {
'ids': ["43E15866EF0033A2"]
},
'developersandbox' : {
'ids': ["77426907BBAD558E"]
}
};
/* Some playlists include the title in the description meta-data, so we need to account for this when building the thumbnail lists, so we don't show the title twice
* This string is read via indexOf(), so multiple IDs need only be comma-separated in this string.
*/
var playlistsWithTitleInDescription = "734A052F802C96B9";
/* This 'featured' object defines the Feature Videos list.
* Each playlist ID is paired with a custom video description.
*/
var featured = {
// How to Make your Android UI Fast..
'N6YdwzAvwOA' : "Make your user interface fast, with more efficient AdapterViews, better bitmap scaling, faster redrawing, ViewStub layouts, fewer Views, and more.",
// Coding for Life: Battery Life
'OUemfrKe65c' : "Learn what kinds of operations consume the most battery and how you can reduce your usage, with tips for parsing and zipping data, using wakelocks, and running a Service.",
// How Do I Code Thee?
'GARMe7Km_gk' : "If you'd like to augment your Android applications with pieces written in JavaScript or native code, watch this video."
};
/* When an event on the browser history occurs (back, forward, load),
* load the video found in the URL hash
*/
$(window).history(function(e, hash) {
if (location.href.indexOf("#v=") != -1) {
videoId = location.href.split("#v=");
clickVideo(videoId[1]); // click the link with a matching class
}
});
/* Load a video into the player box.
* @param id The YouTube video ID
* @param title The video title to display in the player box (character escaped)
* @param autoplay Whether to automatically play the video
*/
function loadVideo(id, title, autoplay) {
if($("." + id).hasClass("noplay")) {
console.log("noplay");
autoplay = false;
$("." + id).removeClass("noplay");
}
swfobject.embedSWF('http://www.youtube.com/v/' + id + '&rel=1&border=0&fs=1&autoplay=' +
(autoplay?1:0), 'player', '500', '334', '9.0.0', false, false, {allowfullscreen: 'true'});
$("#videoPlayerTitle").html("<h2>" + unescape(title) + "</h2>");
$.history.add('v=' + id); // add the current video to the browser history
document.getElementById("doc-content").scrollTop = 0; // scroll the window to the top
}
/* Draw all videos from a playlist into a 'videoPreviews' list
* @param data The feed data returned from the youtube request
*/
function renderPlaylist(data) {
var MAX_DESC_LENGTH = 390; // the length at which we will trim the description
var feed = data.feed;
var entries = feed.entry || [];
var playlistId = feed.yt$playlistId.$t;
var ul = $('<ul class="videoPreviews" />');
// Loop through each entry (each video) and add it to the 'videoPreviews' list
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var title = entry.title.$t;
var id = entry.media$group.yt$videoid.$t;
var thumbUrl = entry.media$group.media$thumbnail[0].url;
var fullDescription = entry.media$group.media$description.$t;
var playerUrl = entry.media$group.media$content[0].url;
// Check whether this playlist includes the video title inside the description meta-data, so we can remove it
if (playlistsWithTitleInDescription.indexOf(playlistId) != -1) {
var lines = fullDescription.split("\n");
// If the first line includes the first 17 chars from the title, let's use the title from the desciption instead (because it's a more complete title)
// This accounts for, literally, "Google I/O 2009 -", which is (so far) the min AND max for properly identifying a title in the only playlist with titles in the description
if (lines[0].indexOf(title.slice(0,16)) != -1) {
h3Title = "<h3>" + lines[0] + "</h3>";
if (lines[2].length < 30) lines = lines.slice(3); // also, if the second line is very short (the speaker name), slice it out too
else lines = lines.slice(1); // otherwise, slice after the first line
}
fullDescription = lines.join("");
}
var shortDescription = fullDescription.substr(0, MAX_DESC_LENGTH);
shortDescription += shortDescription.length == MAX_DESC_LENGTH ? "..." : ""; // add ellipsis if we've chopped the description
var img = $('<img src="' + thumbUrl + '" width="120" height="90"/>');
var a = $('<a class="' + id + '" href="#" onclick="loadVideo(\'' + id + '\',\'' + escape(title) + '\',true); return setSelected(this);" />');
var pShortDescription = $('<p class="short">' + shortDescription + '</p>');
var pFullDescription = $('<p class="full">' + fullDescription + '</p>');
var h3Title = "<h3>" + title + "</h3>";
var pToggle = "<p class='toggle'><a href='#' onclick='return toggleDescription(this)'><span class='more'>more</span><span class='less'>less</span></a></p>";
var li = $('<li/>');
li.append(a);
a.append(img).append(h3Title).append(pShortDescription);
// Add the full description and "more/less" toggle, if necessary
if (fullDescription.length > MAX_DESC_LENGTH) {
a.append(pFullDescription);
li.append(pToggle);
}
ul.append(li);
}
// Now add the 'videoPreviews' list to the page, and be sure we put it in the right tab
// This is the part that allows us to put multiple playlists in one tab
for (var x in playlists) {
var ids = playlists[x].ids;
for (var i in ids) {
if (ids[i] == playlistId) {
$("#"+x+"Box").append(ul);
break;
}
}
}
}
/* Draw a featured video into the existing 'videoPreviews' list
* @param data The video data returned from the youtube request
*/
function renderFeatured(data) {
var MAX_TITLE_LENGTH = 48;
var entry = data.entry || [];
var id = entry.media$group.yt$videoid.$t;
var description = featured[id];
var title = entry.title.$t;
var thumbUrl = entry.media$group.media$thumbnail[0].url;
var playerUrl = entry.media$group.media$content[0].url;
var ellipsis = title.length > MAX_TITLE_LENGTH ? "..." : "";
var h3Title = "<h3>"+ title.substr(0,MAX_TITLE_LENGTH) + ellipsis + "</h3>";
var img = $('<img src="' + thumbUrl + '" width="120" height="90"/>');
var p = $('<p>' + description + '</p>');
var a = $('<a class="' + id + '" href="#" onclick="loadVideo(\'' + id + '\',\'' + title + '\',true); return setSelected(this);" />');
var li = $("<li/>");
a.append(h3Title).append(img).append(p);
li.append(a);
$("#mainBodyRight .videoPreviews").append(li);
}
/* Request the playlist feeds from YouTube */
function showPlaylists() {
for (var x in playlists) {
var ids = playlists[x].ids;
for (var i in ids) {
var script = "<script type='text/javascript' src='http://gdata.youtube.com/feeds/api/playlists/"
+ ids[i] +
"?v=2&alt=json-in-script&callback=renderPlaylist'><\/script>";
$("body").append(script);
}
}
}
/* Request the featured videos from YouTube */
function showFeatured() {
for (var id in featured) {
var script = "<script type='text/javascript' src='http://gdata.youtube.com/feeds/api/videos/"
+ id +
"?v=2&alt=json-in-script&callback=renderFeatured'><\/script>";
$("body").append(script);
}
}
/* Reveal a tab (playlist) box
* @param name The name of the tab
*/
function showBox(name) {
$("#"+name+"Box").addClass("selected").siblings().removeClass("selected");
$("#"+name+"Tab").addClass("selected").siblings().removeClass("selected");
return false;
}
/* Highlight a video thumbnail, including all duplicates that there may be
* @param link The link <a> object that was clicked
*/
function setSelected(link) {
var videoId = $(link).attr("class");
if (videoId.indexOf("selected") != -1) { // this means this video is already selected and playing, so bail out
return false;
}
$(".videoPreviews .selected").removeClass("selected");
$("a." + videoId).addClass("selected").each( function (i) {
if ($(this).is(":hidden")) {
var boxName = $(this).parent().parent().parent().attr("id").split("Box");
$("#"+boxName[0]+"Tab a").click();
}
});
return false;
}
/* Reveal and hide the long/short descriptions for a video in the playlist
* @param link The link <a> object that was clicked
*/
function toggleDescription(link) {
var aToggle = $(link);
$("span", aToggle).toggle();
var aDescription = $(">a", aToggle.parent().parent());
$("p.short", aDescription).toggle();
$("p.full", aDescription).toggle();
if ($("span.less", aToggle).is(":visible")) {
aDescription.css("height", "auto");
} else {
aDescription.css("height", "90px");
}
return false;
}
/* Add actions to the page onload event so that we load a video right away */
addLoadEvent(function () {
// if there's a video url in the hash, click that video
if (location.href.indexOf("#v=") != -1) {
var videoId = location.href.split("#v=");
clickVideo(videoId[1]);
} else { // otherwise, click the default video
clickDefaultVideo();
}
});
var clickVideoAttempts = 0; // Used with clickVideo()
/* Click a video in order to load it and select it
* @param videoId The ID of the video to click
*/
function clickVideo(videoId) {
if ($("." + videoId).length != 0) { // if we find the video, click it and return
$("." + videoId).addClass("noplay"); // add class to indicate we should NOT autoplay (class removed by loadVideo)
$("." + videoId + ":first").click();
return;
} else { // if we don't find it, increment clickVideoAttempts
console.log("video NOT found: " + videoId);
clickVideoAttempts++;
}
// if we don't find it after 20 attempts (2 seconds), click the first feature video
if (clickVideoAttempts > 10) {
console.log("video never found, clicking default...");
clickVideoAttempts = 0;
clickDefaultVideo();
} else { // try again after 100 milliseconds
setTimeout('clickVideo("'+videoId+'")', 100);
}
}
/* Click the default video that should be loaded on page load (the first video in the featured list) */
function clickDefaultVideo() {
if ($("#mainBodyRight .videoPreviews a:first").length != 0) {
var videoId = $("#mainBodyRight .videoPreviews a:first").attr("class");
$("." + videoId).addClass("noplay"); // add class to indicate we should NOT autoplay (class removed by loadVideo)
$("." + videoId + ":first").click();
return;
} else { // if we don't find it, increment clickVideoAttempts
console.log("default video NOT found");
clickVideoAttempts++;
}
// if we don't find it after 50 attempts (5 seconds), just fail
if (clickVideoAttempts > 50) {
console.log("default video never found...");
} else { // try again after 100 milliseconds
setTimeout('clickDefaultVideo()', 100);
}
}
</script>
<div id="mainBodyFixed">
<div id="mainBodyLeft" class="videoPlayer" >
<div id="videoPlayerBox">
<div id="videoBorder">
<div id="videoPlayerTitle"></div>
<div id="objectWrapper">
<object id="player"></object>
</div>
</div>
</div>
</div><!-- end mainBodyLeft -->
<div id="mainBodyRight" class="videoPlayer">
<h2>Featured Videos</h2>
<ul class="videoPreviews"></ul>
</div><!-- end mainBodyRight -->
<ul id="videoTabs">
<li id="aboutTab" class="selected"><a onclick="return showBox('about');" href="#">About the Platform</a></li>
<li id="developertipsTab"><a onclick="return showBox('developertips');" href="#">Developer Tips</a></li>
<li id="googleioTab"><a onclick="return showBox('googleio');" href="#">Google I/O Sessions</a></li>
<li id="developersandboxTab"><a onclick="return showBox('developersandbox');" href="#">Developer Sandbox</a></li>
</ul>
<div id="videos">
<div id="aboutBox" class="selected"></div>
<div id="developertipsBox"></div>
<div id="googleioBox"></div>
<div id="developersandboxBox"></div>
</div>
</div><!-- end mainBodyFixed -->
<script type="text/javascript">
// Initialization actions
showFeatured(); // load featured videos
showPlaylists(); // load playslists
</script>