Home | History | Annotate | Download | only in ui
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.camera.ui;
     18 
     19 import android.graphics.RectF;
     20 import android.view.GestureDetector;
     21 import android.view.TextureView;
     22 import android.view.View;
     23 
     24 /**
     25  * This interface defines a listener that watches preview status, including SurfaceTexture
     26  * change and preview gestures.
     27  */
     28 public interface PreviewStatusListener extends TextureView.SurfaceTextureListener {
     29     /**
     30      * The preview status listener needs to provide an
     31      * {@link android.view.GestureDetector.OnGestureListener} in order to listen
     32      * to the touch events that happen on preview.
     33      *
     34      * @return a listener that listens to touch events
     35      */
     36     public GestureDetector.OnGestureListener getGestureListener();
     37 
     38     /**
     39      * An {@link android.view.View.OnTouchListener} can be provided in addition to
     40      * or instead of a {@link android.view.GestureDetector.OnGestureListener}
     41      * for listening to touch events on the preview.  The listener is called whenever
     42      * there is a touch event on the {@link com.android.camera.ui.PreviewOverlay}.
     43      */
     44     public View.OnTouchListener getTouchListener();
     45 
     46     /**
     47      * Gets called when preview TextureView gets a layout change call.
     48      */
     49     public void onPreviewLayoutChanged(View v, int left, int top, int right,
     50             int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom);
     51 
     52     /**
     53      * This listener gets notified when the actual preview frame changes due
     54      * to a transform matrix being applied to the TextureView
     55      */
     56     public interface PreviewAreaChangedListener {
     57         public void onPreviewAreaChanged(RectF previewArea);
     58     }
     59 
     60     /**
     61      * The preview status listener needs to know for the specific module whether
     62      * preview TextureView should automatically adjust its transform matrix based
     63      * on the current aspect ratio, width and height of the TextureView.
     64      *
     65      * @return whether transform matrix should be automatically adjusted
     66      */
     67     public boolean shouldAutoAdjustTransformMatrixOnLayout();
     68 
     69     /**
     70      * Gets called when the preview is flipped (i.e. 180-degree rotated).
     71      */
     72     public void onPreviewFlipped();
     73 
     74     /**
     75      * This listener gets notified when the preview aspect ratio is changed.
     76      */
     77     public interface PreviewAspectRatioChangedListener {
     78         public void onPreviewAspectRatioChanged(float aspectRatio);
     79     }
     80 }
     81