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.module; 18fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 19846d3abfe3da2fa2a5593c7d40a196005408bed1Sascha Haeberlingimport com.android.camera.CameraActivity; 205d18769f53db81d401488811250570290a73626bErin Dahlgrenimport com.android.camera.ShutterButton; 21b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgrenimport com.android.camera.app.CameraAppUI.BottomBarUISpec; 22b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgrenimport com.android.camera.hardware.HardwareSpec; 231ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgrenimport com.android.camera.settings.SettingsManager; 245a344964cb003525727c31d295ca3a592c245606Sol Boucherimport com.android.ex.camera2.portability.CameraAgent; 25fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 26fa27423125e78f43d8dbae987c34314a238f205cAngus Kong/** 27fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * The controller at app level. 28fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 295d18769f53db81d401488811250570290a73626bErin Dahlgrenpublic interface ModuleController extends ShutterButton.OnShutterButtonListener { 308c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling /** Preview is fully visible. */ 318c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling public static final int VISIBILITY_VISIBLE = 0; 328c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling /** Preview is covered by e.g. the transparent mode drawer. */ 338c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling public static final int VISIBILITY_COVERED = 1; 348c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling /** Preview is fully hidden, e.g. by the filmstrip. */ 358c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling public static final int VISIBILITY_HIDDEN = 2; 369f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 379f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** Life cycle management **********************/ 38fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 39fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 40fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Initializes the module. 41c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * 42846d3abfe3da2fa2a5593c7d40a196005408bed1Sascha Haeberling * @param activity The camera activity. 43c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * @param isSecureCamera Whether the app is in secure camera mode. 44c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * @param isCaptureIntent Whether the app is in capture intent mode. 45fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 46846d3abfe3da2fa2a5593c7d40a196005408bed1Sascha Haeberling public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent); 47fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 48fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 49fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Resumes the module. Always call this method whenever it's being put in 50fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * the foreground. 51fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 52fa27423125e78f43d8dbae987c34314a238f205cAngus Kong public void resume(); 53fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 54fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 55fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Pauses the module. Always call this method whenever it's being put in the 56fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * background. 57fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 58fa27423125e78f43d8dbae987c34314a238f205cAngus Kong public void pause(); 59fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 60fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 61fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Destroys the module. Always call this method to release the resources used 62fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * by this module. 63fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 6420fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong public void destroy(); 6551ae7a844570f85b68a989034f7391260d88a783Angus Kong 669f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** UI / Camera preview **********************/ 679f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 6851ae7a844570f85b68a989034f7391260d88a783Angus Kong /** 69faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong * Called when the preview becomes visible/invisible. 70faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong * 718c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling * @param visible Whether the preview is visible, one of 728c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling * {@link #VISIBILITY_VISIBLE}, {@link #VISIBILITY_COVERED}, 738c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling * {@link #VISIBILITY_HIDDEN} 74faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong */ 758c1a922df154182b53f00c38198db7da0b4feb20Sascha Haeberling public void onPreviewVisibilityChanged(int visibility); 76faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong 77faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong /** 7853ae041d63ee7a251c73ac47abeeb143a2f0da44Angus Kong * Called when the framework layout orientation changed. 7953ae041d63ee7a251c73ac47abeeb143a2f0da44Angus Kong * 802f0e4a3995684c986afad55db7715c15393a9df0Angus Kong * @param isLandscape Whether the new orientation is landscape or portrait. 819f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong */ 822f0e4a3995684c986afad55db7715c15393a9df0Angus Kong public void onLayoutOrientationChanged(boolean isLandscape); 839f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 849f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /** 8513e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * Called when back key is pressed. 8613e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * 8713e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * @return Whether the back key event is processed. 8813e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong */ 8913e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong public abstract boolean onBackPressed(); 9013e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong 919f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** App-level resources **********************/ 929f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 939f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /** 9451ae7a844570f85b68a989034f7391260d88a783Angus Kong * Called by the app when the camera is available. The module should use 9551ae7a844570f85b68a989034f7391260d88a783Angus Kong * {@link com.android.camera.app.AppController#} 9620fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong * 9720fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong * @param cameraProxy The camera device proxy. 9851ae7a844570f85b68a989034f7391260d88a783Angus Kong */ 995a344964cb003525727c31d295ca3a592c245606Sol Boucher public void onCameraAvailable(CameraAgent.CameraProxy cameraProxy); 1004efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren 1014efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren /** 1021ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren * Called by the app on startup or module switches, this allows the module 1031ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren * to perform a hard reset on specific settings. 1041ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren */ 1051ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren public void hardResetSettings(SettingsManager settingsManager); 1061ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren 1071ca516f2b612f91e0857ca87d978d39c2aba7c8cErin Dahlgren /** 108b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * Returns a {@link com.android.camera.hardware.HardwareSpec} 109b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * based on the module's open camera device. 1100a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren */ 111b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren public HardwareSpec getHardwareSpec(); 112b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren 113b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren /** 114b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * Returns a {@link com.android.camera.app.CameraAppUI.BottomBarUISpec} 115b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * which represents the module's ideal bottom bar layout of the 116b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * mode options. The app edits the final layout based on the 117b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren * {@link com.android.camera.hardware.HardwareSpec}. 118b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren */ 119b1641f5df0cf839b54385ea4d2e43521620fc237Erin Dahlgren public BottomBarUISpec getBottomBarSpec(); 1200a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren 1210a6a8d8e4e1c9796aac606379a42970cdffb8911Erin Dahlgren /** 1224efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren * Used by the app on configuring the bottom bar color and visibility. 1234efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren */ 1244efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // Necessary because not all modules have a bottom bar. 1254efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // TODO: once all modules use the generic module UI, move this 1264efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // logic into the app. 1274efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren public boolean isUsingBottomBar(); 128fa27423125e78f43d8dbae987c34314a238f205cAngus Kong} 129