diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 47 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 18 |
2 files changed, 64 insertions, 1 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index eeb8984..cb29a52 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -74,6 +74,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; +import java.util.StringTokenizer; /** * Activity of the Camera which used to see preview and take pictures. @@ -114,6 +115,7 @@ public class Camera extends Activity implements View.OnClickListener, // The parameter strings to communicate with camera driver. public static final String PARM_WHITE_BALANCE = "whitebalance"; public static final String PARM_EFFECT = "effect"; + public static final String PARM_BRIGHTNESS = "exposure-offset"; public static final String PARM_PICTURE_SIZE = "picture-size"; public static final String PARM_JPEG_QUALITY = "jpeg-quality"; public static final String PARM_ROTATION = "rotation"; @@ -123,6 +125,7 @@ public class Camera extends Activity implements View.OnClickListener, public static final String PARM_GPS_TIMESTAMP = "gps-timestamp"; public static final String SUPPORTED_WHITE_BALANCE = "whitebalance-values"; public static final String SUPPORTED_EFFECT = "effect-values"; + public static final String SUPPORTED_BRIGHTNESS = "exposure-offset-values"; public static final String SUPPORTED_PICTURE_SIZE = "picture-size-values"; private OrientationEventListener mOrientationListener; @@ -144,6 +147,10 @@ public class Camera extends Activity implements View.OnClickListener, private int mViewFinderWidth, mViewFinderHeight; private boolean mPreviewing = false; + private int mCurrentBrightness = 5; + private int mMaxBrightness = 10; + private int mMinBrightness = 0; + private Capturer mCaptureObject; private ImageCapture mImageCapture = null; @@ -1019,6 +1026,28 @@ public class Camera extends Activity implements View.OnClickListener, getString(R.string.pref_camera_focusmode_default)); mGpsIndicator.setVisibility(View.INVISIBLE); + String brightness = mPreferences.getString( + CameraSettings.KEY_BRIGHTNESS, + getString(R.string.pref_camera_brightness_default)); + String supportedParamStr = mParameters.get(SUPPORTED_BRIGHTNESS); + StringTokenizer tokenizer = new StringTokenizer(supportedParamStr, ","); + ArrayList brightnessList = new ArrayList(); + while (tokenizer.hasMoreElements()) { + brightnessList.add(tokenizer.nextElement()); + } + try { + if (brightnessList.size() > 0) { + mMaxBrightness = Integer.parseInt( + (String)brightnessList.get(brightnessList.size()-1)); + mMinBrightness = Integer.parseInt( + (String)brightnessList.get(0)); + } + mCurrentBrightness = Integer.parseInt(brightness); + } + catch (NumberFormatException ex) { + // Simply use the default value and ignore settings in mParameters. + } + // install an intent filter to receive SD card related events. IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED); @@ -1166,6 +1195,23 @@ public class Camera extends Activity implements View.OnClickListener, getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); switch (keyCode) { + // TODO: change the following two handlers to OSD control. + case KeyEvent.KEYCODE_DPAD_LEFT: + if (mCurrentBrightness > mMinBrightness) { + mParameters.set(PARM_BRIGHTNESS, --mCurrentBrightness); + mCameraDevice.setParameters(mParameters); + Log.v(TAG, "--brightness=" + mCurrentBrightness); + } + break; + + case KeyEvent.KEYCODE_DPAD_RIGHT: + if (mCurrentBrightness < mMaxBrightness) { + mParameters.set(PARM_BRIGHTNESS, ++mCurrentBrightness); + mCameraDevice.setParameters(mParameters); + Log.v(TAG, "++brightness=" + mCurrentBrightness); + } + break; + case KeyEvent.KEYCODE_BACK: if (mStatus == SNAPSHOT_IN_PROGRESS) { // ignore backs while we're taking a picture @@ -1379,6 +1425,7 @@ public class Camera extends Activity implements View.OnClickListener, } setCameraParameter(); + final long wallTimeStart = SystemClock.elapsedRealtime(); final long threadTimeStart = Debug.threadCpuTimeNanos(); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index d75eae5..84f832f 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -36,6 +36,7 @@ public class CameraSettings extends PreferenceActivity implements public static final String KEY_WHITE_BALANCE = "pref_camera_whitebalance_key"; public static final String KEY_EFFECT = "pref_camera_effect_key"; + public static final String KEY_BRIGHTNESS = "pref_camera_brightness_key"; public static final String KEY_PICTURE_SIZE = "pref_camera_picturesize_key"; public static final String KEY_JPEG_QUALITY = "pref_camera_jpegquality_key"; public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key"; @@ -44,6 +45,7 @@ public class CameraSettings extends PreferenceActivity implements private ListPreference mVideoQuality; private ListPreference mWhiteBalance; private ListPreference mEffect; + private ListPreference mBrightness; private ListPreference mPictureSize; private ListPreference mJpegQuality; private ListPreference mFocusMode; @@ -64,6 +66,7 @@ public class CameraSettings extends PreferenceActivity implements updateVideoQualitySummary(); updateWhiteBalanceSummary(); updateEffectSummary(); + updateBrightSummary(); updatePictureSizeSummary(); updateJpegQualitySummary(); updateFocusModeSummary(); @@ -73,6 +76,8 @@ public class CameraSettings extends PreferenceActivity implements mVideoQuality = (ListPreference) findPreference(KEY_VIDEO_QUALITY); mWhiteBalance = (ListPreference) findPreference(KEY_WHITE_BALANCE); mEffect = (ListPreference) findPreference(KEY_EFFECT); + mBrightness = (ListPreference) findPreference(KEY_BRIGHTNESS); + mPictureSize = (ListPreference) findPreference(KEY_PICTURE_SIZE); mJpegQuality = (ListPreference) findPreference(KEY_JPEG_QUALITY); mFocusMode = (ListPreference) findPreference(KEY_FOCUS_MODE); @@ -94,6 +99,11 @@ public class CameraSettings extends PreferenceActivity implements R.array.pref_camera_effect_entries, R.array.pref_camera_effect_entryvalues); + // Create brightness settings. + createSettings(mBrightness, Camera.SUPPORTED_BRIGHTNESS, + R.array.pref_camera_brightness_entries, + R.array.pref_camera_brightness_entryvalues); + // Create picture size settings. createSettings(mPictureSize, Camera.SUPPORTED_PICTURE_SIZE, R.array.pref_camera_picturesize_entries, @@ -168,6 +178,10 @@ public class CameraSettings extends PreferenceActivity implements mEffect.setSummary(mEffect.getEntry()); } + private void updateBrightSummary() { + mBrightness.setSummary(mBrightness.getEntry()); + } + private void updatePictureSizeSummary() { mPictureSize.setSummary(mPictureSize.getEntry()); } @@ -194,6 +208,8 @@ public class CameraSettings extends PreferenceActivity implements updateJpegQualitySummary(); } else if (key.equals(KEY_FOCUS_MODE)) { updateFocusModeSummary(); - } + } else if (key.equals(KEY_BRIGHTNESS)) { + updateBrightSummary(); + } } } |