Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 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 | |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 19 | import android.content.res.Configuration; |
| 20 | |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 21 | import com.android.camera.app.CameraManager; |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 22 | import com.android.camera.app.AppController; |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 23 | import com.android.camera.app.MediaSaver; |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * The controller at app level. |
| 27 | */ |
| 28 | public interface ModuleController { |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 29 | |
| 30 | /********************** Life cycle management **********************/ |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Initializes the module. |
Angus Kong | c02b13a | 2013-11-12 11:50:57 -0800 | [diff] [blame] | 34 | * |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 35 | * @param app The app which initializes this module. |
Angus Kong | c02b13a | 2013-11-12 11:50:57 -0800 | [diff] [blame] | 36 | * @param isSecureCamera Whether the app is in secure camera mode. |
| 37 | * @param isCaptureIntent Whether the app is in capture intent mode. |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 38 | */ |
Angus Kong | 6284815 | 2013-11-08 17:25:29 -0800 | [diff] [blame] | 39 | public void init(AppController app, boolean isSecureCamera, boolean isCaptureIntent); |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Resumes the module. Always call this method whenever it's being put in |
| 43 | * the foreground. |
| 44 | */ |
| 45 | public void resume(); |
| 46 | |
| 47 | /** |
| 48 | * Pauses the module. Always call this method whenever it's being put in the |
| 49 | * background. |
| 50 | */ |
| 51 | public void pause(); |
| 52 | |
| 53 | /** |
| 54 | * Destroys the module. Always call this method to release the resources used |
| 55 | * by this module. |
| 56 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 57 | public void destroy(); |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 58 | |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 59 | /********************** UI / Camera preview **********************/ |
| 60 | |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 61 | /** |
| 62 | * Called by the app when the preview size is changed. |
| 63 | * |
| 64 | * @param width The new width. |
| 65 | * @param height The new height. |
| 66 | */ |
| 67 | public void onPreviewSizeChanged(int width, int height); |
| 68 | |
| 69 | /** |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 70 | * Called when the |
| 71 | * {@link android.app.Activity#onConfigurationChanged(android.content.res.Configuration)} |
| 72 | * happened. |
| 73 | */ |
| 74 | public void onConfigurationChanged(Configuration config); |
| 75 | |
| 76 | /** |
| 77 | * Called when the UI orientation is changed. |
| 78 | * |
| 79 | * @param orientation The new orientation. |
| 80 | */ |
| 81 | public void onOrientationChanged(int orientation); |
| 82 | |
Angus Kong | 13e87c4 | 2013-11-25 10:02:47 -0800 | [diff] [blame^] | 83 | /** |
| 84 | * Called when back key is pressed. |
| 85 | * |
| 86 | * @return Whether the back key event is processed. |
| 87 | */ |
| 88 | public abstract boolean onBackPressed(); |
| 89 | |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 90 | /********************** App-level resources **********************/ |
| 91 | |
| 92 | /** |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 93 | * Called by the app when the camera is available. The module should use |
| 94 | * {@link com.android.camera.app.AppController#} |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 95 | * |
| 96 | * @param cameraProxy The camera device proxy. |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 97 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 98 | public void onCameraAvailable(CameraManager.CameraProxy cameraProxy); |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Called by the app when the {@link com.android.camera.app.MediaSaver} is |
| 102 | * available. |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 103 | * |
| 104 | * @param mediaSaver The {@link com.android.camera.app.MediaSaver} to use. |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 105 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 106 | public void onMediaSaverAvailable(MediaSaver mediaSaver); |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 107 | } |