summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraSettings.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:25 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:25 -0800
commitb97ccf3f20bee44daf70f10966809e39e30ab4f7 (patch)
treefb6c421cd04ffed74e50cd62e4fdab34d5a9f448 /src/com/android/camera/CameraSettings.java
parent0eaec58e292ce4eaa6baadecf643f0f65e48d278 (diff)
downloadLegacyCamera-b97ccf3f20bee44daf70f10966809e39e30ab4f7.zip
LegacyCamera-b97ccf3f20bee44daf70f10966809e39e30ab4f7.tar.gz
LegacyCamera-b97ccf3f20bee44daf70f10966809e39e30ab4f7.tar.bz2
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'src/com/android/camera/CameraSettings.java')
-rw-r--r--src/com/android/camera/CameraSettings.java59
1 files changed, 54 insertions, 5 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 0c0f31b..0145d64 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -16,28 +16,77 @@
package com.android.camera;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
+import android.preference.ListPreference;
import android.preference.PreferenceActivity;
/**
* CameraSettings
*/
public class CameraSettings extends PreferenceActivity
+ implements OnSharedPreferenceChangeListener
{
+ public static final String KEY_VIDEO_QUALITY = "pref_camera_videoquality_key";
+ public static final boolean DEFAULT_VIDEO_QUALITY_VALUE = true;
+
+ private ListPreference mVideoQuality;
+
public CameraSettings()
{
}
- protected int resourceId() {
- return R.xml.camera_preferences;
- }
-
/** Called with the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
- addPreferencesFromResource(resourceId());
+ addPreferencesFromResource(R.xml.camera_preferences);
+
+ initUI();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ updateVideoQuality();
+ }
+
+ private void initUI() {
+ mVideoQuality = (ListPreference) findPreference(KEY_VIDEO_QUALITY);
+ getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+ }
+
+ private void updateVideoQuality() {
+ boolean vidQualityValue = getBooleanPreference(mVideoQuality, DEFAULT_VIDEO_QUALITY_VALUE);
+ int vidQualityIndex = vidQualityValue ? 1 : 0;
+ String[] vidQualities =
+ getResources().getStringArray(R.array.pref_camera_videoquality_entries);
+ String vidQuality = vidQualities[vidQualityIndex];
+ mVideoQuality.setSummary(vidQuality);
+ }
+
+ private static int getIntPreference(ListPreference preference, int defaultValue) {
+ String s = preference.getValue();
+ int result = defaultValue;
+ try {
+ result = Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ // Ignore, result is already the default value.
+ }
+ return result;
+ }
+
+ private boolean getBooleanPreference(ListPreference preference, boolean defaultValue) {
+ return getIntPreference(preference, defaultValue ? 1 : 0) != 0;
+ }
+
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+ if (key.equals(KEY_VIDEO_QUALITY)) {
+ updateVideoQuality();
+ }
}
}