106db742814dd635d100639f977fcfdc904deb778Doris Liu/*
206db742814dd635d100639f977fcfdc904deb778Doris Liu * Copyright (C) 2013 The Android Open Source Project
306db742814dd635d100639f977fcfdc904deb778Doris Liu *
406db742814dd635d100639f977fcfdc904deb778Doris Liu * Licensed under the Apache License, Version 2.0 (the "License");
506db742814dd635d100639f977fcfdc904deb778Doris Liu * you may not use this file except in compliance with the License.
606db742814dd635d100639f977fcfdc904deb778Doris Liu * You may obtain a copy of the License at
706db742814dd635d100639f977fcfdc904deb778Doris Liu *
806db742814dd635d100639f977fcfdc904deb778Doris Liu *      http://www.apache.org/licenses/LICENSE-2.0
906db742814dd635d100639f977fcfdc904deb778Doris Liu *
1006db742814dd635d100639f977fcfdc904deb778Doris Liu * Unless required by applicable law or agreed to in writing, software
1106db742814dd635d100639f977fcfdc904deb778Doris Liu * distributed under the License is distributed on an "AS IS" BASIS,
1206db742814dd635d100639f977fcfdc904deb778Doris Liu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1306db742814dd635d100639f977fcfdc904deb778Doris Liu * See the License for the specific language governing permissions and
1406db742814dd635d100639f977fcfdc904deb778Doris Liu * limitations under the License.
1506db742814dd635d100639f977fcfdc904deb778Doris Liu */
1606db742814dd635d100639f977fcfdc904deb778Doris Liu
1706db742814dd635d100639f977fcfdc904deb778Doris Liupackage com.android.camera.ui;
1806db742814dd635d100639f977fcfdc904deb778Doris Liu
19a1ec04a9f9526418f5cb17a5afbfc48aca1e02d0Doris Liuimport android.graphics.RectF;
2006db742814dd635d100639f977fcfdc904deb778Doris Liuimport android.view.GestureDetector;
2106db742814dd635d100639f977fcfdc904deb778Doris Liuimport android.view.TextureView;
224a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liuimport android.view.View;
2306db742814dd635d100639f977fcfdc904deb778Doris Liu
2406db742814dd635d100639f977fcfdc904deb778Doris Liu/**
2506db742814dd635d100639f977fcfdc904deb778Doris Liu * This interface defines a listener that watches preview status, including SurfaceTexture
2606db742814dd635d100639f977fcfdc904deb778Doris Liu * change and preview gestures.
2706db742814dd635d100639f977fcfdc904deb778Doris Liu */
2806db742814dd635d100639f977fcfdc904deb778Doris Liupublic interface PreviewStatusListener extends TextureView.SurfaceTextureListener {
2906db742814dd635d100639f977fcfdc904deb778Doris Liu    /**
3006db742814dd635d100639f977fcfdc904deb778Doris Liu     * The preview status listener needs to provide an
3106db742814dd635d100639f977fcfdc904deb778Doris Liu     * {@link android.view.GestureDetector.OnGestureListener} in order to listen
3206db742814dd635d100639f977fcfdc904deb778Doris Liu     * to the touch events that happen on preview.
3306db742814dd635d100639f977fcfdc904deb778Doris Liu     *
3406db742814dd635d100639f977fcfdc904deb778Doris Liu     * @return a listener that listens to touch events
3506db742814dd635d100639f977fcfdc904deb778Doris Liu     */
3606db742814dd635d100639f977fcfdc904deb778Doris Liu    public GestureDetector.OnGestureListener getGestureListener();
374a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu
384a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu    /**
39d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren     * An {@link android.view.View.OnTouchListener} can be provided in addition to
40d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren     * or instead of a {@link android.view.GestureDetector.OnGestureListener}
41d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren     * for listening to touch events on the preview.  The listener is called whenever
42d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren     * there is a touch event on the {@link com.android.camera.ui.PreviewOverlay}.
43d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren     */
44d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren    public View.OnTouchListener getTouchListener();
45d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren
46d8de077f72b04cee1bdf26e5ca1678ac5297bd71Erin Dahlgren    /**
474a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu     * Gets called when preview TextureView gets a layout change call.
484a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu     */
494a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu    public void onPreviewLayoutChanged(View v, int left, int top, int right,
504a010db8a60008b2bf67b93b64f77f63affc29f3Doris Liu            int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom);
5170da918464276b110c43868caa272c97baadb89eDoris Liu
5270da918464276b110c43868caa272c97baadb89eDoris Liu    /**
532bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong     * This listener gets notified when the actual preview frame changes due
5470da918464276b110c43868caa272c97baadb89eDoris Liu     * to a transform matrix being applied to the TextureView
5570da918464276b110c43868caa272c97baadb89eDoris Liu     */
562bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong    public interface PreviewAreaChangedListener {
572bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong        public void onPreviewAreaChanged(RectF previewArea);
5870da918464276b110c43868caa272c97baadb89eDoris Liu    }
5970da918464276b110c43868caa272c97baadb89eDoris Liu
6070da918464276b110c43868caa272c97baadb89eDoris Liu    /**
6170da918464276b110c43868caa272c97baadb89eDoris Liu     * The preview status listener needs to know for the specific module whether
6270da918464276b110c43868caa272c97baadb89eDoris Liu     * preview TextureView should automatically adjust its transform matrix based
6370da918464276b110c43868caa272c97baadb89eDoris Liu     * on the current aspect ratio, width and height of the TextureView.
6470da918464276b110c43868caa272c97baadb89eDoris Liu     *
6570da918464276b110c43868caa272c97baadb89eDoris Liu     * @return whether transform matrix should be automatically adjusted
6670da918464276b110c43868caa272c97baadb89eDoris Liu     */
6770da918464276b110c43868caa272c97baadb89eDoris Liu    public boolean shouldAutoAdjustTransformMatrixOnLayout();
6870da918464276b110c43868caa272c97baadb89eDoris Liu
6970da918464276b110c43868caa272c97baadb89eDoris Liu    /**
7011ddd7389b89e9a876eba607e246e8b8d0dfecdfDoris Liu     * Gets called when the preview is flipped (i.e. 180-degree rotated).
7111ddd7389b89e9a876eba607e246e8b8d0dfecdfDoris Liu     */
7211ddd7389b89e9a876eba607e246e8b8d0dfecdfDoris Liu    public void onPreviewFlipped();
7328a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu
7428a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu    /**
7528a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu     * This listener gets notified when the preview aspect ratio is changed.
7628a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu     */
7728a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu    public interface PreviewAspectRatioChangedListener {
7828a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu        public void onPreviewAspectRatioChanged(float aspectRatio);
7928a2950939614a0c1c83787960ce1a218fb69a5eDoris Liu    }
8006db742814dd635d100639f977fcfdc904deb778Doris Liu}
81