Skip to content
June 13, 2012 / fastr.de

fastr.de MTfix for Andoird 2.x Applications Version 0.1 released

Version 0.1 of my MTfix classes to support multi-touch in WebViews on Android 2.x devices is ready.

The Browser/WebView Class in Android prior version 3 does not fully support multi-touch events.
So I wrote an Android TouchListener class that captures the touches directly from the device and sends them via JavaScript to your webapplication and a JavaScript class that triggers TouchEvents when it recieved data from the TouchListener class.
You can find an video showing MTfix in action here and an example-app for you to Test here

What can this class do for you:

  • recognizes more then one touch in your WebView
  • pinch to zoom works
  • you can do gesture detection in javascript because you get all touchstart, touchstop and touchmove events in the webview

Limitations of this version:

  • The Webapp has to be a fullscreen app (disable scrollbars!). When you scroll the touches are not at the right position anymore.
  • In the JavaScript file are to variables xMul and yMul to fix a touchdevice point to webpage point calculation issue. The values
    this.xMul = 1.03;
    this.yMul = 1.11;
    

    are for my device. When you have to tweek these values please leave me a comment.

  • Not widly tested yet. So when you use it please give me feedback.
    Twitter: @fastr_de (i’m not writing tweets yet but read DMs and @fastr_de)
    Email: strachanski@googlemail.com.
    or leave an comment.

Howto use the library: (I’ve tried to explain it completly, when you stuck feel free to contact me)

  1. Download the files
  2. Import the MTfixTouchListener.java file into your Android Application project.
  3. Set the TouchListener of your WebView to a new instance of MTfixTouchListener
    wv = new WebView(activity);
    wv.setOnTouchListener(new MTfixTouchListener(activity));
    wv.loadUrl("http://www.YourMultitouchWebapp.org");
    
  4. Optional: call static function checkMTfix(<Your WebView>) to check if the javascript part is correctly implemented and ready.
    MTfixTouchListener.checkMTfix(wv)
    
  5. copy fastrMTfix.js to your webapp and include it in your HTML-Page
     <script src="pathToYourJavascript/fastrMTfix.js"></script>
     

That’s it!

What’s next:

  • api level detection
  • autodisable on Android >= version 3 (API 11)
  • implement TouchEvents completly
  • calculate pageX/Y, screenX/Y, clientX/Y correctly (should fix the “don’t scroll” limitation)
  • test, test, test
  • …? ideas?

It’s version 0.1 so it’s not ready. The TouchEvents are not fully implemented yet but it works perfect in my webapps.

 

Creative Commons License
fastr.de MTfix for Android 2.x Applications by Fabian Strachanski is licensed under a Creative Commons Attribution 3.0 Unported License.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: