public void onChangeCamera() {
ModuleController moduleController = mController.getCurrentModuleController();
applyModuleSpecs(moduleController.getHardwareSpec(), moduleController.getBottomBarSpec());
+ syncModeOptionIndicators();
+ }
+ /**
+ * Updates the mode option indicators according to the current settings.
+ */
+ public void syncModeOptionIndicators() {
if (mIndicatorIconController != null) {
// Sync the settings state with the indicator state.
mIndicatorIconController.syncIndicators();
import android.view.MotionEvent;
import android.view.View;
-import com.android.camera.ButtonManager;
import com.android.camera.CameraActivity;
import com.android.camera.CameraModule;
-import com.android.camera.FatalErrorHandler;
import com.android.camera.app.AppController;
import com.android.camera.app.CameraAppUI;
import com.android.camera.async.MainThread;
import com.android.camera.captureintent.stateful.StateMachineImpl;
import com.android.camera.debug.Log;
import com.android.camera.hardware.HardwareSpec;
-import com.android.camera.one.OneCamera;
-import com.android.camera.one.OneCameraAccessException;
-import com.android.camera.one.OneCameraCharacteristics;
-import com.android.camera.settings.CameraFacingSetting;
import com.android.camera.settings.SettingsManager;
-import com.android.camera.stats.UsageStatistics;
import com.android.camera.ui.PreviewStatusListener;
import com.android.camera.ui.TouchCoordinate;
import com.android.camera.util.Size;
import com.android.camera2.R;
import com.android.ex.camera2.portability.CameraAgent;
-import com.google.common.logging.eventprotos;
/**
* The camera module that handles image capture intent.
public void resume() {
mModuleUI.onModuleResumed();
mResourceConstructed.get().getAppController().addPreviewAreaSizeChangedListener(mModuleUI);
- mResourceConstructed.get().getAppController().getCameraAppUI().onChangeCamera();
mStateMachine.processEvent(new EventResume());
}
@Override
public HardwareSpec getHardwareSpec() {
- final CameraFacingSetting cameraFacingSetting =
- mResourceConstructed.get().getCameraFacingSetting();
- final OneCameraCharacteristics characteristics;
- try {
- characteristics = mResourceConstructed.get().getCameraManager()
- .getCameraCharacteristics(cameraFacingSetting.getCameraFacing());
- } catch (OneCameraAccessException ocae) {
- mResourceConstructed.get().getFatalErrorHandler().onGenericCameraAccessFailure();
- return null;
- }
-
- return new HardwareSpec() {
- @Override
- public boolean isFrontCameraSupported() {
- return mResourceConstructed.get().getCameraManager()
- .hasCameraFacing(OneCamera.Facing.FRONT);
- }
-
- @Override
- public boolean isHdrSupported() {
- return false;
- }
-
- @Override
- public boolean isHdrPlusSupported() {
- return false;
- }
-
- @Override
- public boolean isFlashSupported() {
- return characteristics.isFlashSupported();
- }
- };
+ /**
+ * Instead of passively providing CameraAppUI the hardware spec here,
+ * {@link com.android.camera.captureintent.state.StateOpeningCamera}
+ * will actively specify hardware spec.
+ */
+ return null;
}
@Override
public CameraAppUI.BottomBarUISpec getBottomBarSpec() {
- CameraAppUI.BottomBarUISpec bottomBarSpec = new CameraAppUI.BottomBarUISpec();
- /** Camera switch button UI spec. */
- bottomBarSpec.enableCamera = true;
- bottomBarSpec.cameraCallback = new ButtonManager.ButtonCallback() {
- @Override
- public void onStateChanged(int cameraId) {
- mStateMachine.processEvent(new EventTapOnSwitchCameraButton());
- }
- };
- /** Grid lines button UI spec. */
- bottomBarSpec.enableGridLines = true;
- /** HDR button UI spec. */
- bottomBarSpec.enableHdr = false;
- bottomBarSpec.hideHdr = true;
- bottomBarSpec.hdrCallback = null;
- /** Timer button UI spec. */
- bottomBarSpec.enableSelfTimer = true;
- bottomBarSpec.showSelfTimer = true;
- /** Flash button UI spec. */
- bottomBarSpec.enableFlash = true;
- bottomBarSpec.hideFlash = false;
-
- /** Intent image review UI spec. */
- bottomBarSpec.showCancel = true;
- bottomBarSpec.cancelCallback = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mStateMachine.processEvent(new EventTapOnCancelIntentButton());
- }
- };
- bottomBarSpec.showDone = true;
- bottomBarSpec.doneCallback = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mStateMachine.processEvent(new EventTapOnConfirmPhotoButton());
- }
- };
- bottomBarSpec.showRetake = true;
- bottomBarSpec.retakeCallback = new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mStateMachine.processEvent(new EventTapOnRetakePhotoButton());
- }
- };
- return bottomBarSpec;
+ /**
+ * Instead of passively providing CameraAppUI the bottom bar spec here,
+ * {@link com.android.camera.captureintent.state.StateOpeningCamera}
+ * will actively specify bottom bar spec.
+ */
+ return null;
}
@Override
import com.android.camera.app.CameraAppUI;
import com.android.camera.async.MainThread;
+import com.android.camera.hardware.HardwareSpec;
import com.android.camera.ui.CountDownView;
import com.android.camera.ui.PreviewOverlay;
import com.android.camera.ui.PreviewStatusListener;
}
/**
+ * Configures the bottom bar UI.
+ *
+ * @param hardwareSpec The hardware spec.
+ * @param bottomBarSpec The bottom bar spec.
+ */
+ public void applyModuleSpecs(
+ HardwareSpec hardwareSpec,
+ CameraAppUI.BottomBarUISpec bottomBarSpec) {
+ MainThread.checkMainThread();
+ mAppUI.applyModuleSpecs(hardwareSpec, bottomBarSpec);
+ }
+
+ /**
* Called when the module got resumed.
*/
public void onModuleResumed() {
mIntentReviewImageView.setImageBitmap(null);
mAppUI.transitionToIntentCaptureLayout();
- mAppUI.showModeOptions();
+ mAppUI.syncModeOptionIndicators();
mAppUI.enableModeOptions();
+ mAppUI.showModeOptions();
mAppUI.setShutterButtonEnabled(true);
mAppUI.setShouldSuppressCaptureIndicator(true);
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
+import com.android.camera.ButtonManager;
+import com.android.camera.app.CameraAppUI;
import com.android.camera.async.RefCountBase;
+import com.android.camera.captureintent.event.EventTapOnCancelIntentButton;
+import com.android.camera.captureintent.event.EventTapOnConfirmPhotoButton;
+import com.android.camera.captureintent.event.EventTapOnRetakePhotoButton;
+import com.android.camera.captureintent.event.EventTapOnSwitchCameraButton;
import com.android.camera.captureintent.resource.ResourceConstructed;
import com.android.camera.captureintent.resource.ResourceSurfaceTexture;
import com.android.camera.captureintent.stateful.EventHandler;
import com.android.camera.captureintent.stateful.State;
import com.android.camera.captureintent.stateful.StateImpl;
import com.android.camera.debug.Log;
+import com.android.camera.hardware.HardwareSpec;
import com.android.camera.one.OneCamera;
import com.android.camera.one.OneCameraAccessException;
import com.android.camera.one.OneCameraCaptureSetting;
import com.android.camera.one.v2.photo.ImageRotationCalculatorImpl;
import com.android.camera.util.Size;
+import android.view.View;
+
/**
* Represents a state that the module is waiting for a camera to be opened.
*/
mResourceConstructed,
mResourceSurfaceTexture));
}
+
+ mResourceConstructed.get().getMainThread().execute(new Runnable() {
+ @Override
+ public void run() {
+ mResourceConstructed.get().getModuleUI().applyModuleSpecs(
+ getHardwareSpec(), getBottomBarSpec());
+ }
+ });
+
return Optional.of((State) StateStartingPreview.from(
StateOpeningCamera.this,
mResourceConstructed,
public boolean isPaused() {
return mIsPaused;
}
+
+ private HardwareSpec getHardwareSpec() {
+ return new HardwareSpec() {
+ @Override
+ public boolean isFrontCameraSupported() {
+ return mResourceConstructed.get().getCameraManager()
+ .hasCameraFacing(OneCamera.Facing.FRONT);
+ }
+
+ @Override
+ public boolean isHdrSupported() {
+ return false;
+ }
+
+ @Override
+ public boolean isHdrPlusSupported() {
+ return false;
+ }
+
+ @Override
+ public boolean isFlashSupported() {
+ return mCameraCharacteristics.isFlashSupported();
+ }
+ };
+ }
+
+ private CameraAppUI.BottomBarUISpec getBottomBarSpec() {
+ CameraAppUI.BottomBarUISpec bottomBarSpec = new CameraAppUI.BottomBarUISpec();
+ /** Camera switch button UI spec. */
+ bottomBarSpec.enableCamera = true;
+ bottomBarSpec.cameraCallback = new ButtonManager.ButtonCallback() {
+ @Override
+ public void onStateChanged(int cameraId) {
+ getStateMachine().processEvent(new EventTapOnSwitchCameraButton());
+ }
+ };
+ /** Grid lines button UI spec. */
+ bottomBarSpec.enableGridLines = true;
+ /** HDR button UI spec. */
+ bottomBarSpec.enableHdr = false;
+ bottomBarSpec.hideHdr = true;
+ bottomBarSpec.hdrCallback = null;
+ /** Timer button UI spec. */
+ bottomBarSpec.enableSelfTimer = true;
+ bottomBarSpec.showSelfTimer = true;
+ /** Flash button UI spec. */
+ bottomBarSpec.enableFlash = mCameraCharacteristics.isFlashSupported();
+
+ /** Intent image review UI spec. */
+ bottomBarSpec.showCancel = true;
+ bottomBarSpec.cancelCallback = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getStateMachine().processEvent(new EventTapOnCancelIntentButton());
+ }
+ };
+ bottomBarSpec.showDone = true;
+ bottomBarSpec.doneCallback = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getStateMachine().processEvent(new EventTapOnConfirmPhotoButton());
+ }
+ };
+ bottomBarSpec.showRetake = true;
+ bottomBarSpec.retakeCallback = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ getStateMachine().processEvent(new EventTapOnRetakePhotoButton());
+ }
+ };
+ return bottomBarSpec;
+ }
}