ModuleController.java revision 4efa8b54c1df4e06f2d3caed2568015a737f9dda
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 199f1db5210361802a30a7866825c3b29ef5fe0024Angus Kongimport android.content.res.Configuration; 209f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 21fa27423125e78f43d8dbae987c34314a238f205cAngus Kongimport com.android.camera.app.AppController; 22a63dbb6231f06031204fe20b19a87d0440bd1661Sascha Haeberlingimport com.android.camera.app.CameraManager; 23fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 24fa27423125e78f43d8dbae987c34314a238f205cAngus Kong/** 25fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * The controller at app level. 26fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 27fa27423125e78f43d8dbae987c34314a238f205cAngus Kongpublic interface ModuleController { 289f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 299f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** Life cycle management **********************/ 30fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 31fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 32fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Initializes the module. 33c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * 3451ae7a844570f85b68a989034f7391260d88a783Angus Kong * @param app The app which initializes this module. 35c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * @param isSecureCamera Whether the app is in secure camera mode. 36c02b13af4c44fe23d4a563d3c2df1ca50e44affcAngus Kong * @param isCaptureIntent Whether the app is in capture intent mode. 37fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 38628481532e1e58a0a26330d238e850aec5657bceAngus Kong public void init(AppController app, boolean isSecureCamera, boolean isCaptureIntent); 39fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 40fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 41fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Resumes the module. Always call this method whenever it's being put in 42fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * the foreground. 43fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 44fa27423125e78f43d8dbae987c34314a238f205cAngus Kong public void resume(); 45fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 46fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 47fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Pauses the module. Always call this method whenever it's being put in the 48fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * background. 49fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 50fa27423125e78f43d8dbae987c34314a238f205cAngus Kong public void pause(); 51fa27423125e78f43d8dbae987c34314a238f205cAngus Kong 52fa27423125e78f43d8dbae987c34314a238f205cAngus Kong /** 53fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * Destroys the module. Always call this method to release the resources used 54fa27423125e78f43d8dbae987c34314a238f205cAngus Kong * by this module. 55fa27423125e78f43d8dbae987c34314a238f205cAngus Kong */ 5620fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong public void destroy(); 5751ae7a844570f85b68a989034f7391260d88a783Angus Kong 589f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** UI / Camera preview **********************/ 599f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 6051ae7a844570f85b68a989034f7391260d88a783Angus Kong /** 61faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong * Called when the preview becomes visible/invisible. 62faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong * 63faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong * @param visible Whether the preview is visible. 64faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong */ 65faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong public void onPreviewVisibilityChanged(boolean visible); 66faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong 67faaee012acc80ad369cb03df9c196e48140f1e7bAngus Kong /** 6851ae7a844570f85b68a989034f7391260d88a783Angus Kong * Called by the app when the preview size is changed. 6951ae7a844570f85b68a989034f7391260d88a783Angus Kong * 7051ae7a844570f85b68a989034f7391260d88a783Angus Kong * @param width The new width. 7151ae7a844570f85b68a989034f7391260d88a783Angus Kong * @param height The new height. 7251ae7a844570f85b68a989034f7391260d88a783Angus Kong */ 7351ae7a844570f85b68a989034f7391260d88a783Angus Kong public void onPreviewSizeChanged(int width, int height); 7451ae7a844570f85b68a989034f7391260d88a783Angus Kong 7551ae7a844570f85b68a989034f7391260d88a783Angus Kong /** 7653ae041d63ee7a251c73ac47abeeb143a2f0da44Angus Kong * Called when the framework layout orientation changed. 7753ae041d63ee7a251c73ac47abeeb143a2f0da44Angus Kong * 782f0e4a3995684c986afad55db7715c15393a9df0Angus Kong * @param isLandscape Whether the new orientation is landscape or portrait. 799f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong */ 802f0e4a3995684c986afad55db7715c15393a9df0Angus Kong public void onLayoutOrientationChanged(boolean isLandscape); 819f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 829f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /** 839f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong * Called when the UI orientation is changed. 849f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong * 852f0e4a3995684c986afad55db7715c15393a9df0Angus Kong * @param orientation The new orientation, valid values are 0, 90, 180 and 862f0e4a3995684c986afad55db7715c15393a9df0Angus Kong * 270. 879f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong */ 889f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong public void onOrientationChanged(int orientation); 899f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 9013e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong /** 9113e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * Called when back key is pressed. 9213e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * 9313e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong * @return Whether the back key event is processed. 9413e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong */ 9513e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong public abstract boolean onBackPressed(); 9613e87c4d06e96e03adc229637f07baf3b56b90d6Angus Kong 979f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /********************** App-level resources **********************/ 989f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong 999f1db5210361802a30a7866825c3b29ef5fe0024Angus Kong /** 10051ae7a844570f85b68a989034f7391260d88a783Angus Kong * Called by the app when the camera is available. The module should use 10151ae7a844570f85b68a989034f7391260d88a783Angus Kong * {@link com.android.camera.app.AppController#} 10220fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong * 10320fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong * @param cameraProxy The camera device proxy. 10451ae7a844570f85b68a989034f7391260d88a783Angus Kong */ 10520fad249cbb587b8cf03e8e53bc64ff8e0bec7fdAngus Kong public void onCameraAvailable(CameraManager.CameraProxy cameraProxy); 1064efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren 1074efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren /** 1084efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren * Used by the app on configuring the bottom bar color and visibility. 1094efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren */ 1104efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // Necessary because not all modules have a bottom bar. 1114efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // TODO: once all modules use the generic module UI, move this 1124efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren // logic into the app. 1134efa8b54c1df4e06f2d3caed2568015a737f9ddaErin Dahlgren public boolean isUsingBottomBar(); 114fa27423125e78f43d8dbae987c34314a238f205cAngus Kong} 115