Flex application on iOS with Flash Builder 4.5.1
Why Windows?
First thing I have to say is that this tutorial is for Windows only. I'm sorry, but at this point, developing Flex applications under Ubuntu is a bit too complicated. I am not a Mac user, so I have to use Windows for Flex development. My computer has an i7 CPU and 8GB of RAM, so I prefer to use a Windows 7 virtual machine instead of dual boot, but feel free to go with your own preference here.
Adobe Flash Builder 4.5.1
On June 20th, an update of Flash Builder 4.5 (4.5.1 in fact) was released. It includes more support for iOS and Blackberry tablet. It is now very easy to deploy on iOS devices, as long as you have the correct certificate files (next section).
Before you continue, make sure your Flash Builder is up-to-date:
- Start it as administrator (right click on the program icon and click "Run as administrator")
- Go in Flash Builder's Help menu -> Search for Flash Builder Updates...
- Accept and install all updates
- Go back to Help menu -> Software Updates...
- Accept and install all updates
- Restart Flash Builder
Generate required certificates
To be deployed in "development mode" on your iOS device(s), your application needs to be digitally signed. Here's the documentation on how to achieve all the different steps. Remember to follow instructions for Windows!
Three very important things you need to know:
- Open a DOS shell "as Administrator" to avoid some OpenSSL errors and warning.
- Before generating your key (as you will read in the documentation), execute the following command in your DOS shell: set RNDFILE=.rnd or you will get the following error: unable to write 'random state' e is 65537 (0x10001).
- When using OpenSSL, do not ignore error messages. If OpenSSL generates an error message, it may still output files. However, those files may not be usable. If you see errors, check your syntax and run the command again.
Create a Hello World application
Now, let's create a very simple Hello World application using Flash Builder.
- In Flash Builder's menu,go to: New / Flex Mobile Project
- Give it a name and click Next
- Select Apple iOS as your only target platform
- Select the View-Based Application template and click Finish
- Add a simple Label object saying "Hello World" or whatever you like in the View that is automatically created
- Let Flash Builder know about your certificates:
- Open the Project Properties window
- In the left menu, go to Flex Build Packaging / Apple iOS
- Browse and select your certificate file (.p12 file created earlier)
- Browse and select your provisioning file (downloaded from your Apple account)
- Build your project (or make a release build for better performance and lighter footprint).
For a video tutorial that might help you even more, please visit this page.
Add your device to your developer account
Just like it is required during standard native application development, your device needs to be "ready" for development. Here's Apple documentation on how to do that: Provisioning a Device for Development (you'll have to scroll down a little). I'm sorry for not giving any more help on this point. I don't know a lot about Apple's development processes. That part was actually done by another member of my team. But I'm sure Google will give you all the help you need.
Deploying using iTunes
You're almost there! Here are the final steps, all done using iTunes:
- Import your provisioning profile into iTunes
- Import the ipa file built by Flash Builder (found in the "bin-debug" folder of your project's workspace) into iTunes
- Sync your iOS device so your application gets installed
That's it! I'm aware there might be some missing details in this tutorial, but feel free to post any question you might have. I'll be very happy to help.
Install LibreOffice Dictionaries Under Ubuntu
======
UPDATE: read this article if you're using Ubuntu 12.04 (Precise Pangolin)
======
Since the arrival of Natty Narwhal (11.04),
LibreOffice has become the default productivity suite under Ubuntu. Being a French speaking person, installing the French dictionary turns out be really useful. It may sound stupid, but it took me about an hour of googling before finally finding this page: LibreOffice - Ubuntu Wiki.
Installing the good package
It turns out the only thing you have to do is install the right package for every language you need. For example:
- French: language-support-writing-fr
- Spanish: language-support-writing-es
- Italian: language-support-writing-it
Open Synaptic Package Manager, install the package of your choice, and you're done!
Installing an OpenOffice extension
For some reason, you might want to install a dictionary as an OpenOffice extension (also works with LibreOffice). In this case, visit this page, and download the extensions (one extension per language) you need. Double click on each downloaded extension file (.oxt) and LibreOffice will do the rest. For most users, I suggest installing the package instead of the extension though.
Remove Underline from Android TextView Link
As you may already know, the TextView object has a property named android:autoLink that creates HTML or email links automatically. You also got properties to change link colors such as android:textColorLink and android:textColorHighlight. The only missing option many of us would like to have is a way to remove the underline under the link itself.
Sadly, removing the underline seems to be somewhat "hard" to achieve. So here's my way of doing this, greatly inspired of the code I found on this blog.
First, let's create a TextView:
<TextView android:id="@+id/myTextView"
android:text="Want to search www.google.com?"
android:textColor="#409bbf"
android:textColorLink="#783302"
android:textColorHighlight="#ff0000"
android:autoLink="web"/>
The TextView above should look approximately like this when rendered in Android:
Want to search www.google.com?
Then we need a "util" class we'll name URLSpanNoUnderline:
package com.evilcodingmonkey.android.util;
import android.text.TextPaint;
import android.text.style.URLSpan;
public class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String p_Url) {
super(p_Url);
}
public void updateDrawState(TextPaint p_DrawState) {
super.updateDrawState(p_DrawState);
p_DrawState.setUnderlineText(false);
}
}
If you already have a StringUtil-like class (I always have one in my projects), add the following function to it. You may add this function anywhere you want anyway...
/**
* Removes URL underlines in a string by replacing URLSpan occurrences by
* URLSpanNoUnderline objects.
*
* @param p_Text A Spannable object. For example, a TextView casted as
* Spannable.
*/
public static void removeUnderlines(Spannable p_Text) {
URLSpan[] spans = p_Text.getSpans(0, p_Text.length(), URLSpan.class);
for(URLSpan span:spans) {
int start = p_Text.getSpanStart(span);
int end = p_Text.getSpanEnd(span);
p_Text.removeSpan(span);
span = new URLSpanNoUnderline(span.getURL());
p_Text.setSpan(span, start, end, 0);
}
}
The last thing you have to do to replace all occurences of URLSpan by URLSpanNoUnderline in your TextView objects. I do that by modifying the onCreate function of my Activity classes. For example, this is the onCreate function of the "about" screen of my app:
protected void onCreate(Bundle p_SavedInstanceState) {
super.onCreate(p_SavedInstanceState);
setContentView(R.layout.about);
// Remove underlines from HTML links
TextView txtUrlGoogle = (TextView)findViewById(R.id.textUrlGoogle);
// Make sure the TextView was instantiated correctly
if(txtUrlGoogle != null) {
StringUtil.removeUnderlines((Spannable)txtUrlGoogle.getText());
}
}
And we're done! As you can see, this is totally reusable. All TextView properties such as color will continue to work as they are intended to. As I said at the beginning of my post, I did not invented this way of removing underlines, but I think this will help clarify it, and show how it can be easily reused.