Android / IOS Adobe Air Native Extension Contact Manager

My first contribution to a public repo.
ContactEdtior
A few simple functions enable reading and writing contact informations from ios and android devices from adobe air application without directly accessing the database. This very nice and straight farward extension has been started by memeller.

As always android requires manifests. Just for accessing contacts informations:

<uses-permission android:name="android.permission.READ_CONTACTS" />

But more if Your app is going to add or remove any info:

<uses-permission android:name="android.permission.WRITE_CONTACTS" />
#only if adding:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

This extension does not allow any acount info to be read but beacause Android manages it differently GET_ACCOUNTS is needed for displaying a native popup single choice box for defining to wich acount contact will be added.

Grab the source from Github: https://github.com/memeller/ContactEditor
Or see the demo directly on Your Android here: DEMO

Tagged

Adobe Air Native Extension System Properties IOS / Android

New update on the as3NativeAlert and my older post:.

Added support for the SystemProperties class for IOS.

Available parameters for IOS:

  • os – like in Capabilities
  • UID – the UDID of the device
  • name – the name of the device
    • Usage:

      if(SystemProperties.isSupported()){
      	var dictionary:Dictionary = SystemProperties.getProperites(); 
      	for (var key:String in dictionary) 
      	{ 
      		var readingType:String = key; 
      		var readingValue:String = dictionary[key]; 
      		trace(readingType + "=" + readingValue); 
      	} 
      	dictionary = null;
      }
      

as3 Native Cursor Manager

Basically the main advantage of as3 development is the multi-platform support.
It is understandable that a typical user does not care about that and he wants the best performance on the platform that he has picked.
Usually while distributing applications people forget about the little things like showing the busy cursor. While in native code there always is a function for showing a busy cursor in flash using the native busy cursor isn’t so easy to show because in native code it disappears after the function ends.
I’v made this simple class that has only one function – Showing the busy cursor similar to the native ones. I’t is different dependently on the platform.
On Mac Os:
On Windows 7, Vista:
On other versions of Windows:
On Linux:

Grab the code on Git-hub:
https://github.com/mateuszmackowiak/as3NativeCursorManager

import pl.mateuszmackowiak.visuals.CursorManager;
// to show the busy cursor
CursorManager.setBusyCursor();

// to hide it
CursorManager.removeBusyCursor();

Also want to mention about AIR 3 Windows-x86 Native Extension for Taskbar (Progress) API.
These are small things but they really make a difference in the overview of the app.

Tagged , , , ,

Android Native Extension Text Input Dialog for Adobe Air

Andorid Text Input Dialog Native Extension for Adobe Air

New in asNativeAlert .

So once again to make the package compatible with every platform I’m working on I’v packed to the same ANE file additional classes.
I think one of the main feature of a basic Dialog Box on every platform is to show some kind of input for people to interact with it.
So NativeTextInputDialog add this functionality to the whole package.

Usage:

public function openTextInputDialog(event:MouseEvent):void{
	if(NativeTextInputDialog.isSupported()){
		textInputDialog = new NativeTextInputDialog();
		textInputDialog.theme = NativeTextInputDialog.THEME_HOLO_LIGHT;
		textInputDialog.addEventListener(NativeDialogEvent.CANCLED,trace);
		textInputDialog.addEventListener(NativeDialogEvent.OPENED,trace);
		textInputDialog.addEventListener(NativeExtensionErrorEvent.ERROR,trace);
		textInputDialog.addEventListener(NativeTextInputDialogEvent.CLOSED, onTextInputDialogClosedHandler);
		var buttons:Vector.<String> = new Vector.<String>();
		buttons.push("OK","Cancle");
		var v:Vector.<NativeTextInput> = new Vector.<NativeTextInput>();
		var ti1:NativeTextInput = new NativeTextInput("name");
		ti1.inputType = NativeTextInput.text;
		ti1.messageBefore ="name:";
		ti1.text = "jacek";
		v.push(ti1);
		var ti2:NativeTextInput = new NativeTextInput("password");
		ti2.inputType = NativeTextInput.textPassword;
		ti2.messageBefore ="password:";
		ti2.text = "dddd";
		v.push(ti2);
		textInputDialog.show(titleInput.text,v,buttons);
	}
}
private function onTextInputDialogClosedHandler(event:NativeTextInputDialogEvent):void
{
	for each (var n:NativeTextInput in event.list) 
	{
		trace(n.name+":  "+n.text);
	}
	trace(event.buttonIndex);
}
Tagged , , ,

Android System Properites in Adobe Air Native Extension

Packed new Feature in asNativeAlert .
SystemProperties class can provide some of the missing properties that You can’t get in adobe air.

Class supports two functions. One like always isSupported and the second getProperites() returns a flash Dictionary object with all the properties.
Available parameters:

  • os – like in Capabilities
  • language – the set language in the system
  • architecture of the cpu
  • package name
  • source directory
  • application uid -always when a application is installed on device the system creates a unique id for setting up the space for it
  • UID – created a unique ID for the device based on some of the device properties
    • Extension requires adding permission in the application xml descriptor.

      <uses-permission android:name="android.permission.READ_PHONE_STATE" />

      Usage:

      if(SystemProperties.isSupported()){
      	var dictionary:Dictionary = SystemProperties.getAndroidProperites(); 
      	trace(SystemProperties.ARCHITECTURE+"  "+dictionary[SystemProperties.ARCHITECTURE]);
      	trace(SystemProperties.JAVA_NUMBER+"  "+dictionary[SystemProperties.JAVA_NUMBER]);
      	trace(SystemProperties.LANGUAGE+"  "+dictionary[SystemProperties.LANGUAGE]);
      	trace(SystemProperties.OS+"  "+dictionary[SystemProperties.OS]);
      	trace(SystemProperties.VERSION+"  "+dictionary[SystemProperties.VERSION]);
      	trace(SystemProperties.PACKAGE_DIRECTORY+"  "+dictionary[SystemProperties.PACKAGE_DIRECTORY]);
      	trace(SystemProperties.PACKAGE_NAME+"  "+dictionary[SystemProperties.PACKAGE_NAME]);
      	trace(SystemProperties.APP_UID+"  "+dictionary[SystemProperties.APP_UID]);
      	trace(SystemProperties.UID+"  "+dictionary[SystemProperties.UID]);
      }
      

as3 Android native extension Toast message

as3 adobe air native extension Toast
I’ll make it short. (only Android but all packed in one ane)
New classes in my as3NativeAlert.
Just for NOT adding a another ane to the project that could be incompatible with all platforms I’ve added Toast notification in my Native Extension.
Usage:

     Toast.show("some message",Toast.LENGTH_LONG);

Or there is a possibility to show it in any place on the screen:

     var randX:int = Math.random()*200;
     var randY:int = Math.random()*200;
     Toast.showWithDifferentGravit("some message",Toast.LENGTH_SHORT,Toast.GRAVITY_LEFT,randX,randY);

Every class has a isSupported variable.

as3 Android native multi-choice (single) dialog for adobe Air

Android Native Extension Dialog for Air
The more I work on extensions the more I see how chaotic they are.
But never mind..
New classes in my as3NativeAlert.
Now a class NativeMultiChoiceDialog has the ability to show a native android popup multi-choice(or single) dialog inside Adobe Air project.

Usage:

private var NativeListDialog;
private var choces:Vector.<String>;
private var buttons:Vector.<String>;
private var checkedItems:Vector.<Boolean>;
private var selectedIndex:int = -1;

protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
      choces = new Vector.<String>();
//the text of the items to be displayed in the list.
      choces.push("one",'two","three","four");
      checkedItems = new Vector.<Boolean>();  
// specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
      checkedItems.push(true,false,false,true);
      buttons = new Vector.<String>();
//the labels for the buttons. It should be null in which case there will be only one button "OK". If non null max length 3 buttons
      buttons.push("OK","Settings","Cancle");
}
protected function openMultiChoiceDialog(event:MouseEvent):void
{
      multChDialog = new NativeListDialog();
      multChDialog.theme = NativeListDialog.THEME_HOLO_DARK;
      multChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
      multChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
      multChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
      multChDialog.title ="Some Title";
      multChDialog.cancleble = true;
      multChDialog.showMultiChoice(choces,checkedItems,buttons);
}
public function openSingleChoiceDialog(event:MouseEvent):void
{
	singleChDialog = new NativeListDialog();
	singleChDialog.theme = ThemeSelector.selectedItem.data;
	singleChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	singleChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
	singleChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	singleChDialog.addEventListener(LogEvent.LOG_EVENT,traceEvent);
	singleChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
	singleChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
	singleChDialog.cancleble = true;
	singleChDialog.showSingleChoice(choces,selectedIndex,buttons,titleInput.text);
}
public function closeNativeDialogHandler(event:NativeDialogEvent):void
{
	var dialog:NativeListDialog = (event.target  as NativeListDialog);
	dialog.removeEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.OPENED,traceEvent);
	dialog.removeEventListener(NativeExtensionErrorEvent.ERROR,onError);
	dialog.kill();
}

private function onListChange(event:NativeDialogListEvent):void
{
        var dialog:NativeListDialog = (event.target as NativeListDialog)
	if(dialog.selectedIndex>-1){
		selectedIndex = dialog.selectedIndex;
	}else{
		const a:Vector.<String> = dialog.selectedLabels;
		if(a.length>0){
			for (var i:int = 0; i < a.length; i++) 
			{
				trace(a[i]);
			}
		}
	}
}

like always available themes for android :

THEME_DEVICE_DEFAULT_DARK
THEME_DEVICE_DEFAULT_LIGHT
THEME_HOLO_DARK
THEME_HOLO_LIGHT
THEME_TRADITIONAL

All my extensions are compiled by Android SDK revision 12 (Android 3.1).

Tagged

as3 Native Progress – Air native extension for a popup progressbar

Native Progress demo picture

My new Updates on the as3NativeAlert.
I’v implemented a new class NativeProgress.
It extends the “ane” with the ability to display the native dialog showing a progress bar or a spinner.

Available themes for android :

THEME_DEVICE_DEFAULT_DARK
THEME_DEVICE_DEFAULT_LIGHT
THEME_HOLO_DARK
THEME_HOLO_LIGHT
THEME_TRADITIONAL

Usage:

private var progressPopup:NativeProgress;
private var p:int = 0;
private var myTimer:Timer = new Timer(100);

protected function openProgressPopup(style:int):void
{
     progressPopup = new NativeProgress(style);
     progressPopup.theme = NativeProgress.THEME_HOLO_DARK;
     progressPopup.setSecondaryProgress(45);
     progressPopup.addEventListener(NativeDialogEvent.OPENED,traceEvent);
     progressPopup.addEventListener(NativeDialogEvent.CANCLED,closeNativeProcessHandler);
     progressPopup.addEventListener(NativeDialogEvent.CLOSED,closeNativeProcessHandler);
     progressPopup.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
     progressPopup.setMax(50);
     progressPopup.setIndeterminate = true;
     progressPopup.show(0, titleInput.text , messageInput.text,true);

     myTimer.addEventListener(TimerEvent.TIMER, updateProgress);
     myTimer.start();
}

private function closeNativeProcessHandler(event:Event):void
{
     progressPopup.removeEventListener(NativeDialogEvent.CANCLED,closeNativeProcessHandler);
     progressPopup.removeEventListener(NativeDialogEvent.CLOSED,closeNativeProcessHandler);
     progressPopup.removeEventListener(NativeExtensionErrorEvent.ERROR,onError);
     progressPopup.removeEventListener(NativeDialogEvent.OPENED,traceEvent);

     progressPopup.kill();

     myTimer.removeEventListener(TimerEvent.TIMER,updateProgress);
     myTimer.stop();
     p = 0;
}
private function updateProgress(event:TimerEvent):void
{
     p++;
     if(p>=50){
          p = 0;
          progressPopup.hide();
	  (event.target as Timer).stop();
     }else
	progressPopup.setProgress(p);
}
			
protected function viewBackKeyPressedHandler(event:FlexEvent):void
{
     event.preventDefault();
     myTimer.removeEventListener(TimerEvent.TIMER,updateProgress);
     myTimer.stop();
     p = 0;
     if(progressPopup){
	progressPopup.hide();
     }
}
//NativeApplication.nativeApplication.addEventListener(Event.EXITING,exiting);
protected function exiting(event:Event):void
{
     if(progressPopup)
	progressPopup.kill();
}

AS3 NATIVE ALERT- Android / IOS / Windows

Update: fixed iOS air 3.2 bug

Got a new device. The Lenovo Thinkpad Tablet and with that the app that I’m working on requires some changes.
I’v added support for Android in my NativeAlert Extension.
Not only it’s a plain alert that pops out over the Adobe AIR content but it also has the ability to change themes. This is quite important in my work because I have not decided how will the application look like.

Grab the source from github:
https://github.com/mateuszmackowiak/NativeAlert

Available themes for android:

THEME_DEVICE_DEFAULT_DARK
THEME_DEVICE_DEFAULT_LIGHT
THEME_HOLO_DARK
THEME_HOLO_LIGHT
THEME_TRADITIONAL

Usage:

 NativeAlert.show( "some message" , "title" , "first button label" , "otherButtons,LabelsSeperated,WithAComma" , someAnswerFunction , themesForThisAlert);

Also added a function for setting default theme:

NativeAlert.defaultAndroidTheme = NativeAlert.THEME_DEVICE_DEFAULT_DARK;

as3 Native Alert

I’m currently working on this mobile project that requires using a StageWebView component. The problem with that component is as some of You have noticed it’s not in the standard flash display list. It’s a component that can cover everything even a popup displaying a error message. There are two ways to solve that popup error.
One is :every time something should be shown use the drawViewPortToBitmapData method.
The second solution is to use the native extension to create a native alert like in this tutorial liquid-photo

Love the work that the guys form Liquid-photo have done. But… I can’t imagine to debug everything on IOS. Using windows to do that is long and annoying.So I made some changes to their project on github.

The basic change is that I’v added a extension for Windows platform.So there is no more annoying error of incompatible components.
First I was using a simple trace message. But that didn’t work. It doesn’t allow everything that a simple popup with multiple buttons can do.

The second change is in the action script library. In Air on desktop there is a library called Alert. It enables static method show. I’v tried to make my library similar.

Grab the source from github:
https://github.com/mateuszmackowiak/NativeAlert

Usage:

NativeAlert.show( "some message" , "title" , "first button label" , "otherButtons,LabelsSeperated,WithAComma" , someAnswerFunction);

Remember to always dispose before closing the app.

NativeAlert.dispose();

I’v also added a static function isSupported Like adobe recommends.