Skip to content

roamtouch/gesturekit-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

GestureKit Technology

Android Addon

An Android library to recognize advanced gestures on Android apps.

Please go to our Download page and download the last zip file for Android.

The zip file includes the jar library and a HelloWorld sample to play with also available at the PLAY STORE.


Compatibility

Android Froyo (2.2, API level 8) or higher


Usage

1 - Import jar files into your project

Download and add it to your project's build path.

If you are working on Gingerbread MR1 or lower you must download jackson library from [jackson url] and then include it in your build path.

2 - GestureKit permissions

Edit your AndroidManifest.xml and add the following permissions

    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

3 - Create GestureKit Service

Edit your AndroidManifest.xml and add the following lines of code.

    <service android:name="com.roamtouch.gesturekit.communications.GestureKitService" ></service>

4 - Instance a GestureKit object

You must create it using your host Activity and your GID. GestureKit object should be paused and resumed. For example

    public class MyActivity extends Activity{
       ...
       private GestureKit gestureKit;
       
           @Override
           public void onCreate(Bundle savedInstanceState) {
           ...
           this.gestureKit = new GestureKit(this, [a valid GID]);
           ...
       }   
      
    }

5 - Setup GestureKit

There two ways to bind gestures with actions: Matching Name Method (MNM) or GKActionInterface

MNM: you should declare a method with the same name of the defined GestureKit method. For example, you define the "PLAY" method, then you should declare:

    public void PLAY(){
       ...
    }

MNM: If you have set a Gate parameter while creating the gesture provide a paramenter on your method like this.

    public void PLAY(String gate){
       ...
    }

6 - Creating a GestureAction plugin for GestureKit

You can create your own Gesture Actions for Android, the class you create will listen for a gesture to be recognized and will interface via GKActionInterface.

Consists in declare an object implementing

GKActionInterface

This interface is defined as follows:

    public interface GKActionInterface {
       public Vector getActionID();
       public void onGestureRecognized(Object... params);
    }

getActionID returns method name.

onGestureRecognized has the code to be called when the gesture is recognized.

an example:

    public class MyAction implements GKActionInterface {
       public String getActionID() {
        return "PLAY";        
       }

       public void onGestureRecognized(Object... params){
           Log.i("gesture PLAY recognized!");
         //Let's do something cool
    }
   }

You should consider that GKActionInterface's methods will be called before MNMs, so if you declare a GKActionInterface method with the same name as a MNM, MNM will not be called.

7 - Customizing GKVisor [optional]

GestureKit has a default visor called GestureKitVisor, it's responsible of show GestueKit status as "loading", "drawing gestures", "ready" and "warning".ample, you define the "PLAY" method, then you should declare:

It can be replaced by your own Visor just implementing VisorInterface and then setting it to your GestureKit object calling setVisor method. VisorInterface is as follows:

    public interface VisorInterface {
       public void proccessTouchEvent(MotionEvent event);
       public void clear();
       public void showErrorLogo();
       public void showLoadingLogo();
       public void showOkLogo();
    }

proccessTouchEvent method is used to draw current's gesture shape, it should receive all motion events generated by your UI. clear method is called after a gesture is finished, is called either if it is recognized or not.

showErrorLogo method is called after an error or warning are occured. For example, if you are offline or your GID is not valid.

showLoadingLogo method is called while a background process is executing. For example when GestrueKit is downloading data.

showOkLogo method is called every time GestureKit is ready.

Maintained by

Credits

RoamTouch logo

License

Licensed under Apache v2 License.

Copyright (c) 2014 RoamTouch.

About

An Android library to recognize gestures on Android apps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published