<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eli Moss on Medium]]></title>
        <description><![CDATA[Stories by Eli Moss on Medium]]></description>
        <link>https://medium.com/@eli.moss?source=rss-dbb2978a096b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xhCLzssZ84OQgEQs</url>
            <title>Stories by Eli Moss on Medium</title>
            <link>https://medium.com/@eli.moss?source=rss-dbb2978a096b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 14:16:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eli.moss/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making multi-touch joyful on Android]]></title>
            <link>https://medium.com/healthyio/making-multi-touch-joyful-on-android-4f7d1b0b5e7d?source=rss-dbb2978a096b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f7d1b0b5e7d</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[multi-touch]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Eli Moss]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 14:41:10 GMT</pubDate>
            <atom:updated>2022-10-02T14:41:10.343Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Do we even have a problem?</strong></p><p>If we take a close look, we can observe that multi-touch behaves inconsistently across various mobile apps.<br>For example, the existence of the option to drag the view with two fingers, or the focus point adjustment when doing pinch-to-zoom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*yluT9-OxK_p0gCnS9093Gg.gif" /><figcaption>Example 1 (not draggable with 2 fingers)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*6lEDy530OlkYoeDipOxesg.gif" /><figcaption>Example 2 (focusing to screen’s center point instead of the touch coordinates)</figcaption></figure><p>Another great example can be observed in the WhatsApp app.<br>Take an Android and an iPhone device and take a photo from the app’s camera (right from the chat). <br>Then try to draw something on the picture and pinch-to-zoom (or even simply move around the photo with your fingers).<br>What you’ll notice is that in iPhone you can draw with one finger, and pinch / move around with two fingers.<br>And on Android? You have to click a “toggle” button to switch between those two “modes” (drawing and multi-touch)</p><p>Here’s a demonstration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*jqf27FduLXhkleLNMM0o8g.gif" /><figcaption>WhatsApp on Android</figcaption></figure><p>This should come as no surprise, as the Android Framework provides us with half-baked solutions (mostly fragments of code that can be seen throughout Google’s examples on the official website).<br>This means that many times the multi-touch implementations you come across lack certain rather basic functionalities or features.</p><p>Some 3rd-party libraries and solutions provide “layers” to help implement multi-touch capabilities in your app more conveniently.<br>However, they fail to provide both the full scope of possible multi touch capabilities (e.g — rotation, etc.), as well as control over them.</p><p><strong>Onions coming to your rescue!</strong></p><p>I like to think of the Ultimate MultiTouch library as an 3-layered onion, where the innermost part follows two principles, one is to offer the full gamut of core touch &amp; multi-touch capabilities, and the second is to try to have as much control over them.</p><p>Then, a middle layer which contains the capabilities that are outside the core functionality of multi touch gestures, aimed at more advanced and specific tasks.</p><p>And lastly, the outermost layer which provides tools that are not directly related to the multi-touch library (e.g — super convenient touch gestures, wrapper and math utilities).</p><p>Now, let’s dive deeper into covering these three layers.</p><p><strong>Be the master (Layer 1)</strong></p><p>The core functionality’s controllable variables that are part of this library comprise the so called ‘Optionals’ interface, and can virtually be grouped into 4 main categories :</p><p>1. Zoom (Scaling)<br> — isZoomEnabled : controls whether scaling/zooming is enabled.<br> — isDoubleTapEnabled : controls whether double tap gesture is enabled.<br> — minScale : controls minimum scale factor. By default it’s simply 1 (original view).<br> — maxScale : controls the maximum scale factor. By default it’s 4 (i.e — 4x zoom)</p><p>2. Bounds effect (the animation effect when you reach the limit of scaling when doing pinch-to-zoom)<br> — isBoundsLimitEffectEnabled : controls whether the effect is enabled.<br> — boundsLimitEffectScaleFactor : controls the “bounce” effect scale factor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*SVCte-KOc9YO-1BkD89OzQ.gif" /><figcaption>Illustration of the “bounds effect”</figcaption></figure><p>3. Dragging<br> — isOneFingerDraggingEnabled : controls whether one finger dragging is enabled.<br> — isMultiFingerDraggingEnabled : controls whether two finger dragging is enabled.</p><p>4. Rotation<br> — isRotationEnabled : controls whether view rotation is enabled.</p><p><strong>Squeezing the onions (Layer 2)</strong></p><p>Now, what if you wanted to get more of your multitouch-based component? <br>For example, what if you wanted to get the touch points respective to the original view (before scaling/zoom) ?<br>Or what if you wanted to send analytics to be able to understand better how your users use your component — i.e: what kind of gesture they use (pinch to zoom, double tap) and the zooming directions (zoom in, zoom out) ?</p><p>All of this and (much) more is possible with the help of the Ultimate MultiTouch library, and this is essentially the second layer of the onion.</p><p>The library provides a callback listener, which not only propagates certain gesture manipulation callbacks, but also provides additional pieces of data and special classes (e.g — TransformedPoint.kt, ScalingType.kt) that can help with more advanced tasks, like the ones mentioned above.</p><p>Example :</p><pre>multiTouchFrameView.apply {<br>    onScroll { p1: TransformedPoint, p2: TransformedPoint?, isNowMultipleFingersDown: Boolean -&gt;<br>        //<br>    }<br>    onScalingEnded { scale -&gt;<br>        //<br>    }<br>}</pre><p>Highlights :<br> — <strong>TransformedPoint class </strong>: stores the corresponding touch point relative to the original view (“transformed point”).<br> <br> For example, we at <a href="http://healthy.io/">Healthy.io</a> use it to correspond the user’s touch point on a manipulated view back to the original-sized bitmap. <br>Consequently, we are able to confidently detect which organ on the human body was touched/selected by the clinician using the app after any multi-touch manipulations on the view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*nlJKj2OFR0tyk0nrw_UHYg.gif" /><figcaption><a href="http://healthy.io/">Healthy.io</a> — Minuteful for Wound app</figcaption></figure><p>- <strong>ScalingType class</strong> : extra gesture information<br> 1. Tells whether the user is doing a Pinch-to-zoom gesture or a Double-Tap<br> 2. Tells whether the multi-touch gesture is zooming in or zooming out.</p><p>For example, we at <a href="http://healthy.io/">Healthy.io</a> use this for analytics, to better understand how our users interact with our multitouch-based components across various features/screens.</p><p><strong>The geeky part — internals overview</strong></p><p>What I’ve built is essentially a <strong>FrameLayout</strong> “on steroids”.<br>It performs all of the view manipulations on the child view at a specific index, indicated by the “currentTargetViewIndex” variable, which of course can be changed and played with.</p><p>All the child views of that FrameLayout, have their “<strong>tag</strong>” contain the manipulated view’s representation.</p><p>Let’s try to visualize the original view and its manipulated “view representation” (orange rectangle) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHkQhuSxeZGGhIrNBEhPaA.png" /></figure><p>Upon every view manipulation (translation, rotation, scaling/zooming, etc.) this representation is updated and utilized accordingly to achieve this library’s intention.<br>It is also used when calculating the mapped touch points adjusted to the original view.</p><p>The latter is achieved with the help of some Linear Algebra calculations, the methods of which are also open and available to users for their own use.</p><p><strong>Extras (Layer 3)</strong></p><p>Now let’s talk about the third and last layer of the onion.<br>Every piece of code/functionality that was used here and that could potentially be of help to the developers community — is entirely open for free use, outside of this library’s intended scope.</p><p>This includes :<br>1. Touch gestures wrapper — easily, conveniently and quickly implement various touch gesture on a view.<br> Android has two main and separate detectors, one for gestures and another for scaling transformation gestures.<br> Using Kotlin’s capabilities, I’ve wrapped those implementations into a convenient extension function that can be used on any View class/subclass. <br>This is used internally in the library, but can also be used by you in any scenario regardless of whether you’re using MultiTouchFrameLayout.<br>All you need to do is simply call detectTouches and then implement your desired callback.</p><p>Example :</p><pre>class MyView ... {</pre><pre>  ...</pre><pre>  detectTouches {<br>      onScroll { e1, e2, distanceX, distanceY -&gt;<br>          //<br>      }<br>      onScale { scaleFactor, focusX, focusY, spanDelta -&gt;<br>          //<br>      }<br>      onDoubleTap { e, focusX, focusY -&gt;<br>          //<br>      }<br>      onTouch { e -&gt;<br>          //<br>      }<br>      onTap { e -&gt;<br>          //<br>      }<br>      ....<br>  }<br>}</pre><p>2. Math — Linear Algebra<br> As part of the functions that map touch points of manipulated views to the respective coordinates on the original view, I had to resort to some good old Linear Algebra.<br> This includes :<br> — matrix definition (e.g — vector, matrix)<br> — matrix basic operation definitions (e.g — matrix multiplication)<br> — handy matrix definitions (e.g — rotation matrix, transpose, etc.)<br> — radians &lt;&gt; angle conversion functions</p><p><strong>Wrapping Up</strong></p><p>You’re more than welcome to explore and try out the library. Hopefully you’ll find the documentation helpful: <a href="https://github.com/HealthyIO/Ultimate-Multitouch">https://github.com/HealthyIO/Ultimate-Multitouch</a></p><p>We’d also appreciate and welcome any contributors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f7d1b0b5e7d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/healthyio/making-multi-touch-joyful-on-android-4f7d1b0b5e7d">Making multi-touch joyful on Android</a> was originally published in <a href="https://medium.com/healthyio">Healthyio</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>