1fa27423125e78f43d8dbae987c34314a238f205cAngus Kong/*
2fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Copyright (C) 2013 The Android Open Source Project
3fa27423125e78f43d8dbae987c34314a238f205cAngus Kong *
4fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Licensed under the Apache License, Version 2.0 (the "License");
5fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * you may not use this file except in compliance with the License.
6fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * You may obtain a copy of the License at
7fa27423125e78f43d8dbae987c34314a238f205cAngus Kong *
8fa27423125e78f43d8dbae987c34314a238f205cAngus Kong *      http://www.apache.org/licenses/LICENSE-2.0
9fa27423125e78f43d8dbae987c34314a238f205cAngus Kong *
10fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Unless required by applicable law or agreed to in writing, software
11fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * distributed under the License is distributed on an "AS IS" BASIS,
12fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * See the License for the specific language governing permissions and
14fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * limitations under the License.
15fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */
16fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
17fa27423125e78f43d8dbae987c34314a238f205cAngus Kongpackage com.android.camera.app;
18fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
19e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberlingimport android.app.Activity;
202272f8a6bfc8adca8ada7a215bef038d45256085Senpo Huimport android.app.Dialog;
21fa27423125e78f43d8dbae987c34314a238f205cAngus Kongimport android.content.Context;
220eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kongimport android.content.Intent;
2351ae7a844570f85b68a989034f7391260d88a783Angus Kongimport android.graphics.Bitmap;
2470da918464276b110c43868caa272c97baadb89eDoris Liuimport android.graphics.Matrix;
2502c129a598b6a165885fe950275675d62993d2eeSeth Raphaelimport android.graphics.RectF;
2651ae7a844570f85b68a989034f7391260d88a783Angus Kongimport android.graphics.SurfaceTexture;
27fa27423125e78f43d8dbae987c34314a238f205cAngus Kongimport android.net.Uri;
28e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberlingimport android.view.View;
2951ae7a844570f85b68a989034f7391260d88a783Angus Kongimport android.widget.FrameLayout;
3051ae7a844570f85b68a989034f7391260d88a783Angus Kong
311848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgrenimport com.android.camera.ButtonManager;
3266b942a3d20aac65454961ef2bc219ca560b9fbaPuneet Lallimport com.android.camera.FatalErrorHandler;
332d4be2576b265a4abfbabbda20862fcea19c1395Sascha Haeberlingimport com.android.camera.SoundPlayer;
34e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberlingimport com.android.camera.module.ModuleController;
351d84d7107686aa428ee2eeb1a8caf0ea3e43b1dfPaul Rohdeimport com.android.camera.one.OneCameraOpener;
368f51086c8177056345de996963515c4bd3415254Sascha Haeberlingimport com.android.camera.one.config.OneCameraFeatureConfig;
37fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Huimport com.android.camera.settings.ResolutionSetting;
38357b7673f03d9b45d281d585cc3f4f87dc7d727bErin Dahlgrenimport com.android.camera.settings.SettingsManager;
39c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberlingimport com.android.camera.ui.AbstractTutorialOverlay;
4006db742814dd635d100639f977fcfdc904deb778Doris Liuimport com.android.camera.ui.PreviewStatusListener;
41fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
42fa27423125e78f43d8dbae987c34314a238f205cAngus Kong/**
43fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * The controller at app level.
44fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */
45831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kongpublic interface AppController {
46fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
47fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
4851ae7a844570f85b68a989034f7391260d88a783Angus Kong     * An interface which defines the shutter events listener.
49fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
5051ae7a844570f85b68a989034f7391260d88a783Angus Kong    public interface ShutterEventsListener {
5151ae7a844570f85b68a989034f7391260d88a783Angus Kong        /**
5251ae7a844570f85b68a989034f7391260d88a783Angus Kong         * Called when the shutter state is changed to pressed.
5351ae7a844570f85b68a989034f7391260d88a783Angus Kong         */
5451ae7a844570f85b68a989034f7391260d88a783Angus Kong        public void onShutterPressed();
5551ae7a844570f85b68a989034f7391260d88a783Angus Kong
5651ae7a844570f85b68a989034f7391260d88a783Angus Kong        /**
5751ae7a844570f85b68a989034f7391260d88a783Angus Kong         * Called when the shutter state is changed to released.
5851ae7a844570f85b68a989034f7391260d88a783Angus Kong         */
5951ae7a844570f85b68a989034f7391260d88a783Angus Kong        public void onShutterReleased();
6051ae7a844570f85b68a989034f7391260d88a783Angus Kong
6151ae7a844570f85b68a989034f7391260d88a783Angus Kong        /**
6251ae7a844570f85b68a989034f7391260d88a783Angus Kong         * Called when the shutter is clicked.
6351ae7a844570f85b68a989034f7391260d88a783Angus Kong         */
6451ae7a844570f85b68a989034f7391260d88a783Angus Kong        public void onShutterClicked();
65fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
6651ae7a844570f85b68a989034f7391260d88a783Angus Kong        /**
6751ae7a844570f85b68a989034f7391260d88a783Angus Kong         * Called when the shutter is long pressed.
6851ae7a844570f85b68a989034f7391260d88a783Angus Kong         */
6951ae7a844570f85b68a989034f7391260d88a783Angus Kong        public void onShutterLongPressed();
7051ae7a844570f85b68a989034f7391260d88a783Angus Kong    }
71fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
72fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
730eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong     * @return the {@link android.content.Context} being used.
74fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
7551ae7a844570f85b68a989034f7391260d88a783Angus Kong    public Context getAndroidContext();
7651ae7a844570f85b68a989034f7391260d88a783Angus Kong
778f51086c8177056345de996963515c4bd3415254Sascha Haeberling    /** @return the camera feature configuration for the device. */
788f51086c8177056345de996963515c4bd3415254Sascha Haeberling    public OneCameraFeatureConfig getCameraFeatureConfig();
798f51086c8177056345de996963515c4bd3415254Sascha Haeberling
80c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren    /**
812272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu     * Creates a new dialog which can be shown in the app.
822272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu     *
832272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu     * @return  {@link android.app.Dialog} of the app.
842272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu     */
852272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu    public Dialog createDialog();
862272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu
872272f8a6bfc8adca8ada7a215bef038d45256085Senpo Hu    /**
886190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     * @return a String scope uniquely identifing the current module.
896190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     */
906190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    public String getModuleScope();
916190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren
926190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    /**
936190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     * @return a String scope uniquely identifing the current camera id.
946190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     */
956190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    public String getCameraScope();
966190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren
976190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    /**
980eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong     * Starts an activity.
990eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong     *
1000eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong     * @param intent Used to start the activity.
1010eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong     */
1020eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong    public void launchActivityByIntent(Intent intent);
1030eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong
1040eaf01670a1198c95b6472ec0dc076c9f84971deAngus Kong    /**
105e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling     * See {@link Activity#openContextMenu(View)}
106e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling     */
107e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling    public void openContextMenu(View view);
108e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling
109e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling    /**
110e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling     * See {@link Activity#registerForContextMenu(View)}
111e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling     */
112e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling    public void registerForContextMenu(View view);
113e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling
114e8959e7a72cd6f057ac4cd8bd47075272700e62eSascha Haeberling    /**
115c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren     * Returns whether the app is currently paused.
116c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren     */
117c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren    public boolean isPaused();
118c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren
119f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu    /**
1200a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren     * Returns the current module controller.
1210a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren     */
1220a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren    public ModuleController getCurrentModuleController();
1230a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren
1240a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren    /**
125831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kong     * Returns the currently active module index.
126831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kong     */
127831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kong    public int getCurrentModuleIndex();
128831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kong
129831347d9cb5c0e3f03db7aadfc89e91b231104e7Angus Kong    /**
130427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu     * Returns the module ID for a specific mode.
131427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu     */
132427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu    public int getModuleId(int modeIndex);
133427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu
134427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu    /**
135bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     * Gets the mode that can be switched to from the given mode id through
136bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     * quick switch.
137bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     *
138bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     * @param currentModuleIndex index of the current mode
139bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     * @return mode id to quick switch to if index is valid, otherwise returns
140bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     *         the given mode id itself
141bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu     */
142bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu    public int getQuickSwitchToModuleId(int currentModuleIndex);
143bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu
144bd1b8f910d6f2c94daac304f4bd1a098939474c3Doris Liu    /**
1451ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren     * Based on a mode switcher index, choose the correct module index.
1461ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren     *
1471ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren     * @param modeIndex mode switcher index.
1481ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren     * @return module index.
1491ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren     */
1501ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren    public int getPreferredChildModeIndex(int modeIndex);
1511ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren
1521ba90e3ea4b8280c28cf6d87e5b4cc6b3b5f1645Erin Dahlgren    /**
153f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu     * This gets called when mode is changed.
154f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu     *
155f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu     * @param moduleIndex index of the new module to switch to
156f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu     */
157f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu    public void onModeSelected(int moduleIndex);
158f55f3c461c5a6ae6b61fa75562ca01683aa93f9aDoris Liu
1599d264309a341c52601bdccdeff6647e0ce58c31fDoris Liu    /**
1609d264309a341c52601bdccdeff6647e0ce58c31fDoris Liu     * This gets called when settings is selected and settings dialog needs to open.
1619d264309a341c52601bdccdeff6647e0ce58c31fDoris Liu     */
1629d264309a341c52601bdccdeff6647e0ce58c31fDoris Liu    public void onSettingsSelected();
1639d264309a341c52601bdccdeff6647e0ce58c31fDoris Liu
1649f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    /********************** UI / Camera preview **********************/
165fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
1666809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu
1676809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu    /**
1686809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu     * Freeze what is currently shown on screen until the next preview frame comes
1696809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu     * in. This can be used for camera switch to hide the UI changes underneath
1706809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu     * until preview is ready.
1716809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu     */
1726809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu    public void freezeScreenUntilPreviewReady();
1736809eb840f358430d3032c0532fb42d6dcfd06efDoris Liu
174fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
17551ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Returns the {@link android.graphics.SurfaceTexture} used by the preview
17651ae7a844570f85b68a989034f7391260d88a783Angus Kong     * UI.
177fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
17851ae7a844570f85b68a989034f7391260d88a783Angus Kong    public SurfaceTexture getPreviewBuffer();
179fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
180fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
1815a367545ab931a308c8d8555ef5a747dc9565cafDoris Liu     * Gets called from module when preview is ready to start.
1825a367545ab931a308c8d8555ef5a747dc9565cafDoris Liu     */
1835a367545ab931a308c8d8555ef5a747dc9565cafDoris Liu    public void onPreviewReadyToStart();
1845a367545ab931a308c8d8555ef5a747dc9565cafDoris Liu
1855a367545ab931a308c8d8555ef5a747dc9565cafDoris Liu    /**
1862b906b8c9754b564d5113c7a342654c82f97f180Doris Liu     * Gets called from module when preview is started.
1872b906b8c9754b564d5113c7a342654c82f97f180Doris Liu     */
1882b906b8c9754b564d5113c7a342654c82f97f180Doris Liu    public void onPreviewStarted();
1892b906b8c9754b564d5113c7a342654c82f97f180Doris Liu
1902b906b8c9754b564d5113c7a342654c82f97f180Doris Liu    /**
1912bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong     * Adds a listener to receive callbacks when preview area changes.
192482de029dc20e0a577388a602985fb31c3200309Doris Liu     */
193482de029dc20e0a577388a602985fb31c3200309Doris Liu    public void addPreviewAreaSizeChangedListener(
1942bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong            PreviewStatusListener.PreviewAreaChangedListener listener);
195482de029dc20e0a577388a602985fb31c3200309Doris Liu
196482de029dc20e0a577388a602985fb31c3200309Doris Liu    /**
1972bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong     * Removes a listener that receives callbacks when preview area changes.
198482de029dc20e0a577388a602985fb31c3200309Doris Liu     */
199482de029dc20e0a577388a602985fb31c3200309Doris Liu    public void removePreviewAreaSizeChangedListener(
2002bacca795a1b0adb0daf515c43c48234b44bbba5Angus Kong            PreviewStatusListener.PreviewAreaChangedListener listener);
201482de029dc20e0a577388a602985fb31c3200309Doris Liu
202482de029dc20e0a577388a602985fb31c3200309Doris Liu    /**
2034d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu     * Sets up one shot preview callback in order to notify UI when the next
2044d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu     * preview frame comes in.
2054d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu     */
2064d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu    public void setupOneShotPreviewListener();
2074d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu
2084d4a4bc8891bbfc5a7ca842f2981829ac3a716e8Doris Liu    /**
20970da918464276b110c43868caa272c97baadb89eDoris Liu     * Gets called from module when preview aspect ratio has changed.
21070da918464276b110c43868caa272c97baadb89eDoris Liu     *
21170da918464276b110c43868caa272c97baadb89eDoris Liu     * @param aspectRatio aspect ratio of preview stream
21270da918464276b110c43868caa272c97baadb89eDoris Liu     */
21370da918464276b110c43868caa272c97baadb89eDoris Liu    public void updatePreviewAspectRatio(float aspectRatio);
21470da918464276b110c43868caa272c97baadb89eDoris Liu
21570da918464276b110c43868caa272c97baadb89eDoris Liu    /**
21602c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * Gets called from module when the module needs to change the transform
21702c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * matrix of the preview TextureView. It does not modify the matrix before
21802c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * applying it.
21908b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling     *
22002c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * @param matrix transform matrix to be set on preview TextureView
2216382c70a769b9ec94a3b0372ee27c0cd075e8be8Seth Raphael     * @param aspectRatio the desired aspect ratio of the preview
22202c129a598b6a165885fe950275675d62993d2eeSeth Raphael     */
2236382c70a769b9ec94a3b0372ee27c0cd075e8be8Seth Raphael    public void updatePreviewTransformFullscreen(Matrix matrix, float aspectRatio);
22402c129a598b6a165885fe950275675d62993d2eeSeth Raphael
22502c129a598b6a165885fe950275675d62993d2eeSeth Raphael    /**
22602c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * Call this to find the full rect available for a full screen preview
22708b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling     *
22802c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * @return the rect of the full screen minus any decor.
22902c129a598b6a165885fe950275675d62993d2eeSeth Raphael     */
23002c129a598b6a165885fe950275675d62993d2eeSeth Raphael    public RectF getFullscreenRect();
23102c129a598b6a165885fe950275675d62993d2eeSeth Raphael
23202c129a598b6a165885fe950275675d62993d2eeSeth Raphael    /**
23302c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * Gets called from module when the module needs to change the transform
23402c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * matrix of the preview TextureView. It is encouraged to use
23502c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * {@link #updatePreviewAspectRatio(float)} over this function, unless the
23602c129a598b6a165885fe950275675d62993d2eeSeth Raphael     * module needs to rotate the surface texture using transform matrix.
23708b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling     *
23870da918464276b110c43868caa272c97baadb89eDoris Liu     * @param matrix transform matrix to be set on preview TextureView
23970da918464276b110c43868caa272c97baadb89eDoris Liu     */
24070da918464276b110c43868caa272c97baadb89eDoris Liu    public void updatePreviewTransform(Matrix matrix);
24170da918464276b110c43868caa272c97baadb89eDoris Liu
24270da918464276b110c43868caa272c97baadb89eDoris Liu    /**
24306db742814dd635d100639f977fcfdc904deb778Doris Liu     * Sets the preview status listener, which will get notified when TextureView
24406db742814dd635d100639f977fcfdc904deb778Doris Liu     * surface has changed
24506db742814dd635d100639f977fcfdc904deb778Doris Liu     *
24606db742814dd635d100639f977fcfdc904deb778Doris Liu     * @param previewStatusListener the listener to get callbacks
24706db742814dd635d100639f977fcfdc904deb778Doris Liu     */
24806db742814dd635d100639f977fcfdc904deb778Doris Liu    public void setPreviewStatusListener(PreviewStatusListener previewStatusListener);
24906db742814dd635d100639f977fcfdc904deb778Doris Liu
25006db742814dd635d100639f977fcfdc904deb778Doris Liu    /**
25151ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Returns the {@link android.widget.FrameLayout} as the root of the module
25251ae7a844570f85b68a989034f7391260d88a783Angus Kong     * layout.
253fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
25451ae7a844570f85b68a989034f7391260d88a783Angus Kong    public FrameLayout getModuleLayoutRoot();
25551ae7a844570f85b68a989034f7391260d88a783Angus Kong
2569f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    /**
2579f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     * Locks the system orientation.
2589f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     */
2599f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    public void lockOrientation();
2609f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong
2619f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    /**
2629f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     * Unlocks the system orientation.
2639f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     */
2649f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    public void unlockOrientation();
2659f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong
26651ae7a844570f85b68a989034f7391260d88a783Angus Kong    /********************** Shutter button  **********************/
267fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
268fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
26951ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Sets the shutter events listener.
27051ae7a844570f85b68a989034f7391260d88a783Angus Kong     *
27151ae7a844570f85b68a989034f7391260d88a783Angus Kong     * @param listener The listener.
272fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
27351ae7a844570f85b68a989034f7391260d88a783Angus Kong    public void setShutterEventsListener(ShutterEventsListener listener);
274fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
275fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
276fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     * Enables/Disables the shutter.
277fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
278fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    public void setShutterEnabled(boolean enabled);
279fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
280fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
281fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     * Checks whether the shutter is enabled.
282fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
283fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    public boolean isShutterEnabled();
284fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
28551ae7a844570f85b68a989034f7391260d88a783Angus Kong    /********************** Capture animation **********************/
28651ae7a844570f85b68a989034f7391260d88a783Angus Kong
28751ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
288427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu     * Starts flash animation with optional shorter flash.
28917d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers     *
29017d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers     * @param shortFlash true for shorter flash (faster cameras).
29117d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers     */
292427a915be4bcc84fa1c32d9e9e1b7473c522f732Senpo Hu    public void startFlashAnimation(boolean shortFlash);
29317d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers
29417d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers    /**
29517d9084e38e64f06a9d411d64fe3c2739d299cdaAndy Huibers     * Starts normal pre-capture animation.
29651ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
29751ae7a844570f85b68a989034f7391260d88a783Angus Kong    public void startPreCaptureAnimation();
29851ae7a844570f85b68a989034f7391260d88a783Angus Kong
29951ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
30051ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Cancels the pre-capture animation.
30151ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
30251ae7a844570f85b68a989034f7391260d88a783Angus Kong    public void cancelPreCaptureAnimation();
30351ae7a844570f85b68a989034f7391260d88a783Angus Kong
30451ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
30551ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Starts the post-capture animation with the current preview image.
30651ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
30751ae7a844570f85b68a989034f7391260d88a783Angus Kong    public void startPostCaptureAnimation();
30851ae7a844570f85b68a989034f7391260d88a783Angus Kong
30951ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
31051ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Starts the post-capture animation with the given thumbnail.
31151ae7a844570f85b68a989034f7391260d88a783Angus Kong     *
31251ae7a844570f85b68a989034f7391260d88a783Angus Kong     * @param thumbnail The thumbnail for the animation.
31351ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
31451ae7a844570f85b68a989034f7391260d88a783Angus Kong    public void startPostCaptureAnimation(Bitmap thumbnail);
31551ae7a844570f85b68a989034f7391260d88a783Angus Kong
31651ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
31751ae7a844570f85b68a989034f7391260d88a783Angus Kong     * Cancels the post-capture animation.
31851ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
3199f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    public void cancelPostCaptureAnimation();
32051ae7a844570f85b68a989034f7391260d88a783Angus Kong
32151ae7a844570f85b68a989034f7391260d88a783Angus Kong    /********************** Media saving **********************/
322fa27423125e78f43d8dbae987c34314a238f205cAngus Kong
323fa27423125e78f43d8dbae987c34314a238f205cAngus Kong    /**
3249f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     * Notifies the app of the newly captured media.
325fa27423125e78f43d8dbae987c34314a238f205cAngus Kong     */
3269f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong    public void notifyNewMedia(Uri uri);
32751ae7a844570f85b68a989034f7391260d88a783Angus Kong
32851ae7a844570f85b68a989034f7391260d88a783Angus Kong    /********************** App-level resources **********************/
32951ae7a844570f85b68a989034f7391260d88a783Angus Kong
33051ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
33113e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong     * Keeps the screen turned on.
33213e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong     *
33313e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong     * @param enabled Whether to keep the screen on.
33413e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong     */
33513e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong    public void enableKeepScreenOn(boolean enabled);
33613e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong
33713e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong    /**
33820fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong     * Returns the {@link com.android.camera.app.CameraProvider}.
33951ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
34020fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong    public CameraProvider getCameraProvider();
34151ae7a844570f85b68a989034f7391260d88a783Angus Kong
34251ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
34308b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling     * Returns the new camera API manager.
34408b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling     */
3451d84d7107686aa428ee2eeb1a8caf0ea3e43b1dfPaul Rohde    public OneCameraOpener getCameraOpener();
34608b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling
34708b3c94a7d7aff30b5da8e99649346e37b67a5c5Sascha Haeberling    /**
3489f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong     * Returns the {@link OrientationManagerImpl}.
34951ae7a844570f85b68a989034f7391260d88a783Angus Kong     *
35051ae7a844570f85b68a989034f7391260d88a783Angus Kong     * @return {@code null} if not available yet.
35151ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
35251ae7a844570f85b68a989034f7391260d88a783Angus Kong    public OrientationManager getOrientationManager();
35351ae7a844570f85b68a989034f7391260d88a783Angus Kong
35451ae7a844570f85b68a989034f7391260d88a783Angus Kong    /**
355386c5b885b99f67f9c0a7380f4be153f28333089Puneet Lall     * Returns the {@link LocationManager}.
35651ae7a844570f85b68a989034f7391260d88a783Angus Kong     *
35751ae7a844570f85b68a989034f7391260d88a783Angus Kong     * @return {@code null} if not available yet.
35851ae7a844570f85b68a989034f7391260d88a783Angus Kong     */
35951ae7a844570f85b68a989034f7391260d88a783Angus Kong    public LocationManager getLocationManager();
360c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren
361c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren    /**
362386c5b885b99f67f9c0a7380f4be153f28333089Puneet Lall     * Returns the {@link SettingsManager}.
363c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren     */
364c120b0f6e5ea919fcbb87f832a2b6c82509a2114Erin Dahlgren    public SettingsManager getSettingsManager();
365c4e665625b88a8363fa2bd9848bf88ec9b45637fAngus Kong
366c4e665625b88a8363fa2bd9848bf88ec9b45637fAngus Kong    /**
367fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu     * Returns the {@link com.android.camera.settings.ResolutionSetting}.
368fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu     *
369fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu     * @return the current resolution setting.
370fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu     */
371fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu    public ResolutionSetting getResolutionSetting();
372fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu
373fb0496133a0b4b526dc70f6447bd4b97d95de95fSenpo Hu    /**
374c4e665625b88a8363fa2bd9848bf88ec9b45637fAngus Kong     * @return Common services and functionality to be shared.
375c4e665625b88a8363fa2bd9848bf88ec9b45637fAngus Kong     */
376c4e665625b88a8363fa2bd9848bf88ec9b45637fAngus Kong    public CameraServices getServices();
377357b7673f03d9b45d281d585cc3f4f87dc7d727bErin Dahlgren
378357b7673f03d9b45d281d585cc3f4f87dc7d727bErin Dahlgren    /**
379698e271d2b263778bfa73d1e67d6e2cd2783c89ezafir     * @return The error handler to invoke for errors.
38066b942a3d20aac65454961ef2bc219ca560b9fbaPuneet Lall     */
38166b942a3d20aac65454961ef2bc219ca560b9fbaPuneet Lall    public FatalErrorHandler getFatalErrorHandler();
38266b942a3d20aac65454961ef2bc219ca560b9fbaPuneet Lall
38366b942a3d20aac65454961ef2bc219ca560b9fbaPuneet Lall    /**
3846190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     * Returns the {@link com.android.camera.app.CameraAppUI}.
3850f3c4b4fc9ac87d7d4c3d04c3cb3426c711f57eaSpike Sprague     *
3860f3c4b4fc9ac87d7d4c3d04c3cb3426c711f57eaSpike Sprague     * @return {@code null} if not available yet.
3870f3c4b4fc9ac87d7d4c3d04c3cb3426c711f57eaSpike Sprague     */
3880f3c4b4fc9ac87d7d4c3d04c3cb3426c711f57eaSpike Sprague    public CameraAppUI getCameraAppUI();
3891848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgren
3901848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgren    /**
3916190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     * Returns the {@link com.android.camera.app.ModuleManager}.
3926190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     *
3936190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     * @return {@code null} if not available yet.
3946190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren     */
3956190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    public ModuleManager getModuleManager();
3966190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren
3976190c36db653e848f29d1caefc4fa1bb61e8a662Erin Dahlgren    /**
3981848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgren     * Returns the {@link com.android.camera.ButtonManager}.
3991848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgren     */
4001848494bd09c85002d8c59d4feb8a6e0dc32871fErin Dahlgren    public ButtonManager getButtonManager();
401a7cbfc04d888624858271facdbf68797c54df8b6Sascha Haeberling
4022d4be2576b265a4abfbabbda20862fcea19c1395Sascha Haeberling    /** Returns a sound player that can be used to play custom sounds. */
4032d4be2576b265a4abfbabbda20862fcea19c1395Sascha Haeberling    public SoundPlayer getSoundPlayer();
4042d4be2576b265a4abfbabbda20862fcea19c1395Sascha Haeberling
405a7cbfc04d888624858271facdbf68797c54df8b6Sascha Haeberling    /** Whether auto-rotate is enabled.*/
406a7cbfc04d888624858271facdbf68797c54df8b6Sascha Haeberling    public boolean isAutoRotateScreen();
407c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberling
408c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberling    /**
409c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberling     * Shows the given tutorial overlay.
410c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberling     */
411c813ce181810a444b6fea4a399e6685aef4103e2Sascha Haeberling    public void showTutorial(AbstractTutorialOverlay tutorial);
4120cf4a02c13a7710dc9b26ac39bea15a95ac48bafSascha Haeberling
4130cf4a02c13a7710dc9b26ac39bea15a95ac48bafSascha Haeberling    /**
41424be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     * Finishes the activity since the intent is completed successfully.
41524be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     *
41624be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     * @param resultIntent The intent that carries the result.
41724be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     */
41824be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu    public void finishActivityWithIntentCompleted(Intent resultIntent);
41924be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu
42024be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu    /**
42124be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     * Finishes the activity since the intent got canceled.
42224be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu     */
42324be7cc6d138129b4087ef28f114701de54aba3cSenpo Hu    public void finishActivityWithIntentCanceled();
424fa27423125e78f43d8dbae987c34314a238f205cAngus Kong}
425