ModuleController.java revision 4efa8b54c1df4e06f2d3caed2568015a737f9dda
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 17package com.android.camera.module; 18 19import android.content.res.Configuration; 20 21import com.android.camera.app.AppController; 22import com.android.camera.app.CameraManager; 23 24/** 25 * The controller at app level. 26 */ 27public interface ModuleController { 28 29 /********************** Life cycle management **********************/ 30 31 /** 32 * Initializes the module. 33 * 34 * @param app The app which initializes this module. 35 * @param isSecureCamera Whether the app is in secure camera mode. 36 * @param isCaptureIntent Whether the app is in capture intent mode. 37 */ 38 public void init(AppController app, boolean isSecureCamera, boolean isCaptureIntent); 39 40 /** 41 * Resumes the module. Always call this method whenever it's being put in 42 * the foreground. 43 */ 44 public void resume(); 45 46 /** 47 * Pauses the module. Always call this method whenever it's being put in the 48 * background. 49 */ 50 public void pause(); 51 52 /** 53 * Destroys the module. Always call this method to release the resources used 54 * by this module. 55 */ 56 public void destroy(); 57 58 /********************** UI / Camera preview **********************/ 59 60 /** 61 * Called when the preview becomes visible/invisible. 62 * 63 * @param visible Whether the preview is visible. 64 */ 65 public void onPreviewVisibilityChanged(boolean visible); 66 67 /** 68 * Called by the app when the preview size is changed. 69 * 70 * @param width The new width. 71 * @param height The new height. 72 */ 73 public void onPreviewSizeChanged(int width, int height); 74 75 /** 76 * Called when the framework layout orientation changed. 77 * 78 * @param isLandscape Whether the new orientation is landscape or portrait. 79 */ 80 public void onLayoutOrientationChanged(boolean isLandscape); 81 82 /** 83 * Called when the UI orientation is changed. 84 * 85 * @param orientation The new orientation, valid values are 0, 90, 180 and 86 * 270. 87 */ 88 public void onOrientationChanged(int orientation); 89 90 /** 91 * Called when back key is pressed. 92 * 93 * @return Whether the back key event is processed. 94 */ 95 public abstract boolean onBackPressed(); 96 97 /********************** App-level resources **********************/ 98 99 /** 100 * Called by the app when the camera is available. The module should use 101 * {@link com.android.camera.app.AppController#} 102 * 103 * @param cameraProxy The camera device proxy. 104 */ 105 public void onCameraAvailable(CameraManager.CameraProxy cameraProxy); 106 107 /** 108 * Used by the app on configuring the bottom bar color and visibility. 109 */ 110 // Necessary because not all modules have a bottom bar. 111 // TODO: once all modules use the generic module UI, move this 112 // logic into the app. 113 public boolean isUsingBottomBar(); 114} 115