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.module;
18 
19 import com.android.camera.CameraActivity;
20 import com.android.camera.ShutterButton;
21 import com.android.camera.app.CameraAppUI.BottomBarUISpec;
22 import com.android.camera.hardware.HardwareSpec;
23 import com.android.camera.settings.SettingsManager;
24 import com.android.ex.camera2.portability.CameraAgent;
25 
26 /**
27  * The controller at app level.
28  */
29 public interface ModuleController extends ShutterButton.OnShutterButtonListener {
30     /** Preview is fully visible. */
31     public static final int VISIBILITY_VISIBLE = 0;
32     /** Preview is covered by e.g. the transparent mode drawer. */
33     public static final int VISIBILITY_COVERED = 1;
34     /** Preview is fully hidden, e.g. by the filmstrip. */
35     public static final int VISIBILITY_HIDDEN = 2;
36 
37     /********************** Life cycle management **********************/
38 
39     /**
40      * Initializes the module.
41      *
42      * @param activity The camera activity.
43      * @param isSecureCamera Whether the app is in secure camera mode.
44      * @param isCaptureIntent Whether the app is in capture intent mode.
45      */
init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent)46     public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent);
47 
48     /**
49      * Resumes the module. Always call this method whenever it's being put in
50      * the foreground.
51      */
resume()52     public void resume();
53 
54     /**
55      * Pauses the module. Always call this method whenever it's being put in the
56      * background.
57      */
pause()58     public void pause();
59 
60     /**
61      * Destroys the module. Always call this method to release the resources used
62      * by this module.
63      */
destroy()64     public void destroy();
65 
66     /********************** UI / Camera preview **********************/
67 
68     /**
69      * Called when the preview becomes visible/invisible.
70      *
71      * @param visible Whether the preview is visible, one of
72      *            {@link #VISIBILITY_VISIBLE}, {@link #VISIBILITY_COVERED},
73      *            {@link #VISIBILITY_HIDDEN}
74      */
onPreviewVisibilityChanged(int visibility)75     public void onPreviewVisibilityChanged(int visibility);
76 
77     /**
78      * Called when the framework layout orientation changed.
79      *
80      * @param isLandscape Whether the new orientation is landscape or portrait.
81      */
onLayoutOrientationChanged(boolean isLandscape)82     public void onLayoutOrientationChanged(boolean isLandscape);
83 
84     /**
85      * Called when back key is pressed.
86      *
87      * @return Whether the back key event is processed.
88      */
onBackPressed()89     public abstract boolean onBackPressed();
90 
91     /********************** App-level resources **********************/
92 
93     /**
94      * Called by the app when the camera is available. The module should use
95      * {@link com.android.camera.app.AppController#}
96      *
97      * @param cameraProxy The camera device proxy.
98      */
onCameraAvailable(CameraAgent.CameraProxy cameraProxy)99     public void onCameraAvailable(CameraAgent.CameraProxy cameraProxy);
100 
101     /**
102      * Called by the app on startup or module switches, this allows the module
103      * to perform a hard reset on specific settings.
104      */
hardResetSettings(SettingsManager settingsManager)105     public void hardResetSettings(SettingsManager settingsManager);
106 
107     /**
108      * Returns a {@link com.android.camera.hardware.HardwareSpec}
109      * based on the module's open camera device.
110      */
getHardwareSpec()111     public HardwareSpec getHardwareSpec();
112 
113     /**
114      * Returns a {@link com.android.camera.app.CameraAppUI.BottomBarUISpec}
115      * which represents the module's ideal bottom bar layout of the
116      * mode options.  The app edits the final layout based on the
117      * {@link com.android.camera.hardware.HardwareSpec}.
118      */
getBottomBarSpec()119     public BottomBarUISpec getBottomBarSpec();
120 
121     /**
122      * Used by the app on configuring the bottom bar color and visibility.
123      */
124     // Necessary because not all modules have a bottom bar.
125     // TODO: once all modules use the generic module UI, move this
126     // logic into the app.
isUsingBottomBar()127     public boolean isUsingBottomBar();
128 }
129