diff options
author | Chih-Chung Chang <chihchung@google.com> | 2009-11-09 13:01:13 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2009-11-09 16:50:18 +0800 |
commit | faf398ff0fa2b51348b4545505112d70ba7b47a1 (patch) | |
tree | 8330d6f4e248f6dedb45c5f05f89aa2f0b6633d8 /src | |
parent | ff7da7918997b56fbf5f410bedf263622e014bb0 (diff) | |
download | LegacyCamera-faf398ff0fa2b51348b4545505112d70ba7b47a1.zip LegacyCamera-faf398ff0fa2b51348b4545505112d70ba7b47a1.tar.gz LegacyCamera-faf398ff0fa2b51348b4545505112d70ba7b47a1.tar.bz2 |
Fix 2241232: Read system properties for quality setting.
Change-Id: Ic823abd0c352b3eca0b8ef504307bd1de7d1700f
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 26 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 16 |
2 files changed, 40 insertions, 2 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 30f427e..972476d 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -44,6 +44,7 @@ import android.os.Environment; import android.os.Handler; import android.os.Message; import android.os.SystemClock; +import android.os.SystemProperties; import android.preference.PreferenceManager; import android.provider.MediaStore; import android.text.format.DateFormat; @@ -874,6 +875,7 @@ public class Camera extends Activity implements View.OnClickListener, mSurfaceView = (SurfaceView) findViewById(R.id.camera_preview); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); + CameraSettings.upgradePreferences(mPreferences); /* * To reduce startup time, we start the preview in another thread. @@ -1726,7 +1728,7 @@ public class Camera extends Activity implements View.OnClickListener, String jpegQuality = mPreferences.getString( CameraSettings.KEY_JPEG_QUALITY, getString(R.string.pref_camera_jpegquality_default)); - mParameters.setJpegQuality(Integer.parseInt(jpegQuality)); + mParameters.setJpegQuality(getQualityNumber(jpegQuality)); // Set zoom. if (mParameters.isZoomSupported()) { @@ -2039,6 +2041,28 @@ public class Camera extends Activity implements View.OnClickListener, getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mHandler.sendEmptyMessageDelayed(CLEAR_SCREEN_DELAY, SCREEN_DELAY); } + + private static String[] mQualityStrings = {"superfine", "fine", "normal"}; + private static String[] mQualityNumbers = SystemProperties.get( + "ro.media.enc.jpeg.quality", "85,75,65").split(","); + private static int DEFAULT_QUALITY = 85; + + // Translate from a quality string to a quality number using the system + // properties. + private static int getQualityNumber(String jpegQuality) { + // Find the index of the input string + int index = Util.indexOf(mQualityStrings, jpegQuality); + + if (index == -1 || index > mQualityNumbers.length - 1) { + return DEFAULT_QUALITY; + } + + try { + return Integer.parseInt(mQualityNumbers[index]); + } catch (NumberFormatException ex) { + return DEFAULT_QUALITY; + } + } } class FocusRectangle extends View { diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index e7d7d0e..9b106ff 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -37,7 +37,7 @@ public class CameraSettings { "pref_camera_whitebalance_key"; public static final String KEY_SCENE_MODE = "pref_camera_scenemode_key"; - public static final int CURRENT_VERSION = 1; + public static final int CURRENT_VERSION = 2; // max mms video duration in seconds. public static final int MMS_VIDEO_DURATION = @@ -249,6 +249,20 @@ public class CameraSettings { if (pref.getString(KEY_VIDEO_DURATION, "1").equals("1")) { editor.putString(KEY_VIDEO_DURATION, "10"); } + version = 1; + } + if (version == 1) { + // Change jpeg quality {65,75,85} to {normal,fine,superfine} + String quality = pref.getString(KEY_JPEG_QUALITY, "85"); + if (quality.equals("65")) { + quality = "normal"; + } else if (quality.equals("75")) { + quality = "fine"; + } else { + quality = "superfine"; + } + editor.putString(KEY_JPEG_QUALITY, quality); + version = 2; } editor.putInt(KEY_VERSION, CURRENT_VERSION); editor.commit(); |