<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Thanks, Mister!</title>
	<atom:link href="http://thanksmister.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thanksmister.com</link>
	<description>Flex, AIR, &#38; Android Development Blog</description>
	<lastBuildDate>Fri, 18 May 2012 22:41:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thanksmister.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Thanks, Mister!</title>
		<link>http://thanksmister.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thanksmister.com/osd.xml" title="Thanks, Mister!" />
	<atom:link rel='hub' href='http://thanksmister.com/?pushpress=hub'/>
		<item>
		<title>Android: Removing Fade Effect on ActionBar when using setActionView()</title>
		<link>http://thanksmister.com/2012/04/03/android-removing-fade-effect-from-actionbar/</link>
		<comments>http://thanksmister.com/2012/04/03/android-removing-fade-effect-from-actionbar/#comments</comments>
		<pubDate>Wed, 04 Apr 2012 02:38:30 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[ActionBar]]></category>
		<category><![CDATA[ActionBarSherlock]]></category>
		<category><![CDATA[ICS]]></category>
		<category><![CDATA[MenuItem]]></category>
		<category><![CDATA[setActionView]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=2026</guid>
		<description><![CDATA[Letting me start by explaining the desired effect I was trying to achieve. On the Android Google+ application if you hit refresh there is a spinner animation that replaces the refresh ActionBar item when pressed. I was able to achieve this but setting the pressed MenuItem to a new layout by using &#8220;MenuItem.setActionView()&#8221;. However, on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=2026&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Letting me start by explaining the desired effect I was trying to achieve.  On the Android Google+ application if you hit refresh there is a spinner animation that replaces the refresh ActionBar item when pressed. I was able to achieve this but setting the pressed MenuItem to a new layout by using &#8220;MenuItem.setActionView()&#8221;.</p>
<p>However, on ICS if you have a two ore more MenuItems always available in the Android ActionBar (i.e. you set android:showAsAction=&#8221;ifRoom&#8221; in the mainmenu.xml file below) swapping the the icon on one MenuItem when pressed causes a slight ghost selection of the other. </p>
<p>The MenuItem next to the one pressed immediately shows a highlight as you stop pressing the refresh icon. This ghost selection behavior is produced because the default ICS background selector contains a fade animation.  Swapping the icon causes the animation up/fade to transfer to the next non-customized ActionBar MenuItem, the one you didn&#8217;t select.</p>
<p><strong>Here is a code example (not complete) on how to swap out the MenuItem with a custom spinner:</strong><br />
<pre class="brush: java;">
private View mRefreshIndeterminateProgressView; // save inflated layout for reference
private MenuItem refreshItem; // reference to actionbar menu item we want to swap

if (mRefreshIndeterminateProgressView == null) {
   LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   mRefreshIndeterminateProgressView = inflater.inflate(R.layout.actionbar_indeterminate_progress, null);
}
refreshItem.setActionView(mRefreshIndeterminateProgressView); // replace actionbar menu item with progress
// doing refreshItem.setActionView(null) removes the animation
</pre></p>
<p><strong>Here is what the actionbar_indeterminate_progress.xml looks like:</strong><br />
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; 
    android:layout_width=&quot;wrap_content&quot; 
    android:layout_height=&quot;wrap_content&quot; 
    android:gravity=&quot;center&quot;&gt; 
&lt;ProgressBar android:layout_width=&quot;16dp&quot; 
    android:layout_height=&quot;16dp&quot; 
    android:layout_marginLeft=&quot;12dp&quot; 
    android:layout_marginRight=&quot;12dp&quot; 
    android:layout_gravity=&quot;center&quot; 
    style=&quot;?android:attr/indeterminateProgressStyle&quot;/&gt; 
&lt;/FrameLayout&gt; 
</pre></p>
<p><strong>Here is your mainmenu.xml:</strong><br />
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

&lt;item android:id=&quot;@+id/detail_menu_refresh&quot; 
    android:title=&quot;Refresh&quot; 
    android:icon=&quot;@drawable/ic_action_refresh&quot; 
    android:showAsAction=&quot;ifRoom&quot;/&gt; 

 &lt;item android:id=&quot;@+id/main_menu_share&quot; 
    android:title=&quot;Share&quot; 
    android:icon=&quot;@drawable/ic_action_share&quot;
    android:showAsAction=&quot;ifRoom&quot;/&gt;

 &lt;item android:id=&quot;@+id/main_menu_about&quot; 
    android:title=&quot;About&quot; 
    android:icon=&quot;@drawable/ic_action_about&quot;
    android:showAsAction=&quot;never&quot;/&gt;

 &lt;/menu&gt;
</pre></p>
<p>The solution is to set your own custom selector background for the ActionBar so you can remove the fade.  To do this, I grabbed the abs__item_background_holo_dark.xml from (ActionBarSherlock &gt; Library &gt; res &gt; drawable) and the associated graphics to add to my project. You could easily do this without using ActionBarSherlock and just ActionBar and regular themes for your project.  I then removed the following line from the nod in the xml which disables the fade:<br />
<pre class="brush: xml;"> android:exitFadeDuration=&quot;@android:integer/config_mediumAnimTime&quot; </pre><br />
<strong>Here is modified abs__item_background_holo_dark.xml:</strong><br />
<pre class="brush: xml;"> 
&lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
    &lt;!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --&gt;
    &lt;item android:state_focused=&quot;true&quot;  android:state_enabled=&quot;false&quot; android:state_pressed=&quot;true&quot; android:drawable=&quot;@drawable/abs__list_selector_disabled_holo_dark&quot; /&gt;
    &lt;item android:state_focused=&quot;true&quot;  android:state_enabled=&quot;false&quot; android:drawable=&quot;@drawable/abs__list_selector_disabled_holo_dark&quot; /&gt;
    &lt;item android:state_focused=&quot;true&quot;  android:state_pressed=&quot;true&quot; android:drawable=&quot;@drawable/abs__list_selector_background_transition_holo_dark&quot; /&gt;
    &lt;item android:state_focused=&quot;false&quot; android:state_pressed=&quot;true&quot; android:drawable=&quot;@drawable/abs__list_selector_background_transition_holo_dark&quot; /&gt;
    &lt;item android:state_focused=&quot;true&quot;  android:drawable=&quot;@drawable/abs__list_focused_holo&quot; /&gt;
    &lt;item  android:drawable=&quot;@android:color/transparent&quot; /&gt;
&lt;/selector&gt;

</pre></p>
<p><strong>Here is how I set it up in my styles.xml file:</strong></p>
<p><pre class="brush: xml;"> 
&lt;style name=&quot;Dark&quot; parent=&quot;Theme.Sherlock.Light.DarkActionBar&quot;&gt;
    &lt;item name=&quot;actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
    &lt;item name=&quot;android:actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
    &lt;item name=&quot;actionBarItemBackground&quot;&gt;@drawable/abs__item_background_holo_dark&lt;/item&gt;
    &lt;item name=&quot;android:actionBarItemBackground&quot;&gt;@drawable/abs__item_background_holo_dark&lt;/item&gt;
&lt;/style&gt;

&lt;style name=&quot;Widget.Styled.ActionBar&quot; parent=&quot;Widget.Sherlock.Light.ActionBar.Solid.Inverse&quot;/&gt;

</pre></p>
<p>I got a great <a href="https://github.com/JakeWharton/ActionBarSherlock/issues/425#issuecomment-4945815" target="_blank">tip</a> on how to fix this from Jake Wharton, the creator of <a href="http://actionbarsherlock.com/" target="_blank">ActionBarSherlock</a>.  I recommend using his library if you want to have a consistent ActionBar across all versions of your Android applications. </p>
<p>- Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/2026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/2026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/2026/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=2026&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2012/04/03/android-removing-fade-effect-from-actionbar/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>
	</item>
		<item>
		<title>Android: Changing the Default Indeterminate Progress Size in ActionBarSherlock</title>
		<link>http://thanksmister.com/2012/03/30/change-default-progress-actionbarsherlock/</link>
		<comments>http://thanksmister.com/2012/03/30/change-default-progress-actionbarsherlock/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 23:12:30 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[ActionBarSherlock]]></category>
		<category><![CDATA[Theme]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1964</guid>
		<description><![CDATA[Just a quick post on how to change the default size of the Indeterminate Progress animation when using ActionBarSherlock (ABS). This uses the dark halo them for Android 4.0.1 but tested and working from version 2.3.2 to 4.0.1 of the SDK. Here are the before and after shots: Grab the progress_small_holo.xml and associated images from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1964&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick post on how to change the default size of the Indeterminate Progress animation when using <a href="http://actionbarsherlock.com/" target="_blank">ActionBarSherlock</a> (ABS).  This uses the dark halo them for Android 4.0.1 but tested and working from version 2.3.2 to 4.0.1 of the SDK.  Here are the before and after shots:</p>
<p><img src="http://thanksmister.files.wordpress.com/2012/03/android_progess_default.png?w=300&h=105" alt="" title="android_progess_default" width="300" height="105" class="aligncenter size-medium wp-image-1975" /></p>
<p><img src="http://thanksmister.files.wordpress.com/2012/03/android_progess_small.png?w=300&h=105" alt="" title="android_progess_small" width="300" height="105" class="aligncenter size-medium wp-image-1976" /></p>
<p>Grab the progress_small_holo.xml and associated images from the Android SDK (15) and move them to your project (from your SDK location: android/platforms/android-15/data/res/drawable). We will be using this to style the progress animation in the ActionBar for ABS  Set up your style.xml as follows:</p>
<p><strong>values/styles.xml</strong></p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;
    &lt;style name=&quot;Dark&quot; parent=&quot;Theme.Sherlock&quot;&gt;
        &lt;item name=&quot;actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
        &lt;item name=&quot;android:actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
    &lt;/style&gt;

    &lt;style name=&quot;Widget.Styled.ActionBar&quot; parent=&quot;Widget.Sherlock.Light.ActionBar&quot;&gt;
        &lt;item name=&quot;android:indeterminateProgressStyle&quot;&gt;@style/IndeterminateProgress&lt;/item&gt; 
        &lt;item name=&quot;indeterminateProgressStyle&quot;&gt;@style/IndeterminateProgress&lt;/item&gt; 
    &lt;/style&gt;

    &lt;style name=&quot;IndeterminateProgress&quot; parent=&quot;@android:style/Widget.ProgressBar.Small&quot;&gt; 
       &lt;item name=&quot;android:indeterminateDrawable&quot;&gt;@drawable/progress_small_holo&lt;/item&gt; 
   &lt;/style&gt; 
&lt;/resource&gt;
</pre></p>
<p><strong>values-v14/styles.xml (ICS) </strong></p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;resources&gt;
    &lt;style name=&quot;Dark&quot; parent=&quot;Theme.Sherlock&quot;&gt;
        &lt;item name=&quot;actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
        &lt;item name=&quot;android:actionBarStyle&quot;&gt;@style/Widget.Styled.ActionBar&lt;/item&gt;
    &lt;/style&gt;

    &lt;style name=&quot;Widget.Styled.ActionBar&quot; parent=&quot;Widget.Sherlock.Light.ActionBar&quot;&gt;
        &lt;item name=&quot;android:indeterminateProgressStyle&quot;&gt;@style/IndeterminateProgress&lt;/item&gt; 
        &lt;item name=&quot;indeterminateProgressStyle&quot;&gt;@style/IndeterminateProgress&lt;/item&gt; 
    &lt;/style&gt;

    &lt;style name=&quot;IndeterminateProgress&quot; parent=&quot;@android:style/Widget.ProgressBar.Small&quot;/&gt; 

&lt;/resource&gt;
</pre></p>
<p>You could also add some additional sizing if you want to center the progress animation in the actionbar:</p>
<p><pre class="brush: xml;">
&lt;style name=&quot;IndeterminateProgress&quot; parent=&quot;@android:style/Widget.ProgressBar.Small&quot;&gt;
       &lt;item name=&quot;android:minWidth&quot;&gt;48dp&lt;/item&gt; 
&lt;/style&gt;
</pre></p>
<p>You can see more of the discussion on this <a href="https://groups.google.com/forum/?fromgroups#!topic/actionbarsherlock/JOnM4QP3fJc" target="_blank">thread</a> or from <a href="http://stackoverflow.com/questions/3284083/starting-an-animationdrawable-in-android" target="_blank">StackOver</a>. </p>
<p>-Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1964/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1964/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1964/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1964&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2012/03/30/change-default-progress-actionbarsherlock/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2012/03/android_progess_default.png?w=300" medium="image">
			<media:title type="html">android_progess_default</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2012/03/android_progess_small.png?w=300" medium="image">
			<media:title type="html">android_progess_small</media:title>
		</media:content>
	</item>
		<item>
		<title>Android: Null data returned from Camera Intent</title>
		<link>http://thanksmister.com/2012/03/16/android_null_data_camera_intent/</link>
		<comments>http://thanksmister.com/2012/03/16/android_null_data_camera_intent/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 18:52:45 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Activity]]></category>
		<category><![CDATA[Camera]]></category>
		<category><![CDATA[ContentValues]]></category>
		<category><![CDATA[Cursor]]></category>
		<category><![CDATA[Environment]]></category>
		<category><![CDATA[Galaxy Nexus]]></category>
		<category><![CDATA[MediaStore]]></category>
		<category><![CDATA[Nexus One]]></category>
		<category><![CDATA[Uri]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1943</guid>
		<description><![CDATA[Anyone who has tried calling the image or video capture intent using the default Camera activity probably has been met with much frustration. There are many approaches and workarounds for various phones and API levels because of the insane fragmentation of Android. Most of us just want a simple way to call the default Camera [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1943&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Anyone who has tried calling the image or video capture intent using the default Camera activity probably has been met with much frustration.   There are many approaches and workarounds for various phones and API levels because of the insane fragmentation of Android.   Most of us just want a simple way to call the default Camera activity, have the video or image stored in the Gallery, and retrieve a the Camera intent results for further processing.   </p>
<p>The Android documentation provides what appear to be a very straight forward way to capture images and video and either save them in the default location or a folder of your choosing.   The resources available for doing so can be found here:</p>
<p><a href="https://developer.android.com/guide/topics/media/camera.html" target="_blank">Image capture intent</a><br />
<a href="https://developer.android.com/guide/topics/media/camera.html#saving-media" target="_blank">Saving Media Files</a></p>
<p>However, I am not sure Google actually tests their Android examples on real phones (developer phones).  Testing the method for capturing images on a <strong>Galaxy Nexus</strong> or <strong>Nexus One</strong> both return a null value for the data when receiving the camera intent result. However, capturing video seems to work as expected. Though both the image and video files are written to the specified folders on the device.  </p>
<p>So naturally, as a developer you are stuck with a borked example that must be modified for a real world implementation. Luckily for my needs I didn&#8217;t need to store images or video in an external folder, I wanted the camera application to store the requested media in the default location with a default name.  This is usually the Camera folder.  </p>
<p>Below is my modification to the onActivityResult() method of the Activity for retrieving the Uri of the captured image.  I have left the rest of the code from the Android Camera example for storing video and images in the activity in case you are feeling particularly brave and want to store your images in a different location.</p>
<p>You might ask why I couldn&#8217;t insert the video into the MediaStore the same way I am inserting the captured image (by passing the Uri and ContentValues). Doing this for video actually created two files for me, one in the Media Store, and an 0kb file in the external video folder on the SD card.   This only happened on the Nexus One (Android 2.3.4) and not the Galaxy Nexus (4.0.2).   So you end up with two different methods for making sure media appears in the MediaStore. </p>
<p><strong>AndroidCameraTestsActivity</strong><br />
<pre class="brush: java;">
package com.thanksmister.mobile;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;

public class AndroidCameraTestsActivity extends Activity 
{
	private static final String TAG = AndroidCameraTestsActivity.class.getSimpleName(); 
	
	private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
	private static final int CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE = 200;
	public static final int MEDIA_TYPE_IMAGE = 1;
    public static final int MEDIA_TYPE_VIDEO = 2;

    private Uri fileUri;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    /** 
     * https://developer.android.com/guide/topics/media/camera.html 
     * **/
    public void onCaptureImage(View v) 
    {
        // give the image a name so we can store it in the phone's default location
    	String timeStamp = new SimpleDateFormat(&quot;yyyyMMdd_HHmmss&quot;).format(new Date());
    	
        ContentValues values = new ContentValues();
		values.put(MediaStore.Images.Media.TITLE, &quot;IMG_&quot; + timeStamp + &quot;.jpg&quot;);

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        
        //fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image (this doesn't work at all for images)
        fileUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); // store content values
		intent.putExtra( MediaStore.EXTRA_OUTPUT,  fileUri);
       
        // start the image capture Intent
        startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    }
    
    /** 
     * https://developer.android.com/guide/topics/media/camera.html 
     * **/
    public void onCaptureVideo(View v) 
    {
    	 //create new Intent
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

        //fileUri = getOutputMediaFileUri(MEDIA_TYPE_VIDEO);  // create a file to save the video in specific folder (this works for video only)
        //intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);  // set the image file name
      
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high

        // start the Video Capture Intent
        startActivityForResult(intent, CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);
    }
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) 
    {
    	super.onActivityResult(requestCode, resultCode, data);
    	
        if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
            	
            	// Originally I was going to iterate through the list of images and grab last added to the MediaStore.
            	// But this is not necessary if we store the Uri in the image
            	/*
            	String[] projection = {MediaStore.Images.ImageColumns._ID};
            	String sort = MediaStore.Images.ImageColumns._ID + &quot; DESC&quot;;

            	Cursor cursor = this.managedQuery(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, null, null, sort);

            	try{
            		cursor.moveToFirst();
            		Long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns._ID));
            		fileUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(id));
            	} finally{
            		cursor.close();
            	}
            	*/
                
				if(fileUri != null) {
					Log.d(TAG, &quot;Image saved to:\n&quot; + fileUri);
					Log.d(TAG, &quot;Image path:\n&quot; + fileUri.getPath());
					Log.d(TAG, &quot;Image name:\n&quot; + getName(fileUri)); // use uri.getLastPathSegment() if store in folder
				}
                
            } else if (resultCode == RESULT_CANCELED) {
                // User cancelled the image capture
            } else {
                // Image capture failed, advise user
            }
        }

        if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
            	
                // Video captured and saved to fileUri specified in the Intent
            	fileUri = (Uri) data.getData();
				
				if(fileUri != null) {
					Log.d(TAG, &quot;Video saved to:\n&quot; + fileUri);
					Log.d(TAG, &quot;Video path:\n&quot; + fileUri.getPath());
					Log.d(TAG, &quot;Video name:\n&quot; + getName(fileUri)); // use uri.getLastPathSegment() if store in folder
				}
				
            } else if (resultCode == RESULT_CANCELED) {
                // User cancelled the video capture
            } else {
                // Video capture failed, advise user
            }
        }
    }
    
    /** Create a file Uri for saving an image or video to specific folder
     * https://developer.android.com/guide/topics/media/camera.html#saving-media
     * */
    private static Uri getOutputMediaFileUri(int type)
    {
          return Uri.fromFile(getOutputMediaFile(type));
    }

    /** Create a File for saving an image or video */
    private static File getOutputMediaFile(int type)
    {
        // To be safe, you should check that the SDCard is mounted
        
    	if(Environment.getExternalStorageState() != null) {
    		// this works for Android 2.2 and above
    		File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), &quot;AndroidCameraTestsFolder&quot;);
            
            // This location works best if you want the created images to be shared
            // between applications and persist after your app has been uninstalled.

            // Create the storage directory if it does not exist
            if (! mediaStorageDir.exists()) {
                if (! mediaStorageDir.mkdirs()) {
                    Log.d(TAG, &quot;failed to create directory&quot;);
                    return null;
                }
            }

            // Create a media file name
            String timeStamp = new SimpleDateFormat(&quot;yyyyMMdd_HHmmss&quot;).format(new Date());
            File mediaFile;
            if (type == MEDIA_TYPE_IMAGE){
                mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                &quot;IMG_&quot;+ timeStamp + &quot;.jpg&quot;);
            } else if(type == MEDIA_TYPE_VIDEO) {
                mediaFile = new File(mediaStorageDir.getPath() + File.separator +
                &quot;VID_&quot;+ timeStamp + &quot;.mp4&quot;);
            } else {
                return null;
            }

            return mediaFile;
    	}
        
    	return null;
    }

    // grab the name of the media from the Uri
    protected String getName(Uri uri) 
	{
		String filename = null;

		try {
			String[] projection = { MediaStore.Images.Media.DISPLAY_NAME };
			Cursor cursor = managedQuery(uri, projection, null, null, null);

			if(cursor != null &amp;&amp; cursor.moveToFirst()){
				int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME);
				filename = cursor.getString(column_index);
			} else {
				filename = null;
			}
		} catch (Exception e) {
			Log.e(TAG, &quot;Error getting file name: &quot; + e.getMessage());
		}

		return filename;
	}
}
</pre></p>
<p><strong>Main.xml</strong><br />
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    android:orientation=&quot;vertical&quot; &gt;

    &lt;Button android:text=&quot;Capture Image&quot; android:onClick=&quot;onCaptureImage&quot; 
        android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;/&gt;
    
	&lt;Button android:text=&quot;Capture Video&quot; android:onClick=&quot;onCaptureVideo&quot;
	    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;/&gt;
	
&lt;/LinearLayout&gt;
</pre></p>
<p><strong>ApplicationManifest.xml</strong><br />
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    package=&quot;com.thanksmister.mobile&quot;
    android:versionCode=&quot;1&quot;
    android:versionName=&quot;1.0&quot; &gt;

    &lt;uses-sdk android:targetSdkVersion=&quot;15&quot; android:minSdkVersion=&quot;8&quot;/&gt;
    
    &lt;uses-permission android:name=&quot;android.permission.CAMERA&quot;/&gt;
 	&lt;uses-feature android:name=&quot;android.hardware.camera&quot; /&gt;
 	&lt;uses-feature android:name=&quot;android.hardware.camera.autofocus&quot;/&gt;
  	&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;

    &lt;application
        android:icon=&quot;@drawable/ic_launcher&quot;
        android:label=&quot;@string/app_name&quot; &gt;
        &lt;activity
            android:name=&quot;AndroidCameraTestsActivity&quot;
            android:label=&quot;@string/app_name&quot; &gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;
</pre></p>
<p><strong>Additional Resources:</strong></p>
<p><a href="http://www.thanksmr.com/examples/androidcameratests/AndroidCameraTests.zip">Android Camera Test Project</a><br />
<a href="https://kevinpotgieter.wordpress.com/2011/03/30/null-intent-passed-back-on-samsung-galaxy-tab/" target="_blank">Null Intent passed back On Samsung Galaxy Tab…</a></p>
<p>-Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1943/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1943/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1943/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1943&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2012/03/16/android_null_data_camera_intent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>
	</item>
		<item>
		<title>Flex Chart DataTip Renderer</title>
		<link>http://thanksmister.com/2012/01/18/flex-chart-datatip-renderer/</link>
		<comments>http://thanksmister.com/2012/01/18/flex-chart-datatip-renderer/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 19:06:25 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Chart]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Charts]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[DataTip]]></category>
		<category><![CDATA[LineChart]]></category>
		<category><![CDATA[Spark Skins]]></category>
		<category><![CDATA[ToolTip]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1894</guid>
		<description><![CDATA[Here is a quick post with some code to create custom DataTip renderers for Flex charts using Spark components and containers. Below is a screen shot of the custom DataTip and the source code to create it follows. Main.mxml DataTipSkin.mxml -Mister<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1894&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a quick post with some code to create custom DataTip renderers for Flex charts using Spark components and containers. Below is a screen shot of the custom DataTip and the source code to create it follows. </p>
<p><a href="http://thanksmister.files.wordpress.com/2012/01/cartdatatip.png"><img src="http://thanksmister.files.wordpress.com/2012/01/cartdatatip.png?w=630" alt="" title="CartDataTip"   class="alignnone size-full wp-image-1896" /></a></p>
<p><strong>Main.mxml</strong><br />
<pre class="brush: as3;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:WindowedApplication xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; 
					   xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot; 
					   xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot; 
					   xmlns:charts=&quot;com.thanksmister.charts.*&quot; 
					   width=&quot;480&quot; height=&quot;340&quot;&gt;
	
	&lt;fx:Style source=&quot;assets/css/style.css&quot;/&gt;
	
	&lt;fx:Script&gt;
		&lt;![CDATA[
			import mx.charts.CategoryAxis;
			
			private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String 
			{
				var datNum:Number = Date.parse(item);
				var tempDate:Date = new Date(datNum);
				
				return dateFormatter.format(tempDate).toUpperCase();
			}
		]]&gt;
	&lt;/fx:Script&gt;
	
	&lt;fx:Declarations&gt;
		&lt;mx:DateFormatter id=&quot;dateFormatter&quot; formatString=&quot;MMMM-DD-YYYY&quot; /&gt;
	
		&lt;s:XMLListCollection id=&quot;dp&quot;&gt;
			&lt;s:source&gt;
				&lt;fx:XMLList&gt;
					&lt;quote date=&quot;8/1/2007&quot; open=&quot;40.29&quot; close=&quot;39.58&quot; /&gt;
					&lt;quote date=&quot;8/2/2007&quot; open=&quot;39.4&quot; close=&quot;39.52&quot; /&gt;
					&lt;quote date=&quot;8/3/2007&quot; open=&quot;39.47&quot; close=&quot;38.75&quot; /&gt;
					&lt;quote date=&quot;8/6/2007&quot; open=&quot;38.71&quot; close=&quot;39.38&quot; /&gt;
					&lt;quote date=&quot;8/7/2007&quot; open=&quot;39.08&quot; close=&quot;39.42&quot; /&gt;
					&lt;quote date=&quot;8/8/2007&quot; open=&quot;39.61&quot; close=&quot;40.23&quot; /&gt;
					&lt;quote date=&quot;8/9/2007&quot; open=&quot;39.9&quot; close=&quot;40.75&quot; /&gt;
					&lt;quote date=&quot;8/10/2007&quot; open=&quot;41.3&quot; close=&quot;41.06&quot; /&gt;
					&lt;quote date=&quot;8/13/2007&quot; open=&quot;41&quot; close=&quot;40.83&quot; /&gt;
					&lt;quote date=&quot;8/14/2007&quot; open=&quot;41.01&quot; close=&quot;40.41&quot; /&gt;
					&lt;quote date=&quot;8/15/2007&quot; open=&quot;40.22&quot; close=&quot;40.18&quot; /&gt;
					&lt;quote date=&quot;8/16/2007&quot; open=&quot;39.83&quot; close=&quot;39.96&quot; /&gt;
					&lt;quote date=&quot;8/17/2007&quot; open=&quot;40.18&quot; close=&quot;40.32&quot; /&gt;
					&lt;quote date=&quot;8/20/2007&quot; open=&quot;40.55&quot; close=&quot;40.74&quot; /&gt;
					&lt;quote date=&quot;8/21/2007&quot; open=&quot;40.41&quot; close=&quot;40.13&quot; /&gt;
					&lt;quote date=&quot;8/22/2007&quot; open=&quot;40.4&quot; close=&quot;40.77&quot; /&gt;
					&lt;quote date=&quot;8/23/2007&quot; open=&quot;40.82&quot; close=&quot;40.6&quot; /&gt;
					&lt;quote date=&quot;8/24/2007&quot; open=&quot;40.5&quot; close=&quot;40.41&quot; /&gt;
					&lt;quote date=&quot;8/27/2007&quot; open=&quot;40.38&quot; close=&quot;40.81&quot; /&gt;
				&lt;/fx:XMLList&gt;
			&lt;/s:source&gt;
		&lt;/s:XMLListCollection&gt;

		&lt;s:SolidColorStroke id=&quot;lineStroke&quot; color=&quot;#CCCCCCC&quot; alpha=&quot;.2&quot; weight=&quot;1&quot;/&gt;
		
	&lt;/fx:Declarations&gt;
	
	&lt;s:VGroup width=&quot;100%&quot; height=&quot;100%&quot; paddingBottom=&quot;10&quot; paddingTop=&quot;10&quot; paddingLeft=&quot;10&quot; paddingRight=&quot;10&quot;&gt;
		
		&lt;mx:LineChart id=&quot;lineChart&quot;
					  showDataTips=&quot;true&quot;
					  dataProvider=&quot;{dp}&quot;
					  width=&quot;100%&quot; gutterRight=&quot;10&quot;
					  height=&quot;100%&quot; 
					  dataTipRenderer=&quot;com.thanksmister.charts.DataTipSkin&quot;&gt;
			
			&lt;!-- vertical axis --&gt;
			&lt;mx:verticalAxis&gt;
				&lt;mx:LinearAxis baseAtZero=&quot;false&quot; title=&quot;Price&quot; /&gt;
			&lt;/mx:verticalAxis&gt;
			
			&lt;!-- horizontal axis --&gt;
			&lt;mx:horizontalAxis&gt;
				&lt;mx:CategoryAxis id=&quot;ca&quot; categoryField=&quot;@date&quot; title=&quot;Date&quot; labelFunction=&quot;categoryAxis_labelFunc&quot; /&gt;
			&lt;/mx:horizontalAxis&gt;
			
			&lt;!-- horizontal axis renderer --&gt;
			&lt;mx:horizontalAxisRenderers&gt;
				&lt;mx:AxisRenderer axis=&quot;{ca}&quot; canDropLabels=&quot;true&quot; /&gt;
			&lt;/mx:horizontalAxisRenderers&gt;
			
			&lt;!-- series --&gt;
			&lt;mx:series&gt;
				&lt;mx:LineSeries yField=&quot;@open&quot; form=&quot;segment&quot; displayName=&quot;Open&quot; /&gt;
			&lt;/mx:series&gt;
			
			&lt;!-- series filters --&gt;
			&lt;mx:seriesFilters&gt;
				&lt;fx:Array/&gt;
			&lt;/mx:seriesFilters&gt;
			
			&lt;!-- assign stroke to grid lines --&gt;
			&lt;mx:backgroundElements&gt;
				&lt;mx:GridLines gridDirection=&quot;both&quot; horizontalChangeCount=&quot;2&quot; verticalChangeCount=&quot;6&quot;&gt;
					&lt;mx:horizontalStroke&gt;{lineStroke}&lt;/mx:horizontalStroke&gt;
					&lt;mx:verticalStroke&gt;{lineStroke}&lt;/mx:verticalStroke&gt;
				&lt;/mx:GridLines&gt;
			&lt;/mx:backgroundElements&gt;
			
			&lt;mx:annotationElements&gt;
				&lt;fx:Array&gt;
					&lt;charts:RangeSelector id=&quot;selectedRange&quot; /&gt;
				&lt;/fx:Array&gt;
			&lt;/mx:annotationElements&gt;
			
		&lt;/mx:LineChart&gt;
		
	&lt;/s:VGroup&gt;
	
&lt;/s:WindowedApplication&gt;
</pre></p>
<p><strong>DataTipSkin.mxml</strong><br />
<pre class="brush: as3;">'
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:Group  xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot; 
		 xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;  
		 implements=&quot;mx.core.IFlexDisplayObject, mx.core.IDataRenderer&quot;
		 xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot; width=&quot;120&quot;&gt;
	
	&lt;fx:Script&gt;
		&lt;![CDATA[
			import flashx.textLayout.conversion.TextConverter;
			import flashx.textLayout.elements.TextFlow;
			
			import mx.charts.HitData;
			import mx.charts.series.items.LineSeriesItem;
			
			private var _data:HitData;
			
			[Bindable]
			private var _xValue:String;
			
			[Bindable]
			private var _yValue:String;
			
			[Bindable]
			private var _displayText:TextFlow;
			
			public function get data():Object
			{
				// TODO Auto Generated method stub
				return null;
			}
			
			public function set data(value:Object):void
			{
				// HitData data from chart
				_data = value as HitData;
				
				// The display text used in datatip which comes in HTML format
				_displayText = TextConverter.importToFlow(_data.displayText, TextConverter.TEXT_FIELD_HTML_FORMAT);
				
				// HitData contains a reference to the ChartItem
				var item:LineSeriesItem = _data.chartItem as LineSeriesItem;
				
				// ChartItem xValue and yValue 
				_xValue = String(item.xValue);
				_yValue = String(item.yValue);
			}
		]]&gt;
	&lt;/fx:Script&gt;
	
	&lt;fx:Declarations&gt;
		
	&lt;/fx:Declarations&gt;
	
	&lt;s:Rect right=&quot;0&quot; left=&quot;0&quot; bottom=&quot;0&quot; top=&quot;0&quot;&gt;
		&lt;s:filters&gt;
			&lt;s:DropShadowFilter blurX=&quot;20&quot; blurY=&quot;20&quot; alpha=&quot;0.22&quot; distance=&quot;5&quot; angle=&quot;90&quot; knockout=&quot;false&quot; /&gt;
		&lt;/s:filters&gt;
		&lt;s:fill&gt;
			&lt;s:SolidColor color=&quot;0x393939&quot;/&gt;
		&lt;/s:fill&gt;    
		&lt;s:stroke&gt;
			&lt;s:SolidColorStroke color=&quot;0x1a1a19&quot;  weight=&quot;1&quot; alpha=&quot;.2&quot; /&gt;
		&lt;/s:stroke&gt;
	&lt;/s:Rect&gt;
	
	&lt;s:VGroup width=&quot;100%&quot; height=&quot;100%&quot; paddingTop=&quot;10&quot; paddingRight=&quot;10&quot; paddingBottom=&quot;10&quot; paddingLeft=&quot;10&quot;&gt;
		
		&lt;s:RichEditableText textFlow=&quot;{_displayText}&quot; width=&quot;100%&quot; textAlign=&quot;center&quot; selectable=&quot;false&quot; editable=&quot;false&quot;/&gt;
		
	&lt;/s:VGroup&gt;

&lt;/s:Group&gt;
</pre></p>
<p>-Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1894/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1894/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1894/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1894&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2012/01/18/flex-chart-datatip-renderer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2012/01/cartdatatip.png" medium="image">
			<media:title type="html">CartDataTip</media:title>
		</media:content>
	</item>
		<item>
		<title>Flex Spark Rounded Image and Image Button Controls</title>
		<link>http://thanksmister.com/2012/01/17/flex-spark-rounded-image-and-image-button-controls/</link>
		<comments>http://thanksmister.com/2012/01/17/flex-spark-rounded-image-and-image-button-controls/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 19:28:26 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[Spark Skins]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[Image]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1877</guid>
		<description><![CDATA[I had the pleasure recently of collaborating with Ken Rogers (@pixels4nickels) on a couple of components. I had the need, and probably everyone has at one time or another, of having a image with rounded corners. My other desire was to have an image behave like a button. So we came up with two components, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1877&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure recently of collaborating with Ken Rogers (<a href="pixels4nickels" target="_blank">@pixels4nickels</a>) on a couple of components.  I had the need, and probably everyone has at one time or another, of having a image with rounded corners.  My other desire was to have an image behave like a button.  </p>
<p>So we came up with two components, one is called RoundedImage, this does pretty much what it advertises. It extends the Flex Spark Image control to set a corner radius of the loaded image.  The other component is called ImageButton.  This extends the Spark Button control and loads an image to create a button with rounded corners, pretty straight forward.  </p>
<p>What makes these components nice is that they maintain the aspect ratio of the loaded image by simply setting either a height or width. So if you have a large image and want to scale it proportionally, you just set the width, the height will be scaled maintaining the aspect ratio. If you set both height and width values the loaded image will stretch to fit the dimensions.  </p>
<p>Here is a screen shot of the results when setting with, height, or both:</p>
<p><a href="http://thanksmister.files.wordpress.com/2012/01/screen-shot-2012-01-17-at-11-03-49-am.png"><img src="http://thanksmister.files.wordpress.com/2012/01/screen-shot-2012-01-17-at-11-03-49-am.png?w=630" alt="" title="ImageButtonImage"   class="alignnone size-full wp-image-1878" /></a></p>
<p>You can take a look at the code for the Rounded Image and the Image Button at the following Gist links:</p>
<p>Michael Ritchie Gist: <a href="https://gist.github.com/1627989" target="_blank">https://gist.github.com/1627989</a><br />
Ken Rogers Gist: <a href="https://gist.github.com/1625442" target="_blank">https://gist.github.com/1625442</a><br />
Flex FXP File: <a href="http://thanksmr.com/examples/imagebuttons/ImageButtons.fxp">http://thanksmr.com/examples/imagebuttons/ImageButtons.fxp</a></p>
<p>Big thanks to Ken for his help working out all the kinks and keeping it simple!</p>
<p>-Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1877/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1877/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1877/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1877&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2012/01/17/flex-spark-rounded-image-and-image-button-controls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2012/01/screen-shot-2012-01-17-at-11-03-49-am.png" medium="image">
			<media:title type="html">ImageButtonImage</media:title>
		</media:content>
	</item>
		<item>
		<title>Determining local timezone in ActionScript (AIR, Flex, AS3)</title>
		<link>http://thanksmister.com/2011/10/06/determining-local-timezone-in-actionscript-air-flex-as3/</link>
		<comments>http://thanksmister.com/2011/10/06/determining-local-timezone-in-actionscript-air-flex-as3/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 22:35:49 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1848</guid>
		<description><![CDATA[I made a little utility class that determines the local timezone (PST, EST, MST, CST, etc.). The guts of the utility are three methods, one for determining if the local machine is currently observing daylight savings time, another determines the GMT time from the the local machines current Date, and one for looking up the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1848&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made a little utility class that determines the local timezone (PST, EST, MST, CST, etc.).  The guts of the utility are three methods, one for determining if the local machine is currently observing daylight savings time, another determines the GMT time from the the local machines current Date, and one for looking up the timezone abbreviation by GMT time. This is sort of a conglomerate of code that I could find on different posts and leveraged them to achieve my own goals.</p>
<p>Determining if the daylight savings time is currently being observed.</p>
<p><pre class="brush: as3;">
**
* Determines if local computer is observing daylight savings time for US and London.
* */
public static function isObservingDTS():Boolean
{
     var winter:Date = new Date(2011, 01, 01); // after daylight savings time ends
     var summer:Date = new Date(2011, 07, 01); // during daylight savings time
     var now:Date = new Date();

     var winterOffset:Number = winter.getTimezoneOffset();
     var summerOffset:Number = summer.getTimezoneOffset();
     var nowOffset:Number = now.getTimezoneOffset();

     if((nowOffset == summerOffset) &amp;&amp; (nowOffset != winterOffset)) {
          return true;
     } else {
          return false;
     }
}
</pre></p>
<p>Creating the GMT from a Date object and adjusting for daylight savings time.</p>
<p><pre class="brush: as3;">
/**
* Method to build GMT from date and timezone offset and accounting for daylight savings.
*
* Originally code befor modifications:
* http://flexoop.com/2008/12/flex-date-utils-date-and-time-format-part-i/
* */
private static function buildTimeZoneDesignation( date:Date, dts:Boolean ):String
{
     if ( !date ) {
          return &quot;&quot;;
     }

     var timeZoneAsString:String = &quot;GMT&quot;;
     var timeZoneOffset:Number;

     // timezoneoffset is the number that needs to be added to the local time to get to GMT, so
     // a positive number would actually be GMT -X hours
     if ( date.getTimezoneOffset() / 60 &gt; 0 &amp;&amp; date.getTimezoneOffset() / 60 &lt; 10 ) {
          timeZoneOffset = (dts)? ( date.getTimezoneOffset() / 60 ):( date.getTimezoneOffset() / 60 - 1 );
          timeZoneAsString += &quot;-0&quot; + timeZoneOffset.toString();
     } else if ( date.getTimezoneOffset() &lt; 0 &amp;&amp; date.timezoneOffset / 60 &gt; -10 ) {
          timeZoneOffset = (dts)? ( date.getTimezoneOffset() / 60 ):( date.getTimezoneOffset() / 60 + 1 );
          timeZoneAsString += &quot;+0&quot; + ( -1 * timeZoneOffset ).toString();
     } else {
          timeZoneAsString += &quot;+00&quot;;
     }

     // add zeros to match standard format
     timeZoneAsString += &quot;00&quot;;
     return timeZoneAsString;
}
</pre></p>
<p>Finally, parsing the abbreviation from a simple lookup Array object.</p>
<p><pre class="brush: as3;">
/**
* List of timezone abbreviations and matching GMT times.
* Modified form original code at:
* http://blog.flexexamples.com/2009/07/27/parsing-dates-with-timezones-in-flex/
* */
private static var timeZoneAbbreviations:Array = [
     /* Hawaii-Aleutian Standard/Daylight Time */
     {abbr:&quot;HAST&quot;, zone:&quot;GMT-1000&quot;},
     {abbr:&quot;HADT&quot;, zone:&quot;GMT-0900&quot;},
     /* Alaska Standard/Daylight Time */
     {abbr:&quot;AKST&quot;, zone:&quot;GMT-0900&quot;},
     {abbr:&quot;ASDT&quot;, zone:&quot;GMT-0800&quot;},
     /* Pacific Standard/Daylight Time */
     {abbr:&quot;PST&quot;, zone:&quot;GMT-0800&quot;},
     {abbr:&quot;PDT&quot;, zone:&quot;GMT-0700&quot;},
     /* Mountain Standard/Daylight Time */
     {abbr:&quot;MST&quot;, zone:&quot;GMT-0700&quot;},
     {abbr:&quot;MDT&quot;, zone:&quot;GMT-0600&quot;},
     /* Central Standard/Daylight Time */
     {abbr:&quot;CST&quot;, zone:&quot;GMT-0600&quot;},
     {abbr:&quot;CDT&quot;, zone:&quot;GMT-0500&quot;},
     /* Eastern Standard/Daylight Time */
     {abbr:&quot;EST&quot;, zone:&quot;GMT-0500&quot;},
     {abbr:&quot;EDT&quot;, zone:&quot;GMT-0400&quot;},
     /* Atlantic Standard/Daylight Time */
     {abbr:&quot;AST&quot;, zone:&quot;GMT-0400&quot;},
     {abbr:&quot;ADT&quot;, zone:&quot;GMT-0300&quot;},
     /* Newfoundland Standard/Daylight Time */
     {abbr:&quot;NST&quot;, zone:&quot;GMT-0330&quot;},
     {abbr:&quot;NDT&quot;, zone:&quot;GMT-0230&quot;},
     /* London Standard/Daylight Time */
     {abbr:&quot;BST&quot;, zone:&quot;GMT+0100&quot;},
     {abbr:&quot;GMT&quot;, zone:&quot;GMT+0000&quot;}
];

/**
* Goes through the timze zone abbreviations looking for matching GMT time.
* */
private static function parseTimeZoneFromGMT(gmt:String):String
{
     for each (var obj:Object in timeZoneAbbreviations) {
          if(obj.zone == gmt){
               return obj.abbr;
          }
     }
     return gmt;
}
</pre></p>
<p>This utility is obviously not robust enough to do world timezones, but its enough of a framework to work with if you want to expand past just US timezones (and London).  I am sure there are a lot of different ways this could be improved, so please share resources or ideas if you have them.  You can get the code for the complete utility from GitHub:</p>
<p><a href="http://gist.github.com/1268863">TimzeZoneUtil.as </a></p>
<p>Thanks!</p>
<p>-Mister</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1848/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1848/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1848/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1848&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2011/10/06/determining-local-timezone-in-actionscript-air-flex-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>
	</item>
		<item>
		<title>Truncate Spark Label in the middle and showTruncationTip</title>
		<link>http://thanksmister.com/2011/08/26/truncate-spark-label-in-the-middle-and-showtruncationtip/</link>
		<comments>http://thanksmister.com/2011/08/26/truncate-spark-label-in-the-middle-and-showtruncationtip/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 23:07:39 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[Label]]></category>
		<category><![CDATA[showTruncationTip]]></category>

		<guid isPermaLink="false">http://thanksmister.com/?p=1739</guid>
		<description><![CDATA[Found a little handy customization of the Spark Label control that truncates the label in the middle with a (&#8230;). However it didn&#8217;t show the full label text on roll over when setting the showTruncationTip=&#8221;true&#8221; property of the control. I added a few little lines of code to fix it. The code stores the original [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1739&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Found a little handy customization of the Spark Label control that truncates the label in the middle with a (&#8230;).  However it didn&#8217;t show the full label text on roll over when setting the showTruncationTip=&#8221;true&#8221; property of the control.  I added a few little lines of code to fix it.   </p>
<p>The code stores the original value in a variable called &#8220;_trueText&#8221;, so that just needs to be the value you pass to the toolTip when <strong>showTruncationTip=&#8221;true&#8221;</strong>.  You need to override the mx_internal function to accomplish this. </p>
<p><pre class="brush: as3;">
override mx_internal function setIsTruncated(value:Boolean):void
		{
			if (_isTruncated != value)
			{
				_isTruncated = value;
				if (showTruncationTip)
					toolTip = _isTruncated ? _trueText : null;
				dispatchEvent(new Event(&quot;isTruncatedChanged&quot;));
			}
		}
</pre></p>
<p>Then you need to add one little bit of code in the truncateTextMiddle method that will tell the control that the text is indeed truncated, <strong>setIsTruncated(true);</strong> should be at the end of that method around line 153 in the code snippet below:</p>
<p><pre class="brush: as3;">
	public function truncateTextMiddle(fullText:String, widthToTruncate:Number) : String
		{
			if (!(fullText) || fullText.length &lt; 3 || !this.parent)
			{
				// skip any truncating if no styles (no parent),
				// or text is too small
				return fullText;
			}
			
			// add paddings for some font oversize issues
			var paddingWidth:Number =
				UITextField.mx_internal::TEXT_WIDTH_PADDING +
				this.getStyle(&quot;paddingLeft&quot;) + this.getStyle(&quot;paddingRight&quot;);
			
			// Skip if width is too small
			if (widthToTruncate &lt; paddingWidth + 10) return fullText;
			
			// Prepare measurement object
			// We create new TextField, and copy styles for it from this object
			// We cannot re-use internal original text field instance because
			// it will cause event firing in process of text measurement
			var measurementField:TextField = new TextField();
			
			// Clear so measured text will not get old styles.
			measurementField.text = &quot;&quot;;
			
			// Copy styles into TextField
			var textStyles:UITextFormat = this.determineTextFormatFromStyles();
			measurementField.defaultTextFormat = textStyles;
			var sm:ISystemManager = this.systemManager;
			if (textStyles.font)
			{
				measurementField.embedFonts = sm != null &amp;&amp; sm.isFontFaceEmbedded(textStyles);
			}
			else
			{
				measurementField.embedFonts = false;
			}
			if (textStyles.antiAliasType) {
				measurementField.antiAliasType = textStyles.antiAliasType;
			}
			if (textStyles.gridFitType) {
				measurementField.gridFitType = textStyles.gridFitType;
			}
			if (!isNaN(textStyles.sharpness)) {
				measurementField.sharpness = textStyles.sharpness;
			}
			if (!isNaN(textStyles.thickness)) {
				measurementField.thickness = textStyles.thickness;
			}
			
			// Perform initial measure of text and check if need truncating at all
			
			// To measure text, we set it to measurement text field
			// and get line metrics for first line
			measurementField.text = fullText;
			var fullTextWidth:Number = measurementField.getLineMetrics(0).width + paddingWidth;
			if(fullTextWidth &gt; widthToTruncate){
				// get width of ...
				measurementField.text = &quot;...&quot;;
				var dotsWidth:Number = measurementField.getLineMetrics(0).width;
				
				// Find out what is the half of truncated text without ...
				var halfWidth : Number = (widthToTruncate - paddingWidth - dotsWidth) / 2;
				
				// Make a rough estimate of how much chars we need to cut out
				// This saves steps of character-by-character preocessing
				measurementField.text = &quot;s&quot;;
				var charWidth:Number = measurementField.getLineMetrics(0).width;
				var charsToTruncate:int = Math.round(
					((fullTextWidth - paddingWidth) / 2 - halfWidth) /
					charWidth) + 2;
				
				// allow some distortion to account fractional widths part
				halfWidth = halfWidth - 0.5;
				
				// Below algorithm makes rough middle-truncating
				// Then it is corrected by adding or removing
				// characters for each part until reach required
				// width for each half. Algorith does checks
				// (min max and loop ciodnitions) so that string
				// cannot be less then one character for each half
				
				// see if right part of text approximately fits into half width
				var rightPart:String;
				var widthWithNextChar:Number;
				
				var len:int = fullText.length;
				var currLoc:int = Math.min(len/2 + charsToTruncate + 1, len-1);
				measurementField.text = fullText.substr(currLoc);
				var rightPartWidth:Number = measurementField.getLineMetrics(0).width;
				
				if (rightPartWidth &gt; halfWidth) {
					// throw away characters until fits
					currLoc++;
					while (rightPartWidth &gt; halfWidth &amp;&amp; currLoc &lt; len) {
						measurementField.text = fullText.charAt(currLoc);
						rightPartWidth -= measurementField.getLineMetrics(0).width;
						currLoc++;
					}
					rightPart = fullText.substr(currLoc - 1);
				} else {
					// try to add characters one-by-one and
					// see if it still fits
					widthWithNextChar = 0;
					do {
						currLoc--;
						rightPartWidth += widthWithNextChar;
						measurementField.text = fullText.charAt(currLoc);
						widthWithNextChar = measurementField.getLineMetrics(0).width;
					} while (rightPartWidth + widthWithNextChar &lt;= halfWidth &amp;&amp; currLoc &gt; 0);
					rightPart = fullText.substr(currLoc + 1);
				}
				
				// Do the same with left part, but compare overall string
				// Overall is needed because character-by character
				// would not give us correct total width of string -
				// somehow overall text is measured with sapcers etc. and
				// also there are rounding issues.
				// This way, and by putting left part calculating as last, we allow
				// left part might be larger (may become more than half).
				
				// allow some distortion in widths fractions
				widthToTruncate = widthToTruncate - 0.5 - paddingWidth;
				
				currLoc = Math.max(len/2 - charsToTruncate, 1);
				measurementField.text = fullText.substr(0, currLoc) +
					&quot;...&quot; + rightPart;
				var truncatedWidth:Number = measurementField.getLineMetrics(0).width;
				if (truncatedWidth &gt; widthToTruncate) {
					// throw away characters until fits
					currLoc--;
					while (truncatedWidth &gt; widthToTruncate &amp;&amp; currLoc &gt; 0) {
						measurementField.text = fullText.substr(0, currLoc) +
							&quot;...&quot; + rightPart;
						truncatedWidth = measurementField.getLineMetrics(0).width;
						currLoc--;
					}
					currLoc++;
				} else {
					// try to add characters one-by-one and
					// see if it still fits
					do {
						currLoc++;
						measurementField.text = fullText.substr(0, currLoc) +
							&quot;...&quot; + rightPart;
						widthWithNextChar = measurementField.getLineMetrics(0).width;
					} while (widthWithNextChar &lt;= widthToTruncate &amp;&amp;
						currLoc &lt; len-1);
					currLoc--;
				}

				setIsTruncated(true);
				
				return fullText.substr(0, Math.max(currLoc,1)) +
					&quot;...&quot; + rightPart;
			}
			return fullText;
			
		}
</pre></p>
<p>The original post can be found <a href="http://as3hero.blogspot.com/2011/04/flex-4-truncate-label-in-middle.html" target="_blank">here</a>.</p>
<p>-Mr</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1739/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1739/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1739/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1739&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2011/08/26/truncate-spark-label-in-the-middle-and-showtruncationtip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Android TitleBar with Drop Shadow</title>
		<link>http://thanksmister.com/2011/06/06/android-titlebar-drop-shadow/</link>
		<comments>http://thanksmister.com/2011/06/06/android-titlebar-drop-shadow/#comments</comments>
		<pubDate>Mon, 06 Jun 2011 10:33:07 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[LinearLayout]]></category>
		<category><![CDATA[ListAdapter]]></category>
		<category><![CDATA[ListView]]></category>
		<category><![CDATA[TitleBar]]></category>

		<guid isPermaLink="false">http://www.thanksmister.com/?p=1526</guid>
		<description><![CDATA[Recently I ran into a little challenge with some designs for an Android application. The designs called for a drop shadow to appear on the application TitleBar and the footer bar. The drop shadow effect should appear on top of the scrolling list items. However, I learned that with the Android ListView component there is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1526&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I ran into a little challenge with some designs for an Android application. The designs called for a drop shadow to appear on the application TitleBar and the footer bar. The drop shadow effect should appear on top of the scrolling list items. However, I learned that with the Android ListView component there is already an effect called the fading edge. An additional problem is producing a realistic drop shadow effect that appears to float over the items below it rather than take up space between the TitleBar and the ListView.</p>
<p>The first problem, the built in fading edge effect of the ListView makes the list item appear to fade from the screen as it scrolls to the top or bottom of the list. In general this is a nice effect as the ListView produces it’s own shadow and fade as the list is scrolled under the TitleBar. However, this effect clashes with a custom drop shadow effect on the TitleBar because when list items are pressed or selected they produce a slight glow and blur effect at the top/bottom of the list just below the drop shadow. There are two properties of the ListView component that need to be turned “off” for the effects to be removed:</p>
<p><pre class="brush: java;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;ListView
xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
android:layout_height=&quot;fill_parent&quot;
android:layout_width=&quot;fill_parent&quot;
android:cacheColorHint=&quot;#00000000&quot;
android:fadingEdge=&quot;none&quot;/&gt;
</pre></p>
<p><a href="https://gist.github.com/997273" target="_blank">https://gist.github.com/997273</a></p>
<p>The <a href="http://stackoverflow.com/questions/3221119/android-listview-shadow">fadingEdge=”none”</a> setting removes the blurring and fading of list items as they scroll off screen and the cachColorHint=”#0000000″ removes the list from turning black while scrolled even though the background maybe set to be transparent (you can also set a custom list item drawable background to take care of this problem). There is an interesting article about why this effect is part of the ListView component that can be read on the <a href="http://android-developers.blogspot.com/2009/01/why-is-my-list-black-android.html">Android Developer blog</a>.</p>
<p>So now you have a list that has no shadow, fade, or blur effects. To get the shadow to appear to float above the scrolling content I created a a nice drop shadow PNG file in Photoshop with transparent background. I then used the Android <a href="http://developer.android.com/guide/developing/tools/draw9patch.html">Draw 9-Patch</a> tool to make the shadow file scale horizontally across the top and bottom of the application. You now get the following results:</p>
<p><img class="alignnone size-full wp-image-1527" title="customtitlebar" src="http://thanksmister.files.wordpress.com/2011/06/customtitlebar1.png?w=630" alt=""   /></p>
<p>To get the shadow to “float” on top of the ListView, I used a Relative layout to position the items. I also used my own custom TitleBar and ListAdapter in the application to get the desired appearance, as well as added a static footer graphic. What you get a nice drop shadow on the top and bottom of the application that is always on top of the list. This approach as the advantage that the list is underneath the drop shadow not just position below it as it might be if you used a LinearLayout.</p>
<p>You can download the full project code on <a href="http://goo.gl/NPRPy">GitHub</a>.</p>
<p>-Mr</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1526/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1526/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1526/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1526&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2011/06/06/android-titlebar-drop-shadow/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2011/06/customtitlebar1.png" medium="image">
			<media:title type="html">customtitlebar</media:title>
		</media:content>
	</item>
		<item>
		<title>Remove Underline from Clickable text in TextView on Android</title>
		<link>http://thanksmister.com/2011/05/20/android-remove-underline-from-clickable-text-in-textview/</link>
		<comments>http://thanksmister.com/2011/05/20/android-remove-underline-from-clickable-text-in-textview/#comments</comments>
		<pubDate>Fri, 20 May 2011 11:53:01 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[ClickableSpan]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[SpannableStringBuilder]]></category>
		<category><![CDATA[TextView]]></category>

		<guid isPermaLink="false">http://www.thanksmister.com/?p=1512</guid>
		<description><![CDATA[Been working with the Android SDK (v 2.2) lately and needed to a clickable text area in an TextView but one without any underlined links (so it doesn&#8217;t appear like a hyperlink). I also wanted to capture the click event and launch my own Activity within the same Activty, rather than use something as complicated [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1512&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Been working with the Android SDK (v 2.2) lately and needed to a clickable text area in an TextView but one without any underlined links (so it doesn&#8217;t appear like a hyperlink). I also wanted to capture the click event and launch my own Activity within the same Activty, rather than use something as complicated as <a href="http://developer.android.com/reference/android/text/util/Linkify.html">Linkify</a> for this use case.</p>
<p>This example builds the text value for a TextView component dynamically using a <a href="http://developer.android.com/reference/android/text/SpannableStringBuilder.html">SpannableStringBuilder</a>. To create the span for a given length of text, I created a custom class file that extends <a href="http://developer.android.com/reference/android/text/style/ClickableSpan.html">ClickableSpan</a>. This custom class overrides the the &#8220;<a href="http://developer.android.com/reference/android/text/style/ClickableSpan.html#updateDrawState%28android.text.TextPaint%29">updateDrawState</a>&#8221; method and removes the underline. This seems pretty straight forward, but it was not easy assembling all the pieces from various examples to get the results I desired.</p>
<p>Here is a image preview of the application output:</p>
<p><a href="http://thanksmister.files.wordpress.com/2011/05/clickablelink1.png"><img class="alignnone size-full wp-image-1513" title="Clickable Link Example Application Image" src="http://thanksmister.files.wordpress.com/2011/05/clickablelink1.png?w=630" alt=""   /></a></p>
<p>Full Code: <a href="https://gist.github.com/249970d811d84a529d37" target="_blank">https://gist.github.com/249970d811d84a529d37</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1512/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1512/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1512/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1512&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2011/05/20/android-remove-underline-from-clickable-text-in-textview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>

		<media:content url="http://thanksmister.files.wordpress.com/2011/05/clickablelink1.png" medium="image">
			<media:title type="html">Clickable Link Example Application Image</media:title>
		</media:content>
	</item>
		<item>
		<title>Spark Button and ButtonBar with icons and rollover states</title>
		<link>http://thanksmister.com/2011/04/28/spark-button-two-icon-states/</link>
		<comments>http://thanksmister.com/2011/04/28/spark-button-two-icon-states/#comments</comments>
		<pubDate>Thu, 28 Apr 2011 18:18:44 +0000</pubDate>
		<dc:creator>Michael Ritchie (Mr)</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Spark]]></category>
		<category><![CDATA[Spark Skins]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[ButtonBar]]></category>
		<category><![CDATA[ButtonBarButton]]></category>
		<category><![CDATA[Flex 4]]></category>

		<guid isPermaLink="false">http://www.thanksmister.com/?p=1474</guid>
		<description><![CDATA[The Flash Builder Spark Button control doesn’t come with an icon property out of the box. So you have to extend the Button class and add your own. I created a Spark Skin to add two icons to the Button control, one for the up/disabled state and one for the over/down states. The Spark ButtonBar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1474&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Flash Builder Spark Button control doesn’t come with an icon property out of the box. So you have to extend the Button class and add your own. I created a Spark Skin to add two icons to the Button control, one for the up/disabled state and one for the over/down states.</p>
<p>The Spark ButtonBar control does accommodate an icon, but there is no way to change the icon when the selected index changes. So to change the icon of the selected item, I built a Spark Skin for the ButtonBarButton and the ButtonBar to accomplish the job. Here is the running example of the buttons in action:</p>
<p><a href="http://thanksmr.com/resources/IconButtons.swf">IconButtons.swf</a></p>
<p>The code of the IconButton class and the IconButtonSkin mxml file that accompanies the class:</p>
<p><a href="https://gist.github.com/946886" target="_blank">https://gist.github.com/946886</a></p>
<p>And the code of the IconButtonBarButton class and the IconButtonBarSkin and IconButtonBarButtonskin mxml</p>
<p><a href="https://gist.github.com/947130" target="_blank">https://gist.github.com/947130</a></p>
<p>You can also download the <a href="http://thanksmr.com/resources/IconButtons.zip" target="_blank">IconButtons Flash Builder Project</a>.</p>
<p>-Mr</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thanksmister.wordpress.com/1474/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thanksmister.wordpress.com/1474/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thanksmister.wordpress.com/1474/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thanksmister.com&#038;blog=26538840&#038;post=1474&#038;subd=thanksmister&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thanksmister.com/2011/04/28/spark-button-two-icon-states/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/ab76e95419f5854ec2b978b8605afc3f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thanksmister</media:title>
		</media:content>
	</item>
	</channel>
</rss>
