CameraModule.java revision c4e665625b88a8363fa2bd9848bf88ec9b45637f
1/* 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; 22import android.view.View; 23 24import com.android.camera.app.AppController; 25import com.android.camera.app.CameraProvider; 26import com.android.camera.app.CameraServices; 27import com.android.camera.app.MediaSaver; 28import com.android.camera.module.ModuleController; 29 30public abstract class CameraModule implements ModuleController { 31 32 /** Provides common services and functionality to the module. */ 33 private final CameraServices mServices; 34 private final CameraProvider mCameraProvider; 35 36 public CameraModule(AppController app) { 37 mServices = app.getServices(); 38 mCameraProvider = app.getCameraProvider(); 39 } 40 41 @Deprecated 42 public abstract void init(CameraActivity activity, View frame); 43 44 @Deprecated 45 public abstract void onPreviewFocusChanged(boolean previewFocused); 46 47 @Deprecated 48 public abstract void onConfigurationChanged(Configuration config); 49 50 @Deprecated 51 public abstract void onStop(); 52 53 @Deprecated 54 public abstract void installIntentFilter(); 55 56 @Deprecated 57 public abstract void onActivityResult(int requestCode, int resultCode, Intent data); 58 59 @Deprecated 60 public abstract boolean onBackPressed(); 61 62 @Deprecated 63 public abstract boolean onKeyDown(int keyCode, KeyEvent event); 64 65 @Deprecated 66 public abstract boolean onKeyUp(int keyCode, KeyEvent event); 67 68 @Deprecated 69 public abstract void onSingleTapUp(View view, int x, int y); 70 71 @Deprecated 72 public abstract void onPreviewTextureCopied(); 73 74 @Deprecated 75 public abstract void onCaptureTextureCopied(); 76 77 @Deprecated 78 public abstract void onUserInteraction(); 79 80 @Deprecated 81 public abstract boolean updateStorageHintOnResume(); 82 83 @Deprecated 84 public abstract void onOrientationChanged(int orientation); 85 86 @Deprecated 87 public abstract void onShowSwitcherPopup(); 88 89 @Deprecated 90 public abstract void onMediaSaverAvailable(MediaSaver s); 91 92 @Deprecated 93 public abstract boolean arePreviewControlsVisible(); 94 95 /** 96 * @return An instance containing common services to be used by the module. 97 */ 98 protected CameraServices getServices() { 99 return mServices; 100 } 101 102 /** 103 * @return An instance used by the module to get the camera. 104 */ 105 protected CameraProvider getCameraProvider() { 106 return mCameraProvider; 107 } 108 109 /** 110 * Requests the back camera through {@link CameraProvider}. 111 * This calls {@link 112 * com.android.camera.app.CameraProvider#requestCamera(int)}. The camera 113 * will be returned through {@link 114 * #onCameraAvailable(com.android.camera.app.CameraManager.CameraProxy)} 115 * when it's available. 116 */ 117 protected void requestBackCamera() { 118 mCameraProvider.requestCamera(mCameraProvider.getFirstBackCameraId()); 119 } 120} 121