Merge "make manual exposure compensation settings work acrss different devices bug: 13967706" into ub-camera-everglades
diff --git a/src/com/android/camera/ButtonManager.java b/src/com/android/camera/ButtonManager.java
index c467f5a..cd48928 100644
--- a/src/com/android/camera/ButtonManager.java
+++ b/src/com/android/camera/ButtonManager.java
@@ -74,6 +74,10 @@
private ImageButton mExposureP1;
private ImageButton mExposureP2;
+ private int mMinExposureCompensation;
+ private int mMaxExposureCompensation;
+ private float mExposureCompensationStep;
+
/** A listener for button enabled and visibility
state changes. */
private ButtonStatusListener mListener;
@@ -486,8 +490,12 @@
case R.id.exposure_p2:
comp = 2;
}
- // Each integer compensation represent 1/6 of a stop.
- cb.setExposure(comp * 6);
+
+ if (mExposureCompensationStep != 0.0f) {
+ int compValue =
+ Math.round(comp / mExposureCompensationStep);
+ cb.setExposure(compValue);
+ }
}
};
@@ -500,6 +508,25 @@
}
/**
+ * Set the exposure compensation parameters supported by the current camera mode.
+ * @param min Minimum exposure compensation value.
+ * @param max Maximum exposure compensation value.
+ * @param step Expsoure compensation step value.
+ */
+ public void setExposureCompensationParameters(int min, int max, float step) {
+ mMaxExposureCompensation = max;
+ mMinExposureCompensation = min;
+ mExposureCompensationStep = step;
+
+ mExposureN2.setEnabled(Math.round(min * step) <= -2);
+ mExposureN1.setEnabled(Math.round(min * step) <= -1);
+ mExposureP1.setEnabled(Math.round(max * step) >= 1);
+ mExposureP1.setEnabled(Math.round(max * step) >= 2);
+
+ updateExposureButtons();
+ }
+
+ /**
* Check if a button is enabled with the given button id..
*/
public boolean isEnabled(int buttonId) {
@@ -670,7 +697,7 @@
*/
public void updateExposureButtons() {
String compString = mSettingsManager.get(SettingsManager.SETTING_EXPOSURE_COMPENSATION_VALUE);
- int comp = Integer.parseInt(compString);
+ int compValue = Integer.parseInt(compString);
// Reset all button states.
mExposureN2.setBackground(null);
@@ -684,22 +711,24 @@
Drawable background = context.getResources()
.getDrawable(R.drawable.button_background_selected_photo);
- // Each integer compensation represent 1/6 of a stop.
- switch (comp / 6) {
- case -2:
- mExposureN2.setBackground(background);
- break;
- case -1:
- mExposureN1.setBackground(background);
- break;
- case 0:
- mExposure0.setBackground(background);
- break;
- case 1:
- mExposureP1.setBackground(background);
- break;
- case 2:
- mExposureP2.setBackground(background);
+ if (mExposureCompensationStep != 0.0f) {
+ int comp = Math.round(compValue * mExposureCompensationStep);
+ switch (comp) {
+ case -2:
+ mExposureN2.setBackground(background);
+ break;
+ case -1:
+ mExposureN1.setBackground(background);
+ break;
+ case 0:
+ mExposure0.setBackground(background);
+ break;
+ case 1:
+ mExposureP1.setBackground(background);
+ break;
+ case 2:
+ mExposureP2.setBackground(background);
+ }
}
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 6f0d1b3..a9399d7 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -558,6 +558,9 @@
setExposureCompensation(value);
}
};
+ bottomBarSpec.minExposureCompensation = mParameters.getMinExposureCompensation();
+ bottomBarSpec.maxExposureCompensation = mParameters.getMaxExposureCompensation();
+ bottomBarSpec.exposureCompensationStep = mParameters.getExposureCompensationStep();
if (isImageCaptureIntent()) {
bottomBarSpec.showCancel = true;
diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java
index 98ed1db..ec089c8 100644
--- a/src/com/android/camera/app/CameraAppUI.java
+++ b/src/com/android/camera/app/CameraAppUI.java
@@ -23,6 +23,7 @@
import android.graphics.Matrix;
import android.graphics.RectF;
import android.graphics.SurfaceTexture;
+import android.hardware.Camera;
import android.hardware.display.DisplayManager;
import android.util.CameraPerformanceTracker;
import android.view.GestureDetector;
@@ -427,9 +428,16 @@
* when an expsosure button is pressed. This callback can be null.
*/
public interface ExposureCompensationSetCallback {
- public abstract void setExposure(int value);
+ public void setExposure(int value);
}
public ExposureCompensationSetCallback exposureCompensationSetCallback;
+
+ /**
+ * Exposure compensation parameters.
+ */
+ public int minExposureCompensation;
+ public int maxExposureCompensation;
+ public float exposureCompensationStep;
}
@@ -1708,6 +1716,11 @@
buttonManager.setExposureCompensationCallback(null);
}
+ buttonManager.setExposureCompensationParameters(
+ bottomBarSpec.minExposureCompensation,
+ bottomBarSpec.maxExposureCompensation,
+ bottomBarSpec.exposureCompensationStep);
+
/** Intent UI */
if (bottomBarSpec.showCancel) {
buttonManager.initializePushButton(ButtonManager.BUTTON_CANCEL,