summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCheng-Ru Lin <owenlin@google.com>2009-10-01 05:51:22 +0800
committerCheng-Ru Lin <owenlin@google.com>2009-10-01 12:27:39 +0800
commit301c088512a06ec5154da2d27761537b6607f986 (patch)
treee58c89b3dafce9a02c0dea2c196e1586407a8ba3 /src
parentd18f380d7e57f03cb775e79445cdab22b7c73f09 (diff)
downloadpackages_apps_LegacyCamera-301c088512a06ec5154da2d27761537b6607f986.zip
packages_apps_LegacyCamera-301c088512a06ec5154da2d27761537b6607f986.tar.gz
packages_apps_LegacyCamera-301c088512a06ec5154da2d27761537b6607f986.tar.bz2
More complete support for scene mode.
Now, we will disable focus mode, white balance, and flash mode settings if scene mode is not "auto". The current settings of scene mode on those three preference will also reflect on indicators and on screen settings. Change-Id: I55a20ec1d43b205e35d87185e70820e9c66e5cc6
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java124
-rw-r--r--src/com/android/camera/OnScreenSettings.java48
2 files changed, 138 insertions, 34 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index a7f40dd..2ada58b 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -973,7 +973,11 @@ public class Camera extends Activity implements View.OnClickListener,
updateStorageHint(mPicturesRemaining);
}
+ private boolean mScreenComplete = false;
+
private void showOnScreenSettings() {
+ boolean autoSceneMode = Parameters
+ .SCENE_MODE_AUTO.equals(mParameters.getSceneMode());
if (mSettings == null) {
mSettings = new OnScreenSettings(
findViewById(R.id.camera_preview));
@@ -981,7 +985,27 @@ public class Camera extends Activity implements View.OnClickListener,
mSettings.setPreferenceScreen(helper
.getPreferenceScreen(R.xml.camera_preferences));
mSettings.setOnVisibilityChangedListener(this);
+
+ // If the current screne mode is not auto, then the supported
+ // options is not complete, we need to read it again later.
+ // For example: in the scene mode "ACTION", the supported focus mode
+ // will change from {infinite, macro, auto} to {infinite}.
+ mScreenComplete = autoSceneMode;
+ if (autoSceneMode) {
+ mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE, null);
+ mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE, null);
+ mSettings.overrideSettings(
+ CameraSettings.KEY_WHITE_BALANCE, null);
+ } else {
+ mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,
+ mParameters.getFlashMode());
+ mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,
+ mParameters.getFocusMode());
+ mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,
+ mParameters.getWhiteBalance());
+ }
}
+
mSettings.setVisible(true);
}
@@ -1681,27 +1705,6 @@ public class Camera extends Activity implements View.OnClickListener,
// For the following settings, we need to check if the settings are
// still supported by latest driver, if not, ignore the settings.
- // Set flash mode.
- String flashMode = mPreferences.getString(
- CameraSettings.KEY_FLASH_MODE,
- getString(R.string.pref_camera_flashmode_default));
- List<String> supportedFlash = mParameters.getSupportedFlashModes();
- if (isSupported(flashMode, supportedFlash)) {
- mParameters.setFlashMode(flashMode);
- } else {
- // If the current flashMode is not support, show the
- // FLASH_MODE_OFF icon.
- flashMode = Parameters.FLASH_MODE_OFF;
- }
-
- // Set white balance parameter.
- String whiteBalance = mPreferences.getString(
- CameraSettings.KEY_WHITE_BALANCE,
- getString(R.string.pref_camera_whitebalance_default));
- if (isSupported(whiteBalance, mParameters.getSupportedWhiteBalance())) {
- mParameters.setWhiteBalance(whiteBalance);
- }
-
// Set color effect parameter.
String colorEffect = mPreferences.getString(
CameraSettings.KEY_COLOR_EFFECT,
@@ -1718,12 +1721,78 @@ public class Camera extends Activity implements View.OnClickListener,
mParameters.setSceneMode(sceneMode);
}
- // Set focus mode.
- mFocusMode = mPreferences.getString(
- CameraSettings.KEY_FOCUS_MODE,
- getString(R.string.pref_camera_focusmode_default));
- if (isSupported(mFocusMode, mParameters.getSupportedFocusModes())) {
- mParameters.setFocusMode(mFocusMode);
+ // If scene mode is set, we cannot set flash mode, white balance, and
+ // focus mode, instead, we read it from driver
+ String flashMode;
+ String whiteBalance;
+
+ if (!Parameters.SCENE_MODE_AUTO.equals(sceneMode)) {
+ mCameraDevice.setParameters(mParameters);
+
+ // Setting scene mode will change the settings of flash mode, white
+ // balance, and focus mode. So read back here, so that we know
+ // what's the settings
+ mParameters = mCameraDevice.getParameters();
+ flashMode = mParameters.getFlashMode();
+ whiteBalance = mParameters.getWhiteBalance();
+ mFocusMode = mParameters.getFocusMode();
+ if (mSettings != null) {
+ mSettings.overrideSettings(
+ CameraSettings.KEY_FLASH_MODE, flashMode);
+ mSettings.overrideSettings(
+ CameraSettings.KEY_WHITE_BALANCE, whiteBalance);
+ mSettings.overrideSettings(
+ CameraSettings.KEY_FOCUS_MODE, mFocusMode);
+ }
+ } else {
+ if (mSettings != null) {
+ mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE, null);
+ mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE, null);
+ mSettings.overrideSettings(
+ CameraSettings.KEY_WHITE_BALANCE, null);
+ }
+
+ // Set flash mode.
+ flashMode = mPreferences.getString(
+ CameraSettings.KEY_FLASH_MODE,
+ getString(R.string.pref_camera_flashmode_default));
+ List<String> supportedFlash = mParameters.getSupportedFlashModes();
+ if (isSupported(flashMode, supportedFlash)) {
+ mParameters.setFlashMode(flashMode);
+ } else {
+ // If the current flashMode is not support, show the
+ // FLASH_MODE_OFF icon.
+ flashMode = Parameters.FLASH_MODE_OFF;
+ }
+
+ // Set white balance parameter.
+ whiteBalance = mPreferences.getString(
+ CameraSettings.KEY_WHITE_BALANCE,
+ getString(R.string.pref_camera_whitebalance_default));
+ if (isSupported(whiteBalance, mParameters.getSupportedWhiteBalance())) {
+ mParameters.setWhiteBalance(whiteBalance);
+ }
+
+ // Set focus mode.
+ mFocusMode = mPreferences.getString(
+ CameraSettings.KEY_FOCUS_MODE,
+ getString(R.string.pref_camera_focusmode_default));
+ if (isSupported(mFocusMode, mParameters.getSupportedFocusModes())) {
+ mParameters.setFocusMode(mFocusMode);
+ }
+ mCameraDevice.setParameters(mParameters);
+
+ if (!mScreenComplete && mSettings != null) {
+ // The current scene mode is auto and thus the supported values
+ // of the three settings (flash mode, white balance, and focus
+ // mode) are complete now. If we didn't have the complete
+ // preference screen, read it now.
+ mScreenComplete = true;
+ mParameters = mCameraDevice.getParameters();
+ CameraSettings helper = new CameraSettings(this, mParameters);
+ mSettings.setPreferenceScreen(helper
+ .getPreferenceScreen(R.xml.camera_preferences));
+ }
}
// We post the runner because this function can be called from
@@ -1744,7 +1813,6 @@ public class Camera extends Activity implements View.OnClickListener,
}
});
- mCameraDevice.setParameters(mParameters);
}
private void gotoGallery() {
diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java
index 798b904..a152748 100644
--- a/src/com/android/camera/OnScreenSettings.java
+++ b/src/com/android/camera/OnScreenSettings.java
@@ -29,6 +29,7 @@ import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import java.util.ArrayList;
+import java.util.HashMap;
// Please reference to {@link android.widget.ZoomButtonsController} for detail
// information about adding window to WindowManager.
@@ -55,6 +56,16 @@ public class OnScreenSettings {
private final LayoutInflater mInflater;
+ // We store the override values here. For a given preference,
+ // if the mapping value of the preference key is not null, we will
+ // use the value in this map instead of the value read from the preference
+ //
+ // This is design for the scene mode, for example, in the scene mode
+ // "Action", the focus mode will become "infinite" no matter what in the
+ // preference settings. So, we need to put a {pref_camera_focusmode_key,
+ // "infinite"} entry in this map.
+ private HashMap<String, String> mOverride = new HashMap<String, String>();
+
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -125,6 +136,20 @@ public class OnScreenSettings {
}
}
+ // Override the preference settings, if value == null, then disable the
+ // override.
+ public void overrideSettings(String key, String value) {
+ if (value == null) {
+ if (mOverride.remove(key) != null && mMainAdapter != null) {
+ mMainAdapter.notifyDataSetChanged();
+ }
+ } else {
+ if (mOverride.put(key, value) == null && mMainAdapter != null) {
+ mMainAdapter.notifyDataSetChanged();
+ }
+ }
+ }
+
public void updateLayout() {
// if the mOwnerView is detached from window then skip.
if (mOwnerView.getWindowToken() == null) return;
@@ -268,13 +293,22 @@ public class OnScreenSettings {
PreferenceGroup group = (PreferenceGroup) preference;
((TextView) convertView.findViewById(
R.id.title)).setText(group.getTitle());
- } else if (preference instanceof ListPreference) {
+ } else {
convertView = inflateIfNeed(convertView,
R.layout.on_screen_menu_list_item, parent, false);
- ((TextView) convertView.findViewById(
- R.id.title)).setText(preference.getTitle());
- ((TextView) convertView.findViewById(R.id.summary))
- .setText(((ListPreference) preference).getEntry());
+
+ String override = mOverride.get(preference.getKey());
+ TextView title = (TextView)
+ convertView.findViewById(R.id.title);
+ title.setText(preference.getTitle());
+ title.setEnabled(override == null);
+
+ TextView summary = (TextView)
+ convertView.findViewById(R.id.summary);
+ summary.setText(override == null
+ ? ((ListPreference) preference).getEntry()
+ : override);
+ summary.setEnabled(override == null);
}
return convertView;
}
@@ -287,7 +321,9 @@ public class OnScreenSettings {
@Override
public boolean isEnabled(int position) {
Preference preference = mPreferences.get(position);
- return !(preference instanceof PreferenceGroup);
+ if (preference instanceof PreferenceGroup) return false;
+
+ return mOverride.get(preference.getKey()) == null;
}
public int getCount() {