Home | History | Annotate | Download | only in chromoting
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 package org.chromium.chromoting;
      6 
      7 import android.view.MotionEvent;
      8 
      9 /**
     10  * This interface allows multiple styles of touchscreen UI to be implemented and dynamically
     11  * switched. The DesktopView passes the low-level touchscreen events and other events via this
     12  * interface. The implementation recognizes and processes the touchscreen gestures, and then
     13  * performs actions on the DesktopView (such as panning/zooming the display, injecting input, or
     14  * showing/hiding UI elements). All methods are called on the main UI thread.
     15  */
     16 public interface TouchInputHandler {
     17     // These constants must match those in the generated struct protoc::MouseEvent_MouseButton.
     18     int BUTTON_UNDEFINED = 0;
     19     int BUTTON_LEFT = 1;
     20     int BUTTON_MIDDLE = 2;
     21     int BUTTON_RIGHT = 3;
     22 
     23     /**
     24      * Processes a touch event. This should be called by the View in its onTouchEvent() handler.
     25      */
     26     boolean onTouchEvent(MotionEvent event);
     27 
     28     /**
     29      * Called when the screen configuration is changed, such as when the screen is rotated or an
     30      * external display is plugged in. This is not called if the client display area changes as a
     31      * result of showing/hiding UI elements such as a keyboard. For example, an implementation
     32      * could set a flag to reset the zoom level when the screen is rotated, but not when the
     33      * software keyboard appears. After this is called, the onClientSizeChanged() method will
     34      * shortly be called with the dimensions of the new client display area.
     35      */
     36     void onScreenConfigurationChanged();
     37 
     38     /**
     39      * Called whenever the client display area changes size. The caller will handle repainting
     40      * after this method returns.
     41      */
     42     void onClientSizeChanged(int width, int height);
     43 
     44     /**
     45      * Called when the host screen size is changed. The caller will handle repainting after this
     46      * method returns.
     47      */
     48     void onHostSizeChanged(int width, int height);
     49 
     50     /**
     51      * Whilst an animation is in progress, this method is called repeatedly until the animation is
     52      * cancelled. After this method returns, the DesktopView will schedule a repaint.
     53      */
     54     void processAnimation();
     55 }
     56