blob: c427d8d1e00f495bbf993b07c59b979173f8ae1c [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
Angus Kong9f1db522013-11-09 16:25:59 -080019import android.content.res.Configuration;
20
Angus Kong20fad242013-11-11 18:23:46 -080021import com.android.camera.app.CameraManager;
Angus Kongfa274232013-11-06 16:15:06 -080022import com.android.camera.app.AppController;
Angus Kong20fad242013-11-11 18:23:46 -080023import com.android.camera.app.MediaSaver;
Angus Kongfa274232013-11-06 16:15:06 -080024
25/**
26 * The controller at app level.
27 */
28public interface ModuleController {
Angus Kong9f1db522013-11-09 16:25:59 -080029
30 /********************** Life cycle management **********************/
Angus Kongfa274232013-11-06 16:15:06 -080031
32 /**
33 * Initializes the module.
Angus Kongc02b13a2013-11-12 11:50:57 -080034 *
Angus Kong51ae7a82013-11-08 14:36:45 -080035 * @param app The app which initializes this module.
Angus Kongc02b13a2013-11-12 11:50:57 -080036 * @param isSecureCamera Whether the app is in secure camera mode.
37 * @param isCaptureIntent Whether the app is in capture intent mode.
Angus Kongfa274232013-11-06 16:15:06 -080038 */
Angus Kong62848152013-11-08 17:25:29 -080039 public void init(AppController app, boolean isSecureCamera, boolean isCaptureIntent);
Angus Kongfa274232013-11-06 16:15:06 -080040
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 Kong20fad242013-11-11 18:23:46 -080057 public void destroy();
Angus Kong51ae7a82013-11-08 14:36:45 -080058
Angus Kong9f1db522013-11-09 16:25:59 -080059 /********************** UI / Camera preview **********************/
60
Angus Kong51ae7a82013-11-08 14:36:45 -080061 /**
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 Kong9f1db522013-11-09 16:25:59 -080070 * 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 Kong13e87c42013-11-25 10:02:47 -080083 /**
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 Kong9f1db522013-11-09 16:25:59 -080090 /********************** App-level resources **********************/
91
92 /**
Angus Kong51ae7a82013-11-08 14:36:45 -080093 * Called by the app when the camera is available. The module should use
94 * {@link com.android.camera.app.AppController#}
Angus Kong20fad242013-11-11 18:23:46 -080095 *
96 * @param cameraProxy The camera device proxy.
Angus Kong51ae7a82013-11-08 14:36:45 -080097 */
Angus Kong20fad242013-11-11 18:23:46 -080098 public void onCameraAvailable(CameraManager.CameraProxy cameraProxy);
Angus Kong51ae7a82013-11-08 14:36:45 -080099
100 /**
101 * Called by the app when the {@link com.android.camera.app.MediaSaver} is
102 * available.
Angus Kong20fad242013-11-11 18:23:46 -0800103 *
104 * @param mediaSaver The {@link com.android.camera.app.MediaSaver} to use.
Angus Kong51ae7a82013-11-08 14:36:45 -0800105 */
Angus Kong20fad242013-11-11 18:23:46 -0800106 public void onMediaSaverAvailable(MediaSaver mediaSaver);
Angus Kongfa274232013-11-06 16:15:06 -0800107}