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"/>
<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>
<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>
<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>
<!-- 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>
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"
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";
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
/**
* The Camcorder activity.
private Uri mCurrentVideoUri;
private ContentValues mCurrentVideoValues;
private IconIndicator mWhitebalanceIndicator;
+ private IconIndicator mFlashIndicator;
private MediaRecorderProfile mProfile;
mWhitebalanceIndicator =
(IconIndicator) findViewById(R.id.whitebalance_icon);
+ mFlashIndicator = (IconIndicator) findViewById(R.id.flash_icon);
// Make sure preview is started.
try {
if (mParameters.getSupportedWhiteBalance() == null) {
mWhitebalanceIndicator.setVisibility(View.GONE);
}
+ if (mParameters.getSupportedFlashModes() == null) {
+ mFlashIndicator.setVisibility(View.GONE);
+ }
}
@Override
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) {
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);
}
});
}