1/* 2 * Copyright (C) 2015 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.one; 18 19import com.android.camera.async.Observable; 20import com.android.camera.async.Observables; 21import com.android.camera.device.CameraId; 22import com.android.camera.hardware.HardwareSpec; 23import com.android.camera.one.OneCamera.Facing; 24import com.android.camera.settings.Keys; 25import com.android.camera.settings.ResolutionSetting; 26import com.android.camera.settings.SettingObserver; 27import com.android.camera.settings.SettingsManager; 28import com.android.camera.util.Size; 29import com.google.common.base.Function; 30 31/** 32 * Contains related settings to configure a camera for a particular type of 33 * capture. 34 */ 35public class OneCameraCaptureSetting { 36 private final Size mCaptureSize; 37 private final Observable<OneCamera.PhotoCaptureParameters.Flash> mFlashSetting; 38 private final Observable<Integer> mExposureSetting; 39 private final Observable<Boolean> mHdrSceneSetting; 40 private final boolean mIsHdrPlusEnabled; 41 42 public static OneCameraCaptureSetting create( 43 Size pictureSize, 44 SettingsManager settingsManager, 45 final HardwareSpec hardwareSpec, 46 String cameraSettingScope, 47 boolean isHdrPlusEnabled) { 48 Observable<OneCamera.PhotoCaptureParameters.Flash> flashSetting = new FlashSetting( 49 SettingObserver.ofString(settingsManager, cameraSettingScope, Keys.KEY_FLASH_MODE)); 50 Observable<Integer> exposureSetting = SettingObserver.ofInteger( 51 settingsManager, cameraSettingScope, Keys.KEY_EXPOSURE); 52 Observable<Boolean> hdrSceneSetting; 53 if (hardwareSpec.isHdrSupported()) { 54 hdrSceneSetting = SettingObserver.ofBoolean(settingsManager, 55 SettingsManager.SCOPE_GLOBAL, Keys.KEY_CAMERA_HDR); 56 } else { 57 hdrSceneSetting = Observables.of(false); 58 } 59 return new OneCameraCaptureSetting( 60 pictureSize, 61 flashSetting, 62 exposureSetting, 63 hdrSceneSetting, 64 isHdrPlusEnabled); 65 } 66 67 private OneCameraCaptureSetting( 68 Size captureSize, 69 Observable<OneCamera.PhotoCaptureParameters.Flash> flashSetting, 70 Observable<Integer> exposureSetting, 71 Observable<Boolean> hdrSceneSetting, 72 boolean isHdrPlusEnabled) { 73 mCaptureSize = captureSize; 74 mFlashSetting = flashSetting; 75 mExposureSetting = exposureSetting; 76 mHdrSceneSetting = hdrSceneSetting; 77 mIsHdrPlusEnabled = isHdrPlusEnabled; 78 } 79 80 public Size getCaptureSize() { 81 return mCaptureSize; 82 } 83 84 public Observable<OneCamera.PhotoCaptureParameters.Flash> getFlashSetting() { 85 return mFlashSetting; 86 } 87 88 public Observable<Integer> getExposureSetting() { 89 return mExposureSetting; 90 } 91 92 public Observable<Boolean> getHdrSceneSetting() { 93 return mHdrSceneSetting; 94 } 95 96 public boolean isHdrPlusEnabled() { 97 return mIsHdrPlusEnabled; 98 } 99} 100