<?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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tristan Waddington</title>
	
	<link>http://www.tristanwaddington.com</link>
	<description>Web and Mobile Development</description>
	<lastBuildDate>Sat, 04 May 2013 05:25:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6-beta1-23983</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/twaddington" /><feedburner:info uri="twaddington" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Getting started with the new Android build system</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/iCX0D8FjU-o/</link>
		<comments>http://www.tristanwaddington.com/2013/05/getting-started-with-the-new-android-build-system/#comments</comments>
		<pubDate>Sat, 04 May 2013 05:25:11 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[android build gradle ant maven groovy adt]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1287</guid>
		<description><![CDATA[As many of you might be aware, the Android Development Tools team is working on a brand new build system. The new system has been in development for a while now, but is being officially announced at Google I/O 2013. &#8230; <a href="http://www.tristanwaddington.com/2013/05/getting-started-with-the-new-android-build-system/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As many of you might be aware, the Android Development Tools team is working on a brand new build system. The new system has been in development for a while now, but is being officially announced at <a href="https://developers.google.com/events/io/sessions/325236644">Google I/O 2013</a>. The updated build system does away with Ant and moves to the Gradle build automation tool. You can read more about Gradle at <a href="http://www.gradle.org">gradle.org</a>. The new Android build system is documented on the Android Developer Tools site at <a href="http://tools.android.com/tech-docs/new-build-system">tools.android.com</a>.</p>
<p>Getting started with the new build system is relatively easy. To get started you&#8217;ll need to make sure you have both Maven and Gradle installed.</p>
<h2>Install Homebrew</h2>
<p>If you&#8217;re working on OS X you can make your life a whole lot easier by installing <a href="http://brew.sh/">Homebrew</a>. If you don&#8217;t already have it installed, you can install it by running the following command from your terminal:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">    $ ruby <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)</span>&quot;</span></pre></td></tr></table></div>

<h2>Install Maven</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">    $ brew <span style="color: #c20cb9; font-weight: bold;">install</span> maven</pre></td></tr></table></div>

<h2>Install Gradle</h2>
<p>As of May, 2013, the new Android build system only supports Gradle versions 1.3/1.4. This means it won&#8217;t work with the latest version of Gradle. You&#8217;ll have to follow the instructions at <a href="http://www.gradle.org/installation">gradle.org/installation</a> to install a prior version of Gradle.  Otherwise you could simply install the latest version using Homebrew.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">    $ brew <span style="color: #c20cb9; font-weight: bold;">install</span> gradle</pre></td></tr></table></div>

<p>You can verify you have the correct version of Gradle installed using the following command:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">    $ gradle <span style="color: #660033;">-v</span></pre></td></tr></table></div>

<p>You should see output that looks something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
    <span style="color: #660033;">------------------------------------------------------------</span>
    Gradle <span style="color: #000000;">1.3</span>
    <span style="color: #660033;">------------------------------------------------------------</span>
&nbsp;
    Gradle build time: Tuesday, November <span style="color: #000000;">20</span>, <span style="color: #000000;">2012</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">37</span>:<span style="color: #000000;">38</span> AM UTC
    Groovy: 1.8.6
    Ant: Apache Ant<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> version 1.8.4 compiled on May <span style="color: #000000;">22</span> <span style="color: #000000;">2012</span>
    Ivy: 2.2.0
    JVM: 1.6.0_45 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Apple Inc. <span style="color: #000000;">20.45</span>-b01-<span style="color: #000000;">451</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    OS: Mac OS X 10.8.3 x86_64</pre></td></tr></table></div>

<h2>Add a build.gradle to your project</h2>
<p>Add the following <code>build.gradle</code> file to the root of your Android project:</p>
<p><script src="https://gist.github.com/twaddington/5516182.js"></script></p>
<h2>Build your project</h2>
<p>You should now be able to build your project using the following command:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">    $ gradle clean installDebug</pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/twaddington/~4/iCX0D8FjU-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2013/05/getting-started-with-the-new-android-build-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2013/05/getting-started-with-the-new-android-build-system/</feedburner:origLink></item>
		<item>
		<title>Updating your app to support 7-inch tablets</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/7zWCvs8RR10/</link>
		<comments>http://www.tristanwaddington.com/2013/03/updating-your-app-to-target-7-inch-tablets/#comments</comments>
		<pubDate>Wed, 27 Mar 2013 04:06:48 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[7-inch]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[nexus]]></category>
		<category><![CDATA[nexus 7]]></category>
		<category><![CDATA[tablet]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1274</guid>
		<description><![CDATA[Recently I&#8217;ve spent a lot of time thinking about how to optimize our app layouts for 7-inch tablets like the Nexus 7. It&#8217;s not an easy process, but a few tricks will make your life a whole lot easier. As &#8230; <a href="http://www.tristanwaddington.com/2013/03/updating-your-app-to-target-7-inch-tablets/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently I&#8217;ve spent a lot of time thinking about how to optimize our app layouts for 7-inch tablets like the Nexus 7. It&#8217;s not an easy process, but a few tricks will make your life a whole lot easier.</p>
<p>As of today, the two most common screen resolutions in the 7-inch category are <code>1280x800 - WXGA</code> and <code>1024x600 - WSVGA</code>. Higher-end tablets like the Nexus 7 have a <code>1280x800</code> resolution and thus a higher pixel density. Lower-end tablets like the Samsung Galaxy Tab use a <code>1024x600</code> resolution and have a lower pixel density.</p>
<p>The Nexus 7 has a pixel density of around 213ppi and technically falls into the unique <code>tvdpi</code> density bucket, but for all intents and purposes you can consider it an <code>hdpi</code> device. Lower-end devices with a <code>1024x600</code> resolution have a pixel density of approximately 170ppi and will typically use <code>mdpi</code> assets. I don&#8217;t know of any 7-inch devices with an <code>xhdpi</code> pixel density, but I&#8217;m sure we&#8217;ll see some hit the market soon.</p>
<p>Regardless of the resolution, all 7-inch Android devices fall into the <code>600dp</code> category. That is, they have a width of 600 density-independent pixels when in portrait orientation. We can use this width to provide alternative resources for these devices.</p>
<p>For starters, if you want to specify a custom layout for 7-inch devices you can simply add a new <code>res/layout-sw600dp</code> directory. Any layouts in this directory will be applied to devices that have a &#8220;smallest-width&#8221; of &#8220;600dp&#8221;.</p>
<p>If you don&#8217;t want to provide a completely different layout, but want to bump up the size of all your elements slightly you can use the <code>res/values-sw600dp</code> directory. Any resources provided here like <code>dimens.xml</code> or <code>styles.xml</code> will take precedence on devices like the Nexus 7. This way you can have a single layout file that references dimensions or styles that are dynamic based on the device size.</p>
<p>Finally, you might want to provide alternative drawable resources for 7-inch tablets. You can combine the <code>sw600dp</code> resource qualifier with a density qualifier to provide alternative drawables:</p>
<ul>
<li><code>res/drawable-sw600dp-mdpi</code></li>
<li><code>res/drawable-sw600dp-hdpi</code></li>
<li><code>res/drawable-sw600dp-xhdpi</code></li>
</ul>
<p>As you can see we&#8217;ve simply added the <code>sw600dp</code> qualifier to our typical drawable directories. These resources will be applied to devices of the correct screen density, but only if they are 7-inch tablets or larger.</p>
<p>All of these techniques are also applicable to targeting 10-inch tablets. Simply replace the <code>600dp</code> width qualifier with <code>720dp</code> in the case of 10-inch devices.</p>
<h2>Further reading</h2>
<ul>
<li><a href="http://developer.android.com/guide/practices/screens_support.html#ConfigurationExamples">Android Developers &#8211; Supporting Multiple Screens</a></li>
<li><a href="https://plus.google.com/105051985738280261832/posts/6eWwQvFGLV8">Dianne Hackborn on the Nexus 7</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/7zWCvs8RR10" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2013/03/updating-your-app-to-target-7-inch-tablets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2013/03/updating-your-app-to-target-7-inch-tablets/</feedburner:origLink></item>
		<item>
		<title>Styling the Android Action Bar title using a custom typeface</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/FXAgfZefMmI/</link>
		<comments>http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/#comments</comments>
		<pubDate>Sun, 03 Mar 2013 00:34:55 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[typeface]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1230</guid>
		<description><![CDATA[Styling the Action Bar in Android can frequently seem difficult, if not impossible. It&#8217;s easy to do wrong and hard to do right. However, customizing the Action Bar title with a custom typeface is a surprisingly easy way to spruce &#8230; <a href="http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Styling the Action Bar in Android can frequently seem difficult, if not impossible. It&#8217;s easy to do wrong and hard to do right. However, customizing the Action Bar title with a custom typeface is a surprisingly easy way to spruce up your app design.</p>
<p>There are <a href="http://stackoverflow.com/questions/8607707/how-to-set-a-custom-font-in-the-actionbar-title">several</a> <a href="http://stackoverflow.com/questions/10779037/set-activity-title-ellipse-to-middle">posts</a> on Stack Overflow that recommend accomplishing this by leveraging the Action Bar&#8217;s custom view feature, or by getting a reference to the title TextView. These solutions are adequate but can lead to infuriating edge cases. We can do better.</p>
<p>You might have come across the <a href="http://developer.android.com/reference/android/text/style/TypefaceSpan.html"><code>TypefaceSpan</code></a> class, which allows you to style a section of text in a <code>TextView</code> with a monospace or serif font. This is almost what we want to do, but we need to be able to provide our own <code>Typeface</code> instance.</p>
<p>Here&#8217;s what a custom <code>TypefaceSpan</code> might look like in use:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">    SpannableString s <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SpannableString<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;My Title&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    s.<span style="color: #006633;">setSpan</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> TypefaceSpan<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #0000ff;">&quot;MyTypeface&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">0</span>, s.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
            Spannable.<span style="color: #006633;">SPAN_EXCLUSIVE_EXCLUSIVE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Update the action bar title with the TypefaceSpan instance</span>
    ActionBar actionBar <span style="color: #339933;">=</span> getActionBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    actionBar.<span style="color: #006633;">setTitle</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Notice that we simply create a <code>SpannableString</code> with our desired Action Bar title. We then create a new instance of our custom <code>TypefaceSpan</code> providing it with our Activity context and the typeface name as arguments (so it can load the typeface from our application&#8217;s assets directory). The span is set on the entire length of the title (<code>... 0, s.length(), ...</code>).  Finally, we pass in the <code>Spannable.SPAN_EXCLUSIVE_EXCLUSIVE</code> flag, which simply indicates that the span should be removed if all of the spanned text is deleted. Here&#8217;s what the result might look like:</p>
<p><a href="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_bender.png"><img class="aligncenter size-full wp-image-1245" alt="android_action_bar_typeface_bender" src="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_bender.png" width="720" height="146" /></a></p>
<p><a href="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_cubano.png"><img class="aligncenter size-full wp-image-1247" alt="android_action_bar_typeface_cubano" src="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_cubano.png" width="720" height="146" /></a></p>
<p><a href="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_gotham.png"><img class="aligncenter size-full wp-image-1246" alt="android_action_bar_typeface_gotham" src="http://www.tristanwaddington.com/wp-content/uploads/2013/03/android_action_bar_typeface_gotham.png" width="720" height="146" /></a></p>
<p>But what does the custom <code>TypefaceSpan</code> implementation look like? Well, it&#8217;s surprisingly simple. I&#8217;ve created an example you can use in your own apps. You can get it at <a href="https://gist.github.com/twaddington/b91341ea5615698b53b8">gist.github.com/twaddington/b91341ea5615698b53b8</a>. Simply copy this class into your application and use it like I&#8217;ve indicated above. You can even subclass the custom <code>TypefaceSpan</code> to add additional styles like colors or text shadows.</p>
<h2>Fonts Shown</h2>
<ul>
<li><a href="http://www.losttype.com/font/?name=Bender">Lost Type Co-op: Bender</a></li>
<li><a href="http://www.losttype.com/font/?name=Cubano">Lost Type Co-op: Cubano</a></li>
<li><a href="http://www.typography.com/fonts/font_overview.php?productLineID=100008">Hoefler &#038; Frere-Jones: Gotham</a></li>
</ul>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/FXAgfZefMmI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2013/03/styling-the-android-action-bar-with-a-custom-font/</feedburner:origLink></item>
		<item>
		<title>Android TextView with custom Typeface support</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/8x4yWBz7qIU/</link>
		<comments>http://www.tristanwaddington.com/2012/09/android-textview-with-custom-font-support/#comments</comments>
		<pubDate>Mon, 17 Sep 2012 21:00:46 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[typeface]]></category>
		<category><![CDATA[views]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1175</guid>
		<description><![CDATA[Currently Android does not have a native View class that supports defining a custom Typeface in your layout&#8217;s XML. After inflating your layout you can obtain a reference to the TextView and call the setTypeface(android.graphics.Typeface) method from your Java code, &#8230; <a href="http://www.tristanwaddington.com/2012/09/android-textview-with-custom-font-support/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Currently Android does not have a native View class that supports defining a custom <a href="http://developer.android.com/reference/android/graphics/Typeface.html">Typeface</a> in your layout&#8217;s XML. After inflating your layout you can obtain a reference to the TextView and call the <a href="http://developer.android.com/reference/android/widget/TextView.html#setTypeface(android.graphics.Typeface)"><code>setTypeface(android.graphics.Typeface)</code></a> method from your Java code, but this results in unnecessary duplication of logic and violates the <attr title="Don't Repeat Yourself">DRY</attr> principle.<span id="more-1175"></span></p>
<p>The solution is to write a custom TextView implementation with support for <a href="http://developer.android.com/training/custom-views/create-view.html#customattr">defining custom attributes</a>.</p>
<p>The first thing you should do is create the file <code>attrs.xml</code> in your project&#8217;s <code>res/values</code> directory. Save the following XML to your new file:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><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>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;declare-styleable</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;TypefaceTextView&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;attr</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;typeface&quot;</span> <span style="color: #000066;">format</span>=<span style="color: #ff0000;">&quot;string&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/declare-styleable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This XML simply defines the custom attribute <code>typeface</code> for the not yet existing class <code>TypefaceTextView</code>. It also notes that the attribute value should be parsed as a string.</p>
<p>You can now create the new class <code>TypefaceTextView.java</code> using the following source code:</p>
<p><script src="https://gist.github.com/3739637.js?file=TypefaceTextView.java"></script></p>
<p>You can see that the class simply looks for the custom <code>typeface</code> attribute and attempts to load the named font from your application&#8217;s <code>assets/fonts</code> directory at runtime. The class implements a static <a href="http://developer.android.com/reference/android/support/v4/util/LruCache.html">LruCache</a> to avoid unnecessary hits to disk for fonts that were previously loaded. Note that if you&#8217;re targeting API levels prior to 12 the LruCache is only available using the Android support library.</p>
<p>Assuming you have the font file <code>GothamBold-Family.otf</code> in your project&#8217;s <code>assets/fonts</code> directory, then you can use the custom <code>TypefaceTextView</code> class in your layouts like so:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><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>
<span style="color: #009900;">    <span style="color: #000066;">xmlns:simple</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/com.simple&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;match_parent&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;match_parent&quot;</span></span>
<span style="color: #009900;">    <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>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;com.simple.widget.TypefaceTextView</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;match_parent&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Hello, Gotham!&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">simple:typeface</span>=<span style="color: #ff0000;">&quot;GothamBold&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&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></pre></td></tr></table></div>

<p>If you have another font you wish to use, simply update the value of the <code>simple:typeface</code> attribute of your view. In this way you can use the same class to display a variety of custom typefaces in your Android application.</p>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/8x4yWBz7qIU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/09/android-textview-with-custom-font-support/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/09/android-textview-with-custom-font-support/</feedburner:origLink></item>
		<item>
		<title>Emulating the Android People application’s ListView style</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/SIfj0iPa-Vw/</link>
		<comments>http://www.tristanwaddington.com/2012/09/implementing-the-android-contact-applications-listview-layout/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 07:20:17 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[contacts]]></category>
		<category><![CDATA[ice cream sandwich]]></category>
		<category><![CDATA[ics]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[listview]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[people]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1179</guid>
		<description><![CDATA[As of Android Ice Cream Sandwich (4.0.x), the default contacts application sports a fantastic new look. It&#8217;s both fast and appealing. One of the more interesting aspects of the application is the design of the main contacts list. The ListView &#8230; <a href="http://www.tristanwaddington.com/2012/09/implementing-the-android-contact-applications-listview-layout/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As of Android Ice Cream Sandwich (4.0.x), the default contacts application sports a fantastic new look. It&#8217;s both fast and appealing. One of the more interesting aspects of the application is the design of the main contacts list.<span id="more-1179"></span></p>
<p>The <code>ListView</code> eschews the typical full-width layout in lieu of a padded layout with white margins on either side. These gutters allow for a persistent fast-scroll bar. Because of the extra white space provided by the gutters, the persistent scroll bar does not obscure the most important information, your contacts. It also provides a convenient way to quickly scrub through a long list of people (most of whom you never talk to anymore).</p>
<p>It was not immediately clear to me how they accomplished this layout. I was still puzzled even after reading through the <a href="https://github.com/android/platform_packages_apps_contacts/">source of the Contacts application</a>.</p>
<p>Finally, after a great deal of thought and experimentation, I believe I&#8217;ve stumbled on the solution, and it&#8217;s really quite elegant.</p>
<p>Essentially, the key is the view&#8217;s <a href="http://developer.android.com/reference/android/view/View.html#setScrollBarStyle%28int%29"><code>setScrollBarStyle(int style)</code></a> method. The default style appears to be <a href="http://developer.android.com/reference/android/view/View.html#SCROLLBARS_INSIDE_OVERLAY"><code>SCROLLBARS_INSIDE_OVERLAY</code></a>, which overlays the scroll bar on top of your list items without affecting the layout. This means that adding padding to the list view element will nudge the scroll bar in with the rest of your list content. </p>
<p>However, changing the scroll bar style to <a href="http://developer.android.com/reference/android/view/View.html#SCROLLBARS_OUTSIDE_OVERLAY"><code>SCROLLBARS_OUTSIDE_OVERLAY</code></a> places the scroll bar at the edge of the <code>ListView</code>, outside of your padding! This means that you can easily add padding to the list view element itself and the scroll bar will stay exactly where you want it.</p>
<p>In practice this can be done with very little effort:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Style the &lt;code&gt;ListView&lt;/code&gt; with a persistent scroll bar. */</span>
    @TargetApi<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> setPersistentScrollBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">ListView</span> lv <span style="color: #339933;">=</span> getListView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        lv.<span style="color: #006633;">setFastScrollEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        lv.<span style="color: #006633;">setFastScrollAlwaysVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        lv.<span style="color: #006633;">setScrollBarStyle</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span>.<span style="color: #006633;">SCROLLBARS_OUTSIDE_OVERLAY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Resources r <span style="color: #339933;">=</span> getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> leftPadding <span style="color: #339933;">=</span> r.<span style="color: #006633;">getDimensionPixelSize</span><span style="color: #009900;">&#40;</span>
                R.<span style="color: #006633;">dimen</span>.<span style="color: #006633;">list_view_padding_left</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> rightPadding <span style="color: #339933;">=</span> r.<span style="color: #006633;">getDimensionPixelSize</span><span style="color: #009900;">&#40;</span>
                R.<span style="color: #006633;">dimen</span>.<span style="color: #006633;">list_view_padding_right</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Add left and right padding to the ListView to accommodate the</span>
        <span style="color: #666666; font-style: italic;">// persistent scroll bar.</span>
        lv.<span style="color: #006633;">setPadding</span><span style="color: #009900;">&#40;</span>leftPadding, <span style="color: #cc66cc;">0</span>, rightPadding, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Dropping the <code>setPersistentScrollBar()</code> method into your <code>ListActivity</code> or <code>ListFragment</code> and invoking it in your <code>onCreate(Bundle savedInstanceState)</code> or <code>onActivityCreated(Bundle savedInstanceState)</code> (respectively) method should prove sufficient.</p>
<p>The only slightly tricky part is correctly padding the list view. In the example above, we&#8217;re specifying the padding in our code. However, you could easily do the same in your XML layout. For the example above to work properly, you&#8217;ll need to create a <code>dimens.xml</code> resource in your project&#8217;s <code>res/xml</code> directory that contains the following XML:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><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>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dimen</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;list_view_padding_left&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>16dp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dimen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dimen</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;list_view_padding_right&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>32dp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dimen<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Finally, if you&#8217;re wondering how the pinned list headers work in the Contacts application, you should look over the <a href="https://github.com/android/platform_packages_apps_contacts/blob/master/src/com/android/contacts/widget/PinnedHeaderListDemoActivity.java"><code>PinnedHeaderListDemoActivity.java</code></a> example in the Contact application source.</p>
<p>Happy coding!</p>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/SIfj0iPa-Vw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/09/implementing-the-android-contact-applications-listview-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/09/implementing-the-android-contact-applications-listview-layout/</feedburner:origLink></item>
		<item>
		<title>Appcelerator Titanium KrollDict fails to sanitize JSONObject.NULL values</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/YLR9HVbvKzk/</link>
		<comments>http://www.tristanwaddington.com/2012/07/appcelerator-titanium-krolldict-fails-to-sanitize-jsonobject-null-values/#comments</comments>
		<pubDate>Thu, 26 Jul 2012 06:35:33 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[appcelerator]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1158</guid>
		<description><![CDATA[If you&#8217;re developing an Appcelerator Titanium module for Android it&#8217;s possible that you&#8217;ll run into this exception (see bottom of post for full exception trace): !!! Unable to convert unknown Java object class 'org.json.JSONObject$1' to Js value !!! It took &#8230; <a href="http://www.tristanwaddington.com/2012/07/appcelerator-titanium-krolldict-fails-to-sanitize-jsonobject-null-values/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re developing an Appcelerator Titanium module for Android it&#8217;s possible that you&#8217;ll run into this exception (see bottom of post for full exception trace):</p>
<p><code>!!! Unable to convert unknown Java object class 'org.json.JSONObject$1' to Js value !!!</code></p>
<p>It took me a long time to track down the cause of this error, but essentially the issue is in the JNI layer, which passes native Java objects to the Javascript layer does not know how to handle a <code>JSONObject.NULL</code> value. The Titanium wrapper object <code>KrollDict</code> attempts to convert all non-native Java objects into native ones. <code>JSONObject</code> becomes a simple <code>Map</code>, JSONArray becomes an <code>ArrayList</code> and so on. However, the constructor fails to account for instances of the <a href="http://developer.android.com/reference/org/json/JSONObject.html#NULL"><code>JSONObject.NULL</code></a> object, which is not a simple primitive.</p>
<p>An easy work around would be to ensure the JSON objects that you&#8217;re passing around never have any true JSON null values in them. You can replace them with empty strings, or simply remove the key from the object altogether. This is ultimately the fix we went with. However, a simple two-line patch should solve this issue in the core Titanium code:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="diff" style="font-family:monospace;">From 57868ea5b<span style="color: #440088;">822468563d4</span>a1be2adb901cce383f11 Mon Sep <span style="">17</span> 00:00:00 <span style="">2001</span>
From: Tristan Waddington &lt;tristan.waddington@gmail.com&gt;
Date: Mon, <span style="">4</span> Jun <span style="">2012</span> <span style="">14</span>:<span style="">24</span>:<span style="">15</span> -0700
Subject: <span style="">&#91;</span>PATCH<span style="">&#93;</span> Update the 'fromJSON' method of 'KrollDict' to map the
 'JSONObject.NULL' Object to a real Java null
 representation.
&nbsp;
<span style="color: #888822;">---
 android/titanium/src/java/org/appcelerator/kroll/KrollDict.java |    2 ++</span>
 <span style="">1</span> file changed, <span style="">2</span> insertions<span style="">&#40;</span>+<span style="">&#41;</span>
&nbsp;
diff --git a/android/titanium/src/java/org/appcelerator/kroll/KrollDict.java b/android/titanium/src/java/org/appcelerator/kroll/KrollDict.java
index da29217..<span style="color: #440088;">96017d6</span> <span style="">100644</span>
<span style="color: #888822;">--- a/android/titanium/src/java/org/appcelerator/kroll/KrollDict.java</span>
<span style="color: #888822;">+++ b/android/titanium/src/java/org/appcelerator/kroll/KrollDict.java</span>
<span style="color: #440088;">@@ -56,6 +56,8 @@ public static Object fromJSON<span style="">&#40;</span>Object value<span style="">&#41;</span> <span style="">&#123;</span></span>
 					values<span style="">&#91;</span>i<span style="">&#93;</span> = fromJSON<span style="">&#40;</span>array.get<span style="">&#40;</span>i<span style="">&#41;</span><span style="">&#41;</span>;
 				<span style="">&#125;</span>
 				return values;
<span style="color: #00b000;">+			<span style="">&#125;</span> else if <span style="">&#40;</span>value == JSONObject.NULL<span style="">&#41;</span> <span style="">&#123;</span></span>
<span style="color: #00b000;">+				return null;</span>
 			<span style="">&#125;</span>
 		<span style="">&#125;</span> catch <span style="">&#40;</span>JSONException e<span style="">&#41;</span> <span style="">&#123;</span>
 			Log.e<span style="">&#40;</span>TAG, &quot;Error parsing JSON&quot;, e<span style="">&#41;</span>;
<span style="color: #991111;">-- </span>
1.7.10</pre></td></tr></table></div>

<p>I submitted a <a href="https://github.com/appcelerator/titanium_mobile/pull/2318">pull request</a> to the <a href="https://github.com/appcelerator/titanium_mobile">titanium_mobile</a> repository on GitHub, but all contributors are required to sign a Contributor License Agreement (CLA). Not a big deal, but I don&#8217;t expect to ever submit another patch to this project, so I&#8217;m not inclined to spend a day getting their dev environment bootstrapped and sign my life away for a two-line bug fix (yes, I wrote a passive-aggressive blog post instead).</p>
<p>Unfortunately, they don&#8217;t even seem interested in accepting the patch as a simple bug report so someone else can fix it:</p>
<p><a href="http://www.tristanwaddington.com/wp-content/uploads/2012/07/Screen-Shot-2012-07-25-at-11.29.53-PM.png"><img src="http://www.tristanwaddington.com/wp-content/uploads/2012/07/Screen-Shot-2012-07-25-at-11.29.53-PM-580x228.png" alt="" title="Appcelerator Titanium Pull Request Disinterest" width="580" height="228" class="aligncenter size-medium wp-image-1167" /></a></p>
<p>If you&#8217;re trying to build a platform that&#8217;s meant to be developer focused, willful disinterest is not the best response. If you&#8217;re curious, here&#8217;s the raw <a href="https://github.com/appcelerator/titanium_mobile/pull/2318.patch">patch file</a> and the full exception:</p>
<p><script src="https://gist.github.com/2dd449f4fbb9e6c5b7f3.js"> </script></p>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/YLR9HVbvKzk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/07/appcelerator-titanium-krolldict-fails-to-sanitize-jsonobject-null-values/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/07/appcelerator-titanium-krolldict-fails-to-sanitize-jsonobject-null-values/</feedburner:origLink></item>
		<item>
		<title>Google I/O 2012 – Sessions to Watch</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/yb8MZ_yleNM/</link>
		<comments>http://www.tristanwaddington.com/2012/07/google-io-2012-sessions-to-watch/#comments</comments>
		<pubDate>Mon, 02 Jul 2012 19:03:40 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[2012]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[google io]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1137</guid>
		<description><![CDATA[I recently returned from an awesome trip to San Francisco for my first year of Google I/O. It was a great year to be there and I met some fantastic developers. When I got back my friends asked me what &#8230; <a href="http://www.tristanwaddington.com/2012/07/google-io-2012-sessions-to-watch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I recently returned from an awesome trip to San Francisco for my first year of Google I/O. It was a great year to be there and I met some fantastic developers.</p>
<p>When I got back my friends asked me what sessions they should watch.<span id="more-1137"></span> Really the answer is all of them, as they were mostly fantastic. However, I&#8217;ve attempted to subjectively compile the best sessions in the list below:</p>
<div style="clear: both;"></div>
<h3>Keynote</h3>
<ul>
<li><a href="http://youtu.be/VuC0i4xTyrI?hd=1">Keynote Day 1</a></li>
<li><a href="http://youtu.be/tPtJd6AzU8c?hd=1">Keynote Day 2</a></li>
<li><a href="http://youtu.be/mrcy3m3rPGM?hd=1">Behind the Scenes: Glass Demo Day 2</a></li>
</ul>
<h3>Android</h3>
<ul>
<li><a href="http://youtu.be/Yc8YrVc47TI?hd=1">What&#8217;s New in Android?</a></li>
<li><a href="http://youtu.be/Erd2k6EKxCQ?hd=1">What&#8217;s New in Android Developers&#8217; Tools</a></li>
<li><a href="http://youtu.be/gbQb1PVjfqM?hd=1">Doing More With Less: Being a Good Android Citizen</a> **</li>
<li><a href="http://youtu.be/PwC1OlJo5VM?hd=1">Making Good Apps Great: More Advanced Topics for Expert Android Developers</a> **</li>
<li><a href="http://youtu.be/amZM8oZBgfk?hd=1">Multi-Versioning Android User Interfaces</a></li>
<li><a href="http://youtu.be/XwGHJJYBs0Q?hd=1">Navigation in Android</a></li>
<li><a href="http://youtu.be/2jCVmfCse1E?hd=1">So You&#8217;ve Read the Design Guide; Now What?</a></li>
<li><a href="http://goo.gl/UmU7w">Google Cloud Messaging</a></li>
</ul>
<h3>Google Maps</h3>
<ul>
<li><a href="http://youtu.be/e0K805PeOfI?hd=1">What&#8217;s New in Google Maps?</a></li>
<li><a href="http://youtu.be/Xho2RCqRLYE?hd=1">Maps For Good</a></li>
<li><a href="http://youtu.be/5nRNbKPiSQ8?hd=1">Best Practices for Maps API Developers</a></li>
</ul>
<h3>Web</h3>
<ul>
<li><a href="http://youtu.be/YxogQGnMA9Y?hd=1">Putting the App Back into Web App &#8211; Web Programming with Dart</a></li>
<li><a href="http://youtu.be/O1YjdKh-rPg?hd=1">How to Build Apps that Love Each Other with Web Intents</a></li>
<li><a href="http://youtu.be/ws2VRHq5ars?hd=1">Google Compute Engine &#8212; Technical Details</a></li>
</ul>
<h3>Accessibility</h3>
<ul>
<li><a href="http://youtu.be/q3HliaMjL38?hd=1">Making Android Apps Accessible</a></li>
<li><a href="http://youtu.be/iY-_tO_L3VQ?hd=1">Advancing Accessibility for the Web</a></li>
<li><a href="http://youtu.be/xSGA19rG_D8?hd=1">Developing for a Global Audience: Tools for Localization and Internationalization</a></li>
</ul>
<p>Finally, here is a list of all the recorded <a href="http://www.youtube.com/user/GoogleDevelopers/videos?query=2012">sessions from Google I/O 2012</a>.</p>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/yb8MZ_yleNM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/07/google-io-2012-sessions-to-watch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/07/google-io-2012-sessions-to-watch/</feedburner:origLink></item>
		<item>
		<title>SQLite fire DELETE trigger on a REPLACE</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/x67SCaOctos/</link>
		<comments>http://www.tristanwaddington.com/2012/06/sqlite-fire-delete-trigger-on-a-replac/#comments</comments>
		<pubDate>Sun, 03 Jun 2012 00:47:51 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1114</guid>
		<description><![CDATA[If you&#8217;re using SQLite you might be surprised to know that any DELETE triggers you&#8217;ve created will not fire after a REPLACE operation by default. Delete triggers fire when rows are removed due to a REPLACE conflict resolution. This feature &#8230; <a href="http://www.tristanwaddington.com/2012/06/sqlite-fire-delete-trigger-on-a-replac/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re using SQLite you might be surprised to know that any DELETE triggers you&#8217;ve created <a href="http://www.sqlite.org/draft/changes.html#version_3_6_18">will not fire after a REPLACE operation</a> by default.</p>
<blockquote><p>
Delete triggers fire when rows are removed due to a REPLACE conflict resolution. This feature is only enabled when recursive triggers are enabled.
</p></blockquote>
<p>This was causing us some grief in one of our Android projects where we were using a virtual table for full-text search. Whenever we updated the products table we had a trigger fire to update the virtual-table. However, when we did a REPLACE into the product table a duplicate entry would be entered into the virtual table. We resolved this issue by turning on recursive triggers.</p>
<p>You can enable recursive triggers by running the following SQL query:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="sql" style="font-family:monospace;">PRAGMA recursive_triggers<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'ON'</span></pre></td></tr></table></div>

<p>You can easily use the <a href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#execSQL%28java.lang.String%29"><code>SQLiteDatabase.execSQL</code></a> method if you&#8217;re doing this on Android.</p>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/x67SCaOctos" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/06/sqlite-fire-delete-trigger-on-a-replac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/06/sqlite-fire-delete-trigger-on-a-replac/</feedburner:origLink></item>
		<item>
		<title>Including ActionBarSherlock as a Git submodule</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/Gc-XHMWrMAw/</link>
		<comments>http://www.tristanwaddington.com/2012/06/including-actionbarsherlock-as-a-git-submodule/#comments</comments>
		<pubDate>Sun, 03 Jun 2012 00:33:04 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[actionbar]]></category>
		<category><![CDATA[actionbarsherlock]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[submodule]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1132</guid>
		<description><![CDATA[If you&#8217;re using the ActionBarSherlock library in your Android project you can easily stay up to date by including it as git submodule. $ cd /path/to/project &#160; # Initialize the submodule $ git submodule add https://github.com/JakeWharton/ActionBarSherlock &#160; # Commit your &#8230; <a href="http://www.tristanwaddington.com/2012/06/including-actionbarsherlock-as-a-git-submodule/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re using the <a href="http://actionbarsherlock.com/">ActionBarSherlock</a> library in your Android project you can easily stay up to date by including it as  git submodule.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>project
&nbsp;
<span style="color: #666666; font-style: italic;"># Initialize the submodule </span>
$ <span style="color: #c20cb9; font-weight: bold;">git submodule</span> add https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>JakeWharton<span style="color: #000000; font-weight: bold;">/</span>ActionBarSherlock
&nbsp;
<span style="color: #666666; font-style: italic;"># Commit your changes</span>
$ <span style="color: #c20cb9; font-weight: bold;">git commit</span> <span style="color: #660033;">-am</span> <span style="color: #ff0000;">&quot;Added ActionBarSherlock submodule.&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Ignore local changes in the submodule directory</span>
$ <span style="color: #c20cb9; font-weight: bold;">git status</span> <span style="color: #660033;">--ignore-submodules</span>=dirty</pre></td></tr></table></div>

<p>To ignore changes to the submodule directory (in case permission or other changes are required) you can add the following to your <code>.gitmodules</code> file:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="properties" style="font-family:monospace;"><span style="">&#91;</span>submodule <span style="color: #933;">&quot;ActionBarSherlock&quot;</span><span style="">&#93;</span>
	<span style="color: #000080; font-weight:bold;">path</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> ActionBarSherlock</span>
	<span style="color: #000080; font-weight:bold;">url</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> https://github.com/JakeWharton/ActionBarSherlock</span>
        <span style="color: #000080; font-weight:bold;">ignore</span> <span style="color: #000000;">=</span><span style="color: #008000; font-weight:bold;"> dirty</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/twaddington/~4/Gc-XHMWrMAw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/06/including-actionbarsherlock-as-a-git-submodule/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/06/including-actionbarsherlock-as-a-git-submodule/</feedburner:origLink></item>
		<item>
		<title>Installing Jenkins on an Ubuntu Amazon EC2 instance</title>
		<link>http://feedproxy.google.com/~r/twaddington/~3/7WD_5pvufr4/</link>
		<comments>http://www.tristanwaddington.com/2012/03/installing-jenkins-on-an-ubuntu-amazon-ec2-instance/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 21:00:56 +0000</pubDate>
		<dc:creator>tristan</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[jenkins]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.tristanwaddington.com/?p=1122</guid>
		<description><![CDATA[This tutorial assumes you have already created an Amazon EC2 instance and are able to ssh to it. In our case, we used the Quick Launch Wizard to spin up a 32-bit instance of Ubuntu Server Cloud Guest 11.10 (Oneiric &#8230; <a href="http://www.tristanwaddington.com/2012/03/installing-jenkins-on-an-ubuntu-amazon-ec2-instance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This tutorial assumes you have already created an Amazon EC2 instance and are able to ssh to it. In our case, we used the <em>Quick Launch Wizard</em> to spin up a 32-bit instance of <strong>Ubuntu Server Cloud Guest 11.10 (Oneiric Ocelot)</strong>.</p>
<p>Once you have a running EC2 instance you&#8217;ll need to modify the instance&#8217;s security group to open up ports 22, 80 and 443.</p>
<p>The first thing I did was update the EC2 timezone to our local timezone:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>America<span style="color: #000000; font-weight: bold;">/</span>Los_Angeles <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime</pre></td></tr></table></div>

<p>Install any version control systems you might like to use:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> <span style="color: #c20cb9; font-weight: bold;">git</span></pre></td></tr></table></div>

<p>Then pretty much just follow the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu">installation instructions</a> from the Jenkins Wiki. I&#8217;ve copied the actual steps here for posterity.</p>
<p>Installing Jenkins:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> - http:<span style="color: #000000; font-weight: bold;">//</span>pkg.jenkins-ci.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span>jenkins-ci.org.key <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-key add</span> -
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'echo deb http://pkg.jenkins-ci.org/debian binary/ &amp;gt; /etc/apt/sources.list.d/jenkins.list'</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> update
&nbsp;
<span style="color: #666666; font-style: italic;"># Note this will install the openjdk dependencies automatically!</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> jenkins</pre></td></tr></table></div>

<p>Setting up an Apache Proxy for port 80 -&gt; 8080:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod proxy
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod proxy_http
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod vhost_alias
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2dissite default
$ <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>jenkins</pre></td></tr></table></div>

<p>Use your favorite editor to update <code>/etc/apache2/sites-available/jenkins</code> with the following virtual host configuration:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
	<span style="color: #00007f;">ServerAdmin</span> webmaster@localhost
	<span style="color: #00007f;">ServerName</span> ci.company.com
	<span style="color: #00007f;">ServerAlias</span> ci
	<span style="color: #00007f;">ProxyRequests</span> <span style="color: #0000ff;">Off</span>
	&lt;<span style="color: #000000; font-weight:bold;">Proxy</span> *&gt;
		<span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
		<span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
	&lt;/<span style="color: #000000; font-weight:bold;">Proxy</span>&gt;
	<span style="color: #00007f;">ProxyPreserveHost</span> <span style="color: #0000ff;">on</span>
	<span style="color: #00007f;">ProxyPass</span> / http://localhost:<span style="color: #ff0000;">8080</span>/
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></td></tr></table></div>

<p>Enable the new jenkins virtual host and restart apache:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite jenkins
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apache2ctl restart</span></pre></td></tr></table></div>

<p>Jenkins should now be live and accessible from port 80! Now you can begin configuring Jenkins to your liking. I&#8217;ll follow-up with a post highlighting our Jenkins configuration. For now, here are the plugins we&#8217;ve chosen to install:</p>
<ul>
<li>Green Balls</li>
<li>Post build task</li>
<li>Instant Messaging Plugin</li>
<li>IRC Plugin</li>
<li>Rake plugin</li>
<li>Git Plugin</li>
<li>Github Plugin</li>
<li>GitHub API Plugin</li>
<li>Github OAuth Plugin</li>
</ul>
<img src="http://feeds.feedburner.com/~r/twaddington/~4/7WD_5pvufr4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.tristanwaddington.com/2012/03/installing-jenkins-on-an-ubuntu-amazon-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.tristanwaddington.com/2012/03/installing-jenkins-on-an-ubuntu-amazon-ec2-instance/</feedburner:origLink></item>
	</channel>
</rss>
