OSDN Git Service

Merge "Fix for N4 Video Rotation Bug" into ub-camera-haleakala
[android-x86/packages-apps-Camera2.git] / src / com / android / camera / app / CameraAppUI.java
index 65b6381..3a7dac6 100644 (file)
@@ -352,8 +352,20 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
          */
         public boolean enablePanoOrientation;
 
+        /**
+         * Set true if manual exposure compensation should be visible.
+         *
+         * This option is not constrained by hardware limitations.
+         * For example, this is false in HDR+ mode.
+         */
         public boolean enableExposureCompensation;
 
+        /**
+         * Set true if the device and module support exposure compensation.
+         * Used only to show exposure button in disabled (greyed out) state.
+         */
+        public boolean isExposureCompensationSupported;
+
         /** Intent UI */
 
         /**
@@ -1214,7 +1226,13 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
     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();
@@ -1249,7 +1267,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         mModuleUI = (FrameLayout) mCameraRootView.findViewById(R.id.module_layout);
         mTextureView = (TextureView) mCameraRootView.findViewById(R.id.preview_content);
         mTextureViewHelper = new TextureViewHelper(mTextureView, mCaptureLayoutHelper,
-                mController.getCameraProvider());
+                mController.getCameraProvider(), mController);
         mTextureViewHelper.setSurfaceTextureListener(this);
         mTextureViewHelper.setOnLayoutChangeListener(mPreviewLayoutChangeListener);
 
@@ -1545,8 +1563,7 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         if (mSuppressCaptureIndicator || mFilmstripLayout.getVisibility() == View.VISIBLE) {
             return;
         }
-        mRoundedThumbnailView.setThumbnail(thumbnailBitmap);
-        mRoundedThumbnailView.setRotation(rotation);
+        mRoundedThumbnailView.setThumbnail(thumbnailBitmap, rotation);
     }
 
     /**
@@ -1873,7 +1890,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         applyModuleSpecs(moduleController.getHardwareSpec(),
             moduleController.getBottomBarSpec());
         mBottomBar.transitionToCapture();
-        showModeOptions();
     }
 
     /**
@@ -1884,7 +1900,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
         applyModuleSpecs(moduleController.getHardwareSpec(),
                 moduleController.getBottomBarSpec());
         mBottomBar.transitionToCancel();
-        hideModeOptions();
     }
 
     /**
@@ -1962,29 +1977,22 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
             buttonManager.hideButton(ButtonManager.BUTTON_CAMERA);
         }
 
-        if (bottomBarSpec.hideFlash) {
+        if (bottomBarSpec.hideFlash || !hardwareSpec.isFlashSupported()) {
             // Hide both flash and torch button in flash disable logic
             buttonManager.hideButton(ButtonManager.BUTTON_FLASH);
             buttonManager.hideButton(ButtonManager.BUTTON_TORCH);
         } else {
-            if (hardwareSpec.isFlashSupported()) {
-                if (bottomBarSpec.enableFlash) {
-                    buttonManager.initializeButton(ButtonManager.BUTTON_FLASH,
-                        bottomBarSpec.flashCallback);
-                } else if (bottomBarSpec.enableTorchFlash) {
-                    buttonManager.initializeButton(ButtonManager.BUTTON_TORCH,
-                        bottomBarSpec.flashCallback);
-                } else if (bottomBarSpec.enableHdrPlusFlash) {
-                    buttonManager.initializeButton(ButtonManager.BUTTON_HDR_PLUS_FLASH,
-                        bottomBarSpec.flashCallback);
-                } else {
-                    // Hide both flash and torch button in flash disable logic
-                    buttonManager.disableButton(ButtonManager.BUTTON_FLASH);
-                    buttonManager.disableButton(ButtonManager.BUTTON_TORCH);
-                }
+            if (bottomBarSpec.enableFlash) {
+                buttonManager.initializeButton(ButtonManager.BUTTON_FLASH,
+                    bottomBarSpec.flashCallback);
+            } else if (bottomBarSpec.enableTorchFlash) {
+                buttonManager.initializeButton(ButtonManager.BUTTON_TORCH,
+                    bottomBarSpec.flashCallback);
+            } else if (bottomBarSpec.enableHdrPlusFlash) {
+                buttonManager.initializeButton(ButtonManager.BUTTON_HDR_PLUS_FLASH,
+                    bottomBarSpec.flashCallback);
             } else {
-                // Disable both flash and torch icon if not supported
-                // by the chosen camera hardware.
+                // Disable both flash and torch button in flash disable logic
                 buttonManager.disableButton(ButtonManager.BUTTON_FLASH);
                 buttonManager.disableButton(ButtonManager.BUTTON_TORCH);
             }
@@ -1995,16 +2003,14 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
             buttonManager.hideButton(ButtonManager.BUTTON_HDR_PLUS);
         } else {
             if (hardwareSpec.isHdrPlusSupported()) {
-                if (bottomBarSpec.enableHdr && Keys.isCameraBackFacing(settingsManager,
-                                                                       mController.getModuleScope())) {
+                if (bottomBarSpec.enableHdr) {
                     buttonManager.initializeButton(ButtonManager.BUTTON_HDR_PLUS,
                             bottomBarSpec.hdrCallback);
                 } else {
                     buttonManager.disableButton(ButtonManager.BUTTON_HDR_PLUS);
                 }
             } else if (hardwareSpec.isHdrSupported()) {
-                if (bottomBarSpec.enableHdr && Keys.isCameraBackFacing(settingsManager,
-                                                                       mController.getModuleScope())) {
+                if (bottomBarSpec.enableHdr) {
                     buttonManager.initializeButton(ButtonManager.BUTTON_HDR,
                             bottomBarSpec.hdrCallback);
                 } else {
@@ -2047,26 +2053,37 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
             buttonManager.initializePanoOrientationButtons(bottomBarSpec.panoOrientationCallback);
         }
 
-        boolean enableExposureCompensation = bottomBarSpec.enableExposureCompensation &&
-            !(bottomBarSpec.minExposureCompensation == 0 && bottomBarSpec.maxExposureCompensation == 0) &&
-            mController.getSettingsManager().getBoolean(SettingsManager.SCOPE_GLOBAL,
-                        Keys.KEY_EXPOSURE_COMPENSATION_ENABLED);
-        if (enableExposureCompensation) {
+
+
+        // If manual exposure is enabled both in SettingsManager and
+        // BottomBarSpec,then show the exposure button.
+        // If manual exposure is disabled in the BottomBarSpec (eg. HDR+
+        // enabled), but the device/module has the feature, then disable the exposure
+        // button.
+        // Otherwise, hide the button.
+        if (bottomBarSpec.enableExposureCompensation
+                && !(bottomBarSpec.minExposureCompensation == 0 && bottomBarSpec.maxExposureCompensation == 0)
+                && mController.getSettingsManager().getBoolean(SettingsManager.SCOPE_GLOBAL,
+                        Keys.KEY_EXPOSURE_COMPENSATION_ENABLED)) {
             buttonManager.initializePushButton(ButtonManager.BUTTON_EXPOSURE_COMPENSATION,
                     new View.OnClickListener() {
-                @Override
-                public void onClick(View v) {
-                    mModeOptionsOverlay.showExposureOptions();
-                }
-            });
+                        @Override
+                        public void onClick(View v) {
+                            mModeOptionsOverlay.showExposureOptions();
+                        }
+                    });
             buttonManager.setExposureCompensationParameters(
-                bottomBarSpec.minExposureCompensation,
-                bottomBarSpec.maxExposureCompensation,
-                bottomBarSpec.exposureCompensationStep);
+                    bottomBarSpec.minExposureCompensation,
+                    bottomBarSpec.maxExposureCompensation,
+                    bottomBarSpec.exposureCompensationStep);
 
             buttonManager.setExposureCompensationCallback(
                     bottomBarSpec.exposureCompensationSetCallback);
             buttonManager.updateExposureButtons();
+        } else if (mController.getSettingsManager().getBoolean(SettingsManager.SCOPE_GLOBAL,
+                Keys.KEY_EXPOSURE_COMPENSATION_ENABLED)
+                && bottomBarSpec.isExposureCompensationSupported) {
+            buttonManager.disableButton(ButtonManager.BUTTON_EXPOSURE_COMPENSATION);
         } else {
             buttonManager.hideButton(ButtonManager.BUTTON_EXPOSURE_COMPENSATION);
             buttonManager.setExposureCompensationCallback(null);
@@ -2112,4 +2129,8 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
     public void hideFilmstrip() {
         mFilmstripLayout.hideFilmstrip();
     }
+
+    public int getFilmstripVisibility() {
+        return mFilmstripLayout.getVisibility();
+    }
 }