<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>rel=me &#187; dock</title>
	<atom:link href="http://rel.me/t/dock/feed/" rel="self" type="application/rss+xml" />
	<link>http://rel.me</link>
	<description>programming, objective-c, cocoa, iphone, c</description>
	<lastBuildDate>Wed, 01 Feb 2012 07:26:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Google Reader AIR app</title>
		<link>http://rel.me/2007/10/29/google-reader-air-app/</link>
		<comments>http://rel.me/2007/10/29/google-reader-air-app/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 04:18:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[icon]]></category>

		<guid isPermaLink="false">/2008/01/01/google-reader-air-app</guid>
		<description><![CDATA[Download GReader-0_1.air I was playing around with the actionscript to javascript bridge and built this Google Reader AIR app: I find the unread count from &#8216;reading-list-unread-count&#8217;: 1 2 3 var html:HTML = ... var window:JavaScriptObject = html.htmlControl.window; var unread:String = window.document.getElementById(&#34;reading-list-unread-count&#34;).innerHTML.toString(); Then I generate a dock icon (ignore all the hard coded pixel math): 1 [...]]]></description>
			<content:encoded><![CDATA[<p id="greader_air" style="float: right;padding: 0 18px 0 18px; margin: 0">
Download <a href="http://browsair.s3.amazonaws.com/GReader-0_1.air">GReader-0_1.air</a>
</p>
<p>I was playing around with the actionscript to javascript bridge and built this Google Reader AIR app:</p>
<p><script type="text/javascript">
var flash = new SWFObject("/flash/badge.swf", "greader_air_swf", 217, 180, "8", "#FFFFFF");
flash.addVariable("appname", "GReader");
flash.addVariable("appurl", "http://browsair.s3.amazonaws.com/GReader-0_1.air");
flash.addVariable("airversion", "1.0.M5");
flash.addVariable("buttoncolor", "CCCCCC");
flash.addVariable("messagecolor", "FFFFFF");
flash.addVariable("imageurl", "http://browsair.s3.amazonaws.com/GReader-0_1.png");
flash.write("greader_air");
</script></p>
<p style="clear:both">I find the unread count from &#8216;reading-list-unread-count&#8217;:</p>
<table class="CodeRay">
<tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">
<pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt></pre>
</td>
<td class="code">
<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">var html:HTML = ...<tt>
</tt>var window:JavaScriptObject = html.htmlControl.window;<tt>
</tt>var unread:String = window.document.getElementById(&quot;reading-list-unread-count&quot;).innerHTML.toString();</pre>
</td>
</tr>
</table>
<p>Then I generate a dock icon (ignore all the hard coded pixel math): <br/><br />
<img src="http://ducktyper.com/assets/2007/10/29/GReader_dock_icon.png" style="float:none;padding: 5px 0 0 30px"/>
</p>
<table class="CodeRay">
<tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">
<pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>5<tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt>9<tt>
</tt><strong>10</strong><tt>
</tt>11<tt>
</tt>12<tt>
</tt>13<tt>
</tt>14<tt>
</tt>15<tt>
</tt>16<tt>
</tt>17<tt>
</tt>18<tt>
</tt>19<tt>
</tt><strong>20</strong><tt>
</tt>21<tt>
</tt>22<tt>
</tt>23<tt>
</tt>24<tt>
</tt>25<tt>
</tt>26<tt>
</tt>27<tt>
</tt>28<tt>
</tt>29<tt>
</tt><strong>30</strong><tt>
</tt>31<tt>
</tt>32<tt>
</tt>33<tt>
</tt>34<tt>
</tt>35<tt>
</tt>36<tt>
</tt>37<tt>
</tt>38<tt>
</tt>39<tt>
</tt><strong>40</strong><tt>
</tt>41<tt>
</tt>42<tt>
</tt>43<tt>
</tt>44<tt>
</tt>45<tt>
</tt>46<tt>
</tt>47<tt>
</tt></pre>
</td>
<td class="code">
<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">[Embed(source=&quot;/assets/app_icons/greader/icon_128.png&quot;)]<tt>
</tt>private var iconClass:Class;<tt>
</tt><tt>
</tt>[Embed(source=&quot;/assets/fonts/Verdana.ttf&quot;, fontName=&quot;GReaderDockIconFont&quot;, mimeType=&quot;application/x-font-truetype&quot;)]<tt>
</tt>private var fontClass:Class;<tt>
</tt>....<tt>
</tt><tt>
</tt>private function draw():void {  <tt>
</tt>  var icon:BitmapAsset = BitmapAsset(new iconClass()); <tt>
</tt>      <tt>
</tt>  var shape:Shape = new Shape();<tt>
</tt>  shape.graphics.beginBitmapFill(icon.bitmapData, new Matrix(), true, false);<tt>
</tt>  shape.graphics.drawRect(0, 0, dimensions, dimensions);<tt>
</tt>  shape.graphics.endFill();<tt>
</tt>  <tt>
</tt>  shape.graphics.beginFill(0xDF0013);<tt>
</tt>  shape.graphics.drawCircle(32, dimensions - 32, 32);<tt>
</tt>  shape.graphics.endFill();<tt>
</tt>  addChild(shape);<tt>
</tt>  <tt>
</tt>  if (unreadCount &gt; 0) addChild(buildText());      <tt>
</tt>}<tt>
</tt><tt>
</tt>public function buildText():Bitmap {<tt>
</tt>  var countText:TextField = new TextField();<tt>
</tt>  countText.embedFonts = true;<tt>
</tt><tt>
</tt>  var format:TextFormat = new TextFormat();<tt>
</tt>  format.font = new fontClass().fontName;<tt>
</tt>  format.color = 0xFFFFFF;      <tt>
</tt>  format.size = 26;<tt>
</tt>  format.align = TextFormatAlign.CENTER;<tt>
</tt>  <tt>
</tt>  countText.defaultTextFormat = format;<tt>
</tt>  countText.selectable = false;      <tt>
</tt>  countText.text = unreadCount.toString();<tt>
</tt>  countText.height = 32;<tt>
</tt>  countText.width = 54;<tt>
</tt>  <tt>
</tt>  var bitmapData:BitmapData = new BitmapData(64, 32, true, 0x00000000);<tt>
</tt>  bitmapData.draw(countText);      <tt>
</tt>  var bitmap:Bitmap = new Bitmap(bitmapData);<tt>
</tt>  bitmap.smoothing = true;<tt>
</tt>  bitmap.y = 128 - 52;<tt>
</tt>  bitmap.x = 4;<tt>
</tt>  return bitmap;<tt>
</tt>}</pre>
</td>
</tr>
</table>
<p>Set the dock icon with the generated bitmap data:</p>
<table class="CodeRay">
<tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">
<pre>1<tt>
</tt>2<tt>
</tt></pre>
</td>
<td class="code">
<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">if (Shell.shell.icon is InteractiveIcon) <tt>
</tt>  InteractiveIcon(Shell.shell.icon).bitmaps = icons;</pre>
</td>
</tr>
</table>
<p>For more info on dynamic dock icons, see <a href="http://weblogs.macromedia.com/cantrell/archives/2007/10/generating_dyna.cfm">Generating Dynamic Dock and System Tray Icons in AIR</a></p>
<p>I think the next step is taking a bunch of greasemonkey js scripts and adding them in. This might be how you would do that:</p>
<table class="CodeRay">
<tr>
<td class="line_numbers" title="click to toggle" onclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }">
<pre>1<tt>
</tt>2<tt>
</tt>3<tt>
</tt>4<tt>
</tt>5<tt>
</tt>6<tt>
</tt>7<tt>
</tt>8<tt>
</tt></pre>
</td>
<td class="code">
<pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }">var html:HTML = ...<tt>
</tt>var window:JavaScriptObject = html.htmlControl.window;      <tt>
</tt>var head:JavaScriptObject = window.document.getElementsByTagName(&quot;head&quot;)[0];         <tt>
</tt>var script:JavaScriptObject = window.document.createElement('script');<tt>
</tt>script.type = 'text/javascript';<tt>
</tt>//script.src = 'http://lolcats.com/script.js';<tt>
</tt>script.innerHTML = &quot;alert('HAI.. KTHXBYE');&quot;;<tt>
</tt>head.appendChild(script);</pre>
</td>
</tr>
</table>
<p><strong>Update: </strong> I&#8217;ve seen it tack the CPU when interacting in a couple places so I will try to figure out if its AIR webkit being buggy or me. Also will fix the external link lameness at some point.</p>
<p><strong>Update: </strong> Oops. Looks like it doesn&#8217;t work in Leopard. </p>
]]></content:encoded>
			<wfw:commentRss>http://rel.me/2007/10/29/google-reader-air-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

