<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>AruSahni.net</title>
	
	<link>http://arusahni.net/blog</link>
	<description>Entropic Elocution</description>
	<lastBuildDate>Sun, 20 May 2012 01:46:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/arusahni/entropy" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="arusahni/entropy" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>The Clouuuud</title>
		<link>http://arusahni.net/blog/2012/05/the-clouuuud/</link>
		<comments>http://arusahni.net/blog/2012/05/the-clouuuud/#comments</comments>
		<pubDate>Sun, 20 May 2012 01:36:35 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=119</guid>
		<description><![CDATA[Watch this video on YouTube Embedded with WP YouTube Lyte. Yes, the &#8220;cloud&#8221;.  I hate that buzzword.  I see it everywhere, and seemingly every day I see tech articles and tweets extolling its virtues, heralding it as the next big thing &#8211; a means to trade being tethered to a general-purpose computer at a desk [...]]]></description>
			<content:encoded><![CDATA[<div class="lyMe" id="WYL_W9t5ZqeHcYk" style="width:480px;height:360px;"><noscript><a href="http://youtu.be/W9t5ZqeHcYk"><img src="http://img.youtube.com/vi/W9t5ZqeHcYk/0.jpg" alt="" width="480" height="340" /><br />Watch this video on YouTube</a> Embedded with WP YouTube Lyte.</noscript></div>
<div class="lL" style="width:480px;"></div>
<p>Yes, the &#8220;cloud&#8221;.  I hate that buzzword.  I see it everywhere, and seemingly every day I see tech articles and tweets extolling its virtues, heralding it as the next big thing &#8211; a means to trade being tethered to a general-purpose computer at a desk for being tethered to a faceless corporation&#8217;s ecosystem, accessed through whatever locked-down devices they see it fit to support.</p>
<p>Of course, as with anything that takes control and privacy away from users, there is backlash.  <em>Tonight at 11: are your Facebook photos really private?  The truth may surprise you.</em>  Next thing you know you have parents making their children wear <a title="DIY Infrared LED hats" href="http://hacknmod.com/hack/blind-cameras-with-an-infrared-led-hat/" target="_blank">infrared LED hats</a> to birthday parties.  In order to capitalize on this panic some services have started advertising themselves as an alternative to cloud storage.  Not all of them, however, understand what &#8220;cloud&#8221; storage means.</p>
<p>Like this recent email from my credit union (emphasis mine)&#8230;</p>
<blockquote>
<h4 align="left">Introducing My Virtual StrongBox® – our New Online Safe Deposit Box Service!</h4>
<p>My Virtual StrongBox allows you to safely store copies of critical documents such as birth certificates, insurance policies, wills and more online, <strong><span style="text-decoration: underline;">without having to rely on the &#8220;cloud.&#8221;</span></strong></p>
<p>With My Virtual StrongBox, <strong><span style="text-decoration: underline;">you have immediate access to your documents – where and when you need them</span></strong> – with the assurance that they are <strong><span style="text-decoration: underline;">stored on the same dedicated secure devices</span></strong> where we keep your eStatements and other financial information. Plus, as a Northwest Federal eStatement user, you have access to 100MB of document storage at no charge.</p>
<p>Start safely storing and organizing your important documents. Login to your eStatements directly or through Online Banking, to create your own My Virtual StrongBox today.</p></blockquote>
<p>TL;DR version:</p>
<div id="attachment_122" class="wp-caption aligncenter" style="width: 350px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/05/the-cloud.jpg"><img class="size-full wp-image-122" title="The Cloud" src="http://arusahni.net/blog/wp-content/uploads/2012/05/the-cloud.jpg" alt="Vizzini!" width="340" height="234" /></a><p class="wp-caption-text">My credit union</p></div>
<div id="attachment_123" class="wp-caption aligncenter" style="width: 340px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/05/inigo-montoya.jpg"><img class="size-full wp-image-123" title="Inigo Montoya" src="http://arusahni.net/blog/wp-content/uploads/2012/05/inigo-montoya.jpg" alt="Inigo Montoya" width="330" height="282" /></a><p class="wp-caption-text">Me</p></div>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2012/05/the-clouuuud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Custom Alert DialogFragments</title>
		<link>http://arusahni.net/blog/2012/01/implementing-custom-alert-dialogfragments/</link>
		<comments>http://arusahni.net/blog/2012/01/implementing-custom-alert-dialogfragments/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 15:30:10 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=94</guid>
		<description><![CDATA[While this may seem like a minor UI issue at first, there's something more to it - Android versions 3.0 and above switched the order of the default dialog button actions, placing the positive button on the right, and the negative on the left.  The dialog I'm currently displaying uses the pre-2.0 order.  When you're dealing with muscle memory (especially for deletion dialogs), such UX concerns become important.]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been working on further revisions to <a href="https://market.android.com/details?id=com.thirteenbytes.kongforums" title="KongregateForums on the Android Market" target="_blank">my app</a>.  The most notable of these revisions involves switching action bar implementations from <a href="https://github.com/cyrilmottier/GreenDroid" title="GreenDroid's GitHub page" target="_blank">GreenDroid</a> to <a href="http://actionbarsherlock.com/" title="ActionBarSherlock, a high-level Android compatibility layer" target="_blank">ActionBarSherlock</a>.  While this will benefit me tremendously as I&#8217;ll be able to use native Android 3.0+ components when running on those platforms, it means that I need to start using Fragments as well as the rest of the <a href="http://developer.android.com/sdk/compatibility-library.html" title="Official Android support libraries" target="_blank">Android Support Package</a>.</p>
<div id="attachment_95" class="wp-caption aligncenter" style="width: 230px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/01/220px-Steve_Ballmer_at_CES_2010_cropped1.jpg"><img class="size-full wp-image-95" title="Steve Ballmer" src="http://arusahni.net/blog/wp-content/uploads/2012/01/220px-Steve_Ballmer_at_CES_2010_cropped1.jpg" alt="" width="220" height="263" /></a><p class="wp-caption-text">Refactor Refactor Refactor</p></div>
<p>I&#8217;ve be saving much of what I have learned for another post, but I felt like sharing this tidbit right now.  One thing that quickly became apparent was that a custom dialog that I was using (with positive/negative buttons) was not going to cut it, as the system dialogs were rendering the button strip differently&#8230;</p>
<div id="attachment_96" class="wp-caption aligncenter" style="width: 317px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_custom.png"><img class="size-full wp-image-96" title="KongregateForums Custom Page Dialog" src="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_custom.png" alt="" width="307" height="198" /></a><p class="wp-caption-text">The button strip isn&#39;t displayed correctly</p></div>
<p>This is implemented via&#8230;</p>
<div class="codecolorer-container xml geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:minWidth</span>=<span style="color: #ff0000;">&quot;280dip&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;10dip&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/layoutPageDialogRoot&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EditText</span> <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/editTextPageNumber&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:inputType</span>=<span style="color: #ff0000;">&quot;number&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span> <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/textViewMaxPages&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;&quot;</span> </span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:gravity</span>=<span style="color: #ff0000;">&quot;right&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;requestFocus<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/requestFocus<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span> <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/linearLayout1&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Go!&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/buttonOk&quot;</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_weight</span>=<span style="color: #ff0000;">&quot;1&quot;</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_marginTop</span>=<span style="color: #ff0000;">&quot;3dip&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;0dip&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span> <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Nevermind&quot;</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/buttonCancel&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_weight</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_marginTop</span>=<span style="color: #ff0000;">&quot;3dip&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;0dip&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>While this may seem like a minor UI issue at first, there&#8217;s something more to it &#8211; Android versions 3.0 and above switched the order of the default dialog button actions, placing the positive button on the right and the negative on the left.  The dialog above is using the pre-2.0 order.  When you&#8217;re dealing with muscle memory, such UX concerns become important (especially for deletion dialogs).</p>
<p>So, when refactoring the <code class="codecolorer java geshi"><span class="java">PaginationDialog</span></code> into its own <code class="codecolorer java geshi"><span class="java">DialogFragment</span></code>, I decided to do more than port my code.  I realized that the native <code class="codecolorer java geshi"><span class="java">AlertDialog</span></code> class uses the operating system order, and is styled to match the OS version&#8217;s conventions.  If only there was a way I could throw my layout into that&#8230; wait! There is &#8211; <code class="codecolorer java geshi"><span class="java">AlertDialog.<span style="color: #006633;">Builder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> has a <code class="codecolorer java geshi"><span class="java">setView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code> method!</p>
<p>By removing the buttons from the layout XML file and manually inflating it, I can stuff my Views into the <code class="codecolorer java geshi"><span class="java"><span style="color: #003399;">Dialog</span></span></code> and piggyback off its functionality.</p>
<p>My buttonless layout&#8230;</p>
<div class="codecolorer-container xml geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:100px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/layoutPageDialogRoot&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:minWidth</span>=<span style="color: #ff0000;">&quot;280dip&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">android:padding</span>=<span style="color: #ff0000;">&quot;10dip&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EditText</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/editTextPageNumber&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:inputType</span>=<span style="color: #ff0000;">&quot;number&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/textViewMaxPages&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:gravity</span>=<span style="color: #ff0000;">&quot;right&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;requestFocus<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/requestFocus<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/TextView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>And the full <code class="codecolorer java geshi"><span class="java">DialogFragment</span></code>&#8230;</p>
<div class="codecolorer-container java geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PaginationDialogFragment <span style="color: #000000; font-weight: bold;">extends</span> DialogFragment <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> currentPage, maxPages<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> PaginationDialogFragment newInstance<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> currentPage, <span style="color: #000066; font-weight: bold;">int</span> maxPages<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PaginationDialogFragment p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PaginationDialogFragment<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Bundle args <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Bundle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; args.<span style="color: #006633;">putInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentPage&quot;</span>, currentPage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; args.<span style="color: #006633;">putInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;maxPages&quot;</span>, maxPages<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; p.<span style="color: #006633;">setArguments</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> p<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* (non-Javadoc)<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @see android.support.v4.app.DialogFragment#onCreate(android.os.Bundle)<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; currentPage <span style="color: #339933;">=</span> getArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentPage&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; maxPages <span style="color: #339933;">=</span> getArguments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;maxPages&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Dialog</span> onCreateDialog<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; LayoutInflater inflater <span style="color: #339933;">=</span> LayoutInflater.<span style="color: #006633;">from</span><span style="color: #009900;">&#40;</span>getActivity<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">View</span> v <span style="color: #339933;">=</span> inflater.<span style="color: #006633;">inflate</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">page_dialog</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> AlertDialog.<span style="color: #006633;">Builder</span><span style="color: #009900;">&#40;</span>getActivity<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Go to page...&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setView</span><span style="color: #009900;">&#40;</span>v<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setCancelable</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setPositiveButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ok!&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> DialogInterface.<span style="color: #006633;">OnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span>DialogInterface dialog, <span style="color: #000066; font-weight: bold;">int</span> which<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//validation code</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setNegativeButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Aww, hell no!&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> DialogInterface.<span style="color: #006633;">OnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span>DialogInterface dialog, <span style="color: #000066; font-weight: bold;">int</span> which<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dialog.<span style="color: #006633;">cancel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The important lines in the code snippet displayed above are 28, 29 and 32.  On 28, the app gets the inflater being used by the <code class="codecolorer java geshi"><span class="java">Activity</span></code>.  Remember, you should never instantiate a <code class="codecolorer java geshi"><span class="java">LayoutInflater</span></code> directly.  After that, it&#8217;s pretty trivial to generate the dialog&#8217;s content (29) and then insert it into an <code class="codecolorer java geshi"><span class="java">AlertDialog</span></code>&#8216;s <code class="codecolorer java geshi"><span class="java"><span style="color: #003399;">View</span></span></code> hierarchy.</p>
<p>Run it and what do you get?</p>
<div id="attachment_102" class="wp-caption aligncenter" style="width: 323px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_fixed.png"><img src="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_fixed.png" alt="" title="KongregateForums Fixed PaginationDialog" width="313" height="196" class="size-full wp-image-102" /></a><p class="wp-caption-text">Beautiful!</p></div>
<p>Now, run it in Froyo to see if the buttons are automagically reordered&#8230;<br />
<div id="attachment_107" class="wp-caption aligncenter" style="width: 278px"><a href="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_fixed-froyo.png"><img src="http://arusahni.net/blog/wp-content/uploads/2012/01/kf_pagedialog_fixed-froyo.png" alt="" title="KongregateForums Fixed Froyo PageDialog" width="268" height="198" class="size-full wp-image-107" /></a><p class="wp-caption-text">And there was much rejoicing.</p></div></p>
<p><em>Disclaimer: Yes, I know I&#8217;m inlining strings that would be best stored in an external file. That&#8217;s a step I put off until I&#8217;m ready to make a release build.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2012/01/implementing-custom-alert-dialogfragments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Action Bar and You!</title>
		<link>http://arusahni.net/blog/2011/08/action-bar-and-you/</link>
		<comments>http://arusahni.net/blog/2011/08/action-bar-and-you/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 19:54:41 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=72</guid>
		<description><![CDATA[In which I attempt to implement the action bar design pattern in an Android app.]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve been developing an Android application on and off for the past few months. In the latest iteration of the app, I wanted to make some options that were hidden in a menu more discoverable. The accepted way of doing this in Android is through adopting the Action Bar design pattern. As described in the official <a title="Twitter For Android: a closer look" href="http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html">Android Developers Blog entry</a> on the matter:</p>
<blockquote><p>The Action bar gives your users onscreen access to the most frequently used actions in your application. We recommend you use this pattern if you want to dedicate screen real estate for common actions. Using this pattern replaces the title bar. It works with the Dashboard, as the upper left portion of the Action bar is where we recommend you place a quick link back to the dashboard or other app home screen.</p></blockquote>
<p>Awesome, right? A unified UI paradigm for Android. Let me just add the widget to my Activity&#8230; umm, uhh&#8230; where is it? Nowhere in the Android 2.x SDKs. Instead, Google decided to kill two birds with one stone and encouraged developers to look at <a title="Google Code entry for the I/O schedule" href="https://code.google.com/p/iosched/">their source code</a> for the Google I/O schedule app. This way people could not only learn how to use and implement the pattern, but they can also see what a well-written Android app is supposed to look like.</p>
<p>That&#8217;s all well and good, but what about the <del datetime="2011-08-13T18:19:28+00:00">lazy</del> efficient among us, who don&#8217;t want to reinvent the wheel and write the same instrumentation every time we make an Activity? Once again, Google to the rescue. With the advent of library projects, the ADT plugin for Eclipse makes <a title="Referencing Library Projects" href="http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject">importing standalone/reusable components into your existing project easy</a>. After this feature was made available, the number of rich, third-party libraries for Android skyrocketed. Among these were <a title="ActionBarSherlock, a high-level Honeycomb compatibility layer" href="http://actionbarsherlock.com/">several</a> that had <a title="ActionBar for Android's page on GitHub" href="https://github.com/johannilsson/android-actionbar/">reusable</a> Action Bar controls. After some experimentation, I settled on <a title="GreenDroid's GitHub page" href="https://github.com/cyrilmottier/GreenDroid">GreenDroid</a>.</p>
<h3>So, GreenDroid</h3>
<p>GreenDroid&#8217;s claim to fame is the notion that you need to alter very little of your existing code to get attractive, functional UI components. Since my project was mostly complete at the time of implementation, this was a huge plus. And, for the most part, it ended up being true.<br />
<span id="more-72"></span><br />
After I added GreenDroid as a library project to my existing app, I had to instruct Android to load GD&#8217;s theme. That was as simple as adding the &#8220;android:theme&#8221; attribute to my AndroidManifest.xml:</p>
<div class="codecolorer-container xml geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application</span> <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/app_name&quot;</span> <span style="color: #000066;">android:icon</span>=<span style="color: #ff0000;">&quot;@drawable/ic_launcher&quot;</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;MyAwesomeApp&quot;</span> <span style="color: #000066;">android:description</span>=<span style="color: #ff0000;">&quot;@string/app_description&quot;</span> <span style="color: #000066;">android:theme</span>=<span style="color: #ff0000;">&quot;@style/Theme.GreenDroid.NoTitleBar&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<p>Next, I had to alter my main Application class to extend the GDApplication class. This wasn&#8217;t a problem as I was already extending Application for some global variables.</p>
<div class="codecolorer-container java geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyAwesomeApp <span style="color: #000000; font-weight: bold;">extends</span> GDApplication <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Class<span style="color: #339933;">&lt;?&gt;</span> getHomeActivityClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> HomeActivity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>As you can see, there&#8217;s an interesting override happening here &#8211; getHomeActivityClass.  This method is used by GreenDroid to determine which Activity to launch when the user taps the home icon on the left side of the ActionBar.  Since my &#8220;home&#8221; activity is usually the second one on the Activity stack, this is an awesome feature to have.  </p>
<p>That was painless, right?  I then moved on to port my Activities.  My home activity needed an ActionBar with a refresh button:</p>
<div class="codecolorer-container java geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HomeActivity <span style="color: #000000; font-weight: bold;">extends</span> GDActivity <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//Needed in order to implement the ActionBar</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> LoaderActionBarItem throbber<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> REFRESH <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setActionBarContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">home_activity</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//NB: NOT setContentView()</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; initActionBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> initActionBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; throbber <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>LoaderActionBarItem<span style="color: #009900;">&#41;</span> addActionBarItem<span style="color: #009900;">&#40;</span>Type.<span style="color: #006633;">Refresh</span>, REFRESH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onHandleActionBarItemClick<span style="color: #009900;">&#40;</span>ActionBarItem item, <span style="color: #000066; font-weight: bold;">int</span> position<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>item.<span style="color: #006633;">getItemId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">case</span> REFRESH<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; refreshContent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onHandleActionBarItemClick</span><span style="color: #009900;">&#40;</span>item, position<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> refreshContent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//do stuff. If this is an AsyncTask, move the line below into onPostExecute</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; throbber.<span style="color: #006633;">setLoading</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//switch back to the static refresh image</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>There&#8217;s a lot going on there.  Breaking it down&#8230;</p>
<ul>
<li>Line 2: I&#8217;m storing a reference to the ActionBarItem so I can toggle the indeterminate progress (busy) state from anywhere within the Activity. This is needed to revert back to the refresh button when the content is done refreshing.</li>
<li>Line 3: Just as one would do when defining result codes for a spawned Activity, GreenDroid requires that each ActionBarItem be associated with an integer for the purposes of action identification.</li>
<li>Line 12: Here I&#8217;m appending the action to the ActionBar, defining the action ID, and assigning it to my Activity-level variable for future reference.</li>
</ul>
<p>Run it and what do we get? <div id="attachment_81" class="wp-caption aligncenter" style="width: 493px"><a href="http://arusahni.net/blog/wp-content/uploads/2011/08/gd_home.png"><img src="http://arusahni.net/blog/wp-content/uploads/2011/08/gd_home.png" alt="Home ActionBar" title="GreenDroid_home" width="483" height="68" class="size-full wp-image-81" /></a><p class="wp-caption-text">BOOM. Easy.</p></div></p>
<p>The next Activity, however, wasn&#8217;t as easy. It&#8217;s a ListActivity, which, at first glance, didn&#8217;t seem to be a challenge.  However, there was a complication due to the way layouts are built by GDLIstActivity.  According to the creator of GreenDroid, Cyril Mottier:</p>
<blockquote><p>The setActionBarContentView is normally only a helper method for the GDActivity. If you look at the ActionBarActivity interface, you&#8217;ll see this method is not a part of the ActionBarActivity interface.</p>
<p>The correct method to use when you want to have a custom layout in GDListActivity is to override the createLayout method.</p></blockquote>
<p>So, I couldn&#8217;t just replace the setContentView call as I did before.  Instead I needed to do two things: override the default layout used by GDListActivity, and alter the original layout to provide the components that GreenDroid requires.  Overriding the default layout was pretty straightforward&#8230;</p>
<div class="codecolorer-container java geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomList <span style="color: #000000; font-weight: bold;">extends</span> GDListActivity <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; initActionBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> createLayout<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">custom_list</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>&#8230; but the updated layout caused a little head scratching.  After some experimentation and inspection of the code in the <a href="https://github.com/cyrilmottier/GreenDroid/tree/master/GDCatalog" title="GDCatalog's GitHub page">GDCatalog app</a>, I came up with the following.</p>
<div class="codecolorer-container xml geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;greendroid.widget.ActionBarHost</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@id/gd_action_bar_host&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; <span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;greendroid.widget.ActionBar</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@id/gd_action_bar&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;@dimen/gd_action_bar_height&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:background</span>=<span style="color: #ff0000;">&quot;?attr/gdActionBarBackground&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;FrameLayout</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@id/gd_action_bar_content_view&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;0dp&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_weight</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:background</span>=<span style="color: #ff0000;">&quot;@color/gray&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- INSERT ORIGINAL LAYOUT HERE --&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ListView</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@android:id/list&quot;</span> </span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_weight</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span><br />
<span style="color: #009900;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">android:cacheColorHint</span>=<span style="color: #ff0000;">&quot;@color/gray&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ListView<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/FrameLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/greendroid.widget.ActionBarHost<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Of note should be the use of a FrameLayout to wrap the content of the original layout.  The IDs for the ActionBarHost, ActionBar and FrameLayout <em>must</em> must not differ from those used above.</p>
<p>And, with that, I added action bars to my interface!</p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2011/08/action-bar-and-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun With Spambots</title>
		<link>http://arusahni.net/blog/2011/07/fun-with-spambots/</link>
		<comments>http://arusahni.net/blog/2011/07/fun-with-spambots/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 03:27:09 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[WTF]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[spambot]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=61</guid>
		<description><![CDATA[Recently, a spambot messaged me... I decided to have a little fun with it.]]></description>
			<content:encoded><![CDATA[<p>Spambots exist to teach people a lesson &#8211; never give your credit card numbers to websites proffered by nubile girls with webcams and far too much free time on their hands.  These bots usually follow a script of <em>&#8220;Hi, how are you? Oh, that&#8217;s nice. I&#8217;m bored and fresh out of the shower.  I&#8217;m going to go on my webcam and expose myself on the internet (because that&#8217;s what us twentysomethings do). Here&#8217;s the site!&#8221;</em></p>
<p>Recently, one messaged me on AIM (yes, I still use it), so I decided to have a little fun with it.  The conversation is after the break.<br />
<span id="more-61"></span></p>
<blockquote><p>
<b>superkanter:</b> hi<br />
<b>the squished:</b> hi<br />
<b>superkanter:</b> Hey what&#8217;s up? 23/F here. u?<br />
<b>the squished:</b> 10/m/basement<br />
<b>superkanter:</b> Hmm. Have we chattted before?<br />
<b>the squished:</b> no, my parents never let me out of my cage<br />
<b>superkanter:</b> Oh sorrrry. l waasnt sure. Butt anywayyyssss.. What r u up to?<br />
<b>the squished:</b> Trying to send a message to the outside world for help<br />
<b>the squished:</b> there were loud bangs upstairs<br />
<b>superkanter:</b> Oooo. lm Iike sooooo bored.<br />
<b>superkanter:</b> Hey l got a idea.. lma get on my web-cam. Do u wanna watcch?<br />
<b>the squished:</b> and now there&#8217;s red stuff coming through the floorboards upstairs<br />
<b>the squished:</b> I think it&#8217;s blood<br />
<b>the squished:</b> but I don&#8217;t want to check<br />
<b>the squished:</b> help me.<br />
<b>the squished:</b> please<br />
<b>superkanter:</b> Yeah? Ok u do have to siggnup for freee cause its settup thru this site so that l cant be recorrded. Ok?<br />
<b>superkanter:</b> K babbe. lt&#8217;s super simplIe<br />
<b>the squished:</b> what? MY PARENTS<br />
<b>superkanter:</b> http://access.im/7/nikki goo there then at the top of the pagge cIlick on the goIld buttton up at the top that says JOlIN FREE. K?<br />
<b>the squished:</b> THEY&#8217;RE DEAAAAAAAAADD<br />
<b>the squished:</b> HELP ME<br />
<b>superkanter:</b> AlIso when you signuup it wilI ask for a creddit card to veriffy your age.<br />
<b>the squished:</b> i think i hear people coming downstairs<br />
<b>the squished:</b> please<br />
<b>superkanter:</b> lt wiIl not charge the carrd at alI. Not even a pennny. Ilts just to make sure that u r over 18. AIriight?<br />
<b>the squished:</b> theyre coming for me<br />
<b>superkanter:</b> K. When you get finisshed and lIogged in then vieew my camm and we can have some fuuunnnn!!!<br />
<b>the squished:</b> Who is this?<br />
<b>superkanter:</b> Im nikki. Dont you remember?<br />
<b>the squished:</b> he told you about us<br />
<b>superkanter:</b> lf you tip me some goId or join me in privte l wilI do anythinng you ask me too.<br />
<b>the squished:</b> you must be eliminated<br />
<b>superkanter:</b> l mean ANYTHlING babe :-X<br />
<b>the squished:</b> Please wait while we backtrace your IP<br />
<b>superkanter:</b> Iets taIlk on the site when you get in. Hurry up im ready to plIay.<br />
<b>the squished:</b> Geolocation complete. We will be seeing you in a few minutes, Nikki.
</p></blockquote>
<p>She done goofed.</p>
<p><iframe width="425" height="349" src="http://www.youtube.com/embed/5PuDWxgIxdc" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2011/07/fun-with-spambots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logo WTF</title>
		<link>http://arusahni.net/blog/2011/04/logo-wtf/</link>
		<comments>http://arusahni.net/blog/2011/04/logo-wtf/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 02:32:33 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[WTF]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=40</guid>
		<description><![CDATA[A funny ad found in a recent issue of Popular Science&#8230;]]></description>
			<content:encoded><![CDATA[<p>A funny ad found in a recent issue of Popular Science&#8230;</p>
<div id="attachment_52" class="wp-caption aligncenter" style="width: 410px"><a href="http://arusahni.net/blog/wp-content/uploads/2011/04/funny-ad.jpg"><img src="http://arusahni.net/blog/wp-content/uploads/2011/04/funny-ad.jpg" alt="Shoe ad" title="Shoe Logo WTF" width="400" height="533" class="size-full wp-image-52" /></a><p class="wp-caption-text">Methinks they didn&#039;t think their logo choice all the way through (click to zoom)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2011/04/logo-wtf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File upload gotcha…</title>
		<link>http://arusahni.net/blog/2011/04/file-upload-gotcha/</link>
		<comments>http://arusahni.net/blog/2011/04/file-upload-gotcha/#comments</comments>
		<pubDate>Sun, 03 Apr 2011 15:29:45 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[AppEngine]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=38</guid>
		<description><![CDATA[Don't leave home without your enctype.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on some much-needed updates to an AppEngine service that processes and serves content based on a CSV version of a spreadsheet.  One of these new features is the ability to upload the spreadsheet via an HTML form.  Of course, being early-ish on a Sunday morning, there was a little head scratching&#8230;</p>
<div class="codecolorer-container html4strict geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/admin&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;file&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;csvfile&quot;</span> <span style="color: #000066;">accept</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/csv&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Update CSV&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Looks ok, right? Not quite.  <code class="codecolorer python geshi"><span class="python"><span style="color: #008000;">self</span>.<span style="color: black;">request</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;csvfile&quot;</span><span style="color: black;">&#41;</span></span></code> only returns the file name!  I must be forgetting something.  After my coffee kicked in, I took another look at it and facepalmed.  The following modification returned what I wanted.</p>
<div class="codecolorer-container html4strict geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/admin&quot;</span> <span style="color: #000066;">enctype</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;multipart/form-data&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span></div></td></tr></tbody></table></div>
<p>Sure enough, adding the &#8220;enctype&#8221; attribute has my code returning the contents of the CSV file.</p>
<p>Moral of the story? Don&#8217;t code before your morning intake of caffeine.</p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2011/04/file-upload-gotcha/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I’m alive!</title>
		<link>http://arusahni.net/blog/2010/09/im-alive/</link>
		<comments>http://arusahni.net/blog/2010/09/im-alive/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 00:50:34 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[the universe and everything.]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=31</guid>
		<description><![CDATA[Someone pinged me to say that I need to update this more often&#8230; or at all, really. My goal with this blog was to fill it with useful content, like clever hacks, product reviews and original musings. I didn&#8217;t want to turn it into a diary. And I won&#8217;t. That being said, here are a [...]]]></description>
			<content:encoded><![CDATA[<p>Someone pinged me to say that I need to update this more often&#8230; or at all, really.</p>
<p>My goal with this blog was to fill it with useful content, like clever hacks, product reviews and original musings.  I didn&#8217;t want to turn it into a diary.  And I won&#8217;t.  That being said, here are a few things I feel are of note&#8230;</p>
<ul>
<li><strong>Droiiiiiiiid</strong>&#8230; Yeah, I dropped the Storm like a bad habit.  I&#8217;m now rocking a HTC Droid Incredible, and it lives up to it&#8217;s name.  The minute I was able to, I rooted it and installed <a href="http://www.cyanogenmod.com/">CyanogenMod 6</a> to get the stock Android experience (plus some).</li>
<li><strong>Vrooooom</strong>&#8230; A car, I need a new one.  I&#8217;m currently trying to decide between a hybrid or ICE Honda Civic.  I&#8217;d go with the extra $$$ for a hybrid, but the reduced acceleration is kind of a turn off.  I figure this is a decision best made after test driving.  Don&#8217;t want to put the horse before the carriage.</li>
<li><strong>10001101</strong>&#8230; I&#8217;ve been dabbling in writing Android applications.  Of course, finding the motivation to follow through on a junk project is very difficult.  Work still has me pounding away at ASP.NET/C#.  For all of the negative flack MS gets, I really do like the features of the ecosystem.</li>
</ul>
<p>I&#8217;ll be updating the site/blog some more over the next few weeks.  I promise!</p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2010/09/im-alive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter for BlackBerry®</title>
		<link>http://arusahni.net/blog/2010/05/twitter-for-blackberry/</link>
		<comments>http://arusahni.net/blog/2010/05/twitter-for-blackberry/#comments</comments>
		<pubDate>Fri, 21 May 2010 02:40:32 +0000</pubDate>
		<dc:creator>aru</dc:creator>
				<category><![CDATA[Review]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=8</guid>
		<description><![CDATA[Note: This is an old review that has been sitting in my draft folder.  Rather than delete it, I decided to publish it.  The content may be outdated as I was testing the first official release. Recently, Twitter made waves in the tech world by buying Tweetie (renaming it Twitter for iPhone) and launching their [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: This is an old review that has been sitting in my draft folder.  Rather than delete it, I decided to publish it.  The content may be outdated as I was testing the first official release.</em></p>
<p>Recently, Twitter made waves in the tech world by buying Tweetie (<a href="http://blog.twitter.com/2010/04/twitter-for-iphone.html">renaming it Twitter for iPhone</a>) and launching their own BlackBerry (<a href="http://appworld.blackberry.com/webstore/content/8160">App  World</a>) and Android (<a title="Twitter for Android" href="http://www.androlib.com/android.application.com-twitter-android-CDnF.aspx">QR here</a>) clients.  I&#8217;ve been a long-time ÜberTwitter user, but decided to see what sort of experience the official Twitter app for BlackBerry could provide.  Click past the jump for my review!</p>
<h3><span id="more-8"></span>Look and Feel</h3>
<div id="attachment_12" class="wp-caption aligncenter" style="width: 235px"><a href="http://arusahni.net/blog/wp-content/uploads/2010/04/Capture20_1_2.jpg"><img class="size-medium wp-image-12" title="Main Timeline" src="http://arusahni.net/blog/wp-content/uploads/2010/04/Capture20_1_2-225x300.jpg" alt="A screen shot of the main timeline in the Twitter client for BlackBerry" width="225" height="300" /></a><p class="wp-caption-text">The main timeline.</p></div>
<p>As you can see, the interface is very well laid out an attractive.  The top row of icons provides quick navigation to various timeline views, including mentions, lists and DMs.  There&#8217;s also a text area beneath that can send out a quick tweet or TwitPic.  The hover effects over buttons and links have a nice green glow and there are smooth animations everywhere.</p>
<div id="attachment_16" class="wp-caption aligncenter" style="width: 235px"><a href="http://arusahni.net/blog/wp-content/uploads/2010/04/Capture20_0_2.jpg"><img class="size-medium wp-image-16" title="Trending Topics Word Cloud" src="http://arusahni.net/blog/wp-content/uploads/2010/04/Capture20_0_2-225x300.jpg" alt="The word cloud on the trending topics screen" width="225" height="300" /></a><p class="wp-caption-text">The last thing you want is for tweens to come after you for butchering their idol&#39;s name.</p></div>
<p>As you can, see, though, not everything has been polished in this first release.  There are some obvious glitches/clipping effects in the Trending Topics word cloud (see above).  On the main timeline, the input area is better in theory than in practice &#8211; the update button resides just above the top row of the on-screen keyboard, leading to accidental tweets.  Finally, when compared to other Twitter clients for BlackBerry, tweets on the timeline take up far too much space, resulting in fewer tweets on screen.</p>
<h3>Functionality</h3>
<p>One would think this is the area in which an official client would excel.  However, after using the client for a week, there were several deficiencies that took away from the overall experience of the program.</p>
<ul>
<li><strong>Limited photo support</strong>: Not all popular image services are supported.  This is something that they claim to have fixed in a recent update, but I still find it unsatisfactory.</li>
<li><strong>Bad touchscreen UI</strong>: Yes, I know, BlackBerry doesn&#8217;t really come to mind when associated with the word &#8220;touchscreen&#8221;, but with the huge push the Storm received one would have hoped for a sensible UI.  Unfortunately, the icon bar at the top of the app has hard-to-hit icons, and when the virtual keyboard was out I found myself accidentally tapping the &#8220;Update&#8221; button, leaving me to suffer from the indignity of a partial tweet.</li>
<li><strong>Insufficient Refresh Intervals</strong>:  This is a purely subjective issue, but I like updating my timeline every 3 minutes.  They didn&#8217;t offer a rate that low.</li>
</ul>
<h3><strong>Judgement</strong></h3>
<p>Twitter for BlackBerry is a well put-together client, and is especially impressive for a 1.0 release.  RIM has been active in addressing user feedback, and has polished rough edges and added features (like commenting on retweets) after it became apparent that they were wanted by the community.</p>
<p>However, given my usage patterns, I always find myself going back to ÜberTwitter.  While it may not be as pretty as the official client, it&#8217;s features and usability are unmatched.</p>
<p><strong>Verdict:</strong> Definitely check out Twitter for BlackBerry. It might be what you&#8217;ve been searching for all this time.</p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2010/05/twitter-for-blackberry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pardon My Dust</title>
		<link>http://arusahni.net/blog/2010/04/pardon-my-dust/</link>
		<comments>http://arusahni.net/blog/2010/04/pardon-my-dust/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 21:19:50 +0000</pubDate>
		<dc:creator>Aru</dc:creator>
				<category><![CDATA[Site]]></category>

		<guid isPermaLink="false">http://arusahni.net/blog/?p=4</guid>
		<description><![CDATA[Still getting things set up here.  Looking forward to getting back into the blogging saddle.]]></description>
			<content:encoded><![CDATA[<p>Still getting things set up here.  Looking forward to getting back into the blogging saddle.</p>
]]></content:encoded>
			<wfw:commentRss>http://arusahni.net/blog/2010/04/pardon-my-dust/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

