diff options
-rw-r--r-- | res/layout/video_camera.xml | 5 | ||||
-rw-r--r-- | res/values/arrays.xml | 18 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | res/xml/video_preferences.xml | 8 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 27 |
6 files changed, 62 insertions, 0 deletions
diff --git a/res/layout/video_camera.xml b/res/layout/video_camera.xml index b6717d8..85f7f07 100644 --- a/res/layout/video_camera.xml +++ b/res/layout/video_camera.xml @@ -72,6 +72,11 @@ android:layout_height="wrap_content"> <com.android.camera.IconIndicator style="@style/IconIndicator" + android:id="@+id/flash_icon" + camera:modes="@array/flash_modes" + camera:icons="@array/flash_icons"/> + <com.android.camera.IconIndicator + style="@style/IconIndicator" android:id="@+id/whitebalance_icon" camera:modes="@array/pref_camera_whitebalance_entryvalues" camera:icons="@array/whitebalance_icons"/> diff --git a/res/values/arrays.xml b/res/values/arrays.xml index fe07fba..d8fcec4 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -126,6 +126,22 @@ <item>@drawable/ic_viewfinder_flash_off</item> </array> + <!-- Videocamera Preferences flash mode dialog box entries --> + <string-array name="pref_camera_video_flashmode_entries" translatable="false"> + <item>@string/pref_camera_flashmode_entry_on</item> + <item>@string/pref_camera_flashmode_entry_off</item> + </string-array> + + <string-array name="pref_camera_video_flashmode_entryvalues" translatable="false"> + <item>torch</item> + <item>off</item> + </string-array> + + <array name="pref_camera_video_flashmode_icons"> + <item>@drawable/ic_viewfinder_flash_on</item> + <item>@drawable/ic_viewfinder_flash_off</item> + </array> + <string-array name="pref_camera_recordlocation_entryvalues" translatable="false"> <item>off</item> <item>on</item> @@ -139,6 +155,7 @@ <string-array name="flash_modes" translatable="false"> <item>auto</item> <item>on</item> + <item>torch</item> <item>off</item> <item>@string/pref_camera_flashmode_no_flash</item> </string-array> @@ -146,6 +163,7 @@ <array name="flash_icons"> <item>@drawable/ic_viewfinder_flash_auto</item> <item>@drawable/ic_viewfinder_flash_on</item> + <item>@drawable/ic_viewfinder_flash_on</item> <item>@drawable/ic_viewfinder_flash_off</item> <item>@drawable/ic_viewfinder_empty</item> </array> diff --git a/res/values/strings.xml b/res/values/strings.xml index de74e1e..5cd38e7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -229,6 +229,9 @@ <!-- Settings screen, flash mode dialog title --> <string name="pref_camera_flashmode_dialogtitle">Flash mode</string> + <!-- Default videocamera flash mode setting.--> + <string name="pref_camera_video_flashmode_default" translatable="false">off</string> + <!-- Default white balance setting. --> <string name="pref_camera_whitebalance_default" translatable="false">auto</string> diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml index 105d1fc..3f8b99d 100644 --- a/res/xml/video_preferences.xml +++ b/res/xml/video_preferences.xml @@ -33,6 +33,14 @@ android:entryValues="@array/pref_camera_video_duration_entryvalues" android:dialogTitle="@string/pref_camera_video_duration_dialogtitle" /> <com.android.camera.IconListPreference + android:key="pref_camera_video_flashmode_key" + android:defaultValue="@string/pref_camera_video_flashmode_default" + android:title="@string/pref_camera_flashmode_title" + camera:icons="@array/pref_camera_video_flashmode_icons" + android:entries="@array/pref_camera_video_flashmode_entries" + android:entryValues="@array/pref_camera_video_flashmode_entryvalues" + android:dialogTitle="@string/pref_camera_flashmode_dialogtitle" /> + <com.android.camera.IconListPreference android:key="pref_camera_whitebalance_key" android:defaultValue="@string/pref_camera_whitebalance_default" android:title="@string/pref_camera_whitebalance_title" diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 9f4e954..d8a0e91 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -51,6 +51,7 @@ public class CameraSettings { public static final String KEY_JPEG_QUALITY = "pref_camera_jpegquality_key"; public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key"; public static final String KEY_FLASH_MODE = "pref_camera_flashmode_key"; + public static final String KEY_VIDEOCAMERA_FLASH_MODE = "pref_camera_video_flashmode_key"; public static final String KEY_COLOR_EFFECT = "pref_camera_coloreffect_key"; public static final String KEY_WHITE_BALANCE = "pref_camera_whitebalance_key"; diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 315600e..bc7bca1 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -74,6 +74,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; /** * The Camcorder activity. @@ -138,6 +139,7 @@ public class VideoCamera extends NoSearchActivity private Uri mCurrentVideoUri; private ContentValues mCurrentVideoValues; private IconIndicator mWhitebalanceIndicator; + private IconIndicator mFlashIndicator; private MediaRecorderProfile mProfile; @@ -322,6 +324,7 @@ public class VideoCamera extends NoSearchActivity mWhitebalanceIndicator = (IconIndicator) findViewById(R.id.whitebalance_icon); + mFlashIndicator = (IconIndicator) findViewById(R.id.flash_icon); // Make sure preview is started. try { @@ -340,6 +343,9 @@ public class VideoCamera extends NoSearchActivity if (mParameters.getSupportedWhiteBalance() == null) { mWhitebalanceIndicator.setVisibility(View.GONE); } + if (mParameters.getSupportedFlashModes() == null) { + mFlashIndicator.setVisibility(View.GONE); + } } @Override @@ -1379,12 +1385,31 @@ public class VideoCamera extends NoSearchActivity UPDATE_RECORD_TIME, next_update_delay); } + private static boolean isSupported(String value, List<String> supported) { + return supported == null ? false : supported.indexOf(value) >= 0; + } + private void setCameraParameters() { mParameters = mCameraDevice.getParameters(); mParameters.setPreviewSize(mProfile.mVideoWidth, mProfile.mVideoHeight); mParameters.setPreviewFrameRate(mProfile.mVideoFps); + // Set flash mode. + String flashMode = mPreferences.getString( + CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, + getString(R.string.pref_camera_video_flashmode_default)); + List<String> supportedFlash = mParameters.getSupportedFlashModes(); + if (isSupported(flashMode, supportedFlash)) { + mParameters.setFlashMode(flashMode); + } else { + flashMode = mParameters.getFlashMode(); + if (flashMode == null) { + flashMode = getString( + R.string.pref_camera_flashmode_no_flash); + } + } + // Set white balance parameter. String whiteBalance = Parameters.WHITE_BALANCE_AUTO; if (mParameters.getSupportedWhiteBalance() != null) { @@ -1405,12 +1430,14 @@ public class VideoCamera extends NoSearchActivity mCameraDevice.setParameters(mParameters); final String finalWhiteBalance = whiteBalance; + final String finalFlashMode = flashMode; // It can be execute from the startPreview thread, so we post it // to the main UI thread mHandler.post(new Runnable() { public void run() { mWhitebalanceIndicator.setMode(finalWhiteBalance); + mFlashIndicator.setMode(finalFlashMode); } }); } |