blob: f89c997c9a3d4b22d57124de4596145c3948cebc [file] [log] [blame]
Michael Kolb8872c232013-01-29 10:33:22 -08001/*
2 * Copyright (C) 2012 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;
18
19import android.content.Intent;
20import android.content.res.Configuration;
21import android.view.KeyEvent;
Michael Kolb8872c232013-01-29 10:33:22 -080022import android.view.View;
23
Angus Kongc4e66562013-11-22 23:03:21 -080024import com.android.camera.app.AppController;
25import com.android.camera.app.CameraProvider;
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080026import com.android.camera.app.CameraServices;
Angus Kongfd4fc0e2013-11-07 15:38:09 -080027import com.android.camera.app.MediaSaver;
Angus Kongc4e66562013-11-22 23:03:21 -080028import com.android.camera.module.ModuleController;
Angus Kongfd4fc0e2013-11-07 15:38:09 -080029
Angus Kongc4e66562013-11-22 23:03:21 -080030public abstract class CameraModule implements ModuleController {
Michael Kolb8872c232013-01-29 10:33:22 -080031
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080032 /** Provides common services and functionality to the module. */
33 private final CameraServices mServices;
Angus Kongc4e66562013-11-22 23:03:21 -080034 private final CameraProvider mCameraProvider;
Michael Kolb8872c232013-01-29 10:33:22 -080035
Angus Kongc4e66562013-11-22 23:03:21 -080036 public CameraModule(AppController app) {
37 mServices = app.getServices();
38 mCameraProvider = app.getCameraProvider();
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080039 }
Michael Kolb8872c232013-01-29 10:33:22 -080040
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080041 @Deprecated
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080042 public abstract void onPreviewFocusChanged(boolean previewFocused);
Michael Kolb8872c232013-01-29 10:33:22 -080043
Angus Kong13e87c42013-11-25 10:02:47 -080044 @Override
45 public boolean onBackPressed() {
46 return false;
47 }
Michael Kolb8872c232013-01-29 10:33:22 -080048
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080049 @Deprecated
50 public abstract boolean onKeyDown(int keyCode, KeyEvent event);
Michael Kolb8872c232013-01-29 10:33:22 -080051
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080052 @Deprecated
53 public abstract boolean onKeyUp(int keyCode, KeyEvent event);
Michael Kolb8872c232013-01-29 10:33:22 -080054
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080055 @Deprecated
56 public abstract void onSingleTapUp(View view, int x, int y);
Michael Kolb8872c232013-01-29 10:33:22 -080057
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080058 @Deprecated
Sascha Haeberling280fd3e2013-11-21 13:52:15 -080059 public abstract void onMediaSaverAvailable(MediaSaver s);
60
61 @Deprecated
62 public abstract boolean arePreviewControlsVisible();
63
64 /**
65 * @return An instance containing common services to be used by the module.
66 */
67 protected CameraServices getServices() {
68 return mServices;
69 }
Angus Kongc4e66562013-11-22 23:03:21 -080070
71 /**
72 * @return An instance used by the module to get the camera.
73 */
74 protected CameraProvider getCameraProvider() {
75 return mCameraProvider;
76 }
77
78 /**
79 * Requests the back camera through {@link CameraProvider}.
80 * This calls {@link
81 * com.android.camera.app.CameraProvider#requestCamera(int)}. The camera
82 * will be returned through {@link
83 * #onCameraAvailable(com.android.camera.app.CameraManager.CameraProxy)}
84 * when it's available.
85 */
86 protected void requestBackCamera() {
87 mCameraProvider.requestCamera(mCameraProvider.getFirstBackCameraId());
88 }
Michael Kolb8872c232013-01-29 10:33:22 -080089}