blob: 36fe05d6f4a23cc6a36db468642ee13cc2e2368b [file] [log] [blame]
Angus Kongfa274232013-11-06 16:15:06 -08001/*
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
Sascha Haeberling846d3ab2014-02-04 12:48:55 +010019import com.android.camera.CameraActivity;
Erin Dahlgrenb1641f52014-01-14 15:58:52 -080020import com.android.camera.app.CameraAppUI.BottomBarUISpec;
Sascha Haeberlinga63dbb62013-11-22 11:55:32 -080021import com.android.camera.app.CameraManager;
Erin Dahlgrenb1641f52014-01-14 15:58:52 -080022import com.android.camera.hardware.HardwareSpec;
Angus Kongfa274232013-11-06 16:15:06 -080023
24/**
25 * The controller at app level.
26 */
27public interface ModuleController {
Angus Kong9f1db522013-11-09 16:25:59 -080028
29 /********************** Life cycle management **********************/
Angus Kongfa274232013-11-06 16:15:06 -080030
31 /**
32 * Initializes the module.
Angus Kongc02b13a2013-11-12 11:50:57 -080033 *
Sascha Haeberling846d3ab2014-02-04 12:48:55 +010034 * @param activity The camera activity.
Angus Kongc02b13a2013-11-12 11:50:57 -080035 * @param isSecureCamera Whether the app is in secure camera mode.
36 * @param isCaptureIntent Whether the app is in capture intent mode.
Angus Kongfa274232013-11-06 16:15:06 -080037 */
Sascha Haeberling846d3ab2014-02-04 12:48:55 +010038 public void init(CameraActivity activity, boolean isSecureCamera, boolean isCaptureIntent);
Angus Kongfa274232013-11-06 16:15:06 -080039
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 Kong20fad242013-11-11 18:23:46 -080056 public void destroy();
Angus Kong51ae7a82013-11-08 14:36:45 -080057
Angus Kong9f1db522013-11-09 16:25:59 -080058 /********************** UI / Camera preview **********************/
59
Angus Kong51ae7a82013-11-08 14:36:45 -080060 /**
Angus Kongfaaee012013-12-07 00:38:46 -080061 * 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 Kong51ae7a82013-11-08 14:36:45 -080068 * 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 Kong53ae0412013-12-01 23:21:49 -080076 * Called when the framework layout orientation changed.
77 *
Angus Kong2f0e4a32013-12-03 10:02:35 -080078 * @param isLandscape Whether the new orientation is landscape or portrait.
Angus Kong9f1db522013-11-09 16:25:59 -080079 */
Angus Kong2f0e4a32013-12-03 10:02:35 -080080 public void onLayoutOrientationChanged(boolean isLandscape);
Angus Kong9f1db522013-11-09 16:25:59 -080081
82 /**
83 * Called when the UI orientation is changed.
84 *
Angus Kong2f0e4a32013-12-03 10:02:35 -080085 * @param orientation The new orientation, valid values are 0, 90, 180 and
86 * 270.
Angus Kong9f1db522013-11-09 16:25:59 -080087 */
88 public void onOrientationChanged(int orientation);
89
Angus Kong13e87c42013-11-25 10:02:47 -080090 /**
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 Kong9f1db522013-11-09 16:25:59 -080097 /********************** App-level resources **********************/
98
99 /**
Angus Kong51ae7a82013-11-08 14:36:45 -0800100 * Called by the app when the camera is available. The module should use
101 * {@link com.android.camera.app.AppController#}
Angus Kong20fad242013-11-11 18:23:46 -0800102 *
103 * @param cameraProxy The camera device proxy.
Angus Kong51ae7a82013-11-08 14:36:45 -0800104 */
Angus Kong20fad242013-11-11 18:23:46 -0800105 public void onCameraAvailable(CameraManager.CameraProxy cameraProxy);
Erin Dahlgren4efa8b52013-12-17 18:31:35 -0800106
107 /**
Erin Dahlgrenb1641f52014-01-14 15:58:52 -0800108 * Returns a {@link com.android.camera.hardware.HardwareSpec}
109 * based on the module's open camera device.
Erin Dahlgren0a6a8d82014-01-09 22:17:38 -0800110 */
Erin Dahlgrenb1641f52014-01-14 15:58:52 -0800111 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 Dahlgren0a6a8d82014-01-09 22:17:38 -0800120
121 /**
Erin Dahlgren4efa8b52013-12-17 18:31:35 -0800122 * 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 Kongfa274232013-11-06 16:15:06 -0800128}