summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWu-cheng Li <>2009-04-02 02:38:09 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-02 02:38:09 -0700
commit2ac0387bbd6792187aeaacf10e40688f4260e316 (patch)
treebe13590c2948b30c9c4abb6095ff07a84f0f6bc6 /src
parent87341536812081826656040ac81f8f386c6c1407 (diff)
downloadLegacyCamera-2ac0387bbd6792187aeaacf10e40688f4260e316.zip
LegacyCamera-2ac0387bbd6792187aeaacf10e40688f4260e316.tar.gz
LegacyCamera-2ac0387bbd6792187aeaacf10e40688f4260e316.tar.bz2
AI 144213: Initial implementation of effect settings.
BUG=1753515 Automated import of CL 144213
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java9
-rw-r--r--src/com/android/camera/CameraSettings.java143
2 files changed, 79 insertions, 73 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 767f80b..85a0884 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -105,12 +105,15 @@ 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_JPEG_QUALITY = "jpeg-quality";
public static final String PARM_ROTATION = "rotation";
public static final String PARM_GPS_LATITUDE = "gps-latitude";
public static final String PARM_GPS_LONGITUDE = "gps-longitude";
public static final String PARM_GPS_ALTITUDE = "gps-altitude";
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";
private OrientationEventListener mOrientationListener;
private int mLastOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
@@ -1320,6 +1323,12 @@ public class Camera extends Activity implements View.OnClickListener,
getString(R.string.pref_camera_whitebalance_default));
mParameters.set(PARM_WHITE_BALANCE, whiteBalance);
+ // Set effect parameter.
+ String effect = mPreferences.getString(
+ CameraSettings.KEY_EFFECT,
+ getString(R.string.pref_camera_effect_default));
+ mParameters.set(PARM_EFFECT, effect);
+
try {
mCameraDevice.setParameters(mParameters);
} catch (IllegalArgumentException e) {
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 13952b8..4d0ca21 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -16,138 +16,135 @@
package com.android.camera;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
-
-import java.util.ArrayList;
-import java.util.StringTokenizer;
+import android.util.Log;
/**
* CameraSettings
*/
public class CameraSettings extends PreferenceActivity
- implements OnSharedPreferenceChangeListener
-{
- public static final String KEY_VIDEO_QUALITY = "pref_camera_videoquality_key";
- public static final String KEY_WHITE_BALANCE = "pref_camera_whitebalance_key";
+ implements OnSharedPreferenceChangeListener {
+ public static final String KEY_VIDEO_QUALITY =
+ "pref_camera_videoquality_key";
+ public static final String KEY_WHITE_BALANCE =
+ "pref_camera_whitebalance_key";
+ public static final String KEY_EFFECT = "pref_camera_effect_key";
public static final boolean DEFAULT_VIDEO_QUALITY_VALUE = true;
private ListPreference mVideoQuality;
private ListPreference mWhiteBalance;
+ private ListPreference mEffect;
private Parameters mParameters;
- public CameraSettings()
- {
- }
-
/** Called with the activity is first created. */
@Override
- public void onCreate(Bundle icicle)
- {
+ public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.camera_preferences);
initUI();
-
- // Get parameters.
- android.hardware.Camera device = android.hardware.Camera.open();
- mParameters = device.getParameters();
- device.release();
-
- createWhiteBalanceSettings();
}
@Override
protected void onResume() {
super.onResume();
- updateVideoQuality();
- updateWhiteBalance();
+ updateVideoQualitySummary();
+ updateWhiteBalanceSummary();
+ updateEffectSummary();
}
private void initUI() {
mVideoQuality = (ListPreference) findPreference(KEY_VIDEO_QUALITY);
mWhiteBalance = (ListPreference) findPreference(KEY_WHITE_BALANCE);
- getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
- }
+ mEffect = (ListPreference) findPreference(KEY_EFFECT);
+ getPreferenceScreen().getSharedPreferences().
+ registerOnSharedPreferenceChangeListener(this);
+
+ // Get parameters.
+ android.hardware.Camera device = android.hardware.Camera.open();
+ mParameters = device.getParameters();
+ device.release();
+
+ // Create white balance settings.
+ createSettings(mWhiteBalance, Camera.SUPPORTED_WHITE_BALANCE,
+ R.array.pref_camera_whitebalance_entries,
+ R.array.pref_camera_whitebalance_entryvalues);
- 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);
+ // Create effect settings.
+ createSettings(mEffect, Camera.SUPPORTED_EFFECT,
+ R.array.pref_camera_effect_entries,
+ R.array.pref_camera_effect_entryvalues);
}
- private void createWhiteBalanceSettings() {
- // Get the supported white balance settings.
- String supportedWbStr = mParameters.get("whitebalance-values");
- StringTokenizer tokenizer = new StringTokenizer(supportedWbStr, ",");
- ArrayList<CharSequence> supportedWb = new ArrayList<CharSequence>();
+ private void createSettings(
+ ListPreference pref, String paramName, int prefEntriesResId,
+ int prefEntryValuesResId) {
+ // Get the supported parameter settings.
+ String supportedParamStr = mParameters.get(paramName);
+ StringTokenizer tokenizer = new StringTokenizer(supportedParamStr, ",");
+ ArrayList<CharSequence> supportedParam = new ArrayList<CharSequence>();
while (tokenizer.hasMoreElements()) {
- supportedWb.add(tokenizer.nextToken());
+ supportedParam.add(tokenizer.nextToken());
}
- // Prepare white balance entries and entry values.
- String[] allWbEntries = getResources().getStringArray(
- R.array.pref_camera_whitebalance_entries);
- String[] allWbEntryValues = getResources().getStringArray(
- R.array.pref_camera_whitebalance_entryvalues);
- ArrayList<CharSequence> wbEntries = new ArrayList<CharSequence>();
- ArrayList<CharSequence> wbEntryValues = new ArrayList<CharSequence>();
- for (int i = 0, len = allWbEntryValues.length; i < len; i++) {
- int found = supportedWb.indexOf(allWbEntryValues[i]);
+ // Prepare setting entries and entry values.
+ String[] allEntries = getResources().getStringArray(prefEntriesResId);
+ String[] allEntryValues = getResources().getStringArray(
+ prefEntryValuesResId);
+ ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
+ ArrayList<CharSequence> entryValues = new ArrayList<CharSequence>();
+ for (int i = 0, len = allEntryValues.length; i < len; i++) {
+ int found = supportedParam.indexOf(allEntryValues[i]);
if (found != -1) {
- wbEntries.add(allWbEntries[i]);
- wbEntryValues.add(allWbEntryValues[i]);
+ entries.add(allEntries[i]);
+ entryValues.add(allEntryValues[i]);
}
}
- // Set white balance entries and entry values to list preference.
- mWhiteBalance.setEntries(wbEntries.toArray(
- new CharSequence[wbEntries.size()]));
- mWhiteBalance.setEntryValues(wbEntryValues.toArray(
- new CharSequence[wbEntryValues.size()]));
+ // Set entries and entry values to list preference.
+ pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
+ pref.setEntryValues(entryValues.toArray(
+ new CharSequence[entryValues.size()]));
- String value = mWhiteBalance.getValue();
- int index = mWhiteBalance.findIndexOfValue(value);
+ // Set the value to the first entry if it is invalid.
+ String value = pref.getValue();
+ int index = pref.findIndexOfValue(value);
if (index == -1) {
- mWhiteBalance.setValueIndex(0);
+ pref.setValueIndex(0);
}
}
- private void updateWhiteBalance() {
- // Set preference summary.
- mWhiteBalance.setSummary(mWhiteBalance.getEntry());
+ private void updateVideoQualitySummary() {
+ mVideoQuality.setSummary(mVideoQuality.getEntry());
}
- 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 void updateWhiteBalanceSummary() {
+ // Set preference summary.
+ mWhiteBalance.setSummary(mWhiteBalance.getEntry());
}
- private boolean getBooleanPreference(ListPreference preference, boolean defaultValue) {
- return getIntPreference(preference, defaultValue ? 1 : 0) != 0;
+ private void updateEffectSummary() {
+ // Set preference summary.
+ mEffect.setSummary(mEffect.getEntry());
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
if (key.equals(KEY_VIDEO_QUALITY)) {
- updateVideoQuality();
+ updateVideoQualitySummary();
} else if (key.equals(KEY_WHITE_BALANCE)) {
- updateWhiteBalance();
+ updateWhiteBalanceSummary();
+ } else if (key.equals(KEY_EFFECT)) {
+ updateEffectSummary();
}
}
}