<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Charles Harley</title>
    <description></description>
    <link>https://charlesharley.com/</link>
    <atom:link href="https://charlesharley.com/feed.xml" rel="self" type="application/rss+xml" />
    
      <item>
        <title>Getting Xcode static libraries to work</title>
        <description>&lt;p&gt;Getting Xcode static library dependencies to work is way harder than it should be! This weekend I setup a new Xcode OS X workspace with 2 child projects. One project was the app and the other a static library used by the app. Setting the static library as a dependency of the app project took ages. Part of the reason was my lack of knowledge but Xcode should really give a bit more help.&lt;/p&gt;

&lt;p&gt;Anyway, for the good of the people here are 2 blog posts I found helpful. I was using Xcode 4.6.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.stevex.net/2012/04/static-libraries-in-xcode&quot;&gt;http://blog.stevex.net/2012/04/static-libraries-in-xcode&lt;/a&gt; - I found this the most useful for setting up the dependency, however steps 10 to 16 weren’t needed for Xcode 4.6. Probably because Apple fixed a bug.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4&quot;&gt;http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4&lt;/a&gt; - The instructions for setting up a dependency didn’t quite work for some reason. However, the section on creating a static library is useful.&lt;/p&gt;
</description>
        <pubDate>Sun, 03 Mar 2013 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2013/programming/getting-xcode-static-libraries-to-work</link>
        <guid isPermaLink="true">https://charlesharley.com/2013/programming/getting-xcode-static-libraries-to-work</guid>
      </item>
    
      <item>
        <title>Using AndroVM</title>
        <description>&lt;p&gt;Update: the team behind AndroVM have released &lt;a href=&quot;http://www.genymotion.com/&quot; title=&quot;Genymotion&quot;&gt;Genymotion&lt;/a&gt;. It greatly simplifies the downloading of device images and automatically connects them to adb.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://androvm.org/&quot;&gt;AndroVM&lt;/a&gt; is a novel alternative to the Android emulator with Android running in a virtual machine (VM) using VirtualBox. It works quite well and for some requirements can be significantly faster than the Android emulator.&lt;/p&gt;

&lt;p&gt;Installing and setting up is as simple as installing VirtualBox and importing the Android VirtualBox images available &lt;a href=&quot;http://androvm.org/blog/download/&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To debug and install your apps using adb:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Get the IP address of the VM from the AndroVM Config app running in the VM. If the app doesn’t show an IP address make sure you’ve created a host only network in the VirtualBox preferences and configured the VM to use that host only adapter as “Adapter 1”.&lt;/li&gt;
  &lt;li&gt;Execute ‘adb connect &lt;IP address=&quot;&quot;&gt;'&lt;/IP&gt;&lt;/li&gt;
  &lt;li&gt;From this point the standard adb commands (such as ‘adb install’) should work&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AndroVM is still in it’s infancy and as such does have a few bigger limitations:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Only Android 4.1 images are available.&lt;/li&gt;
  &lt;li&gt;The available screen resolutions are limited but can be easily selected using the AndroVM Config app running in the VM.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the plus side, the team behind AndroVM have promised configuration management software to make it easier to create and run different Android configurations. Additionally the software will also automatically connect the VM to adb.&lt;/p&gt;
</description>
        <pubDate>Mon, 14 Jan 2013 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2013/programming/using-androvm</link>
        <guid isPermaLink="true">https://charlesharley.com/2013/programming/using-androvm</guid>
      </item>
    
      <item>
        <title>UIButton in UITableViewCell has no highlight state</title>
        <description>&lt;p&gt;I recently created a custom UITableViewCell with a UIButton as a subview. Pretty standard except that the highlight state of the button was only activated if you held your finger on the button for more than some fraction of a second. The solution is quite straight forward but is subtle enough to justify a quick blog post.&lt;/p&gt;

&lt;p&gt;Table view cells are displayed using a UITableView which is a subclass of UIScrollView and as such inherits the ability to scroll. A scroll view intercepts touch events and has a short delay to check if the touch event is part of a scroll gesture. If it isn’t then the touch event is passed onto the corresponding view. That explains the delay in the button highlight state.&lt;/p&gt;

&lt;p&gt;We can remove the delay by setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;UIScrollView.delaysContentTouches = NO&lt;/code&gt;. A side effect of this change is that scroll gestures cannot start from the buttons. Depending on how big your buttons are this might not be ideal. The work around for this is to override the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(BOOL)touchesShouldCancelInContentView:(UIView *)view&lt;/code&gt; method in your UITableView subclass like so:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-objective-c&quot;&gt;- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
    // Because we set delaysContentTouches = NO, we return YES for UIButtons
    // so that scrolling works correctly when the scroll gesture
    // starts in the UIButtons.
    if ([view isKindOfClass:[UIButton class]]) {
        return YES;
    }

    return [super touchesShouldCancelInContentView:view];
}
&lt;/code&gt;&lt;/pre&gt;
</description>
        <pubDate>Tue, 08 Jan 2013 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2013/programming/uibutton-in-uitableviewcell-has-no-highlight-state</link>
        <guid isPermaLink="true">https://charlesharley.com/2013/programming/uibutton-in-uitableviewcell-has-no-highlight-state</guid>
      </item>
    
      <item>
        <title>Custom drawable states in Android</title>
        <description>&lt;p&gt;A &lt;a href=&quot;http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList&quot;&gt;state list drawable&lt;/a&gt; is a really useful Android resource for displaying different drawables for a view depending on the state of that view. e.g. we can define a state list drawable for the background of a button that defines a colour for both pressed and unpressed states. The button takes care of switching between the two drawables depending on the state.&lt;/p&gt;

&lt;p&gt;You can make state list drawables even more useful by defining custom states.&lt;/p&gt;

&lt;p&gt;This is a screenshot of a hypothetical email client, notice the difference between read and unread messages.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/custom_drawable_states_screenshot1.png&quot; alt=&quot;Custom drawable states screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The recommended implementation for a screen like this would be to use a &lt;a href=&quot;http://developer.android.com/reference/android/widget/ListView.html&quot;&gt;ListView&lt;/a&gt;. In this example, each item in the list is a &lt;a href=&quot;http://developer.android.com/reference/android/widget/RelativeLayout.html&quot;&gt;RelativeLayout&lt;/a&gt; containing an &lt;a href=&quot;http://developer.android.com/reference/android/widget/ImageView.html&quot;&gt;ImageView&lt;/a&gt; and a &lt;a href=&quot;http://developer.android.com/reference/android/widget/TextView.html&quot;&gt;TextView&lt;/a&gt;. When displaying each item you could manually switch between the two images used and set the background colour accordingly. However, by defining a custom state you can make it simpler and easier to maintain.&lt;/p&gt;

&lt;h2 id=&quot;step-1-declare-the-custom-state-attribute&quot;&gt;Step 1: declare the custom state attribute&lt;/h2&gt;

&lt;p&gt;The custom state is declared in the ‘attrs.xml’ file in the application’s ‘res/values’ directory.&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;resources&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;declare-styleable&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;MessageState&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;attr&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;state_message_unread&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;format=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;boolean&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/declare-styleable&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/resources&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;step-2-use-the-custom-state-in-the-state-list-drawables&quot;&gt;Step 2: use the custom state in the state list drawables&lt;/h2&gt;

&lt;p&gt;In the message list example there are two state list drawables.&lt;/p&gt;

&lt;p&gt;One for the list item background:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;selector&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;xmlns:example=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.android.com/apk/res/com.charlesharley.example.android.customdrawablestates&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!--
    We make the pressed and focused selector items transparent so the ListView's own selector states show through.
    --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:state_pressed=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;android:drawable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@android:color/transparent&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:state_focused=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;android:drawable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@android:color/transparent&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;example:state_message_unread=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;android:drawable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@color/message_list_item_background_unread&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/selector&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And one for the message status icon:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;selector&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:android=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;xmlns:example=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.android.com/apk/res/com.charlesharley.example.android.customdrawablestates&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;android:constantSize=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;example:state_message_unread=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;true&quot;&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;android:drawable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@drawable/message_read_status_unread&quot;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:drawable=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@drawable/message_read_status_read&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/selector&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To use the custom state all you need to do is declare a new XML namespace using your application’s package name and prefix the custom state attribute with the new namespace.&lt;/p&gt;

&lt;h2 id=&quot;step-3-update-the-views-drawable-state-to-include-the-custom-state&quot;&gt;Step 3: update the view’s drawable state to include the custom state&lt;/h2&gt;

&lt;p&gt;Each view provides a number of existing states that can be used by its drawables where applicable, e.g. a &lt;a href=&quot;http://developer.android.com/reference/android/widget/CheckBox.html&quot;&gt;CheckBox&lt;/a&gt; has a checked state. By overriding &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#onCreateDrawableState(int)&quot;&gt;View.onCreateDrawableState()&lt;/a&gt; a custom view can inject its own states, which are then made available to the view’s drawables.&lt;/p&gt;

&lt;p&gt;In the message list example, the relative layout that contains the image view and the text view is a custom implementation that maintains an unread state, which when set, updates the view’s drawable states resulting in the different look for read and unread messages.&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MessageListItemView&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;extends&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RelativeLayout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;STATE_MESSAGE_UNREAD&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;R&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;attr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;state_message_unread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;};&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Constructors, view loading etc...&lt;/span&gt;
    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onCreateDrawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extraSpace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// If the message is unread then we merge our custom message unread state into&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// the existing drawable state before returning it.&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;messageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// We are going to add 1 extra state.&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drawableState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreateDrawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extraSpace&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

            &lt;span class=&quot;n&quot;&gt;mergeDrawableStates&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;STATE_MESSAGE_UNREAD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onCreateDrawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;extraSpace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setMessageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;messageUnread&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;messageUnread&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messageUnread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

            &lt;span class=&quot;c1&quot;&gt;// Refresh the drawable state so that it includes the message unread&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// state if required.&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;refreshDrawableState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What about the message status image view? Good question! Because the image view is a child of our custom view we tell it to duplicate its parent state using &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#setDuplicateParentStateEnabled(boolean)&quot;&gt;View.setDuplicateParentStateEnabled()&lt;/a&gt;. Any state in the parent is passed down to the children including custom states. Brilliant!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/CharlesHarley/Example-Android-CustomDrawableStates&quot;&gt;View example application on Github&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 07 Jun 2012 00:00:00 +0100</pubDate>
        <link>https://charlesharley.com/2012/programming/custom-drawable-states-in-android</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/programming/custom-drawable-states-in-android</guid>
      </item>
    
      <item>
        <title>Tiny Stopwatch for Android</title>
        <description>&lt;p&gt;&lt;img src=&quot;/assets/images/tiny_stopwatch_for_android_icon.png&quot; alt=&quot;Tiny Stopwatch for Android Icon&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Today I released my first personal Android app into the Google Play Store. It is a stopwatch app that supports multiple stopwatches and is designed to work across phones and tablets. It is also built from the ground up to fit in with the new design paradigms used in the latest versions of Android such as the action bar. I also just wanted a better looking stopwatch app.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://play.google.com/store/apps/details?id=com.tinystopwatch.android&quot;&gt;&lt;img src=&quot;http://www.android.com/images/brand/get_it_on_play_logo_large.png&quot; alt=&quot;Image&quot; title=&quot;Get it on Google Play&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 08 May 2012 00:00:00 +0100</pubDate>
        <link>https://charlesharley.com/2012/misc/tiny-stopwatch-for-android</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/misc/tiny-stopwatch-for-android</guid>
      </item>
    
      <item>
        <title>Android screen utility class</title>
        <description>&lt;p&gt;There are a few common operations I infrequently perform related to the Android screen:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Converting a pixels value to the corresponding density independent pixels (DIP) value and vice versa&lt;/li&gt;
  &lt;li&gt;Getting the screen dimensions&lt;/li&gt;
  &lt;li&gt;Checking what orientation the device is in&lt;/li&gt;
  &lt;li&gt;Getting the screen size (small, normal, large, extra-large)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They’re not difficult but it is annoying having to remember exactly how they’re done so I created a utility class to make it a bit easier. Here it is:&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;https://gist.github.com/2504204.js?file=ScreenUtils.java&quot;&gt;&lt;/script&gt;

</description>
        <pubDate>Fri, 27 Apr 2012 00:00:00 +0100</pubDate>
        <link>https://charlesharley.com/2012/programming/android-screen-utility-class</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/programming/android-screen-utility-class</guid>
      </item>
    
      <item>
        <title>Views saving instance state in Android</title>
        <description>&lt;p&gt;The activity &lt;a href=&quot;http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle&quot;&gt;lifecycle&lt;/a&gt; is central to Android development. Although it is quite well defined, it does take a bit of getting used to. One aspect new developers perhaps struggle with is that rotating the device will by default destroy and recreate the activity.&lt;/p&gt;

&lt;p&gt;A well behaved activity will restore its state after a rotation so the user can continue using the application with no lose of state. e.g. &lt;a href=&quot;http://developer.android.com/reference/android/widget/EditText.html&quot;&gt;EditText&lt;/a&gt; widgets should restore the text they contained when the device was rotated and a long running operation should resume without restarting.&lt;/p&gt;

&lt;p&gt;There are a few topics to understand to achieve this effectively but one that I’d like to talk about is views saving and restoring their instance state. In most cases saving state is actually very simple but when creating compound views a couple extra steps are required. Compound views combine multiple views into a single convenient reusable view, e.g. the &lt;a href=&quot;http://developer.android.com/reference/android/widget/NumberPicker.html&quot;&gt;NumberPicker&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;saving-individual-views&quot;&gt;Saving individual views&lt;/h2&gt;

&lt;p&gt;For individual views, saving instance state is as simple as defining a unique &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#attr_android:id&quot; title=&quot;Android documentation on View IDs&quot;&gt;ID&lt;/a&gt; for each view that you want to save its state. The activity will take care of the rest!&lt;/p&gt;

&lt;p&gt;IDs only need to be unique within the activity where they are used.&lt;/p&gt;

&lt;h2 id=&quot;how-saving-instance-state-works&quot;&gt;How saving instance state works&lt;/h2&gt;

&lt;p&gt;The instance state of each view within an activity is saved in shared persisted data with the state for each view referenced using the view’s ID. Hence why the IDs need to be unique.&lt;/p&gt;

&lt;p&gt;To save state the activity traverses the layout hierarchy and for each view it encounters it calls &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#saveHierarchyState(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;View.saveHierarchyState()&lt;/a&gt; which in turn calls &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#dispatchSaveInstanceState(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;View.dispatchSaveInstanceState()&lt;/a&gt;. If the view has an ID this method calls &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#onSaveInstanceState()&quot;&gt;View.onSaveInstanceState()&lt;/a&gt;, which saves its state to a &lt;a href=&quot;http://developer.android.com/reference/android/os/Parcelable.html&quot;&gt;Parcelable&lt;/a&gt; object and returns it. View.dispatchSaveInstanceState() then takes the Parcelable and saves it to the shared persisted data using the ID of the view.&lt;/p&gt;

&lt;p&gt;Restoring state is a very similar process with the activity traversing the layout hierarchy and for each view it calls &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#restoreHierarchyState(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;View.restoreHierarchyState()&lt;/a&gt; which in turn calls &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#dispatchRestoreInstanceState(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;View.dispatchRestoreInstanceState()&lt;/a&gt;. If the view has an ID this method retrieves the corresponding Parcelable from the shared persisted data and passes it through to &lt;a href=&quot;http://developer.android.com/reference/android/view/View.html#onRestoreInstanceState(android.os.Parcelable)&quot;&gt;View.onRestoreInstanceState()&lt;/a&gt;, which then restores the view’s state.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://developer.android.com/reference/android/view/ViewGroup.html&quot;&gt;ViewGroup&lt;/a&gt;, which extends View, modifies the process slightly to pass the call to View.dispatchSaveInstanceState() onto its child views.&lt;/p&gt;

&lt;p&gt;Simple really! :)&lt;/p&gt;

&lt;h2 id=&quot;saving-compound-views&quot;&gt;Saving compound views&lt;/h2&gt;

&lt;p&gt;Saving instance state for compound views works in the same way as individual views but does require a little extra work when creating them to ensure that if an activity contains more than one instance of the same compound view, its state is correctly saved.&lt;/p&gt;

&lt;p&gt;Compound views contain one or more child views and if an activity contains multiple instances of the same compound view then the IDs of the child views are no longer unique. To resolve this issue, the compound view class needs to take on the responsibility of saving and restoring the state of its child views.&lt;/p&gt;

&lt;p&gt;To make it easier to understand I’ve created an &lt;a href=&quot;https://github.com/CharlesHarley/Example-Android-SavingInstanceState&quot;&gt;example project&lt;/a&gt; that defines a compound view that correctly saves and restores the state of its child views. The project contains various files to make the application work but if you want to skip to the important bit take a look at the &lt;a href=&quot;https://github.com/CharlesHarley/Example-Android-SavingInstanceState/blob/master/src/com/example/android/savinginstancestate/views/LockCombinationPicker.java&quot;&gt;LockCombinationPicker&lt;/a&gt; class. It contains 4 overridden methods that ensure the state of the child views are correctly saved and restored.&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Parcelable&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onSaveInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;Parcelable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;superState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onSaveInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SavedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;superState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numberPicker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numberPicker2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numberPicker3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;onRestoreInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Parcelable&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;SavedState&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;savedState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SavedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;onRestoreInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getSuperState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;numberPicker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getNumber1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;numberPicker2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getNumber2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;numberPicker3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;savedState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getNumber3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;dispatchSaveInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SparseArray&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;dispatchFreezeSelfOnly&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;protected&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;dispatchRestoreInstanceState&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;SparseArray&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;dispatchThawSelfOnly&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;LockCombinationPicker saves and restores the state of its children by overriding View.onSaveInstanceState() and View.onRestoreInstanceState() much as you would expect. In addition to this we need to ensure the compound view’s children aren’t then called to save their state as well. We do this by overriding View.dispatchSaveInstanceState() and View.dispatchRestoreInstanceState() and calling &lt;a href=&quot;http://developer.android.com/reference/android/view/ViewGroup.html#dispatchFreezeSelfOnly(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;ViewGroup.dispatchFreezeSelfOnly()&lt;/a&gt; and &lt;a href=&quot;http://developer.android.com/reference/android/view/ViewGroup.html#dispatchThawSelfOnly(android.util.SparseArray&amp;lt;android.os.Parcelable&amp;gt;)&quot;&gt;ViewGroup.dispatchThawSelfOnly()&lt;/a&gt; respectively. These methods ensure that View.onSaveInstanceState() and View.onRestoreInstanceState() are called on the compound view class and not on the child views.&lt;/p&gt;

&lt;p&gt;And that is it! To then save and restore the state of the compound view(s) within an activity just give it a unique ID.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/CharlesHarley/Example-Android-SavingInstanceState&quot;&gt;View example application on Github&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 03 Mar 2012 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2012/programming/views-saving-instance-state-in-android</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/programming/views-saving-instance-state-in-android</guid>
      </item>
    
      <item>
        <title>Android vs iOS development presentation</title>
        <description>&lt;iframe src=&quot;//player.vimeo.com/video/36492043&quot; width=&quot;500&quot; height=&quot;281&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;My colleague, Nick Street, and I gave an ‘Android vs iOS Development’ presentation for Edinburgh Student TechMeetup on behalf of &lt;a href=&quot;http://www.kotikan.com&quot; title=&quot;Kotikan&quot;&gt;Kotikan&lt;/a&gt;. We only had about 25 minutes so didn’t go into too much depth. Was good fun and worth a watch just to find out who wins.&lt;/p&gt;
</description>
        <pubDate>Thu, 09 Feb 2012 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2012/programming/android-vs-ios-development-presentation</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/programming/android-vs-ios-development-presentation</guid>
      </item>
    
      <item>
        <title>Book review: Application Security for the Android Platform</title>
        <description>&lt;p&gt;Just finished reading ‘Application Security for the Android Platform: Processes, Permissions, and Other Safeguards’ by Jeff Six.&lt;/p&gt;

&lt;iframe style=&quot;width: 120px; height: 240px;&quot; src=&quot;http://rcm-uk.amazon.co.uk/e/cm?lt1=_blank&amp;amp;bc1=E7E9EB&amp;amp;IS2=1&amp;amp;npa=1&amp;amp;bg1=E7E9EB&amp;amp;fc1=000000&amp;amp;lc1=0000FF&amp;amp;t=charharl-21&amp;amp;o=2&amp;amp;p=8&amp;amp;l=as4&amp;amp;m=amazon&amp;amp;f=ifr&amp;amp;ref=ss_til&amp;amp;asins=1449315070&quot; height=&quot;240&quot; width=&quot;320&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;The book is essentially a high level introduction to application security when programming for the Android platform but does go into sufficient depth to give you a decent understanding. It covers the following key topics:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Risk assessment&lt;/li&gt;
  &lt;li&gt;Android permissions system&lt;/li&gt;
  &lt;li&gt;Storing data securely&lt;/li&gt;
  &lt;li&gt;Securing server communication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Having studied computer science at university the last two key topics were familiar but it is amazing how much you forget! By far the most useful chapters were on the Android permissions systems. I don’t have sufficient knowledge on application security to properly review the book (hence why I bought it). However, at just under 100 pages it is a good introduction to the topic and very easy to read.&lt;/p&gt;
</description>
        <pubDate>Tue, 03 Jan 2012 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2012/programming/book-review-application-security-android-platform</link>
        <guid isPermaLink="true">https://charlesharley.com/2012/programming/book-review-application-security-android-platform</guid>
      </item>
    
      <item>
        <title>Disabling Android TextView suggestions</title>
        <description>&lt;p&gt;Android TextViews provide suggestions to the user as they type. Although the user can disable this feature in the system settings there are cases where the developer wants to always have suggestions disabled for certain TextViews.&lt;/p&gt;

&lt;p&gt;To achieve this, the documentation indicates that you should use:&lt;/p&gt;

&lt;p&gt;XML:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;TextView&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:inputType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;textNoSuggestions&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Java:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setInputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TYPE_TEXT_FLAG_NO_SUGGESTIONS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Annoyingly some HTC devices ignore this option and so a common approach has been instead to use:&lt;/p&gt;

&lt;p&gt;XML:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;TextView&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:inputType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;textVisiblePassword&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Java:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setInputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TYPE_TEXT_VARIATION_VISIBLE_PASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Although this does work, it will restrict the keyboard language on some HTC devices to English. A better approach, that appears to work across all devices, is:&lt;/p&gt;

&lt;p&gt;XML:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;TextView&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;android:inputType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;textFilter&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Java:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setInputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;InputType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TYPE_TEXT_VARIATION_FILTER&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Wed, 07 Dec 2011 00:00:00 +0000</pubDate>
        <link>https://charlesharley.com/2011/programming/disabling-android-textview-suggestions</link>
        <guid isPermaLink="true">https://charlesharley.com/2011/programming/disabling-android-textview-suggestions</guid>
      </item>
    
  </channel>
</rss>
