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 | |
Sascha Haeberling | 846d3ab | 2014-02-04 12:48:55 +0100 | [diff] [blame^] | 19 | import com.android.camera.CameraActivity; |
Erin Dahlgren | b1641f5 | 2014-01-14 15:58:52 -0800 | [diff] [blame] | 20 | import com.android.camera.app.CameraAppUI.BottomBarUISpec; |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 21 | import com.android.camera.app.CameraManager; |
Erin Dahlgren | b1641f5 | 2014-01-14 15:58:52 -0800 | [diff] [blame] | 22 | import com.android.camera.hardware.HardwareSpec; |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * The controller at app level. |
| 26 | */ |
| 27 | public interface ModuleController { |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 28 | |
| 29 | /********************** Life cycle management **********************/ |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Initializes the module. |
Angus Kong | c02b13a | 2013-11-12 11:50:57 -0800 | [diff] [blame] | 33 | * |
Sascha Haeberling | 846d3ab | 2014-02-04 12:48:55 +0100 | [diff] [blame^] | 34 | * @param activity The camera activity. |
Angus Kong | c02b13a | 2013-11-12 11:50:57 -0800 | [diff] [blame] | 35 | * @param isSecureCamera Whether the app is in secure camera mode. |
| 36 | * @param isCaptureIntent Whether the app is in capture intent mode. |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 37 | */ |
Sascha Haeberling | 846d3ab | 2014-02-04 12:48:55 +0100 | [diff] [blame^] | 38 | public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent); |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 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 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 56 | public void destroy(); |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 57 | |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 58 | /********************** UI / Camera preview **********************/ |
| 59 | |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 60 | /** |
Angus Kong | faaee01 | 2013-12-07 00:38:46 -0800 | [diff] [blame] | 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 | /** |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 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 | /** |
Angus Kong | 53ae041 | 2013-12-01 23:21:49 -0800 | [diff] [blame] | 76 | * Called when the framework layout orientation changed. |
| 77 | * |
Angus Kong | 2f0e4a3 | 2013-12-03 10:02:35 -0800 | [diff] [blame] | 78 | * @param isLandscape Whether the new orientation is landscape or portrait. |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 79 | */ |
Angus Kong | 2f0e4a3 | 2013-12-03 10:02:35 -0800 | [diff] [blame] | 80 | public void onLayoutOrientationChanged(boolean isLandscape); |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Called when the UI orientation is changed. |
| 84 | * |
Angus Kong | 2f0e4a3 | 2013-12-03 10:02:35 -0800 | [diff] [blame] | 85 | * @param orientation The new orientation, valid values are 0, 90, 180 and |
| 86 | * 270. |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 87 | */ |
| 88 | public void onOrientationChanged(int orientation); |
| 89 | |
Angus Kong | 13e87c4 | 2013-11-25 10:02:47 -0800 | [diff] [blame] | 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 | |
Angus Kong | 9f1db52 | 2013-11-09 16:25:59 -0800 | [diff] [blame] | 97 | /********************** App-level resources **********************/ |
| 98 | |
| 99 | /** |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 100 | * Called by the app when the camera is available. The module should use |
| 101 | * {@link com.android.camera.app.AppController#} |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 102 | * |
| 103 | * @param cameraProxy The camera device proxy. |
Angus Kong | 51ae7a8 | 2013-11-08 14:36:45 -0800 | [diff] [blame] | 104 | */ |
Angus Kong | 20fad24 | 2013-11-11 18:23:46 -0800 | [diff] [blame] | 105 | public void onCameraAvailable(CameraManager.CameraProxy cameraProxy); |
Erin Dahlgren | 4efa8b5 | 2013-12-17 18:31:35 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
Erin Dahlgren | b1641f5 | 2014-01-14 15:58:52 -0800 | [diff] [blame] | 108 | * Returns a {@link com.android.camera.hardware.HardwareSpec} |
| 109 | * based on the module's open camera device. |
Erin Dahlgren | 0a6a8d8 | 2014-01-09 22:17:38 -0800 | [diff] [blame] | 110 | */ |
Erin Dahlgren | b1641f5 | 2014-01-14 15:58:52 -0800 | [diff] [blame] | 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 | */ |
| 119 | public BottomBarUISpec getBottomBarSpec(); |
Erin Dahlgren | 0a6a8d8 | 2014-01-09 22:17:38 -0800 | [diff] [blame] | 120 | |
| 121 | /** |
Erin Dahlgren | 4efa8b5 | 2013-12-17 18:31:35 -0800 | [diff] [blame] | 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. |
| 127 | public boolean isUsingBottomBar(); |
Angus Kong | fa27423 | 2013-11-06 16:15:06 -0800 | [diff] [blame] | 128 | } |