Skip to content

Switching to native multi touch

r-oleary edited this page Jun 26, 2016 · 1 revision

Overview

Currently Avare uses a 3rd-party class to implement multi-touch controls in relevant views (https://github.com/apps4av/avare/blob/master/app/src/main/java/org/metalev/multitouch/controller/MultiTouchController.java). This class has not been updated in 6 years, is missing some core multi-touch functionality, and is no longer needed as Android now provides multi-touch gestures natively.

This story is about removing the use of this outdated class, replacing it with native multi-touch.

Benefits

The main user-facing benefit of removing this class is that we can provide native multi-touch that allows for panning and scaling with the same movement. Today with the use of this class, you must either pan or scale, you can not do both at the same time. Replacing this with native controls will allow us to provide a more natural solution that fits better with user expectations.

Design

In general, we need to remove the metalev multitouch class and replace its functionality. This means that each of the Views that use this class need to be refactored to not implement its interface, but rather implement the native OnTouchListener (which they already do) and register a new gesture detector (ScaleGestureDetector) to listen for scaling events.

The impacted views are:

  • LocationView
  • AfdView
  • PlatesView
  • PlatesTagView
  • ThreeDSurfaceView

Each of these need to register a ScaleGestureDetector that handles "scaling" events from Android. Combining these scaling events with Pan events, we can implement true multi-touch.

Other related fixes

As part of this PR, we will also implement auto-scaling for plates and AfdView so they take up the whole viewport when opened. We will prevent zooming out on these plates below that level.

Releasing this code

Since this code modifies a bunch of existing views, we need to make sure we get some beta usage of it before we merge it to master and release it.