summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-05-10 11:38:21 -0700
committerSteve Kondik <steve@cyngn.com>2016-08-21 18:45:51 -0700
commitcba1a4ed8028cb355e1361ef29b177c0b4910b5a (patch)
tree0ff9883f4c6f0617223a7c0ca3909d678a253bf7
parent1fea7d5bb3dd45caf29e90be2e9eae2646567a10 (diff)
downloadandroid_packages_apps_Snap-cba1a4ed8028cb355e1361ef29b177c0b4910b5a.zip
android_packages_apps_Snap-cba1a4ed8028cb355e1361ef29b177c0b4910b5a.tar.gz
android_packages_apps_Snap-cba1a4ed8028cb355e1361ef29b177c0b4910b5a.tar.bz2
SnapdragonCamera: Add SettingsManager, scene, and filter
Add SettingsManager to work as a database for settings. It will handle all dependencies and populate the values. Add scene mode and filter. Restructure UI and menu by combining them and leave the handling of settings to SettingsManager Change-Id: I185163fdddbffd29434e6a9c41b33be6d3388f88 CRs-Fixed: 1018118
-rw-r--r--res/layout/capture_module.xml3
-rw-r--r--res/values/attrs.xml1
-rw-r--r--res/values/camera2arrays.xml579
-rw-r--r--res/values/qcomarrays.xml42
-rw-r--r--res/values/qcomstrings.xml63
-rw-r--r--res/xml/camera_preferences.xml31
-rw-r--r--res/xml/capture_preferences.xml154
-rw-r--r--src/com/android/camera/CameraActivity.java15
-rw-r--r--src/com/android/camera/CameraSettings.java20
-rw-r--r--src/com/android/camera/CaptureMenu.java571
-rw-r--r--src/com/android/camera/CaptureModule.java809
-rw-r--r--src/com/android/camera/CaptureUI.java1367
-rw-r--r--src/com/android/camera/ComboPreferences.java6
-rw-r--r--src/com/android/camera/ListPreference.java15
-rw-r--r--src/com/android/camera/PhotoMenu.java14
-rw-r--r--src/com/android/camera/PhotoModule.java9
-rw-r--r--src/com/android/camera/PreviewGestures.java29
-rw-r--r--src/com/android/camera/RecordLocationPreference.java5
-rw-r--r--src/com/android/camera/SettingsManager.java539
-rw-r--r--src/com/android/camera/VideoModule.java6
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java3
-rw-r--r--src/com/android/camera/ui/FilmStripView.java32
-rw-r--r--src/com/android/camera/ui/ListMenu.java63
-rw-r--r--src/com/android/camera/ui/ListMenuItem.java22
-rw-r--r--src/com/android/camera/ui/ListSubMenu.java3
-rw-r--r--src/com/android/camera/util/CameraUtil.java29
26 files changed, 2837 insertions, 1593 deletions
diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml
index a68af5e..d91b49a 100644
--- a/res/layout/capture_module.xml
+++ b/res/layout/capture_module.xml
@@ -36,7 +36,8 @@
<com.android.camera.ui.AutoFitSurfaceView
android:id="@+id/mdp_preview_content"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:layout_gravity="center" />
<com.android.camera.ui.AutoFitSurfaceView
android:id="@+id/mdp_preview_content2"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index b9c04f2..a243e5f 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -30,6 +30,7 @@
<attr name="entryValues" format="reference" />
<attr name="entries" format="reference" />
<attr name="labelList" format="reference" />
+ <attr name="dependencyList" format="reference" />
</declare-styleable>
<declare-styleable name="IconIndicator">
<attr name="icons" format="reference" />
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
new file mode 100644
index 0000000..9865e39
--- /dev/null
+++ b/res/values/camera2arrays.xml
@@ -0,0 +1,579 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<resources>
+ <string-array name="pref_camera2_camera2_entries" translatable="true">
+ <item>@string/pref_camera2_camera2_entry_disable</item>
+ <item>@string/pref_camera2_camera2_entry_enable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_camera2_entryvalues" translatable="false">
+ <item>@string/pref_camera2_camera2_value_disable</item>
+ <item>@string/pref_camera2_camera2_value_enable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_dual_camera_entries" translatable="true">
+ <item>@string/pref_camera2_dual_camera_entry_dual</item>
+ <item>@string/pref_camera2_dual_camera_entry_bayer</item>
+ <item>@string/pref_camera2_dual_camera_entry_mono</item>
+ </string-array>
+
+ <string-array name="pref_camera2_dual_camera_entryvalues" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ </string-array>
+
+ <string-array name="pref_camera2_dual_camera_dependencylist" translatable="false">
+ <item>pref_camera2_mono_preview_key</item>
+ <item>pref_camera2_clearsight_key</item>
+ </string-array>
+
+ <string-array name="pref_camera2_mono_preview_entries" translatable="true">
+ <item>@string/pref_camera2_mono_preview_entry_off</item>
+ <item>@string/pref_camera2_mono_preview_entry_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_mono_preview_entryvalues" translatable="false">
+ <item>@string/pref_camera2_mono_preview_value_off</item>
+ <item>@string/pref_camera2_mono_preview_value_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_clearsight_entries" translatable="true">
+ <item>@string/pref_camera2_clearsight_entry_off</item>
+ <item>@string/pref_camera2_clearsight_entry_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_clearsight_entryvalues" translatable="false">
+ <item>@string/pref_camera2_clearsight_value_off</item>
+ <item>@string/pref_camera2_clearsight_value_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_scenemode_dependencylist" translatable="false">
+ <item>pref_camera2_coloreffect_key</item>
+ <item>pref_camera2_flashmode_key</item>
+ <item>pref_camera2_whitebalance_key</item>
+ </string-array>
+
+ <!-- Refer to CONTROL_SCENE_MODE of Camera2 API for values
+ -1 refers to ones not supported in Camera2 API
+ 0 is special case added for auto (meaning off)
+ -->
+ <string-array name="pref_camera2_scenemode_entryvalues" translatable="false">
+ <item>0</item>
+ <item>18</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>3</item>
+ <item>4</item>
+ <item>13</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>15</item>
+ <item>10</item>
+ <item>5</item>
+ <item>8</item>
+ <item>9</item>
+ <item>-1</item>
+ </string-array>
+
+ <!-- Camera Preferences Scene Mode dialog box entries -->
+ <string-array name="pref_camera2_scenemode_entries" translatable="false">
+ <item>@string/pref_camera_scenemode_entry_auto</item>
+ <item>@string/pref_camera_scenemode_entry_hdr</item>
+ <item>@string/pref_camera_scenemode_entry_refocus</item>
+ <item>@string/pref_camera_scenemode_entry_optizoom</item>
+ <item>@string/pref_camera_scenemode_entry_portrait</item>
+ <item>@string/pref_camera_scenemode_entry_landscape</item>
+ <item>@string/pref_camera_scenemode_entry_sports</item>
+ <item>@string/pref_camera_scenemode_entry_flowers</item>
+ <item>@string/pref_camera_scenemode_entry_backlight</item>
+ <item>@string/pref_camera_scenemode_entry_candlelight</item>
+ <item>@string/pref_camera_scenemode_entry_sunset</item>
+ <item>@string/pref_camera_scenemode_entry_night</item>
+ <item>@string/pref_camera_scenemode_entry_beach</item>
+ <item>@string/pref_camera_scenemode_entry_snow</item>
+ <item>@string/pref_camera_scenemode_entry_asd</item>
+ </string-array>
+
+ <array name="pref_camera2_scenemode_thumbnails" translatable="false">
+ <item>@drawable/ic_scene_mode_auto</item>
+ <item>@drawable/ic_scene_mode_hdr</item>
+ <item>@drawable/ic_scene_mode_refocus</item>
+ <item>@drawable/ic_scene_mode_optizoom</item>
+ <item>@drawable/ic_scene_mode_portrait</item>
+ <item>@drawable/ic_scene_mode_landscape</item>
+ <item>@drawable/ic_scene_mode_sports</item>
+ <item>@drawable/ic_scene_mode_flower</item>
+ <item>@drawable/ic_scene_mode_backlight</item>
+ <item>@drawable/ic_scene_mode_candlelight</item>
+ <item>@drawable/ic_scene_mode_sunset</item>
+ <item>@drawable/ic_scene_mode_night</item>
+ <item>@drawable/ic_scene_mode_beach</item>
+ <item>@drawable/ic_scene_mode_snow</item>
+ <item>@drawable/ic_scene_mode_smartauto</item>
+ </array>
+
+ <string-array name="pref_camera2_scenemode_labels">
+ <item>@string/pref_camera_scenemode_label_action</item>
+ <item>@string/pref_camera_scenemode_label_night</item>
+ <item>@string/pref_camera_scenemode_label_auto</item>
+ <item>@string/pref_camera_scenemode_label_sunset</item>
+ <item>@string/pref_camera_scenemode_label_party</item>
+ </string-array>
+
+ <array name="pref_camera2_scenemode_icons">
+ <item>@drawable/ic_sce_action</item>
+ <item>@drawable/ic_sce_night</item>
+ <item>@drawable/ic_sce_off</item>
+ <item>@drawable/ic_sce_sunset</item>
+ <item>@drawable/ic_sce_party</item>
+ </array>
+
+ <string-array name="pref_camera2_whitebalance_entryvalues" translatable="false">
+ <item>2</item>
+ <item>4</item>
+ <item>1</item>
+ <item>5</item>
+ <item>6</item>
+ </string-array>
+
+ <!-- Camera Preferences White Balance dialog box entries -->
+ <string-array name="pref_camera2_whitebalance_entries" translatable="false">
+ <item>@string/pref_camera_whitebalance_entry_incandescent</item>
+ <item>@string/pref_camera_whitebalance_entry_fluorescent</item>
+ <item>@string/pref_camera_whitebalance_entry_auto</item>
+ <item>@string/pref_camera_whitebalance_entry_daylight</item>
+ <item>@string/pref_camera_whitebalance_entry_cloudy</item>
+ </string-array>
+
+ <string-array name="pref_camera2_whitebalance_labels" translatable="false">
+ <item>@string/pref_camera_whitebalance_label_incandescent</item>
+ <item>@string/pref_camera_whitebalance_label_fluorescent</item>
+ <item>@string/pref_camera_whitebalance_label_auto</item>
+ <item>@string/pref_camera_whitebalance_label_daylight</item>
+ <item>@string/pref_camera_whitebalance_label_cloudy</item>
+ </string-array>
+
+ <array name="pref_camera2_whitebalance_icons" translatable="false">
+ <item>@drawable/ic_wb_incandescent</item>
+ <item>@drawable/ic_wb_fluorescent</item>
+ <item>@drawable/ic_wb_auto</item>
+ <item>@drawable/ic_wb_sunlight</item>
+ <item>@drawable/ic_wb_cloudy</item>
+ </array>
+
+ <array name="pref_camera2_whitebalance_largeicons" translatable="false">
+ <item>@drawable/ic_wb_incandescent</item>
+ <item>@drawable/ic_wb_fluorescent</item>
+ <item>@drawable/ic_wb_auto</item>
+ <item>@drawable/ic_wb_sunlight</item>
+ <item>@drawable/ic_wb_cloudy</item>
+ </array>
+
+ <!-- Refer to CONTROL_EFFECT_MODE of Camera2 API for values
+ -1 refers to ones not supported in Camera2 API
+ -->
+ <string-array name="pref_camera2_coloreffect_entryvalues" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>4</item>
+ <item>2</item>
+ <item>3</item>
+ <item>5</item>
+ <item>8</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ <item>-1</item>
+ </string-array>
+
+ <string-array name="pref_camera2_coloreffect_icons" translatable="false">
+ <item>@drawable/ic_settings_filter</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ </string-array>
+
+ <!-- Camera Preferences Color effect dialog box entries -->
+ <string-array name="pref_camera2_coloreffect_entries" translatable="false">
+ <item>@string/pref_camera_coloreffect_entry_none</item>
+ <item>@string/pref_camera_coloreffect_entry_mono</item>
+ <item>@string/pref_camera_coloreffect_entry_sepia</item>
+ <item>@string/pref_camera_coloreffect_entry_negative</item>
+ <item>@string/pref_camera_coloreffect_entry_solarize</item>
+ <item>@string/pref_camera_coloreffect_entry_posterize</item>
+ <item>@string/pref_camera_coloreffect_entry_aqua</item>
+ <item>@string/pref_camera_coloreffect_entry_emboss</item>
+ <item>@string/pref_camera_coloreffect_entry_sketch</item>
+ <item>@string/pref_camera_coloreffect_entry_neon</item>
+ <item>@string/pref_camera_coloreffect_entry_pastel</item>
+ <item>@string/pref_camera_coloreffect_entry_mosaic</item>
+ <item>@string/pref_camera_coloreffect_entry_redtint</item>
+ <item>@string/pref_camera_coloreffect_entry_bluetint</item>
+ <item>@string/pref_camera_coloreffect_entry_greentint</item>
+ </string-array>
+
+ <array name="pref_camera2_coloreffect_thumbnails" translatable="false">
+ <item>@drawable/thumb_filter_nofilter</item>
+ <item>@drawable/thumb_filter_monochrome</item>
+ <item>@drawable/thumb_filter_sepia</item>
+ <item>@drawable/thumb_filter_negative</item>
+ <item>@drawable/thumb_filter_solarize</item>
+ <item>@drawable/thumb_filter_posterize</item>
+ <item>@drawable/thumb_filter_aqua</item>
+ <item>@drawable/thumb_filter_emboss</item>
+ <item>@drawable/thumb_filter_sketch</item>
+ <item>@drawable/thumb_filter_neon</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ </array>
+
+ <!-- Camera Preferences flash mode dialog box entries -->
+ <string-array name="pref_camera2_flashmode_entries" translatable="false">
+ <item>@string/pref_camera_flashmode_entry_off</item>
+ <item>@string/pref_camera_flashmode_entry_auto</item>
+ <item>@string/pref_camera_flashmode_entry_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_flashmode_labels" translatable="false">
+ <item>@string/pref_camera_flashmode_label_off</item>
+ <item>@string/pref_camera_flashmode_label_auto</item>
+ <item>@string/pref_camera_flashmode_label_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_flashmode_entryvalues" translatable="false">
+ <item>off</item>
+ <item>auto</item>
+ <item>on</item>
+ </string-array>
+
+ <array name="pref_camera2_flashmode_icons" translatable="false">
+ <item>@drawable/ic_flash_off_holo_light</item>
+ <item>@drawable/ic_flash_auto_holo_light</item>
+ <item>@drawable/ic_flash_on_holo_light</item>
+ </array>
+
+ <array name="pref_camera2_flashmode_largeicons" translatable="false">
+ <item>@drawable/ic_flash_off_holo_light</item>
+ <item>@drawable/ic_flash_auto_holo_light</item>
+ <item>@drawable/ic_flash_on_holo_light</item>
+ </array>
+
+ <!-- Camera Preference save path entries -->
+ <string-array name="pref_camera2_savepath_entries" translatable="false">
+ <item>@string/pref_camera_savepath_entry_0</item>
+ <item>@string/pref_camera_savepath_entry_1</item>
+ </string-array>
+
+ <string-array name="pref_camera2_savepath_entryvalues" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ </string-array>
+
+ <!-- Camera Preferences Picture size dialog box entries -->
+ <string-array name="pref_camera2_picturesize_entries" translatable="false">
+ <item>@string/pref_camera_picturesize_entry_24mp</item>
+ <item>@string/pref_camera_picturesize_entry_21mp</item>
+ <item>@string/pref_camera_picturesize_entry_16mp</item>
+ <item>@string/pref_camera_picturesize_entry_16mp_wide</item>
+ <item>@string/pref_camera_picturesize_entry_13mp</item>
+ <item>@string/pref_camera_picturesize_entry_12mp</item>
+ <item>@string/pref_camera_picturesize_entry_8mp</item>
+ <item>@string/pref_camera_picturesize_entry_8mp</item>
+ <item>@string/pref_camera_picturesize_entry_square</item>
+ <item>@string/pref_camera_picturesize_entry_5mp</item>
+ <item>@string/pref_camera_picturesize_entry_5mp</item>
+ <item>@string/pref_camera_picturesize_entry_5mp</item>
+ <item>@string/pref_camera_picturesize_entry_4mp_wide</item>
+ <item>@string/pref_camera_picturesize_entry_3mp</item>
+ <item>@string/pref_camera_picturesize_entry_3mp</item>
+ <item>@string/pref_camera_picturesize_entry_1920x1080</item>
+ <item>@string/pref_camera_picturesize_entry_2mp</item>
+ <item>@string/pref_camera_picturesize_entry_2mp_wide</item>
+ <item>@string/pref_camera_picturesize_entry_1_5mp</item>
+ <item>@string/pref_camera_picturesize_entry_1_3mp</item>
+ <item>@string/pref_camera_picturesize_entry_1280x768</item>
+ <item>@string/pref_camera_picturesize_entry_1280x720</item>
+ <item>@string/pref_camera_picturesize_entry_1mp</item>
+ <item>@string/pref_camera_picturesize_entry_800x600</item>
+ <item>@string/pref_camera_picturesize_entry_800x480</item>
+ <item>@string/pref_camera_picturesize_entry_960x720</item>
+ <item>@string/pref_camera_picturesize_entry_720x480</item>
+ <item>@string/pref_camera_picturesize_entry_vga</item>
+ <item>@string/pref_camera_picturesize_entry_352x288</item>
+ <item>@string/pref_camera_picturesize_entry_qvga</item>
+ <item>@string/pref_camera_picturesize_entry_176x144</item>
+ </string-array>
+ <!-- When launching the camera app first time, we will set the picture
+ size to the first one in the list that is also supported by the
+ driver -->
+ <string-array name="pref_camera2_picturesize_entryvalues" translatable="false">
+ <item>5656x4242</item>
+ <item>5344x4008</item>
+ <item>4608x3456</item>
+ <item>5312x2988</item>
+ <item>4160x3120</item>
+ <item>4000x3000</item>
+ <item>3840x2160</item>
+ <item>3264x2448</item>
+ <item>2976x2976</item>
+ <item>2592x1944</item>
+ <item>2592x1936</item>
+ <item>2560x1920</item>
+ <item>2688x1512</item>
+ <item>2048x1536</item>
+ <item>2048x1520</item>
+ <item>1920x1080</item>
+ <item>1600x1200</item>
+ <item>1920x1088</item>
+ <item>1440x1080</item>
+ <item>1280x960</item>
+ <item>1280x768</item>
+ <item>1280x720</item>
+ <item>1024x768</item>
+ <item>800x600</item>
+ <item>800x480</item>
+ <item>960x720</item>
+ <item>720x480</item>
+ <item>640x480</item>
+ <item>352x288</item>
+ <item>320x240</item>
+ <item>176x144</item>
+ </string-array>
+
+ <!-- Camera Preferences focus mode dialog box entries -->
+ <string-array name="pref_camera2_focusmode_entries" translatable="false">
+ <item>@string/pref_camera_focusmode_entry_auto</item>
+ <item>@string/pref_camera_focusmode_entry_infinity</item>
+ <item>@string/pref_camera_focusmode_entry_macro</item>
+ <item>@string/pref_camera_focusmode_entry_normal</item>
+ <item>@string/pref_camera_focusmode_entry_continuous</item>
+ </string-array>
+
+ <string-array name="pref_camera2_focusmode_entryvalues" translatable="false">
+ <item>auto</item>
+ <item>infinity</item>
+ <item>macro</item>
+ <item>normal</item>
+ <item>continuous-picture</item>
+ </string-array>
+
+ <string-array name="pref_camera2_focusmode_labels" translatable="false">
+ <item>@string/pref_camera_focusmode_label_auto</item>
+ <item>@string/pref_camera_focusmode_label_infinity</item>
+ <item>@string/pref_camera_focusmode_label_macro</item>
+ </string-array>
+
+ <string-array name="pref_camera2_recordlocation_entryvalues" translatable="false">
+ <item>off</item>
+ <item>on</item>
+ </string-array>
+
+ <array name="pref_camera2_recordlocation_entries" translatable="false">
+ <item>@string/setting_off</item>
+ <item>@string/setting_on</item>
+ </array>
+
+ <array name="pref_camera2_recordlocation_labels" translatable="false">
+ <item>@string/pref_camera_location_label</item>
+ <item>@string/pref_camera_location_label</item>
+ </array>
+
+ <array name="pref_camera2_recordlocation_icons" translatable="false">
+ <item>@drawable/ic_location_off</item>
+ <item>@drawable/ic_location</item>
+ </array>
+
+ <array name="pref_camera2_recordlocation_largeicons" translatable="false">
+ <item>@drawable/ic_location_off</item>
+ <item>@drawable/ic_location</item>
+ </array>
+
+ <array name="pref_camera2_id_entries" translatable="false">
+ <item>@string/pref_camera_id_entry_back</item>
+ <item>@string/pref_camera_id_entry_front</item>
+ </array>
+
+ <array name="pref_camera2_id_labels" translatable="false">
+ <item>@string/pref_camera_id_label_back</item>
+ <item>@string/pref_camera_id_label_front</item>
+ </array>
+
+ <array name="pref_camera2_id_icons" translatable="false">
+ <item>@drawable/ic_switch_back</item>
+ <item>@drawable/ic_switch_front</item>
+ </array>
+
+ <array name="pref_camera2_id_largeicons" translatable="false">
+ <item>@drawable/ic_switch_back</item>
+ <item>@drawable/ic_switch_front</item>
+ </array>
+
+ <string-array name="pref_camera2_timer_sound_entries" translatable="false">
+ <item>@string/setting_off</item>
+ <item>@string/setting_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_timer_sound_entryvalues" translatable="false">
+ <item>@string/setting_off_value</item>
+ <item>@string/setting_on_value</item>
+ </string-array>
+
+ <!-- Icons for exposure compensation -->
+ <array name="pref_camera2_exposure_icons" translatable="false">
+ <item>@drawable/ic_exposure_n3</item>
+ <item>@drawable/ic_exposure_n2</item>
+ <item>@drawable/ic_exposure_n1</item>
+ <item>@drawable/ic_exposure_0</item>
+ <item>@drawable/ic_exposure_p1</item>
+ <item>@drawable/ic_exposure_p2</item>
+ <item>@drawable/ic_exposure_p3</item>
+ </array>
+
+ <!-- Labels for Countdown timer -->
+ <string-array name="pref_camera2_countdown_labels">
+ <item>@string/pref_camera_countdown_label_off</item>
+ <item>@string/pref_camera_countdown_label_one</item>
+ <item>@string/pref_camera_countdown_label_three</item>
+ <item>@string/pref_camera_countdown_label_ten</item>
+ <item>@string/pref_camera_countdown_label_fifteen</item>
+ </string-array>
+
+ <!-- Camera Preferences JPEG quality dialog box entries -->
+ <string-array name="pref_camera2_jpegquality_entries" translatable="false">
+ <item>@string/pref_camera_jpegquality_entry_0</item>
+ <item>@string/pref_camera_jpegquality_entry_1</item>
+ <item>@string/pref_camera_jpegquality_entry_2</item>
+ </string-array>
+
+ <string-array name="pref_camera2_jpegquality_entryvalues" translatable="false">
+ <item>55</item>
+ <item>85</item>
+ <item>100</item>
+ </string-array>
+
+ <!-- Rough estimates of jpeg compression ratio corresponding to qualities defined above. -->
+ <integer-array name="pref_camera2_jpegquality_compression_ratio">
+ <item>48</item>
+ <item>20</item>
+ <item>6</item>
+ </integer-array>
+
+ <!-- Camera Preferences ISO dialog box entries -->
+ <string-array name="pref_camera2_iso_entries">
+ <item>@string/pref_camera_iso_entry_auto</item>
+ <item>@string/pref_camera_iso_entry_isodeblur</item>
+ <item>@string/pref_camera_iso_entry_iso100</item>
+ <item>@string/pref_camera_iso_entry_iso200</item>
+ <item>@string/pref_camera_iso_entry_iso400</item>
+ <item>@string/pref_camera_iso_entry_iso800</item>
+ <item>@string/pref_camera_iso_entry_iso1600</item>
+ </string-array>
+
+ <!-- Do not localize entryvalues -->
+ <string-array name="pref_camera2_iso_entryvalues">
+ <item>@string/pref_camera_iso_value_auto</item>
+ <item>@string/pref_camera_iso_value_isodeblur</item>
+ <item>@string/pref_camera_iso_value_iso100</item>
+ <item>@string/pref_camera_iso_value_iso200</item>
+ <item>@string/pref_camera_iso_value_iso400</item>
+ <item>@string/pref_camera_iso_value_iso800</item>
+ <item>@string/pref_camera_iso_value_iso1600</item>
+ </string-array>
+
+ <!-- Camera Preferences Auto Exposure dialog box entries -->
+ <string-array name="pref_camera2_autoexposure_entries">
+ <item>@string/pref_camera_autoexposure_entry_frameaverage</item>
+ <item>@string/pref_camera_autoexposure_entry_centerweighted</item>
+ <item>@string/pref_camera_autoexposure_entry_spotmetering</item>
+ </string-array>
+
+ <!-- Do not localize entryvalues -->
+ <string-array name="pref_camera2_autoexposure_entryvalues">
+ <item>@string/pref_camera_autoexposure_value_frameaverage</item>
+ <item>@string/pref_camera_autoexposure_value_centerweighted</item>
+ <item>@string/pref_camera_autoexposure_value_spotmetering</item>
+ </string-array>
+
+ <!-- Camera Preferences Redeye Reduction dialog box entries -->
+ <string-array name="pref_camera2_redeyereduction_entries" translatable="false">
+ <item>@string/pref_camera_redeyereduction_entry_disable</item>
+ <item>@string/pref_camera_redeyereduction_entry_enable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_redeyereduction_entryvalues" translatable="false">
+ <item>disable</item>
+ <item>enable</item>
+ </string-array>
+
+ <!-- Camera Preferences Long Shot dialog box entries -->
+ <string-array name="pref_camera2_longshot_entries" translatable="false">
+ <item>@string/setting_off</item>
+ <item>@string/setting_on</item>
+ </string-array>
+
+ <string-array name="pref_camera2_longshot_entryvalues" translatable="false">
+ <item>@string/setting_off_value</item>
+ <item>@string/setting_on_value</item>
+ </string-array>
+
+ <string-array name="pref_camera2_filter_mode_entries" translatable="false">
+ <item>@string/pref_camera_filter_mode_entry_off</item>
+ <item>@string/pref_camera_filter_mode_entry_on</item>
+ </string-array>
+ <string-array name="pref_camera2_filter_mode_entryvalues" translatable="false">
+ <item>Off</item>
+ <item>On</item>
+ </string-array>
+
+ <string-array name="pref_camera2_filter_mode_icons" translatable="false">
+ <item>@drawable/ic_settings_filter</item>
+ <item>@drawable/ic_settings_filter_on</item>
+ </string-array>
+
+</resources>
diff --git a/res/values/qcomarrays.xml b/res/values/qcomarrays.xml
index 3772e17..2b565fd 100644
--- a/res/values/qcomarrays.xml
+++ b/res/values/qcomarrays.xml
@@ -823,46 +823,4 @@
<item>0</item>
<item>1</item>
</string-array>
-
- <string-array name="pref_camera_camera2_entries" translatable="true">
- <item>@string/pref_camera_camera2_entry_enable</item>
- <item>@string/pref_camera_camera2_entry_disable</item>
- </string-array>
-
- <string-array name="pref_camera_camera2_entryvalues" translatable="false">
- <item>@string/pref_camera_camera2_value_enable</item>
- <item>@string/pref_camera_camera2_value_disable</item>
- </string-array>
-
- <string-array name="pref_camera_dual_camera_entries" translatable="true">
- <item>@string/pref_camera_dual_camera_entry_dual</item>
- <item>@string/pref_camera_dual_camera_entry_bayer</item>
- <item>@string/pref_camera_dual_camera_entry_mono</item>
- </string-array>
-
- <string-array name="pref_camera_dual_camera_entryvalues" translatable="false">
- <item>@string/pref_camera_dual_camera_value_dual</item>
- <item>@string/pref_camera_dual_camera_value_bayer</item>
- <item>@string/pref_camera_dual_camera_value_mono</item>
- </string-array>
-
- <string-array name="pref_camera_mono_preview_entries" translatable="true">
- <item>@string/pref_camera_mono_preview_entry_on</item>
- <item>@string/pref_camera_mono_preview_entry_off</item>
- </string-array>
-
- <string-array name="pref_camera_mono_preview_entryvalues" translatable="false">
- <item>@string/pref_camera_mono_preview_value_on</item>
- <item>@string/pref_camera_mono_preview_value_off</item>
- </string-array>
-
- <string-array name="pref_camera_clearsight_entries" translatable="true">
- <item>@string/pref_camera_clearsight_entry_on</item>
- <item>@string/pref_camera_clearsight_entry_off</item>
- </string-array>
-
- <string-array name="pref_camera_clearsight_entryvalues" translatable="false">
- <item>@string/pref_camera_clearsight_value_on</item>
- <item>@string/pref_camera_clearsight_value_off</item>
- </string-array>
</resources>
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index b0c84b7..6acae82 100644
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -418,7 +418,6 @@
<!-- HDR mode -->
<string name="pref_camera_hdr_mode_title">HDR mode</string>
<string name="pref_camera_hdr_mode_default" translatable="false">hdr-mode-multiframe</string>
-
<string name="pref_camera_hdr_mode_entry_sensor">Sensor HDR</string>
<string name="pref_camera_hdr_mode_entry_multi_frame">Multi-frame HDR</string>
@@ -533,41 +532,37 @@
<string name="pref_camera_dis_value_disable" translatable="false">disable</string>
- <string name="pref_camera_camera2_title">Camera2 Mode</string>
- <string name="pref_camera_camera2_default">disable</string>
- <string name="pref_camera_camera2_entry_enable">Enable</string>
- <string name="pref_camera_camera2_entry_disable">Disable</string>
-
- <string name="pref_camera_camera2_value_enable">enable</string>
- <string name="pref_camera_camera2_value_disable">disable</string>
-
- <string name="pref_camera_dual_camera_title">Dual Camera Mode</string>
- <string name="pref_camera_dual_camera_default">dual</string>
- <string name="pref_camera_dual_camera_entry_dual">Dual-camera Linked</string>
- <string name="pref_camera_dual_camera_entry_bayer">Single Bayer Camera</string>
- <string name="pref_camera_dual_camera_entry_mono">Single Mono Camera</string>
-
- <string name="pref_camera_dual_camera_value_dual">dual</string>
- <string name="pref_camera_dual_camera_value_bayer">bayer</string>
- <string name="pref_camera_dual_camera_value_mono">mono</string>
-
- <string name="pref_camera_mono_preview_title">Mono Preview</string>
- <string name="pref_camera_mono_preview_default">off</string>
- <string name="pref_camera_mono_preview_entry_on">On</string>
- <string name="pref_camera_mono_preview_entry_off">Off</string>
-
- <string name="pref_camera_mono_preview_value_on">on</string>
- <string name="pref_camera_mono_preview_value_off">off</string>
-
- <string name="pref_camera_clearsight_title">ClearSight</string>
- <string name="pref_camera_clearsight_default" translatable="false">off</string>
- <string name="pref_camera_clearsight_entry_on">On</string>
- <string name="pref_camera_clearsight_entry_off">Off</string>
-
- <string name="pref_camera_clearsight_value_on" translatable="false">on</string>
- <string name="pref_camera_clearsight_value_off" translatable="false">off</string>
+ <string name="pref_camera2_camera2_title" translatable="true">Camera2 Mode</string>
+ <string name="pref_camera2_camera2_entry_enable" translatable="true">Enable</string>
+ <string name="pref_camera2_camera2_entry_disable" translatable="true">Disable</string>
+ <string name="pref_camera2_camera2_default" translatable="false">disable</string>
+ <string name="pref_camera2_camera2_value_enable" translatable="false">enable</string>
+ <string name="pref_camera2_camera2_value_disable" translatable="false">disable</string>
+
+ <string name="pref_camera2_dual_camera_title" translatable="true">Dual Camera Mode</string>
+ <string name="pref_camera2_dual_camera_entry_dual" translatable="true">Dual-camera Linked</string>
+ <string name="pref_camera2_dual_camera_entry_bayer" translatable="true">Single Bayer Camera</string>
+ <string name="pref_camera2_dual_camera_entry_mono" translatable="true">Single Mono Camera</string>
+ <string name="pref_camera2_dual_camera_default" translatable="false">1</string>
+
+ <string name="pref_camera2_mono_preview_title" translatable="true">Mono Preview</string>
+ <string name="pref_camera2_mono_preview_entry_on" translatable="true">On</string>
+ <string name="pref_camera2_mono_preview_entry_off" translatable="true">Off</string>
+ <string name="pref_camera2_mono_preview_default" translatable="false">off</string>
+ <string name="pref_camera2_mono_preview_value_on" translatable="false">on</string>
+ <string name="pref_camera2_mono_preview_value_off" translatable="false">off</string>
+
+ <string name="pref_camera2_clearsight_title" translatable="true">ClearSight</string>
+ <string name="pref_camera2_clearsight_default" translatable="false">off</string>
+ <string name="pref_camera2_clearsight_entry_on" translatable="false">On</string>
+ <string name="pref_camera2_clearsight_entry_off" translatable="false">Off</string>
+
+ <string name="pref_camera2_clearsight_value_on" translatable="false">on</string>
+ <string name="pref_camera2_clearsight_value_off" translatable="false">off</string>
<string name="clearsight_capture_success">ClearSight capture successful</string>
<string name="clearsight_capture_fail">ClearSight capture failed</string>
+ <string name="pref_camera2_scenemode_default" translatable="false">0</string>
+
</resources>
diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml
index 0507472..12fe714 100644
--- a/res/xml/camera_preferences.xml
+++ b/res/xml/camera_preferences.xml
@@ -366,30 +366,9 @@
camera:singleIcon="@drawable/ic_settings_bright_screen"
camera:entryValues="@array/pref_switch_entryvalues" />
<ListPreference
- camera:key="pref_camera_camera2_key"
- camera:defaultValue="@string/pref_camera_camera2_default"
- camera:title="@string/pref_camera_camera2_title"
- camera:entries="@array/pref_camera_camera2_entries"
- camera:entryValues="@array/pref_camera_camera2_entryvalues" />
- <ListPreference
- camera:key="pref_camera_dual_camera_key"
- camera:defaultValue="@string/pref_camera_dual_camera_default"
- camera:title="@string/pref_camera_dual_camera_title"
- camera:entries="@array/pref_camera_dual_camera_entries"
- camera:entryValues="@array/pref_camera_dual_camera_entryvalues" />
-
- <ListPreference
- camera:defaultValue="@string/pref_camera_mono_preview_default"
- camera:entries="@array/pref_camera_mono_preview_entries"
- camera:entryValues="@array/pref_camera_mono_preview_entryvalues"
- camera:key="pref_camera_mono_preview_key"
- camera:title="@string/pref_camera_mono_preview_title" />
-
- <ListPreference
- camera:defaultValue="@string/pref_camera_clearsight_default"
- camera:entries="@array/pref_camera_clearsight_entries"
- camera:entryValues="@array/pref_camera_clearsight_entryvalues"
- camera:key="pref_camera_clearsight_key"
- camera:title="@string/pref_camera_clearsight_title" />
-
+ camera:key="pref_camera2_camera2_key"
+ camera:defaultValue="@string/pref_camera2_camera2_default"
+ camera:title="@string/pref_camera2_camera2_title"
+ camera:entries="@array/pref_camera2_camera2_entries"
+ camera:entryValues="@array/pref_camera2_camera2_entryvalues" />
</PreferenceGroup>
diff --git a/res/xml/capture_preferences.xml b/res/xml/capture_preferences.xml
new file mode 100644
index 0000000..59803ae
--- /dev/null
+++ b/res/xml/capture_preferences.xml
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<PreferenceGroup
+ xmlns:camera="http://schemas.android.com/apk/res/org.codeaurora.snapcam"
+ camera:title="@string/pref_camera_settings_category">
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_flashmode_default"
+ camera:entries="@array/pref_camera2_flashmode_entries"
+ camera:entryValues="@array/pref_camera2_flashmode_entryvalues"
+ camera:icons="@array/pref_camera2_flashmode_icons"
+ camera:key="pref_camera2_flashmode_key"
+ camera:labelList="@array/pref_camera2_flashmode_labels"
+ camera:largeIcons="@array/pref_camera2_flashmode_largeicons"
+ camera:singleIcon="@drawable/ic_settings_flash"
+ camera:title="@string/pref_camera_flashmode_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_whitebalance_default"
+ camera:entries="@array/pref_camera2_whitebalance_entries"
+ camera:entryValues="@array/pref_camera2_whitebalance_entryvalues"
+ camera:icons="@array/pref_camera2_whitebalance_icons"
+ camera:key="pref_camera2_whitebalance_key"
+ camera:labelList="@array/pref_camera2_whitebalance_labels"
+ camera:largeIcons="@array/pref_camera2_whitebalance_largeicons"
+ camera:singleIcon="@drawable/ic_settings_lightsource"
+ camera:title="@string/pref_camera_whitebalance_title"/>
+
+ <RecordLocationPreference
+ camera:defaultValue="@string/pref_camera_recordlocation_default"
+ camera:entries="@array/pref_camera2_recordlocation_entries"
+ camera:entryValues="@array/pref_camera2_recordlocation_entryvalues"
+ camera:icons="@array/pref_camera2_recordlocation_icons"
+ camera:key="pref_camera2_recordlocation_key"
+ camera:labelList="@array/pref_camera2_recordlocation_labels"
+ camera:largeIcons="@array/pref_camera2_recordlocation_largeicons"
+ camera:singleIcon="@drawable/ic_settings_location"
+ camera:title="@string/pref_camera_recordlocation_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_jpegquality_default"
+ camera:entries="@array/pref_camera2_jpegquality_entries"
+ camera:entryValues="@array/pref_camera2_jpegquality_entryvalues"
+ camera:key="pref_camera2_jpegquality_key"
+ camera:singleIcon="@drawable/ic_settings_quality"
+ camera:title="@string/pref_camera_jpegquality_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_savepath_default"
+ camera:entries="@array/pref_camera2_savepath_entries"
+ camera:entryValues="@array/pref_camera2_savepath_entryvalues"
+ camera:key="pref_camera2_savepath_key"
+ camera:singleIcon="@drawable/ic_settings_storage"
+ camera:title="@string/pref_camera_savepath_title"/>
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_camera2_default"
+ camera:entries="@array/pref_camera2_camera2_entries"
+ camera:entryValues="@array/pref_camera2_camera2_entryvalues"
+ camera:key="pref_camera2_camera2_key"
+ camera:title="@string/pref_camera2_camera2_title"/>
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_dual_camera_default"
+ camera:dependencyList="@array/pref_camera2_dual_camera_dependencylist"
+ camera:entries="@array/pref_camera2_dual_camera_entries"
+ camera:entryValues="@array/pref_camera2_dual_camera_entryvalues"
+ camera:key="pref_camera2_dual_camera_key"
+ camera:title="@string/pref_camera2_dual_camera_title"/>
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_mono_preview_default"
+ camera:entries="@array/pref_camera2_mono_preview_entries"
+ camera:entryValues="@array/pref_camera2_mono_preview_entryvalues"
+ camera:key="pref_camera2_mono_preview_key"
+ camera:title="@string/pref_camera2_mono_preview_title"/>
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_clearsight_default"
+ camera:entries="@array/pref_camera2_clearsight_entries"
+ camera:entryValues="@array/pref_camera2_clearsight_entryvalues"
+ camera:key="pref_camera2_clearsight_key"
+ camera:title="@string/pref_camera2_clearsight_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_coloreffect_default"
+ camera:entries="@array/pref_camera2_coloreffect_entries"
+ camera:entryValues="@array/pref_camera2_coloreffect_entryvalues"
+ camera:key="pref_camera2_coloreffect_key"
+ camera:largeIcons="@array/pref_camera2_coloreffect_icons"
+ camera:singleIcon="@drawable/ic_settings_filter"
+ camera:thumbnails="@array/pref_camera2_coloreffect_thumbnails"
+ camera:title="@string/pref_camera_coloreffect_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera2_scenemode_default"
+ camera:dependencyList="@array/pref_camera2_scenemode_dependencylist"
+ camera:entries="@array/pref_camera2_scenemode_entries"
+ camera:entryValues="@array/pref_camera2_scenemode_entryvalues"
+ camera:key="pref_camera2_scenemode_key"
+ camera:singleIcon="@drawable/ic_settings_scenemode"
+ camera:thumbnails="@array/pref_camera2_scenemode_thumbnails"
+ camera:title="@string/pref_camera_scenemode_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_redeyereduction_default"
+ camera:entries="@array/pref_camera2_redeyereduction_entries"
+ camera:entryValues="@array/pref_camera2_redeyereduction_entryvalues"
+ camera:key="pref_camera2_redeyereduction_key"
+ camera:singleIcon="@drawable/ic_settings_redeye"
+ camera:title="@string/pref_camera_redeyereduction_title"/>
+
+ <IconListPreference
+ camera:defaultValue="@string/pref_camera_id_default"
+ camera:entries="@array/pref_camera2_id_entries"
+ camera:icons="@array/pref_camera2_id_icons"
+ camera:key="pref_camera2_id_key"
+ camera:labelList="@array/pref_camera2_id_labels"
+ camera:largeIcons="@array/pref_camera2_id_largeicons"
+ camera:title="@string/pref_camera_id_title"/>
+
+ <IconListPreference
+ camera:entries="@array/pref_camera2_picturesize_entries"
+ camera:entryValues="@array/pref_camera2_picturesize_entryvalues"
+ camera:key="pref_camera2_picturesize_key"
+ camera:singleIcon="@drawable/ic_settings_picturesize"
+ camera:title="@string/pref_camera_picturesize_title"/>
+</PreferenceGroup>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 19c80a7..543e672 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -168,8 +168,6 @@ public class CameraActivity extends Activity
/** Whether onResume should reset the view to the preview. */
private boolean mResetToPreviewOnResume = true;
- public static boolean CAMERA_2_ON = false;
-
// Supported operations at FilmStripView. Different data has different
// set of supported operations.
private static final int SUPPORT_DELETE = 1 << 0;
@@ -1491,6 +1489,8 @@ public class CameraActivity extends Activity
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
+ SettingsManager.createInstance(this);
+
LayoutInflater inflater = getLayoutInflater();
View rootLayout = inflater.inflate(R.layout.camera, null, false);
mCameraRootFrame = (FrameLayout)rootLayout.findViewById(R.id.camera_root_frame);
@@ -1525,10 +1525,9 @@ public class CameraActivity extends Activity
moduleIndex = ModuleSwitcher.PHOTO_MODULE_INDEX;
}
}
- SharedPreferences pref = PreferenceManager
- .getDefaultSharedPreferences(this);
- CAMERA_2_ON = pref.getBoolean(CameraSettings.KEY_CAMERA2, false);
- if (CAMERA_2_ON && moduleIndex == ModuleSwitcher.PHOTO_MODULE_INDEX)
+
+ boolean cam2on = SettingsManager.getInstance().isCamera2On();
+ if (cam2on && moduleIndex == ModuleSwitcher.PHOTO_MODULE_INDEX)
moduleIndex = ModuleSwitcher.CAPTURE_MODULE_INDEX;
setContentView(R.layout.camera_filmstrip);
@@ -2017,7 +2016,9 @@ public class CameraActivity extends Activity
@Override
public void onModuleSelected(int moduleIndex) {
- if (moduleIndex == 0 && CAMERA_2_ON) moduleIndex = ModuleSwitcher.CAPTURE_MODULE_INDEX;
+ boolean cam2on = SettingsManager.getInstance().isCamera2On();
+ if (cam2on && moduleIndex == ModuleSwitcher.PHOTO_MODULE_INDEX)
+ moduleIndex = ModuleSwitcher.CAPTURE_MODULE_INDEX;
if (mCurrentModuleIndex == moduleIndex) {
if (mCurrentModuleIndex != ModuleSwitcher.CAPTURE_MODULE_INDEX) {
return;
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index a7fade7..3d2b3b6 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -243,11 +243,6 @@ public class CameraSettings {
public static final String KEY_REQUEST_PERMISSION = "request_permission";
- public static final String KEY_CAMERA2 = "pref_camera_camera2_key";
- public static final String KEY_DUAL_CAMERA = "pref_camera_dual_camera_key";
- public static final String KEY_MONO_PREVIEW = "pref_camera_mono_preview_key";
- public static final String KEY_CLEARSIGHT = "pref_camera_clearsight_key";
-
public static final String KEY_SELFIE_FLASH = "pref_selfie_flash_key";
public static final String EXPOSURE_DEFAULT_VALUE = "0";
@@ -1115,7 +1110,7 @@ public class CameraSettings {
return false;
}
- private void filterUnsupportedOptions(PreferenceGroup group,
+ public static void filterUnsupportedOptions(PreferenceGroup group,
ListPreference pref, List<String> supported) {
// Remove the preference if the parameter is not supported or there is
@@ -1144,7 +1139,7 @@ public class CameraSettings {
resetIfInvalid(pref);
}
- private void resetIfInvalid(ListPreference pref) {
+ private static void resetIfInvalid(ListPreference pref) {
// Set the value to the first entry if it is invalid.
String value = pref.getValue();
if (pref.findIndexOfValue(value) == NOT_FOUND) {
@@ -1267,6 +1262,17 @@ public class CameraSettings {
return Integer.parseInt(pref.getString(KEY_CAMERA_ID, rearCameraId));
}
+ public static int getInitialCameraId(SharedPreferences pref) {
+ int id = Integer.parseInt(pref.getString(KEY_CAMERA_ID, "0"));
+ if (id == CaptureModule.BAYER_ID) {
+ int mode = Integer.parseInt(pref.getString(SettingsManager.KEY_DUAL_CAMERA, "1"));
+ if (mode == CaptureModule.MONO_MODE) return CaptureModule.MONO_ID;
+ else return CaptureModule.BAYER_ID;
+ } else {
+ return CaptureModule.FRONT_ID;
+ }
+ }
+
public static void writePreferredCameraId(SharedPreferences pref,
int cameraId) {
Editor editor = pref.edit();
diff --git a/src/com/android/camera/CaptureMenu.java b/src/com/android/camera/CaptureMenu.java
deleted file mode 100644
index 8b8f5c3..0000000
--- a/src/com/android/camera/CaptureMenu.java
+++ /dev/null
@@ -1,571 +0,0 @@
-/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- *
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.camera;
-
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.graphics.Rect;
-import android.preference.PreferenceManager;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewPropertyAnimator;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.Toast;
-
-import com.android.camera.ui.CameraControls;
-import com.android.camera.ui.CountdownTimerPopup;
-import com.android.camera.ui.ListMenu;
-import com.android.camera.ui.ListSubMenu;
-import com.android.camera.ui.ModuleSwitcher;
-import com.android.camera.ui.RotateTextToast;
-
-import org.codeaurora.snapcam.R;
-
-import java.util.Locale;
-
-public class CaptureMenu extends MenuController
- implements ListMenu.Listener,
- CountdownTimerPopup.Listener,
- ListSubMenu.Listener {
- private static final int POPUP_NONE = 0;
- private static final int POPUP_FIRST_LEVEL = 1;
- private static final int POPUP_SECOND_LEVEL = 2;
- private static final int POPUP_IN_ANIMATION_SLIDE = 3;
- private static final int POPUP_IN_ANIMATION_FADE = 4;
- private static final int DEVELOPER_MENU_TOUCH_COUNT = 10;
- private static final int ANIMATION_DURATION = 300;
- private static final String TAG = "SnapCam_CaptureMenu";
- private String[] mOtherKeys1;
- private String[] mOtherKeys2;
- private ListMenu mListMenu;
- private CaptureUI mUI;
- private int mPopupStatus;
- private ListSubMenu mListSubMenu;
- private CameraActivity mActivity;
- private int privateCounter = 0;
-
- public CaptureMenu(CameraActivity activity, CaptureUI ui) {
- super(activity);
- mUI = ui;
- mActivity = activity;
- }
-
- // Return true if the preference has the specified key but not the value.
- private static boolean notSame(ListPreference pref, String key, String value) {
- return (key.equals(pref.getKey()) && !value.equals(pref.getValue()));
- }
-
- // Return true if the preference has the specified key and the value.
- private static boolean same(ListPreference pref, String key, String value) {
- return (key.equals(pref.getKey()) && value.equals(pref.getValue()));
- }
-
- public void initialize(PreferenceGroup group) {
- super.initialize(group);
- mListSubMenu = null;
- mListMenu = null;
- mPopupStatus = POPUP_NONE;
-
- mOtherKeys1 = new String[]{
- CameraSettings.KEY_FLASH_MODE,
- CameraSettings.KEY_RECORD_LOCATION,
- CameraSettings.KEY_JPEG_QUALITY,
- CameraSettings.KEY_CAMERA_SAVEPATH,
- CameraSettings.KEY_WHITE_BALANCE,
- CameraSettings.KEY_CAMERA2,
- CameraSettings.KEY_DUAL_CAMERA,
- CameraSettings.KEY_CLEARSIGHT
- };
-
- //Todo: 2nd string to contain only developer settings
- mOtherKeys2 = new String[]{
- CameraSettings.KEY_FLASH_MODE,
- CameraSettings.KEY_RECORD_LOCATION,
- CameraSettings.KEY_JPEG_QUALITY,
- CameraSettings.KEY_CAMERA_SAVEPATH,
- CameraSettings.KEY_WHITE_BALANCE,
- CameraSettings.KEY_CAMERA2,
- CameraSettings.KEY_DUAL_CAMERA,
- CameraSettings.KEY_CLEARSIGHT,
- CameraSettings.KEY_MONO_PREVIEW
- };
-
- }
-
- @Override
- // Hit when an item in a popup gets selected
- public void onListPrefChanged(ListPreference pref) {
- onSettingChanged(pref);
- closeView();
- }
-
- public boolean handleBackKey() {
- if (mPopupStatus == POPUP_NONE)
- return false;
- if (mPopupStatus == POPUP_FIRST_LEVEL) {
- animateSlideOut(mListMenu, 1);
- } else if (mPopupStatus == POPUP_SECOND_LEVEL) {
- animateFadeOut(mListSubMenu, 2);
- ((ListMenu) mListMenu).resetHighlight();
- }
- return true;
- }
-
- public void tryToCloseSubList() {
- if (mListMenu != null)
- ((ListMenu) mListMenu).resetHighlight();
-
- if (mPopupStatus == POPUP_SECOND_LEVEL) {
- mUI.dismissLevel2();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- }
-
- private void animateFadeOut(final ListView v, final int level) {
- if (v == null || mPopupStatus == POPUP_IN_ANIMATION_FADE)
- return;
- mPopupStatus = POPUP_IN_ANIMATION_FADE;
-
- ViewPropertyAnimator vp = v.animate();
- vp.alpha(0f).setDuration(ANIMATION_DURATION);
- vp.setListener(new AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
-
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (level == 1) {
- mUI.dismissLevel1();
- initializePopup();
- mPopupStatus = POPUP_NONE;
- mUI.cleanupListview();
- } else if (level == 2) {
- mUI.dismissLevel2();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- if (level == 1) {
- mUI.dismissLevel1();
- initializePopup();
- mPopupStatus = POPUP_NONE;
- mUI.cleanupListview();
- } else if (level == 2) {
- mUI.dismissLevel2();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
-
- }
- });
- vp.start();
- }
-
- private void animateSlideOut(final ListView v, final int level) {
- if (v == null || mPopupStatus == POPUP_IN_ANIMATION_SLIDE)
- return;
- mPopupStatus = POPUP_IN_ANIMATION_SLIDE;
-
- ViewPropertyAnimator vp = v.animate();
- if (View.LAYOUT_DIRECTION_RTL == TextUtils
- .getLayoutDirectionFromLocale(Locale.getDefault())) {
- switch (mUI.getOrientation()) {
- case 0:
- vp.translationXBy(v.getWidth());
- break;
- case 90:
- vp.translationYBy(-2 * v.getHeight());
- break;
- case 180:
- vp.translationXBy(-2 * v.getWidth());
- break;
- case 270:
- vp.translationYBy(v.getHeight());
- break;
- }
- } else {
- switch (mUI.getOrientation()) {
- case 0:
- vp.translationXBy(-v.getWidth());
- break;
- case 90:
- vp.translationYBy(2 * v.getHeight());
- break;
- case 180:
- vp.translationXBy(2 * v.getWidth());
- break;
- case 270:
- vp.translationYBy(-v.getHeight());
- break;
- }
- }
- vp.setListener(new AnimatorListener() {
- @Override
- public void onAnimationStart(Animator animation) {
- }
-
- @Override
- public void onAnimationRepeat(Animator animation) {
-
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- if (level == 1) {
- mUI.dismissLevel1();
- initializePopup();
- mPopupStatus = POPUP_NONE;
- mUI.cleanupListview();
- } else if (level == 2) {
- mUI.dismissLevel2();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- }
-
- @Override
- public void onAnimationCancel(Animator animation) {
- if (level == 1) {
- mUI.dismissLevel1();
- initializePopup();
- mPopupStatus = POPUP_NONE;
- mUI.cleanupListview();
- } else if (level == 2) {
- mUI.dismissLevel2();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
-
- }
- });
- vp.setDuration(ANIMATION_DURATION).start();
- }
-
- public void animateFadeIn(final ListView v) {
- ViewPropertyAnimator vp = v.animate();
- vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
- vp.start();
- }
-
- public void animateSlideIn(final View v, int delta, boolean forcePortrait) {
- int orientation = mUI.getOrientation();
- if (!forcePortrait)
- orientation = 0;
-
- ViewPropertyAnimator vp = v.animate();
- float dest;
- if (View.LAYOUT_DIRECTION_RTL == TextUtils
- .getLayoutDirectionFromLocale(Locale.getDefault())) {
- switch (orientation) {
- case 0:
- dest = v.getX();
- v.setX(-(dest - delta));
- vp.translationX(dest);
- break;
- case 90:
- dest = v.getY();
- v.setY(-(dest + delta));
- vp.translationY(dest);
- break;
- case 180:
- dest = v.getX();
- v.setX(-(dest + delta));
- vp.translationX(dest);
- break;
- case 270:
- dest = v.getY();
- v.setY(-(dest - delta));
- vp.translationY(dest);
- break;
- }
- } else {
- switch (orientation) {
- case 0:
- dest = v.getX();
- v.setX(dest - delta);
- vp.translationX(dest);
- break;
- case 90:
- dest = v.getY();
- v.setY(dest + delta);
- vp.translationY(dest);
- break;
- case 180:
- dest = v.getX();
- v.setX(dest + delta);
- vp.translationX(dest);
- break;
- case 270:
- dest = v.getY();
- v.setY(dest - delta);
- vp.translationY(dest);
- break;
- }
- }
- vp.setDuration(ANIMATION_DURATION).start();
- }
-
- public boolean isOverMenu(MotionEvent ev) {
- if (mPopupStatus == POPUP_NONE
- || mPopupStatus == POPUP_IN_ANIMATION_SLIDE
- || mPopupStatus == POPUP_IN_ANIMATION_FADE)
- return false;
- if (mUI.getMenuLayout() == null)
- return false;
- Rect rec = new Rect();
- mUI.getMenuLayout().getChildAt(0).getHitRect(rec);
- return rec.contains((int) ev.getX(), (int) ev.getY());
- }
-
- public boolean isOverPreviewMenu(MotionEvent ev) {
- return false;
- }
-
- public boolean isMenuBeingShown() {
- return mPopupStatus != POPUP_NONE;
- }
-
- public boolean isMenuBeingAnimated() {
- return mPopupStatus == POPUP_IN_ANIMATION_SLIDE || mPopupStatus == POPUP_IN_ANIMATION_FADE;
- }
-
- public boolean isPreviewMenuBeingShown() {
- return false;
- }
-
- public boolean isPreviewMenuBeingAnimated() {
- return false;
- }
-
- public boolean sendTouchToPreviewMenu(MotionEvent ev) {
- return mUI.sendTouchToPreviewMenu(ev);
- }
-
- public boolean sendTouchToMenu(MotionEvent ev) {
- return mUI.sendTouchToMenu(ev);
- }
-
- @Override
- public void overrideSettings(final String... keyvalues) {
- super.overrideSettings(keyvalues);
- if ((mListMenu == null))
- initializePopup();
- mListMenu.overrideSettings(keyvalues);
- }
-
- protected void initializePopup() {
- LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- ListMenu listMenu = (ListMenu) inflater.inflate(
- R.layout.list_menu, null, false);
-
- listMenu.setSettingChangedListener(this);
-
- String[] keys = mOtherKeys1;
- if (mActivity.isDeveloperMenuEnabled())
- keys = mOtherKeys2;
- listMenu.initialize(mPreferenceGroup, keys);
- mListMenu = listMenu;
-
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_DUAL_CAMERA);
- if (!pref.getValue().equals("dual")) {
- setPreference(CameraSettings.KEY_MONO_PREVIEW, "off");
- mListMenu.setPreferenceEnabled(CameraSettings.KEY_MONO_PREVIEW, false);
- setPreference(CameraSettings.KEY_CLEARSIGHT, "off");
- mListMenu.setPreferenceEnabled(CameraSettings.KEY_CLEARSIGHT, false);
- }
-
- if (mListener != null) {
- mListener.onSharedPreferenceChanged();
- }
- }
-
- public void initSwitchItem(final String prefKey, View switcher) {
- final IconListPreference pref =
- (IconListPreference) mPreferenceGroup.findPreference(prefKey);
- if (pref == null)
- return;
-
- int[] iconIds = pref.getLargeIconIds();
- int resid = -1;
- int index = pref.findIndexOfValue(pref.getValue());
- if (!pref.getUseSingleIcon() && iconIds != null) {
- // Each entry has a corresponding icon.
- resid = iconIds[index];
- } else {
- // The preference only has a single icon to represent it.
- resid = pref.getSingleIcon();
- }
- ((ImageView) switcher).setImageResource(resid);
- switcher.setVisibility(View.VISIBLE);
- mPreferences.add(pref);
- mPreferenceMap.put(pref, switcher);
- switcher.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- IconListPreference pref = (IconListPreference) mPreferenceGroup
- .findPreference(prefKey);
- if (pref == null)
- return;
- int index = pref.findIndexOfValue(pref.getValue());
- CharSequence[] values = pref.getEntryValues();
- index = (index + 1) % values.length;
- pref.setValueIndex(index);
- ((ImageView) v).setImageResource(
- ((IconListPreference) pref).getLargeIconIds()[index]);
- if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
- mListener.onCameraPickerClicked(index);
- reloadPreference(pref);
- onSettingChanged(pref);
- }
- });
- }
-
- public void openFirstLevel() {
- if (isMenuBeingShown() || CameraControls.isAnimating()) {
- return;
- }
- if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) {
- initializePopup();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- mUI.showPopup(mListMenu, 1, true);
- }
-
- @Override
- // Hit when an item in the first-level popup gets selected, then bring up
- // the second-level popup
- public void onPreferenceClicked(ListPreference pref) {
- onPreferenceClicked(pref, 0);
- }
-
- public void onPreferenceClicked(ListPreference pref, int y) {
- if (!mActivity.isDeveloperMenuEnabled()) {
- if (pref.getKey().equals(CameraSettings.KEY_REDEYE_REDUCTION)) {
- privateCounter++;
- if (privateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
- mActivity.enableDeveloperMenu();
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(mActivity);
- prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
- RotateTextToast.makeText(mActivity,
- "Camera developer option is enabled now", Toast.LENGTH_SHORT).show();
- }
- } else {
- privateCounter = 0;
- }
- }
-
- LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- ListSubMenu basic = (ListSubMenu) inflater.inflate(
- R.layout.list_sub_menu, null, false);
- basic.initialize(pref, y);
- basic.setSettingChangedListener(this);
- basic.setAlpha(0f);
- mListSubMenu = basic;
- mUI.removeLevel2();
- if (mPopupStatus == POPUP_SECOND_LEVEL) {
- mUI.showPopup(mListSubMenu, 2, false);
- } else {
- mUI.showPopup(mListSubMenu, 2, true);
- }
- mPopupStatus = POPUP_SECOND_LEVEL;
- }
-
- public void onListMenuTouched() {
- mUI.removeLevel2();
- }
-
- public void removeAllView() {
- if (mUI != null)
- mUI.removeLevel2();
-
- if (mListMenu != null) {
- mUI.dismissLevel1();
- mPopupStatus = POPUP_NONE;
- }
- mUI.cleanupListview();
- }
-
- public void closeView() {
- if (mUI != null)
- mUI.removeLevel2();
-
- if (mListMenu != null && mPopupStatus != POPUP_NONE)
- animateSlideOut(mListMenu, 1);
- }
-
- public void setPreference(String key, String value) {
- ListPreference pref = mPreferenceGroup.findPreference(key);
- if (pref != null && !value.equals(pref.getValue())) {
- pref.setValue(value);
- reloadPreferences();
- }
- }
-
- @Override
- public void onSettingChanged(ListPreference pref) {
- super.onSettingChanged(pref);
- String key = pref.getKey();
- String value = pref.getValue();
- Log.d(TAG, "" + key + " " + value);
- //Todo: restructure by using switch and create function for each case
- if (key.equals(CameraSettings.KEY_CAMERA2)) {
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(mActivity);
- if (value.equals("enable")) {
- prefs.edit().putBoolean(CameraSettings.KEY_CAMERA2, true).apply();
- CameraActivity.CAMERA_2_ON = true;
- mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
- } else if (value.equals("disable")) {
- prefs.edit().putBoolean(CameraSettings.KEY_CAMERA2, false).apply();
- CameraActivity.CAMERA_2_ON = false;
- mActivity.onModuleSelected(ModuleSwitcher.PHOTO_MODULE_INDEX);
- }
- } else if (key.equals(CameraSettings.KEY_DUAL_CAMERA)) {
- boolean changeMode = CaptureModule.setMode(value);
- if (changeMode) mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
- } else if (key.equals(CameraSettings.KEY_MONO_PREVIEW)) {
- if (value.equals("on")) {
- } else if (value.equals("off")) {
- }
- } else if (key.equals(CameraSettings.KEY_CLEARSIGHT)) {
- // restart module to re-create sessions and callbacks
- mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
- }
- }
-
- public int getOrientation() {
- return mUI == null ? 0 : mUI.getOrientation();
- }
-}
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 90e1794..574fe4d 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -19,22 +19,6 @@
package com.android.camera;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import org.codeaurora.snapcam.R;
-import org.codeaurora.snapcam.filter.ClearSightImageProcessor;
-import org.codeaurora.snapcam.filter.ClearSightNativeEngine.ClearsightImage;
-
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -42,7 +26,6 @@ import android.content.res.Configuration;
import android.graphics.ImageFormat;
import android.graphics.Point;
import android.graphics.Rect;
-import android.graphics.YuvImage;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
@@ -78,11 +61,31 @@ import com.android.camera.PhotoModule.NamedImages.NamedEntity;
import com.android.camera.ui.RotateTextToast;
import com.android.camera.util.CameraUtil;
+import org.codeaurora.snapcam.R;
+import org.codeaurora.snapcam.filter.ClearSightImageProcessor;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
public class CaptureModule implements CameraModule, PhotoController,
- MediaSaveService.Listener, ClearSightImageProcessor.Callback {
+ MediaSaveService.Listener, ClearSightImageProcessor.Callback,
+ SettingsManager.Listener {
public static final int DUAL_MODE = 0;
public static final int BAYER_MODE = 1;
public static final int MONO_MODE = 2;
+ //Todo: Read ids from the device dynamically
+ public static final int BAYER_ID = 0;
+ public static final int MONO_ID = 1;
+ public static final int FRONT_ID = 1;
+ private static final int BACK_MODE = 0;
+ private static final int FRONT_MODE = 1;
private static final int CANCEL_TOUCH_FOCUS_DELAY = 3000;
private static final int OPEN_CAMERA = 0;
private static final int CANCEL_TOUCH_FOCUS = 1;
@@ -117,11 +120,7 @@ public class CaptureModule implements CameraModule, PhotoController,
* Camera state: Waiting for the touch-to-focus to converge.
*/
private static final int STATE_WAITING_TOUCH_FOCUS = 5;
- //Todo: Read ids from the device dynamically
- private static final int BAYER_ID = 0;
- private static final int MONO_ID = 1;
private static final String TAG = "SnapCam_CaptureModule";
- private static int MODE = DUAL_MODE;
static {
ORIENTATIONS.append(Surface.ROTATION_0, 90);
@@ -149,7 +148,6 @@ public class CaptureModule implements CameraModule, PhotoController,
// The degrees of the device rotated clockwise from its natural orientation.
private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
private int mJpegQuality;
- private Map<String, String> mSettings = new HashMap<String, String>();
private boolean mFirstTimeInitialized;
private boolean mInitialized = false;
private boolean mIsLinked = false;
@@ -161,13 +159,11 @@ public class CaptureModule implements CameraModule, PhotoController,
private String[] mCameraId = new String[MAX_NUM_CAM];
private CaptureUI mUI;
private CameraActivity mActivity;
- private PreferenceGroup mPreferenceGroup;
- private ComboPreferences mPreferences;
- private CameraCharacteristics[] mCharacteristics = new CameraCharacteristics[MAX_NUM_CAM];
- private List<Integer> mCharacteristicsIndex;
+ private List<Integer> mCameraIdList;
private float mZoomValue = 1f;
private FocusStateListener mFocusStateListener;
private LocationManager mLocationManager;
+ private SettingsManager mSettingsManager;
/**
* A {@link CameraCaptureSession } for camera preview.
*/
@@ -257,7 +253,7 @@ public class CaptureModule implements CameraModule, PhotoController,
CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED == afState) {
// CONTROL_AE_STATE can be null on some devices
if (aeState == null || (aeState == CaptureResult
- .CONTROL_AE_STATE_CONVERGED) && isFlashOff()) {
+ .CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) {
mState[id] = STATE_PICTURE_TAKEN;
captureStillPicture(id);
} else {
@@ -311,52 +307,7 @@ public class CaptureModule implements CameraModule, PhotoController,
process(result);
}
};
- private final CameraPreference.OnPreferenceChangedListener prefListener = new
- CameraPreference.OnPreferenceChangedListener() {
- @Override
- public void onSharedPreferenceChanged(ListPreference pref) {
- if (mPaused) return;
- if (CameraSettings.KEY_CAMERA_SAVEPATH.equals(pref.getKey())) {
- Storage.setSaveSDCard(
- mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0")
- .equals("1"));
- mActivity.updateStorageSpaceAndHint();
- }
- switch (MODE) {
- case BAYER_MODE:
- applyPreference(0, pref);
- break;
- case MONO_MODE:
- applyPreference(1, pref);
- break;
- case DUAL_MODE:
- applyPreference(0, pref);
- applyPreference(1, pref);
- }
- mUI.overrideSettings(pref.getKey(), null);
- }
-
- @Override
- public void onSharedPreferenceChanged() {
- if (mPaused) return;
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
- mLocationManager.recordLocation(recordLocation);
- }
-
- @Override
- public void onRestorePreferencesClicked() {
- }
-
- @Override
- public void onOverriddenPreferencesClicked() {
- }
-
- @Override
- public void onCameraPickerClicked(int cameraId) {
- }
- };
private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
@Override
@@ -367,7 +318,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mPaused) {
return;
}
- if (MODE == DUAL_MODE && id == BAYER_ID) {
+ if (isBackMode() && getMode() == DUAL_MODE && id == BAYER_ID) {
Message msg = mCameraHandler.obtainMessage(OPEN_CAMERA, MONO_ID);
mCameraHandler.sendMessage(msg);
}
@@ -376,8 +327,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
- mUI.onCameraOpened(mCharacteristics, mCharacteristicsIndex,
- mPreferenceGroup, prefListener);
+ mUI.onCameraOpened(mCameraIdList);
}
});
}
@@ -418,23 +368,22 @@ public class CaptureModule implements CameraModule, PhotoController,
};
- public static boolean setMode(String value) {
- int mode = DUAL_MODE;
- switch (value) {
- case "dual":
- mode = DUAL_MODE;
+ private boolean isBackMode() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID);
+ if (value == null) return true;
+ if (Integer.parseInt(value) == BAYER_ID) return true;
+ return false;
+ }
+
+ private int getMode() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_DUAL_CAMERA);
+ return Integer.parseInt(value);
+ }
- break;
- case "bayer":
- mode = BAYER_MODE;
- break;
- case "mono":
- mode = MONO_MODE;
- break;
- }
- if (MODE == mode) return false;
- MODE = mode;
- return true;
+ private boolean isClearSightOn() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_CLEARSIGHT);
+ if (value == null) return false;
+ return isBackMode() && getMode() == DUAL_MODE && value.equals("on");
}
public static int getQualityNumber(String jpegQuality) {
@@ -471,8 +420,7 @@ public class CaptureModule implements CameraModule, PhotoController,
//Todo: test record location. Jack to provide instructions
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = getRecordLocation();
mLocationManager.recordLocation(recordLocation);
mUI.initializeFirstTime();
@@ -489,31 +437,38 @@ public class CaptureModule implements CameraModule, PhotoController,
private void initializeSecondTime() {
// Start location update if needed.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = getRecordLocation();
mLocationManager.recordLocation(recordLocation);
MediaSaveService s = mActivity.getMediaSaveService();
if (s != null) {
s.setListener(this);
}
mNamedImages = new NamedImages();
- mUI.initializeSecondTime();
}
private void createSession(final int id) {
if (mPaused || !mCameraOpened[id] || !mSurfaceReady) return;
+ Log.d(TAG, "createSession " + id);
List<Surface> list = new LinkedList<Surface>();
mUI.hidePreviewCover();
try {
Surface surface;
- if (id == BAYER_ID || (id == MONO_ID && MODE == MONO_MODE)) {
- SurfaceHolder sh = mUI.getSurfaceHolder();
- if (sh == null) {
- return;
+ if (isBackMode()) {
+ if (id == BAYER_ID || (id == MONO_ID && getMode() == MONO_MODE)) {
+ SurfaceHolder sh = mUI.getSurfaceHolder();
+ if (sh == null) {
+ return;
+ }
+ surface = sh.getSurface();
+ } else {
+ SurfaceHolder sh = mUI.getSurfaceHolder2();
+ if (sh == null) {
+ return;
+ }
+ surface = sh.getSurface();
}
- surface = sh.getSurface();
} else {
- SurfaceHolder sh = mUI.getSurfaceHolder2();
+ SurfaceHolder sh = mUI.getSurfaceHolder();
if (sh == null) {
return;
}
@@ -528,48 +483,46 @@ public class CaptureModule implements CameraModule, PhotoController,
CameraCaptureSession.StateCallback captureSessionCallback =
new CameraCaptureSession.StateCallback() {
- @Override
- public void onConfigured(CameraCaptureSession cameraCaptureSession) {
- // The camera is already closed
- if (mPaused || null == mCameraDevice[id]) {
- return;
- }
- // When the session is ready, we start displaying the preview.
- mCaptureSession[id] = cameraCaptureSession;
- initializePreviewConfiguration(id);
- try {
- if (MODE == DUAL_MODE) {
- linkBayerMono(id);
- mIsLinked = true;
+ @Override
+ public void onConfigured(CameraCaptureSession cameraCaptureSession) {
+ // The camera is already closed
+ if (mPaused || null == mCameraDevice[id]) {
+ return;
+ }
+ // When the session is ready, we start displaying the preview.
+ mCaptureSession[id] = cameraCaptureSession;
+ initializePreviewConfiguration(id);
+ try {
+ if (isBackMode() && getMode() == DUAL_MODE) {
+ linkBayerMono(id);
+ mIsLinked = true;
+ }
+ // Finally, we start displaying the camera preview.
+ mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id]
+ .build(), mCaptureCallback, mCameraHandler);
+
+ if (isClearSightOn()) {
+ ClearSightImageProcessor.getInstance().onCaptureSessionConfigured(id == BAYER_ID, cameraCaptureSession);
+ }
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
}
- // Finally, we start displaying the camera preview.
- mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id]
- .build(), mCaptureCallback, mCameraHandler);
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
- ClearSightImageProcessor.getInstance().onCaptureSessionConfigured(id == BAYER_ID, cameraCaptureSession);
+ @Override
+ public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
+ Log.d(TAG, "cameracapturesession - onConfigureFailed");
}
- } catch (CameraAccessException e) {
- e.printStackTrace();
- }
- }
- @Override
- public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
- Log.d(TAG, "cameracapturesession - onConfigureFailed");
- }
-
- @Override
- public void onClosed(CameraCaptureSession session) {
- Log.d(TAG, "cameracapturesession - onClosed");
- }
- };
+ @Override
+ public void onClosed(CameraCaptureSession session) {
+ Log.d(TAG, "cameracapturesession - onClosed");
+ }
+ };
list.add(surface);
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
+ if(isClearSightOn()) {
ClearSightImageProcessor.getInstance().createCaptureSession(
id==BAYER_ID, mCameraDevice[id], list, captureSessionCallback);
} else {
@@ -593,8 +546,27 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ public void reinit() {
+ String pictureSize = mSettingsManager.getValue(SettingsManager
+ .KEY_PICTURE_SIZE);
+
+ Size size = parsePictureSize(pictureSize);
+ mUI.setPreviewSize(size.getHeight(), size.getWidth());
+ mSettingsManager.reinit(getMainCameraId());
+ }
+
+ public boolean getRecordLocation() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_RECORD_LOCATION);
+ if (value == null) value = RecordLocationPreference.VALUE_NONE;
+ return RecordLocationPreference.VALUE_ON.equals(value);
+ }
+
@Override
public void init(CameraActivity activity, View parent) {
+ mActivity = activity;
+ mSettingsManager = SettingsManager.getInstance();
+ mSettingsManager.registerListener(this);
+ mSettingsManager.init();
Log.d(TAG, "init");
for (int i = 0; i < MAX_NUM_CAM; i++) {
mCameraOpened[i] = false;
@@ -602,32 +574,20 @@ public class CaptureModule implements CameraModule, PhotoController,
}
mSurfaceReady = false;
- mActivity = activity;
for (int i = 0; i < MAX_NUM_CAM; i++) {
mState[i] = STATE_PREVIEW;
}
- mPreferences = new ComboPreferences(mActivity);
- CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(), activity);
-
- mPreferences.setLocalId(mActivity, BAYER_ID);
- CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
-
- PreferenceInflater inflater = new PreferenceInflater(mActivity);
- PreferenceGroup group =
- (PreferenceGroup) inflater.inflate(R.xml.camera_preferences);
- mPreferenceGroup = group;
-
- ListPreference pref = group.findPreference(CameraSettings.KEY_DUAL_CAMERA);
- setMode(pref.getValue());
-
mContentResolver = mActivity.getContentResolver();
mUI = new CaptureUI(activity, this, parent);
mUI.initializeControlByIntent();
+ String pictureSize = mSettingsManager.getValue(SettingsManager.KEY_PICTURE_SIZE);
+ Size size = parsePictureSize(pictureSize);
+ mUI.setPreviewSize(size.getHeight(), size.getWidth());
mFocusStateListener = new FocusStateListener(mUI);
mLocationManager = new LocationManager(mActivity, mUI);
- Storage.setSaveSDCard(
- mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
+ Storage.setSaveSDCard(mSettingsManager.getValue(SettingsManager
+ .KEY_CAMERA_SAVEPATH).equals("1"));
}
/**
@@ -635,17 +595,21 @@ public class CaptureModule implements CameraModule, PhotoController,
*/
private void takePicture() {
Log.d(TAG, "takePicture");
- switch (MODE) {
- case DUAL_MODE:
- lockFocus(BAYER_ID);
- lockFocus(MONO_ID);
- break;
- case BAYER_MODE:
- lockFocus(BAYER_ID);
- break;
- case MONO_MODE:
- lockFocus(MONO_ID);
- break;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ lockFocus(BAYER_ID);
+ lockFocus(MONO_ID);
+ break;
+ case BAYER_MODE:
+ lockFocus(BAYER_ID);
+ break;
+ case MONO_MODE:
+ lockFocus(MONO_ID);
+ break;
+ }
+ } else {
+ lockFocus(FRONT_ID);
}
}
@@ -667,12 +631,8 @@ public class CaptureModule implements CameraModule, PhotoController,
builder.setTag(id);
builder.addTarget(getPreviewSurface(id));
- builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
- builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
- builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
- applyWhiteBalance(builder);
- applyZoom(builder, id);
- applyAFRegions(builder, id);
+ applySettingsForLockFocus(builder, id);
+
mState[id] = STATE_WAITING_LOCK;
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
@@ -689,14 +649,8 @@ public class CaptureModule implements CameraModule, PhotoController,
builder.addTarget(getPreviewSurface(id));
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_AUTO;
- builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
- builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
- builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest
- .CONTROL_AF_TRIGGER_START);
-
- applyWhiteBalance(builder);
- applyZoom(builder, id);
- applyAFRegions(builder, id);
+ applySettingsForAutoFocus(builder, id);
+
mState[id] = STATE_WAITING_TOUCH_FOCUS;
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
setAFModeToPreview(id, mControlAFMode);
@@ -740,9 +694,7 @@ public class CaptureModule implements CameraModule, PhotoController,
return;
}
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- final boolean csEnabled = pref.getValue().equals(
- mActivity.getString(R.string.pref_camera_clearsight_value_on));
+ final boolean csEnabled = isClearSightOn();
CaptureRequest.Builder captureBuilder;
if(csEnabled) {
@@ -759,27 +711,28 @@ public class CaptureModule implements CameraModule, PhotoController,
captureBuilder.addTarget(getPreviewSurface(id));
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
captureBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);
- applyCaptureSettings(captureBuilder, id);
+ applySettingsForCapture(captureBuilder, id);
if(csEnabled) {
ClearSightImageProcessor.getInstance().capture(
id==BAYER_ID, mCaptureSession[id], captureBuilder, mCaptureCallbackHandler);
} else {
captureBuilder.addTarget(mImageReader[id].getSurface());
+ mCaptureSession[id].stopRepeating();
mCaptureSession[id].capture(captureBuilder.build(), new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session,
- CaptureRequest request,
- TotalCaptureResult result) {
+ CaptureRequest request,
+ TotalCaptureResult result) {
Log.d(TAG, "captureStillPicture onCaptureCompleted: " + id);
}
@Override
public void onCaptureFailed(CameraCaptureSession session,
- CaptureRequest request,
- CaptureFailure result) {
+ CaptureRequest request,
+ CaptureFailure result) {
Log.d(TAG, "captureStillPicture onCaptureFailed: " + id);
}
@@ -808,14 +761,9 @@ public class CaptureModule implements CameraModule, PhotoController,
.TEMPLATE_PREVIEW);
builder.setTag(id);
builder.addTarget(getPreviewSurface(id));
- builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
- builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
- builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
- CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
- // Applying flash only to capture does not work. Need to apply flash here.
- applyFlash(builder);
- applyWhiteBalance(builder);
- applyZoom(builder, id);
+
+ applySettingsForPrecapture(builder, id);
+
mState[id] = STATE_WAITING_PRECAPTURE;
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
@@ -833,24 +781,18 @@ public class CaptureModule implements CameraModule, PhotoController,
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIdList = manager.getCameraIdList();
-
for (int i = 0; i < cameraIdList.length; i++) {
String cameraId = cameraIdList[i];
- CameraCharacteristics characteristics
- = manager.getCameraCharacteristics(cameraId);
- mCharacteristics[i] = characteristics;
- mCharacteristicsIndex.add(i);
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
+ mCameraIdList.add(i);
StreamConfigurationMap map = characteristics.get(
CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
if (map == null) {
continue;
}
- Boolean available = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
- Log.d(TAG, "flash : " + (available == null ? false : available));
mCameraId[i] = cameraId;
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
+ if(isClearSightOn()) {
Size largest = Collections.max(
Arrays.asList(map.getOutputSizes(ImageFormat.YUV_420_888)),
new CompareSizesByArea());
@@ -864,7 +806,12 @@ public class CaptureModule implements CameraModule, PhotoController,
Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
new CompareSizesByArea());
- mImageReader[i] = ImageReader.newInstance(largest.getWidth(), largest.getHeight(),
+ String pictureSize = mSettingsManager.getValue(SettingsManager
+ .KEY_PICTURE_SIZE);
+
+ Size size = parsePictureSize(pictureSize);
+
+ mImageReader[i] = ImageReader.newInstance(size.getWidth(), size.getHeight(),
ImageFormat.JPEG, 3);
mImageReader[i].setOnImageAvailableListener(new ImageAvailableListener(i) {
@Override
@@ -889,11 +836,9 @@ public class CaptureModule implements CameraModule, PhotoController,
}, mImageAvailableHandler);
}
}
- mAutoFocusSupported = CameraUtil.isAutoFocusSupported(mCharacteristics,
- mCharacteristicsIndex);
+ mAutoFocusSupported = mSettingsManager.isAutoFocusSupported(mCameraIdList);
} catch (CameraAccessException e) {
e.printStackTrace();
- } catch (NullPointerException e) {
}
}
@@ -909,14 +854,8 @@ public class CaptureModule implements CameraModule, PhotoController,
builder.setTag(id);
builder.addTarget(getPreviewSurface(id));
- builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest
- .CONTROL_MODE_AUTO);
- builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
- builder.set(CaptureRequest.CONTROL_AF_TRIGGER,
- CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);
- //Todo: Create applyCommonSettings function for settings applied everytime
- applyWhiteBalance(builder);
- applyZoom(builder, id);
+ applySettingsForUnlockFocus(builder, id);
+
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
mState[id] = STATE_PREVIEW;
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
@@ -929,6 +868,13 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private Size parsePictureSize(String value) {
+ int indexX = value.indexOf('x');
+ int width = Integer.parseInt(value.substring(0, indexX));
+ int height = Integer.parseInt(value.substring(indexX + 1));
+ return new Size(width, height);
+ }
+
/**
* Closes the current {@link CameraDevice}.
*/
@@ -977,6 +923,48 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private void applySettingsForLockFocus(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
+ applyAFRegions(builder, id);
+ applyCommonSettings(builder, id);
+ }
+
+ private void applySettingsForCapture(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE);
+ applyFlash(builder, id);
+ applyJpegQuality(builder);
+ applyCommonSettings(builder, id);
+ }
+
+ private void applySettingsForPrecapture(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
+ CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START);
+ applyFlash(builder, id);
+ applyCommonSettings(builder, id);
+ }
+
+ private void applySettingsForUnlockFocus(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AF_TRIGGER,
+ CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);
+ applyCommonSettings(builder, id);
+ }
+
+ private void applySettingsForAutoFocus(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest
+ .CONTROL_AF_TRIGGER_START);
+ applyAFRegions(builder, id);
+ applyCommonSettings(builder, id);
+ }
+
+ private void applyCommonSettings(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
+ builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode);
+ applyWhiteBalance(builder);
+ applyColorEffect(builder);
+ applySceneMode(builder);
+ applyZoom(builder, id);
+ }
+
/**
* Starts a background thread and its {@link Handler}.
*/
@@ -1060,8 +1048,7 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "onPause");
mUI.showPreviewCover();
if (mLocationManager != null) mLocationManager.recordLocation(false);
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
+ if(isClearSightOn()) {
ClearSightImageProcessor.getInstance().close();
}
closeCamera();
@@ -1076,24 +1063,29 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onResumeAfterSuper() {
- Log.d(TAG, "onResume " + MODE);
- mCharacteristicsIndex = new ArrayList<>();
- startBackgroundThread();
+ Log.d(TAG, "onResume " + getMode());
+ mUI.setSwitcherIndex();
+ mCameraIdList = new ArrayList<>();
setUpCameraOutputs();
- readInitialValues();
+ startBackgroundThread();
Message msg = Message.obtain();
msg.what = OPEN_CAMERA;
- switch (MODE) {
- case DUAL_MODE:
- case BAYER_MODE:
- msg.obj = BAYER_ID;
- mCameraHandler.sendMessage(msg);
- break;
- case MONO_MODE:
- msg.what = OPEN_CAMERA;
- msg.obj = MONO_ID;
- mCameraHandler.sendMessage(msg);
- break;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ case BAYER_MODE:
+ msg.obj = BAYER_ID;
+ mCameraHandler.sendMessage(msg);
+ break;
+ case MONO_MODE:
+ msg.what = OPEN_CAMERA;
+ msg.obj = MONO_ID;
+ mCameraHandler.sendMessage(msg);
+ break;
+ }
+ } else {
+ msg.obj = FRONT_ID;
+ mCameraHandler.sendMessage(msg);
}
if (!mFirstTimeInitialized) {
initializeFirstTime();
@@ -1148,17 +1140,21 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onZoomChanged(float requestedZoom) {
mZoomValue = requestedZoom;
- switch (MODE) {
- case DUAL_MODE:
- applyZoomAndUpdate(BAYER_ID);
- applyZoomAndUpdate(MONO_ID);
- break;
- case BAYER_MODE:
- applyZoomAndUpdate(BAYER_ID);
- break;
- case MONO_MODE:
- applyZoomAndUpdate(MONO_ID);
- break;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ applyZoomAndUpdate(BAYER_ID);
+ applyZoomAndUpdate(MONO_ID);
+ break;
+ case BAYER_MODE:
+ applyZoomAndUpdate(BAYER_ID);
+ break;
+ case MONO_MODE:
+ applyZoomAndUpdate(MONO_ID);
+ break;
+ }
+ } else {
+ applyZoomAndUpdate(FRONT_ID);
}
}
@@ -1211,29 +1207,37 @@ public class CaptureModule implements CameraModule, PhotoController,
Log.d(TAG, "onSingleTapUp " + x + " " + y);
mUI.setFocusPosition(x, y);
mUI.onFocusStarted();
- switch (MODE) {
- case DUAL_MODE:
- triggerFocusAtPoint(x, y, BAYER_ID);
- triggerFocusAtPoint(x, y, MONO_ID);
- break;
- case BAYER_MODE:
- triggerFocusAtPoint(x, y, BAYER_ID);
- break;
- case MONO_MODE:
- triggerFocusAtPoint(x, y, MONO_ID);
- break;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ triggerFocusAtPoint(x, y, BAYER_ID);
+ triggerFocusAtPoint(x, y, MONO_ID);
+ break;
+ case BAYER_MODE:
+ triggerFocusAtPoint(x, y, BAYER_ID);
+ break;
+ case MONO_MODE:
+ triggerFocusAtPoint(x, y, MONO_ID);
+ break;
+ }
+ } else {
+ triggerFocusAtPoint(x, y, FRONT_ID);
}
}
private int getMainCameraId() {
- switch (MODE) {
- case DUAL_MODE:
- case BAYER_MODE:
- return BAYER_ID;
- case MONO_MODE:
- return MONO_ID;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ case BAYER_MODE:
+ return BAYER_ID;
+ case MONO_MODE:
+ return MONO_ID;
+ }
+ return 0;
+ } else {
+ return FRONT_ID;
}
- return 0;
}
private boolean isTouchToFocusAllowed() {
@@ -1265,16 +1269,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void enableRecordingLocation(boolean enable) {
- Log.d(TAG, "CaptureModule enableRecordingLocation " + enable);
- setLocationPreference(enable ? RecordLocationPreference.VALUE_ON
- : RecordLocationPreference.VALUE_OFF);
- }
- private void setLocationPreference(String value) {
- mPreferences.edit()
- .putString(CameraSettings.KEY_RECORD_LOCATION, value)
- .apply();
- prefListener.onSharedPreferenceChanged();
}
@Override
@@ -1284,17 +1279,21 @@ public class CaptureModule implements CameraModule, PhotoController,
}
Log.d(TAG, "onPreviewUIReady");
mSurfaceReady = true;
- switch (MODE) {
- case DUAL_MODE:
- createSession(BAYER_ID);
- createSession(MONO_ID);
- break;
- case BAYER_MODE:
- createSession(BAYER_ID);
- break;
- case MONO_MODE:
- createSession(MONO_ID);
- break;
+ if (isBackMode()) {
+ switch (getMode()) {
+ case DUAL_MODE:
+ createSession(BAYER_ID);
+ createSession(MONO_ID);
+ break;
+ case BAYER_MODE:
+ createSession(BAYER_ID);
+ break;
+ case MONO_MODE:
+ createSession(MONO_ID);
+ break;
+ }
+ } else {
+ createSession(FRONT_ID);
}
}
@@ -1332,6 +1331,7 @@ public class CaptureModule implements CameraModule, PhotoController,
int oldOrientation = mOrientation;
mOrientation = CameraUtil.roundOrientation(orientation, mOrientation);
if (oldOrientation != mOrientation) {
+ mUI.onOrientationChanged();
mUI.setOrientation(mOrientation, true);
}
}
@@ -1345,8 +1345,7 @@ public class CaptureModule implements CameraModule, PhotoController,
public void onMediaSaveServiceConnected(MediaSaveService s) {
if (mFirstTimeInitialized) {
s.setListener(this);
- ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_CLEARSIGHT);
- if(pref.getValue().equals(mActivity.getString(R.string.pref_camera_clearsight_value_on))) {
+ if (isClearSightOn()) {
ClearSightImageProcessor.getInstance().setMediaSaveService(s);
}
}
@@ -1364,13 +1363,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void onSwitchSavePath() {
- if (mUI.mMenuInitialized) {
- mUI.setPreference(CameraSettings.KEY_CAMERA_SAVEPATH, "1");
- } else {
- mPreferences.edit()
- .putString(CameraSettings.KEY_CAMERA_SAVEPATH, "1")
- .apply();
- }
+ mSettingsManager.setValue(SettingsManager.KEY_CAMERA_SAVEPATH, "1");
RotateTextToast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
Toast.LENGTH_SHORT).show();
}
@@ -1390,39 +1383,24 @@ public class CaptureModule implements CameraModule, PhotoController,
}
- private boolean isFlashOff() {
- return readSetting(CameraSettings.KEY_FLASH_MODE).equals("off");
+ private boolean isFlashOff(int id) {
+ if (!mSettingsManager.isFlashSupported(id)) return true;
+ return mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE).equals("off");
}
private void initializePreviewConfiguration(int id) {
- mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_MODE, CaptureRequest
- .CONTROL_MODE_AUTO);
- mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest
- .CONTROL_AF_MODE_CONTINUOUS_PICTURE);
mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest
.CONTROL_AF_TRIGGER_IDLE);
mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest
.CONTROL_AE_MODE_ON);
mPreviewRequestBuilder[id].set(CaptureRequest.FLASH_MODE, CaptureRequest
.FLASH_MODE_OFF);
- applyWhiteBalance(mPreviewRequestBuilder[id]);
- applyZoom(mPreviewRequestBuilder[id], id);
- }
-
- private void readInitialValues() {
- for (int i = 0; i < mPreferenceGroup.size(); i++) {
- CameraPreference pref = mPreferenceGroup.get(i);
- if (pref instanceof ListPreference) {
- ListPreference listPref = (ListPreference) pref;
- storeSetting(listPref.getKey(), listPref.getValue());
- }
- }
+ applyCommonSettings(mPreviewRequestBuilder[id], id);
}
public Rect cropRegionForZoom(int id) {
Log.d(TAG, "cropRegionForZoom " + id);
- Rect activeRegion = mCharacteristics[id].get(CameraCharacteristics
- .SENSOR_INFO_ACTIVE_ARRAY_SIZE);
+ Rect activeRegion = mSettingsManager.getSensorActiveArraySize(id);
Rect cropRegion = new Rect();
int xCenter = activeRegion.width() / 2;
@@ -1438,36 +1416,23 @@ public class CaptureModule implements CameraModule, PhotoController,
request.set(CaptureRequest.SCALER_CROP_REGION, cropRegionForZoom(id));
}
- private void applyCaptureSettings(CaptureRequest.Builder request, int id) {
- applyFlash(request);
- applyWhiteBalance(request);
- applyJpegQuality(request);
- applyZoom(request, id);
- }
-
- private void applyPreference(int cameraId, ListPreference pref) {
+ private boolean applyPreferenceToPreview(int cameraId, String key, String value) {
boolean updatePreview = false;
- String key = pref.getKey();
- String value = pref.getValue();
- storeSetting(key, value);
switch (key) {
- //Todo: CreateUISettings file and add UI preference settings to there
- case CameraSettings.KEY_JPEG_QUALITY:
- mJpegQuality = getQualityNumber(value);
- break;
- case CameraSettings.KEY_WHITE_BALANCE:
+ case SettingsManager.KEY_WHITE_BALANCE:
updatePreview = true;
applyWhiteBalance(mPreviewRequestBuilder[cameraId]);
break;
+ case SettingsManager.KEY_COLOR_EFFECT:
+ updatePreview = true;
+ applyColorEffect(mPreviewRequestBuilder[cameraId]);
+ break;
+ case SettingsManager.KEY_SCENE_MODE:
+ updatePreview = true;
+ applySceneMode(mPreviewRequestBuilder[cameraId]);
+ break;
}
- if (updatePreview) {
- try {
- mCaptureSession[cameraId].setRepeatingRequest(mPreviewRequestBuilder[cameraId]
- .build(), mCaptureCallback, mCameraHandler);
- } catch (CameraAccessException e) {
- e.printStackTrace();
- }
- }
+ return updatePreview;
}
private void applyZoomAndUpdate(int id) {
@@ -1480,14 +1445,6 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
- private void storeSetting(String key, String value) {
- mSettings.put(key, value);
- }
-
- private String readSetting(String key) {
- return mSettings.get(key);
- }
-
private void applyJpegQuality(CaptureRequest.Builder request) {
request.set(CaptureRequest.JPEG_QUALITY, (byte) mJpegQuality);
}
@@ -1500,64 +1457,73 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
- private void applyWhiteBalance(CaptureRequest.Builder request) {
- String value = readSetting(CameraSettings.KEY_WHITE_BALANCE);
- switch (value) {
- case "incandescent":
- request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest
- .CONTROL_AWB_MODE_INCANDESCENT);
- break;
- case "fluorescent":
- request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest
- .CONTROL_AWB_MODE_FLUORESCENT);
- break;
- case "auto":
- request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest
- .CONTROL_AWB_MODE_AUTO);
- break;
- case "daylight":
- request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest
- .CONTROL_AWB_MODE_DAYLIGHT);
- break;
- case "cloudy-daylight":
- request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest
- .CONTROL_AWB_MODE_CLOUDY_DAYLIGHT);
- break;
+ private void applySceneMode(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ if (value == null) return;
+ int mode = Integer.parseInt(value);
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED) {
+ request.set(CaptureRequest.CONTROL_SCENE_MODE, mode);
+ request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
+ } else {
+ request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
}
}
- private Surface getPreviewSurface(int id) {
- if (MODE == DUAL_MODE && id == MONO_ID) {
- return mUI.getSurfaceHolder2().getSurface();
- } else {
- return mUI.getSurfaceHolder().getSurface();
- }
+ private void applyColorEffect(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT);
+ if (value == null) return;
+ int mode = Integer.parseInt(value);
+ request.set(CaptureRequest.CONTROL_EFFECT_MODE, mode);
+ }
+
+ private void applyWhiteBalance(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_WHITE_BALANCE);
+ if (value == null) return;
+ int mode = Integer.parseInt(value);
+ request.set(CaptureRequest.CONTROL_AWB_MODE, mode);
}
private void applyFlash(CaptureRequest.Builder request, String value) {
- switch (value) {
- case "on":
- request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest
- .CONTROL_AE_MODE_ON_ALWAYS_FLASH);
+ int mode = Integer.parseInt(value);
+ String redeye = mSettingsManager.getValue(SettingsManager.KEY_REDEYE_REDUCTION);
+ request.set(CaptureRequest.CONTROL_AE_MODE, mode);
+ switch (mode) {
+ case CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH:
request.set(CaptureRequest.FLASH_MODE, CaptureRequest
.FLASH_MODE_SINGLE);
break;
- case "auto":
- request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest
- .CONTROL_AE_MODE_ON_AUTO_FLASH);
- break;
- case "off":
- request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest
- .CONTROL_AE_MODE_ON);
+ case CaptureRequest.CONTROL_AE_MODE_ON:
request.set(CaptureRequest.FLASH_MODE, CaptureRequest
.FLASH_MODE_OFF);
break;
+ case CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH:
+ if (redeye.equals("disable")) {
+ request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest
+ .CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE);
+ }
+ break;
}
}
- private void applyFlash(CaptureRequest.Builder request) {
- String value = readSetting(CameraSettings.KEY_FLASH_MODE);
- applyFlash(request, value);
+ private void applyFlash(CaptureRequest.Builder request, int id) {
+ if (mSettingsManager.isFlashSupported(id)) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE);
+ applyFlash(request, value);
+ } else {
+ request.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);
+ }
+ }
+
+ private Surface getPreviewSurface(int id) {
+ if (isBackMode()) {
+ if (getMode() == DUAL_MODE && id == MONO_ID) {
+ return mUI.getSurfaceHolder2().getSurface();
+ } else {
+ return mUI.getSurfaceHolder().getSurface();
+ }
+ } else {
+ return mUI.getSurfaceHolder().getSurface();
+ }
}
@Override
@@ -1622,6 +1588,75 @@ public class CaptureModule implements CameraModule, PhotoController,
mLastResultAFState = resultAFState;
}
+ @Override
+ public void onSettingsChanged(List<SettingsManager.SettingState> settings) {
+ if (mPaused) return;
+ boolean updatePreviewBayer = false;
+ boolean updatePreviewMono = false;
+ boolean updatePreviewFront = false;
+ for (SettingsManager.SettingState settingState : settings) {
+
+ String key = settingState.key;
+ SettingsManager.Values values = settingState.values;
+ String value;
+ if (values.overriddenValue != null) {
+ value = values.overriddenValue;
+ } else {
+ value = values.value;
+ }
+ if (SettingsManager.KEY_CAMERA_SAVEPATH.equals(key)) {
+ Storage.setSaveSDCard(value.equals("1"));
+ mActivity.updateStorageSpaceAndHint();
+ continue;
+ }
+ if (SettingsManager.KEY_JPEG_QUALITY.equals(key)) {
+ mJpegQuality = getQualityNumber(value);
+ continue;
+ }
+
+ if (isBackMode()) {
+ switch (getMode()) {
+ case BAYER_MODE:
+ updatePreviewBayer |= applyPreferenceToPreview(BAYER_ID, key, value);
+ break;
+ case MONO_MODE:
+ updatePreviewMono |= applyPreferenceToPreview(MONO_ID, key, value);
+ break;
+ case DUAL_MODE:
+ updatePreviewBayer |= applyPreferenceToPreview(BAYER_ID, key, value);
+ updatePreviewMono |= applyPreferenceToPreview(MONO_ID, key, value);
+ break;
+ }
+ } else {
+ updatePreviewFront |= applyPreferenceToPreview(FRONT_ID, key, value);
+ }
+ }
+ if (updatePreviewBayer) {
+ try {
+ mCaptureSession[BAYER_ID].setRepeatingRequest(mPreviewRequestBuilder[BAYER_ID]
+ .build(), mCaptureCallback, mCameraHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ if (updatePreviewMono) {
+ try {
+ mCaptureSession[MONO_ID].setRepeatingRequest(mPreviewRequestBuilder[MONO_ID]
+ .build(), mCaptureCallback, mCameraHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ if (updatePreviewFront) {
+ try {
+ mCaptureSession[FRONT_ID].setRepeatingRequest(mPreviewRequestBuilder[FRONT_ID]
+ .build(), mCaptureCallback, mCameraHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
/**
* Compares two {@code Size}s based on their areas.
*/
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index a6accae..0060f2c 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -19,37 +19,35 @@
package com.android.camera;
-import android.content.res.Configuration;
-import android.graphics.Matrix;
+import android.animation.Animator;
+import android.content.Context;
+import android.content.res.Resources;
import android.graphics.Point;
-import android.graphics.RectF;
import android.graphics.drawable.AnimationDrawable;
import android.hardware.Camera.Face;
-import android.hardware.camera2.CameraCharacteristics;
+import android.text.TextUtils;
import android.util.Log;
+import android.view.Display;
import android.view.Gravity;
+import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
-import android.view.SurfaceView;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
+import android.view.ViewPropertyAnimator;
+import android.view.WindowManager;
import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
+import android.widget.ImageView;
import android.widget.LinearLayout;
-import android.widget.ListView;
-import android.widget.PopupWindow;
+import android.widget.TextView;
-import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.FocusOverlayManager.FocusUI;
+import com.android.camera.ui.AutoFitSurfaceView;
import com.android.camera.ui.CameraControls;
-import com.android.camera.ui.CameraRootView;
import com.android.camera.ui.FocusIndicator;
+import com.android.camera.ui.ListMenu;
import com.android.camera.ui.ListSubMenu;
import com.android.camera.ui.ModuleSwitcher;
import com.android.camera.ui.PieRenderer;
-import com.android.camera.ui.PieRenderer.PieListener;
import com.android.camera.ui.RenderOverlay;
import com.android.camera.ui.RotateImageView;
import com.android.camera.ui.RotateLayout;
@@ -60,150 +58,173 @@ import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
import java.util.List;
+import java.util.Locale;
-public class CaptureUI implements PieListener,
+public class CaptureUI implements FocusOverlayManager.FocusUI,
PreviewGestures.SingleTapListener,
- FocusUI,
- SurfaceHolder.Callback,
LocationManager.Listener,
- CameraRootView.MyDisplayListener,
- CameraManager.CameraFaceDetectionCallback {
-
+ CameraManager.CameraFaceDetectionCallback,
+ SettingsManager.Listener,
+ ListMenu.Listener,
+ ListSubMenu.Listener {
+ private static final int HIGHLIGHT_COLOR = 0xff33b5e5;
private static final String TAG = "SnapCam_CaptureUI";
+ private static final int SETTING_MENU_NONE = 0;
+ private static final int SETTING_MENU_IN_ANIMATION = 1;
+ private static final int SETTING_MENU_ON = 2;
+ private static final int SETTING_MENU_LEVEL_ONE = 0;
+ private static final int SETTING_MENU_LEVEL_TWO = 1;
+ private static final int SCENE_AND_FILTER_MENU_NONE = 0;
+ private static final int SCENE_AND_FILTER_MENU_IN_ANIMATION = 1;
+ private static final int SCENE_AND_FILTER_MENU_ON = 2;
+ private static final int MODE_FILTER = 0;
+ private static final int MODE_SCENE = 1;
+ private static final int ANIMATION_DURATION = 300;
+ private static final int CLICK_THRESHOLD = 200;
public boolean mMenuInitialized = false;
- private boolean surface1created = false;
- private boolean surface2created = false;
+ String[] mSettingKeys = new String[]{
+ SettingsManager.KEY_FLASH_MODE,
+ SettingsManager.KEY_RECORD_LOCATION,
+ SettingsManager.KEY_PICTURE_SIZE,
+ SettingsManager.KEY_JPEG_QUALITY,
+ SettingsManager.KEY_CAMERA_SAVEPATH,
+ SettingsManager.KEY_WHITE_BALANCE,
+ SettingsManager.KEY_CAMERA2,
+ SettingsManager.KEY_DUAL_CAMERA,
+ SettingsManager.KEY_CLEARSIGHT
+ };
+ String[] mDeveloperKeys = new String[]{
+ SettingsManager.KEY_FLASH_MODE,
+ SettingsManager.KEY_RECORD_LOCATION,
+ SettingsManager.KEY_PICTURE_SIZE,
+ SettingsManager.KEY_JPEG_QUALITY,
+ SettingsManager.KEY_CAMERA_SAVEPATH,
+ SettingsManager.KEY_WHITE_BALANCE,
+ SettingsManager.KEY_CAMERA2,
+ SettingsManager.KEY_DUAL_CAMERA,
+ SettingsManager.KEY_CLEARSIGHT,
+ SettingsManager.KEY_MONO_PREVIEW
+ };
private CameraActivity mActivity;
- private PhotoController mController;
- private PreviewGestures mGestures;
-
private View mRootView;
+ private View mPreviewCover;
+ private CaptureModule mModule;
+ private AutoFitSurfaceView mSurfaceView;
+ private AutoFitSurfaceView mSurfaceView2;
private SurfaceHolder mSurfaceHolder;
private SurfaceHolder mSurfaceHolder2;
+ private boolean surface1created = false;
+ private boolean surface2created = false;
+ private int mOrientation;
+ private RotateLayout mMenuLayout;
+ private RotateLayout mSubMenuLayout;
+ private int mSettingMenuState;
+ private int mSettingMenuLevel;
+ private int mSceneAndFilterMenuStatus;
+ private int mSceneAndFilterMenuMode;
+ private ListMenu mSettingMenu;
+ private ListSubMenu mSettingSubMenu;
+ private PreviewGestures mGestures;
+ private boolean mUIhidden = false;
+ private SettingsManager mSettingsManager;
private SurfaceHolder.Callback callback = new SurfaceHolder.Callback() {
// SurfaceHolder callbacks
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ Log.v(TAG, "surfaceChanged: width =" + width + ", height = " + height);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
- mSurfaceHolder2 = holder;
- if (surface1created) mController.onPreviewUIReady();
- surface2created = true;
+ Log.v(TAG, "surfaceCreated");
+ mSurfaceHolder = holder;
+ if (surface2created) mModule.onPreviewUIReady();
+ surface1created = true;
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
- mSurfaceHolder2 = null;
- surface2created = false;
+ Log.v(TAG, "surfaceDestroyed");
+ mSurfaceHolder = null;
+ surface1created = false;
+ mModule.onPreviewUIDestroyed();
}
};
- private PopupWindow mPopup;
+
private ShutterButton mShutterButton;
private RenderOverlay mRenderOverlay;
private View mMenuButton;
- private CaptureMenu mMenu;
private ModuleSwitcher mSwitcher;
private CameraControls mCameraControls;
- // Small indicators which show the camera settings in the viewfinder.
- private OnScreenIndicators mOnScreenIndicators;
private PieRenderer mPieRenderer;
private ZoomRenderer mZoomRenderer;
- private int mPreviewWidth = 0;
- private int mPreviewHeight = 0;
- private int mOriginalPreviewWidth = 0;
- private int mOriginalPreviewHeight = 0;
- private float mSurfaceTextureUncroppedWidth;
- private float mSurfaceTextureUncroppedHeight;
-
- private SurfaceView mSurfaceView = null;
- private SurfaceView mSurfaceView2 = null;
- private Matrix mMatrix = null;
- private boolean mAspectRatioResize;
-
- private boolean mOrientationResize;
- private boolean mPrevOrientationResize;
- private View mPreviewCover;
- private RotateLayout mMenuLayout;
- private RotateLayout mSubMenuLayout;
- private LinearLayout mPreviewMenuLayout;
- private boolean mUIhidden = false;
- private int mPreviewOrientation = -1;
private int mScreenRatio = CameraUtil.RATIO_UNKNOWN;
private int mTopMargin = 0;
private int mBottomMargin = 0;
+ private LinearLayout mSceneAndFilterLayout;
+ private int mSceneAndFilterMenuSize;
- private int mOrientation;
- private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
+ private View mFilterModeSwitcher;
+ private View mSceneModeSwitcher;
+ private View mFrontBackSwitcher;
+
+ private SurfaceHolder.Callback callback2 = new SurfaceHolder.Callback() {
+
+ // SurfaceHolder callbacks
@Override
- public void onLayoutChange(View v, int left, int top, int right,
- int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- int width = right - left;
- int height = bottom - top;
-
- int orientation = mActivity.getResources().getConfiguration().orientation;
- if ((orientation == Configuration.ORIENTATION_PORTRAIT && width > height)
- || (orientation == Configuration.ORIENTATION_LANDSCAPE && width < height)) {
- // The screen has rotated; swap SurfaceView width & height
- // to ensure correct preview
- int oldWidth = width;
- width = height;
- height = oldWidth;
- Log.d(TAG, "Swapping SurfaceView width & height dimensions");
- if (mOriginalPreviewWidth != 0 && mOriginalPreviewHeight != 0) {
- int temp = mOriginalPreviewWidth;
- mOriginalPreviewWidth = mOriginalPreviewHeight;
- mOriginalPreviewHeight = temp;
- }
- }
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ }
- if (mPreviewWidth != width || mPreviewHeight != height
- || (mOrientationResize != mPrevOrientationResize)
- || mAspectRatioResize) {
- if (mOriginalPreviewWidth == 0) mOriginalPreviewWidth = width;
- if (mOriginalPreviewHeight == 0) mOriginalPreviewHeight = height;
- mPreviewWidth = width;
- mPreviewHeight = height;
- setTransformMatrix(mPreviewWidth, mPreviewHeight);
- mController.onScreenSizeChanged((int) mSurfaceTextureUncroppedWidth,
- (int) mSurfaceTextureUncroppedHeight);
- mAspectRatioResize = false;
- }
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ mSurfaceHolder2 = holder;
+ if (surface1created) mModule.onPreviewUIReady();
+ surface2created = true;
+ }
- if (mMenu != null)
- mMenu.tryToCloseSubList();
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ mSurfaceHolder2 = null;
+ surface2created = false;
}
};
- public CaptureUI(CameraActivity activity, PhotoController controller, View parent) {
+ public CaptureUI(CameraActivity activity, CaptureModule module, View parent) {
mActivity = activity;
- mController = controller;
+ mModule = module;
mRootView = parent;
+ mSettingsManager = SettingsManager.getInstance();
+ mSettingsManager.registerListener(this);
mActivity.getLayoutInflater().inflate(R.layout.capture_module,
(ViewGroup) mRootView, true);
mPreviewCover = mRootView.findViewById(R.id.preview_cover);
// display the view
- mSurfaceView = (SurfaceView) mRootView.findViewById(R.id.mdp_preview_content);
- mSurfaceView2 = (SurfaceView) mRootView.findViewById(R.id.mdp_preview_content2);
+ mSurfaceView = (AutoFitSurfaceView) mRootView.findViewById(R.id.mdp_preview_content);
+ mSurfaceView2 = (AutoFitSurfaceView) mRootView.findViewById(R.id.mdp_preview_content2);
mSurfaceView2.setZOrderMediaOverlay(true);
mSurfaceHolder = mSurfaceView.getHolder();
- mSurfaceHolder.addCallback(this);
+ mSurfaceHolder.addCallback(callback);
mSurfaceHolder2 = mSurfaceView2.getHolder();
- mSurfaceHolder2.addCallback(callback);
- Log.v(TAG, "Using mdp_preview_content (MDP path)");
+ mSurfaceHolder2.addCallback(callback2);
mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
mShutterButton = (ShutterButton) mRootView.findViewById(R.id.shutter_button);
+ mFilterModeSwitcher = mRootView.findViewById(R.id.filter_mode_switcher);
+ mSceneModeSwitcher = mRootView.findViewById(R.id.scene_mode_switcher);
+ mFrontBackSwitcher = mRootView.findViewById(R.id.front_back_switcher);
+ initFilterModeButton();
+ initSceneModeButton();
+ initSwitchCamera();
+
mSwitcher = (ModuleSwitcher) mRootView.findViewById(R.id.camera_switcher);
mSwitcher.setCurrentIndex(ModuleSwitcher.PHOTO_MODULE_INDEX);
mSwitcher.setSwitchListener(mActivity);
- mSwitcher.setOnClickListener(new OnClickListener() {
+ mSwitcher.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mController.getCameraState() == PhotoController.LONGSHOT) {
+ if (mModule.getCameraState() == PhotoController.LONGSHOT) {
return;
}
mSwitcher.showPopup();
@@ -217,10 +238,6 @@ public class CaptureUI implements PieListener,
mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls);
- initIndicators();
- mOrientationResize = false;
- mPrevOrientationResize = false;
-
Point size = new Point();
mActivity.getWindowManager().getDefaultDisplay().getSize(size);
mScreenRatio = CameraUtil.determineRatio(size.x, size.y);
@@ -234,64 +251,11 @@ public class CaptureUI implements PieListener,
mCameraControls.setMargins(mTopMargin, mBottomMargin);
}
- private void setTransformMatrix(int width, int height) {
- mMatrix = mSurfaceView.getMatrix();
-
- // Calculate the new preview rectangle.
- RectF previewRect = new RectF(0, 0, width, height);
- mMatrix.mapRect(previewRect);
- mController.onPreviewRectChanged(CameraUtil.rectFToRect(previewRect));
- }
-
- // SurfaceHolder callbacks
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.v(TAG, "surfaceChanged: width =" + width + ", height = " + height);
- }
-
- @Override
- public void surfaceCreated(SurfaceHolder holder) {
- Log.v(TAG, "surfaceCreated");
- mSurfaceHolder = holder;
- if (surface2created) mController.onPreviewUIReady();
- surface1created = true;
- if (mPreviewWidth != 0 && mPreviewHeight != 0) {
- // Re-apply transform matrix for new surface texture
- setTransformMatrix(mPreviewWidth, mPreviewHeight);
- }
- }
-
- @Override
- public void surfaceDestroyed(SurfaceHolder holder) {
- Log.v(TAG, "surfaceDestroyed");
- mSurfaceHolder = null;
- surface1created = false;
- mController.onPreviewUIDestroyed();
- }
-
- public View getRootView() {
- return mRootView;
- }
-
- private void initIndicators() {
- mOnScreenIndicators = new OnScreenIndicators(mActivity,
- mRootView.findViewById(R.id.on_screen_indicators));
- }
-
- public void onCameraOpened(CameraCharacteristics[] characteristics,
- List<Integer> characteristicsIndex, PreferenceGroup prefGroup,
- OnPreferenceChangedListener listener) {
+ public void onCameraOpened(List<Integer> cameraIds) {
if (mPieRenderer == null) {
mPieRenderer = new PieRenderer(mActivity);
- mPieRenderer.setPieListener(this);
mRenderOverlay.addRenderer(mPieRenderer);
}
-
- if (mMenu == null) {
- mMenu = new CaptureMenu(mActivity, this);
- mMenu.setListener(listener);
- }
- mMenu.initialize(prefGroup);
mMenuInitialized = true;
if (mZoomRenderer == null) {
@@ -304,209 +268,659 @@ public class CaptureUI implements PieListener,
mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer);
mRenderOverlay.setGestures(mGestures);
}
- mGestures.setCaptureMenu(mMenu);
+ mGestures.setCaptureUI(this); // need to handle touch
- mGestures.setZoomEnabled(CameraUtil.isZoomSupported(characteristics, characteristicsIndex));
+ mGestures.setZoomEnabled(mSettingsManager.isZoomSupported(cameraIds));
mGestures.setRenderOverlay(mRenderOverlay);
mRenderOverlay.requestLayout();
- initializeZoom(characteristics, characteristicsIndex);
+ initializeZoom(cameraIds);
mActivity.setPreviewGestures(mGestures);
}
- public void initializeControlByIntent() {
- mMenuButton = mRootView.findViewById(R.id.menu);
- mMenuButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mMenu != null) {
- mMenu.openFirstLevel();
- }
- }
- });
- }
-
- public void hideUI() {
- mSwitcher.closePopup();
- if (mUIhidden)
- return;
- mUIhidden = true;
- mCameraControls.hideUI();
- }
-
- public void showUI() {
- if (!mUIhidden || (mMenu != null && mMenu.isMenuBeingShown()))
- return;
- mUIhidden = false;
- mCameraControls.showUI();
- }
-
- public boolean arePreviewControlsVisible() {
- return !mUIhidden;
+ public ViewGroup getSceneAndFilterLayout() {
+ return mSceneAndFilterLayout;
}
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
mShutterButton.setImageResource(R.drawable.shutter_button_anim);
- mShutterButton.setOnClickListener(new OnClickListener() {
+ mShutterButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!CameraControls.isAnimating())
doShutterAnimation();
}
});
- mShutterButton.setOnShutterButtonListener(mController);
+ mShutterButton.setOnShutterButtonListener(mModule);
mShutterButton.setVisibility(View.VISIBLE);
}
- // called from onResume every other time
- public void initializeSecondTime() {
- if (mMenu != null) {
- mMenu.reloadPreferences();
+ public void initializeZoom(List<Integer> ids) {
+ if (!mSettingsManager.isZoomSupported(ids) || (mZoomRenderer == null))
+ return;
+
+ Float zoomMax = mSettingsManager.getMaxZoom(ids);
+ mZoomRenderer.setZoomMax(zoomMax);
+ mZoomRenderer.setZoom(1f);
+ mZoomRenderer.setOnZoomChangeListener(new ZoomChangeListener());
+ }
+
+ public void enableGestures(boolean enable) {
+ if (mGestures != null) {
+ mGestures.setEnabled(enable);
}
}
- public void doShutterAnimation() {
- AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getDrawable();
- frameAnimation.stop();
- frameAnimation.start();
+ public boolean isPreviewMenuBeingShown() {
+ return mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_ON;
}
- public void initializeZoom(CameraCharacteristics[] characteristics,
- List<Integer> characteristicsIndex) {
- if ((characteristics == null) || !CameraUtil.isZoomSupported(characteristics,
- characteristicsIndex) || (mZoomRenderer == null))
- return;
- if (mZoomRenderer != null) {
- float zoomMax = Float.MAX_VALUE;
- for (int i = 0; i < characteristicsIndex.size(); i++) {
- zoomMax = Math.min(characteristics[characteristicsIndex.get(i)].get
- (CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM), zoomMax);
+ public void removeSceneAndFilterMenu(boolean animate) {
+ if (animate) {
+ animateSlideOut(mSceneAndFilterLayout);
+ } else {
+ mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_NONE;
+ if (mSceneAndFilterLayout != null) {
+ ((ViewGroup) mRootView).removeView(mSceneAndFilterLayout);
+ mSceneAndFilterLayout = null;
}
- mZoomRenderer.setZoomMax(zoomMax);
- mZoomRenderer.setZoom(1f);
- mZoomRenderer.setOnZoomChangeListener(new ZoomChangeListener());
}
}
- @Override
- public void showGpsOnScreenIndicator(boolean hasSignal) {
+ public void initSwitchCamera() {
+ mFrontBackSwitcher.setVisibility(View.INVISIBLE);
+ String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID);
+ if (value == null)
+ return;
+
+ int[] largeIcons = mSettingsManager.getResource(SettingsManager.KEY_CAMERA_ID,
+ SettingsManager.RESOURCE_TYPE_LARGEICON);
+ ((ImageView) mFrontBackSwitcher).setImageResource(largeIcons[mSettingsManager
+ .getValueIndex(SettingsManager.KEY_CAMERA_ID)]);
+ mFrontBackSwitcher.setVisibility(View.VISIBLE);
+ mFrontBackSwitcher.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_CAMERA_ID);
+ if (value == null)
+ return;
+
+ int index = mSettingsManager.getValueIndex(SettingsManager.KEY_CAMERA_ID);
+ CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_CAMERA_ID);
+ index = (index + 1) % entries.length;
+ mSettingsManager.setValueIndex(SettingsManager.KEY_CAMERA_ID, index);
+ int[] largeIcons = mSettingsManager.getResource(SettingsManager.KEY_CAMERA_ID,
+ SettingsManager.RESOURCE_TYPE_LARGEICON);
+ ((ImageView) v).setImageResource(largeIcons[index]);
+ }
+ });
}
- @Override
- public void hideGpsOnScreenIndicator() {
+ public void initSceneModeButton() {
+ mSceneModeSwitcher.setVisibility(View.INVISIBLE);
+ String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ if (value == null) return;
+ updateSceneModeIcon();
+ mSceneModeSwitcher.setVisibility(View.VISIBLE);
+ mSceneModeSwitcher.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ addSceneMode();
+ ViewGroup menuLayout = getSceneAndFilterLayout();
+ if (menuLayout != null) {
+ View view = menuLayout.getChildAt(0);
+ adjustOrientation();
+ animateSlideIn(view, mSceneAndFilterMenuSize, false);
+ }
+ }
+ });
}
- public void overrideSettings(final String... keyvalues) {
- if (mMenu == null)
- return;
- mMenu.overrideSettings(keyvalues);
+ public void initFilterModeButton() {
+ mFilterModeSwitcher.setVisibility(View.INVISIBLE);
+ String value = mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT);
+ if (value == null) return;
+ changeFilterModeControlIcon(value);
+
+ updateFilterModeIcon(!mSettingsManager.isOverriden(SettingsManager.KEY_COLOR_EFFECT));
+ mFilterModeSwitcher.setVisibility(View.VISIBLE);
+ mFilterModeSwitcher.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ addFilterMode();
+ ViewGroup menuLayout = getSceneAndFilterLayout();
+ if (menuLayout != null) {
+ View view = getSceneAndFilterLayout().getChildAt(0);
+ adjustOrientation();
+ animateSlideIn(view, mSceneAndFilterMenuSize, false);
+ }
+ }
+ });
}
- public void enableGestures(boolean enable) {
- if (mGestures != null) {
- mGestures.setEnabled(enable);
+ public void setSwitcherIndex() {
+ mSwitcher.setCurrentIndex(ModuleSwitcher.PHOTO_MODULE_INDEX);
+ }
+
+ public void addSceneMode() {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ if (value == null) return;
+
+ int rotation = CameraUtil.getDisplayRotation(mActivity);
+ boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+ if (!mIsDefaultToPortrait) {
+ rotation = (rotation + 90) % 360;
+ }
+ WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+
+ CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE);
+
+ int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_SCENE_MODE,
+ SettingsManager.RESOURCE_TYPE_THUMBNAIL);
+ Resources r = mActivity.getResources();
+ int height = (int) (r.getDimension(R.dimen.scene_mode_height) + 2
+ * r.getDimension(R.dimen.scene_mode_padding) + 1);
+ int width = (int) (r.getDimension(R.dimen.scene_mode_width) + 2
+ * r.getDimension(R.dimen.scene_mode_padding) + 1);
+
+ int gridRes;
+ boolean portrait = (rotation == 0) || (rotation == 180);
+ int size = height;
+ if (portrait) {
+ gridRes = R.layout.vertical_grid;
+ size = width;
+ } else {
+ gridRes = R.layout.horiz_grid;
+ }
+ mSceneAndFilterMenuSize = size;
+ hideUI();
+
+ LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ FrameLayout gridOuterLayout = (FrameLayout) inflater.inflate(
+ gridRes, null, false);
+
+ removeSceneAndFilterMenu(false);
+ mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_ON;
+ mSceneAndFilterMenuMode = MODE_SCENE;
+ mSceneAndFilterLayout = new LinearLayout(mActivity);
+ ViewGroup.LayoutParams params = null;
+ if (portrait) {
+ params = new ViewGroup.LayoutParams(size, FrameLayout.LayoutParams.MATCH_PARENT);
+ mSceneAndFilterLayout.setLayoutParams(params);
+ ((ViewGroup) mRootView).addView(mSceneAndFilterLayout);
+ } else {
+ params = new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, size);
+ mSceneAndFilterLayout.setLayoutParams(params);
+ ((ViewGroup) mRootView).addView(mSceneAndFilterLayout);
+ mSceneAndFilterLayout.setY(display.getHeight() - size);
}
+ gridOuterLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams
+ .MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
+ LinearLayout gridLayout = (LinearLayout) gridOuterLayout.findViewById(R.id.layout);
+
+ final View[] views = new View[entries.length];
+ int init = mSettingsManager.getValueIndex(SettingsManager.KEY_SCENE_MODE);
+ for (int i = 0; i < entries.length; i++) {
+ RotateLayout sceneBox = (RotateLayout) inflater.inflate(
+ R.layout.scene_mode_view, null, false);
+
+ ImageView imageView = (ImageView) sceneBox.findViewById(R.id.image);
+ TextView label = (TextView) sceneBox.findViewById(R.id.label);
+ final int j = i;
+
+ sceneBox.setOnTouchListener(new View.OnTouchListener() {
+ private long startTime;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ startTime = System.currentTimeMillis();
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) {
+ mSettingsManager.setValueIndex(SettingsManager.KEY_SCENE_MODE, j);
+ updateSceneModeIcon();
+ for (View v1 : views) {
+ v1.setBackgroundResource(R.drawable.scene_mode_view_border);
+ }
+ View border = v.findViewById(R.id.border);
+ border.setBackgroundResource(R.drawable
+ .scene_mode_view_border_selected);
+ removeSceneAndFilterMenu(true);
+ }
+ }
+ return true;
+ }
+ });
+
+ View border = sceneBox.findViewById(R.id.border);
+ views[j] = border;
+ if (i == init)
+ border.setBackgroundResource(R.drawable.scene_mode_view_border_selected);
+
+ imageView.setImageResource(thumbnails[i]);
+ label.setText(entries[i]);
+ gridLayout.addView(sceneBox);
+ }
+ mSceneAndFilterLayout.addView(gridOuterLayout);
}
- // forward from preview gestures to controller
- @Override
- public void onSingleTapUp(View view, int x, int y) {
- mController.onSingleTapUp(view, x, y);
+ public void updateSceneModeIcon() {
+ int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_SCENE_MODE,
+ SettingsManager.RESOURCE_TYPE_THUMBNAIL);
+ int thumbnail = thumbnails[mSettingsManager.getValueIndex(SettingsManager
+ .KEY_SCENE_MODE)];
+ if (thumbnail == -1)
+ thumbnail = 0;
+ ((ImageView) mSceneModeSwitcher).setImageResource(thumbnail);
}
- public boolean onBackPressed() {
- if (mMenu != null && mMenu.handleBackKey()) {
- return true;
+ public void addFilterMode() {
+ if (mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT) == null)
+ return;
+
+ int rotation = CameraUtil.getDisplayRotation(mActivity);
+ boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+ if (!mIsDefaultToPortrait) {
+ rotation = (rotation + 90) % 360;
+ }
+ WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+ CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_COLOR_EFFECT);
+
+ Resources r = mActivity.getResources();
+ int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2
+ * r.getDimension(R.dimen.filter_mode_padding) + 1);
+ int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2
+ * r.getDimension(R.dimen.filter_mode_padding) + 1);
+
+ int gridRes;
+ boolean portrait = (rotation == 0) || (rotation == 180);
+ int size = height;
+ if (portrait) {
+ gridRes = R.layout.vertical_grid;
+ size = width;
+ } else {
+ gridRes = R.layout.horiz_grid;
}
+ mSceneAndFilterMenuSize = size;
+ hideUI();
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- return true;
+ int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_COLOR_EFFECT,
+ SettingsManager.RESOURCE_TYPE_THUMBNAIL);
+ LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ FrameLayout gridOuterLayout = (FrameLayout) inflater.inflate(
+ gridRes, null, false);
+
+ removeSceneAndFilterMenu(false);
+ mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_ON;
+ mSceneAndFilterMenuMode = MODE_FILTER;
+ mSceneAndFilterLayout = new LinearLayout(mActivity);
+
+ ViewGroup.LayoutParams params = null;
+ if (portrait) {
+ params = new ViewGroup.LayoutParams(size, FrameLayout.LayoutParams.MATCH_PARENT);
+ mSceneAndFilterLayout.setLayoutParams(params);
+ ((ViewGroup) mRootView).addView(mSceneAndFilterLayout);
+ } else {
+ params = new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, size);
+ mSceneAndFilterLayout.setLayoutParams(params);
+ ((ViewGroup) mRootView).addView(mSceneAndFilterLayout);
+ mSceneAndFilterLayout.setY(display.getHeight() - size);
}
- // In image capture mode, back button should:
- // 1) if there is any popup, dismiss them, 2) otherwise, get out of
- // image capture
- if (mController.isImageCaptureIntent()) {
- mController.onCaptureCancelled();
- return true;
- } else if (!mController.isCameraIdle()) {
- // ignore backs while we're taking a picture
- return true;
+ gridOuterLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams
+ .MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
+ LinearLayout gridLayout = (LinearLayout) gridOuterLayout.findViewById(R.id.layout);
+ final View[] views = new View[entries.length];
+
+ int init = mSettingsManager.getValueIndex(SettingsManager.KEY_COLOR_EFFECT);
+ for (int i = 0; i < entries.length; i++) {
+ RotateLayout filterBox = (RotateLayout) inflater.inflate(
+ R.layout.filter_mode_view, null, false);
+ ImageView imageView = (ImageView) filterBox.findViewById(R.id.image);
+ final int j = i;
+
+ filterBox.setOnTouchListener(new View.OnTouchListener() {
+ private long startTime;
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ startTime = System.currentTimeMillis();
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) {
+ mSettingsManager.setValueIndex(SettingsManager
+ .KEY_COLOR_EFFECT, j);
+ for (View v1 : views) {
+ v1.setBackground(null);
+ }
+ ImageView image = (ImageView) v.findViewById(R.id.image);
+ image.setBackgroundColor(HIGHLIGHT_COLOR);
+ }
+ }
+ return true;
+ }
+ });
+
+ views[j] = imageView;
+ if (i == init)
+ imageView.setBackgroundColor(HIGHLIGHT_COLOR);
+ TextView label = (TextView) filterBox.findViewById(R.id.label);
+
+ imageView.setImageResource(thumbnails[i]);
+ label.setText(entries[i]);
+ gridLayout.addView(filterBox);
}
- if (mSwitcher != null && mSwitcher.showsPopup()) {
- mSwitcher.closePopup();
- return true;
+ mSceneAndFilterLayout.addView(gridOuterLayout);
+ }
+
+ private void changeFilterModeControlIcon(String value) {
+ int index;
+ if (value.equals("0")) {
+ index = 0;
} else {
- return false;
+ index = 1;
}
+ ImageView iv = (ImageView) mFilterModeSwitcher;
+ iv.setImageResource(mSettingsManager.getResource(SettingsManager
+ .KEY_COLOR_EFFECT, SettingsManager.RESOURCE_TYPE_LARGEICON)[index]);
}
- public void onPreviewFocusChanged(boolean previewFocused) {
- if (previewFocused) {
- showUI();
+ private void updateFilterModeIcon(boolean enable) {
+ buttonSetEnabled(mFilterModeSwitcher, enable);
+ }
+
+ private void buttonSetEnabled(View v, boolean enable) {
+ v.setEnabled(enable);
+ if (v instanceof ViewGroup) {
+ View v2 = ((ViewGroup) v).getChildAt(0);
+ if (v2 != null)
+ v2.setEnabled(enable);
+ }
+ }
+
+ private void animateFadeOut(final View v, final int level) {
+ if (v == null || mSettingMenuState == SETTING_MENU_IN_ANIMATION)
+ return;
+ mSettingMenuState = SETTING_MENU_IN_ANIMATION;
+
+ ViewPropertyAnimator vp = v.animate();
+ vp.alpha(0f).setDuration(ANIMATION_DURATION);
+ vp.setListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ finishSettingMenuAnimateOut(level);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ finishSettingMenuAnimateOut(level);
+ }
+ });
+ vp.start();
+ }
+
+ private void animateSlideOut(final View v, final int level) {
+ if (v == null || mSettingMenuState == SETTING_MENU_IN_ANIMATION)
+ return;
+ mSettingMenuState = SETTING_MENU_IN_ANIMATION;
+ ViewPropertyAnimator vp = v.animate();
+ if (View.LAYOUT_DIRECTION_RTL == TextUtils
+ .getLayoutDirectionFromLocale(Locale.getDefault())) {
+ switch (getOrientation()) {
+ case 0:
+ vp.translationXBy(v.getWidth());
+ break;
+ case 90:
+ vp.translationYBy(-2 * v.getHeight());
+ break;
+ case 180:
+ vp.translationXBy(-2 * v.getWidth());
+ break;
+ case 270:
+ vp.translationYBy(v.getHeight());
+ break;
+ }
} else {
- hideUI();
+ switch (getOrientation()) {
+ case 0:
+ vp.translationXBy(-v.getWidth());
+ break;
+ case 90:
+ vp.translationYBy(2 * v.getHeight());
+ break;
+ case 180:
+ vp.translationXBy(2 * v.getWidth());
+ break;
+ case 270:
+ vp.translationYBy(-v.getHeight());
+ break;
+ }
}
- if (mGestures != null) {
- mGestures.setEnabled(previewFocused);
+ vp.setListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ finishSettingMenuAnimateOut(level);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ finishSettingMenuAnimateOut(level);
+ }
+ });
+ vp.setDuration(ANIMATION_DURATION).start();
+ }
+
+ private void finishSettingMenuAnimateOut(int level) {
+ if (level == SETTING_MENU_LEVEL_ONE) {
+ mSettingMenuState = SETTING_MENU_ON;
+ removeSettingMenu(level, false);
+ cleanUpMenus();
+ } else if (level == SETTING_MENU_LEVEL_TWO) {
+ mSettingMenuState = SETTING_MENU_ON;
+ removeSettingMenu(level, false);
}
- if (mRenderOverlay != null) {
- // this can not happen in capture mode
- mRenderOverlay.setVisibility(previewFocused ? View.VISIBLE : View.GONE);
+ }
+
+ private void finishScenceAndFilterMenuAnimateOut() {
+ removeSceneAndFilterMenu(false);
+ cleanUpMenus();
+ }
+
+ public void animateFadeIn(View v) {
+ ViewPropertyAnimator vp = v.animate();
+ vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
+ vp.start();
+ }
+
+ private void animateSlideOut(final View v) {
+ if (v == null || mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_IN_ANIMATION)
+ return;
+ mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_IN_ANIMATION;
+
+ ViewPropertyAnimator vp = v.animate();
+ if (View.LAYOUT_DIRECTION_RTL == TextUtils
+ .getLayoutDirectionFromLocale(Locale.getDefault())) {
+ vp.translationXBy(v.getWidth()).setDuration(ANIMATION_DURATION);
+ } else {
+ vp.translationXBy(-v.getWidth()).setDuration(ANIMATION_DURATION);
}
- if (mPieRenderer != null) {
- mPieRenderer.setBlockFocus(!previewFocused);
+ vp.setListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ finishScenceAndFilterMenuAnimateOut();
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ finishScenceAndFilterMenuAnimateOut();
+ }
+ });
+ vp.start();
+ }
+
+ public void animateSlideIn(View v, int delta, boolean forcePortrait) {
+ int orientation = getOrientation();
+ if (!forcePortrait)
+ orientation = 0;
+
+ ViewPropertyAnimator vp = v.animate();
+ float dest;
+ if (View.LAYOUT_DIRECTION_RTL == TextUtils
+ .getLayoutDirectionFromLocale(Locale.getDefault())) {
+ switch (orientation) {
+ case 0:
+ dest = v.getX();
+ v.setX(-(dest - delta));
+ vp.translationX(dest);
+ break;
+ case 90:
+ dest = v.getY();
+ v.setY(-(dest + delta));
+ vp.translationY(dest);
+ break;
+ case 180:
+ dest = v.getX();
+ v.setX(-(dest + delta));
+ vp.translationX(dest);
+ break;
+ case 270:
+ dest = v.getY();
+ v.setY(-(dest - delta));
+ vp.translationY(dest);
+ break;
+ }
+ } else {
+ switch (orientation) {
+ case 0:
+ dest = v.getX();
+ v.setX(dest - delta);
+ vp.translationX(dest);
+ break;
+ case 90:
+ dest = v.getY();
+ v.setY(dest + delta);
+ vp.translationY(dest);
+ break;
+ case 180:
+ dest = v.getX();
+ v.setX(dest + delta);
+ vp.translationX(dest);
+ break;
+ case 270:
+ dest = v.getY();
+ v.setY(dest - delta);
+ vp.translationY(dest);
+ break;
+ }
}
- setShowMenu(previewFocused);
+ vp.setDuration(ANIMATION_DURATION).start();
}
- public ViewGroup getMenuLayout() {
- return mMenuLayout;
+ private void initializeSettingMenu() {
+ LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ mSettingMenu = (ListMenu) inflater.inflate(
+ R.layout.list_menu, null, false);
+
+ mSettingMenu.setSettingChangedListener(this);
+ mSettingMenu.setSettingsManager(mSettingsManager);
+
+ String[] keys = mSettingKeys;
+ if (mActivity.isDeveloperMenuEnabled())
+ keys = mDeveloperKeys;
+ mSettingMenu.initializeForCamera2(keys);
+ }
+
+ public boolean isMenuBeingShown() {
+ return mSettingMenuState != SETTING_MENU_NONE;
}
- public void showPopup(ListView popup, int level, boolean animate) {
+ public boolean isMenuBeingAnimated() {
+ return mSettingMenuState == SETTING_MENU_IN_ANIMATION;
+ }
+
+
+ public void showSettingMenu() {
+ if (isMenuBeingShown() || CameraControls.isAnimating()) {
+ return;
+ }
+ if (mSettingMenu == null) {
+ initializeSettingMenu();
+ }
+ showSettingMenu(SETTING_MENU_LEVEL_ONE, true);
+ }
+
+ private void showSettingMenu(int level, boolean animate) {
FrameLayout.LayoutParams params;
hideUI();
- popup.setVisibility(View.VISIBLE);
- if (level == 1) {
+ mSettingMenu.setVisibility(View.VISIBLE);
+ mSettingMenuState = SETTING_MENU_ON;
+ if (level == SETTING_MENU_LEVEL_ONE) {
+ mSettingMenuLevel = SETTING_MENU_LEVEL_ONE;
if (mMenuLayout == null) {
mMenuLayout = new RotateLayout(mActivity, null);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
- params = new FrameLayout.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT,
- Gravity.LEFT | Gravity.TOP);
+ params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1,
+ FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
- params = new FrameLayout.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT,
- Gravity.RIGHT | Gravity.TOP);
+ params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1,
+ FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
mMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mMenuLayout);
}
mMenuLayout.setOrientation(mOrientation, true);
- mMenuLayout.addView(popup);
- }
- if (level == 2) {
+ mMenuLayout.addView(mSettingMenu);
+ } else if (level == SETTING_MENU_LEVEL_TWO) {
+ mSettingMenuLevel = SETTING_MENU_LEVEL_TWO;
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
((ViewGroup) mRootView).addView(mSubMenuLayout);
}
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
- params = new FrameLayout.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT,
- Gravity.LEFT | Gravity.TOP);
+ params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2,
+ FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
} else {
- params = new FrameLayout.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT,
- Gravity.RIGHT | Gravity.TOP);
+ params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2,
+ FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
}
int screenHeight = (mOrientation == 0 || mOrientation == 180)
? mRootView.getHeight() : mRootView.getWidth();
- int height = ((ListSubMenu) popup).getPreCalculatedHeight();
- int yBase = ((ListSubMenu) popup).getYBase();
+ int height = mSettingSubMenu.getPreCalculatedHeight();
+ int yBase = mSettingSubMenu.getYBase();
int y = Math.max(0, yBase);
if (yBase + height > screenHeight)
y = Math.max(0, screenHeight - height);
@@ -518,112 +932,117 @@ public class CaptureUI implements PieListener,
mSubMenuLayout.setLayoutParams(params);
- mSubMenuLayout.addView(popup);
+ mSubMenuLayout.addView(mSettingSubMenu);
mSubMenuLayout.setOrientation(mOrientation, true);
}
if (animate) {
- if (level == 1)
- mMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
- if (level == 2)
- mMenu.animateFadeIn(popup);
- } else
- popup.setAlpha(0.85f);
- }
-
- public void removeLevel2() {
- if (mSubMenuLayout != null) {
- View v = mSubMenuLayout.getChildAt(0);
- mSubMenuLayout.removeView(v);
+ if (level == SETTING_MENU_LEVEL_ONE) {
+ animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
+ }
+ if (level == SETTING_MENU_LEVEL_TWO) {
+ animateFadeIn(mSettingSubMenu);
+ }
+ } else {
+ if (level == SETTING_MENU_LEVEL_ONE) {
+ mMenuLayout.setAlpha(0.85f);
+ }
+ if (level == SETTING_MENU_LEVEL_TWO) {
+ mSettingSubMenu.setAlpha(0.85f);
+ }
}
}
- public void cleanupListview() {
- showUI();
- mActivity.setSystemBarsVisibility(false);
- }
-
- public void dismissAllPopup() {
- if (mPopup != null && mPopup.isShowing()) {
- mPopup.dismiss();
- }
+ public void initializeControlByIntent() {
+ mMenuButton = mRootView.findViewById(R.id.menu);
+ mMenuButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showSettingMenu();
+ }
+ });
}
- public void dismissLevel1() {
- if (mMenuLayout != null) {
- ((ViewGroup) mRootView).removeView(mMenuLayout);
- mMenuLayout = null;
- }
+ public void doShutterAnimation() {
+ AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getDrawable();
+ frameAnimation.stop();
+ frameAnimation.start();
}
- public void dismissLevel2() {
- if (mSubMenuLayout != null) {
- ((ViewGroup) mRootView).removeView(mSubMenuLayout);
- mSubMenuLayout = null;
- }
+ public void showUI() {
+ if (!mUIhidden || isMenuBeingShown())
+ return;
+ mUIhidden = false;
+ mCameraControls.showUI();
}
- public boolean sendTouchToPreviewMenu(MotionEvent ev) {
- return mPreviewMenuLayout.dispatchTouchEvent(ev);
+ public void hideUI() {
+ mSwitcher.closePopup();
+ if (mUIhidden)
+ return;
+ mUIhidden = true;
+ mCameraControls.hideUI();
}
- public boolean sendTouchToMenu(MotionEvent ev) {
- if (mMenuLayout != null) {
- View v = mMenuLayout.getChildAt(0);
- return v.dispatchTouchEvent(ev);
- }
- return false;
+ public void cleanUpMenus() {
+ showUI();
+ mActivity.setSystemBarsVisibility(false);
}
- public void dismissSceneModeMenu() {
- if (mPreviewMenuLayout != null) {
- ((ViewGroup) mRootView).removeView(mPreviewMenuLayout);
- mPreviewMenuLayout = null;
- }
+ public boolean arePreviewControlsVisible() {
+ return !mUIhidden;
}
- public void onShowSwitcherPopup() {
- if (mPieRenderer != null && mPieRenderer.showsItems()) {
- mPieRenderer.hide();
- }
+ public void onOrientationChanged() {
+ removeSettingMenu(SETTING_MENU_LEVEL_TWO, false);
+ if (mSettingMenu != null)
+ mSettingMenu.resetHighlight();
}
- private void setShowMenu(boolean show) {
- if (mOnScreenIndicators != null) {
- mOnScreenIndicators.setVisibility(show ? View.VISIBLE : View.GONE);
- }
+ public void removeAllSettingMenu(boolean animate) {
+ removeSettingMenu(SETTING_MENU_LEVEL_TWO, false);
+ removeSettingMenu(SETTING_MENU_LEVEL_ONE, animate);
}
- public boolean collapseCameraControls() {
- // TODO: Mode switcher should behave like a popup and should hide itself when there
- // is a touch outside of it.
- mSwitcher.closePopup();
- // Remove all the popups/dialog boxes
- boolean ret = false;
- if (mMenu != null) {
- mMenu.removeAllView();
- }
- if (mPopup != null) {
- dismissAllPopup();
- ret = true;
- }
- onShowSwitcherPopup();
- return ret;
+ public void removeAllSettingMenu() {
+ removeAllSettingMenu(false);
}
- public void setDisplayOrientation(int orientation) {
- if ((mPreviewOrientation == -1 || mPreviewOrientation != orientation)
- && mMenu != null && mMenu.isPreviewMenuBeingShown()) {
- dismissSceneModeMenu();
+ public void removeSettingMenu(int level, boolean animate) {
+ if (mSettingMenuState == SETTING_MENU_NONE)
+ return;
+ if (!animate) {
+ if (level == SETTING_MENU_LEVEL_TWO) {
+ if (mSubMenuLayout != null) {
+ mSubMenuLayout.removeView(mSubMenuLayout.getChildAt(0));
+ mSubMenuLayout = null;
+ }
+ mSettingSubMenu = null;
+ mSettingMenuState = SETTING_MENU_ON;
+ mSettingMenuLevel = SETTING_MENU_LEVEL_ONE;
+ } else if (level == SETTING_MENU_LEVEL_ONE) {
+ mSettingMenu.resetHighlight();
+ if (mMenuLayout != null) {
+ mMenuLayout.removeView(mMenuLayout.getChildAt(0));
+ mMenuLayout = null;
+ }
+ mSettingMenu = null;
+ mSettingMenuState = SETTING_MENU_NONE;
+ cleanUpMenus();
+ }
+ } else {
+ if (level == SETTING_MENU_LEVEL_TWO) {
+ mSettingMenu.resetHighlight();
+ animateFadeOut(mSettingSubMenu, level);
+ } else if (level == SETTING_MENU_LEVEL_ONE) {
+ animateSlideOut(mSettingMenu, level);
+ }
}
- mPreviewOrientation = orientation;
}
- public boolean isShutterPressed() {
- return mShutterButton.isPressed();
+ public void removeAllMenu() {
+ removeAllSettingMenu();
}
- // shutter button handling
-
/**
* Enables or disables the shutter button.
*/
@@ -633,29 +1052,36 @@ public class CaptureUI implements PieListener,
}
}
- public void pressShutterButton() {
- if (mShutterButton.isInTouchMode()) {
- mShutterButton.requestFocusFromTouch();
- } else {
- mShutterButton.requestFocus();
+ private boolean handleBackKeyOnMenu() {
+ if (mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_ON) {
+ removeSceneAndFilterMenu(true);
+ return true;
}
- mShutterButton.setPressed(true);
- }
-
- @Override
- public void onPieOpened(int centerX, int centerY) {
- setSwipingEnabled(false);
- // Close module selection menu when pie menu is opened.
- mSwitcher.closePopup();
+ if (mSettingMenuState == SETTING_MENU_NONE)
+ return false;
+ if (mSettingMenuState == SETTING_MENU_ON) {
+ removeSettingMenu(mSettingMenuLevel, true);
+ }
+ return true;
}
- @Override
- public void onPieClosed() {
- setSwipingEnabled(true);
- }
+ public boolean onBackPressed() {
+ if (handleBackKeyOnMenu()) return true;
+ if (mPieRenderer != null && mPieRenderer.showsItems()) {
+ mPieRenderer.hide();
+ return true;
+ }
- public void setSwipingEnabled(boolean enable) {
- mActivity.setSwipingEnabled(enable);
+ if (!mModule.isCameraIdle()) {
+ // ignore backs while we're taking a picture
+ return true;
+ }
+ if (mSwitcher != null && mSwitcher.showsPopup()) {
+ mSwitcher.closePopup();
+ return true;
+ } else {
+ return false;
+ }
}
public SurfaceHolder getSurfaceHolder() {
@@ -677,20 +1103,22 @@ public class CaptureUI implements PieListener,
}
}
- public void hideSurfaceView() {
- mSurfaceView.setVisibility(View.INVISIBLE);
- }
-
- public void showSurfaceView() {
- mSurfaceView.setVisibility(View.VISIBLE);
- }
-
public void onPause() {
// Clear UI.
collapseCameraControls();
}
- // focus UI implementation
+ public boolean collapseCameraControls() {
+ // TODO: Mode switcher should behave like a popup and should hide itself when there
+ // is a touch outside of it.
+ mSwitcher.closePopup();
+ // Remove all the popups/dialog boxes
+ boolean ret = false;
+ removeAllMenu();
+ mCameraControls.showRefocusToast(false);
+ return ret;
+ }
+
private FocusIndicator getFocusIndicator() {
return mPieRenderer;
}
@@ -703,10 +1131,6 @@ public class CaptureUI implements PieListener,
public void clearFaces() {
}
- public void setPreference(String key, String value) {
- mMenu.setPreference(key, value);
- }
-
@Override
public void clearFocus() {
FocusIndicator indicator = getFocusIndicator();
@@ -731,13 +1155,13 @@ public class CaptureUI implements PieListener,
}
@Override
- public void onFocusFailed(boolean timeout) {
- FocusIndicator indicator = getFocusIndicator();
- if (indicator != null) indicator.showFail(timeout);
+ public void onFocusFailed(boolean timeOut) {
+
}
@Override
public void pauseFaceDetection() {
+
}
@Override
@@ -754,11 +1178,20 @@ public class CaptureUI implements PieListener,
public void onFaceDetection(Face[] faces, CameraManager.CameraProxy camera) {
}
- @Override
- public void onDisplayChanged() {
- Log.d(TAG, "Device flip detected.");
- mCameraControls.checkLayoutFlip();
- mController.updateCameraOrientation();
+ public Point getSurfaceViewSize() {
+ Point point = new Point();
+ if (mSurfaceView != null) point.set(mSurfaceView.getWidth(), mSurfaceView.getHeight());
+ return point;
+ }
+
+ public Point getSurfaceView2Size() {
+ Point point = new Point();
+ if (mSurfaceView2 != null) point.set(mSurfaceView2.getWidth(), mSurfaceView2.getHeight());
+ return point;
+ }
+
+ public void adjustOrientation() {
+ setOrientation(mOrientation, true);
}
public void setOrientation(int orientation, boolean animation) {
@@ -768,8 +1201,8 @@ public class CaptureUI implements PieListener,
mMenuLayout.setOrientation(orientation, animation);
if (mSubMenuLayout != null)
mSubMenuLayout.setOrientation(orientation, animation);
- if (mPreviewMenuLayout != null) {
- ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0);
+ if (mSceneAndFilterLayout != null) {
+ ViewGroup vg = (ViewGroup) mSceneAndFilterLayout.getChildAt(0);
if (vg != null)
vg = (ViewGroup) vg.getChildAt(0);
if (vg != null) {
@@ -779,33 +1212,145 @@ public class CaptureUI implements PieListener,
}
}
}
-
RotateTextToast.setOrientation(orientation);
if (mZoomRenderer != null) {
mZoomRenderer.setOrientation(orientation);
}
}
- public Point getSurfaceViewSize() {
- Point point = new Point();
- if (mSurfaceView != null) point.set(mSurfaceView.getWidth(), mSurfaceView.getHeight());
- return point;
+ public int getOrientation() {
+ return mOrientation;
}
- public Point getSurfaceView2Size() {
- Point point = new Point();
- if (mSurfaceView2 != null) point.set(mSurfaceView2.getWidth(), mSurfaceView2.getHeight());
- return point;
+ @Override
+ public void showGpsOnScreenIndicator(boolean hasSignal) {
+
}
- public int getOrientation() {
- return mOrientation;
+ @Override
+ public void hideGpsOnScreenIndicator() {
+
+ }
+
+ @Override
+ public void onSingleTapUp(View view, int x, int y) {
+ mModule.onSingleTapUp(view, x, y);
+ }
+
+ public void onPreviewFocusChanged(boolean previewFocused) {
+ if (previewFocused) {
+ showUI();
+ } else {
+ hideUI();
+ }
+ if (mGestures != null) {
+ mGestures.setEnabled(previewFocused);
+ }
+ if (mRenderOverlay != null) {
+ // this can not happen in capture mode
+ mRenderOverlay.setVisibility(previewFocused ? View.VISIBLE : View.GONE);
+ }
+ if (mPieRenderer != null) {
+ mPieRenderer.setBlockFocus(!previewFocused);
+ }
+ }
+
+ public ViewGroup getMenuLayout() {
+ return mMenuLayout;
+ }
+
+ public boolean isShutterPressed() {
+ return mShutterButton.isPressed();
+ }
+
+ public void pressShutterButton() {
+ if (mShutterButton.isInTouchMode()) {
+ mShutterButton.requestFocusFromTouch();
+ } else {
+ mShutterButton.requestFocus();
+ }
+ mShutterButton.setPressed(true);
+ }
+
+ @Override
+ public void onSettingsChanged(List<SettingsManager.SettingState> settings) {
+ for (SettingsManager.SettingState setting : settings) {
+ String key = setting.key;
+ SettingsManager.Values values = setting.values;
+ String value = (values.overriddenValue == null) ? values.value : values.overriddenValue;
+ switch (key) {
+ case SettingsManager.KEY_CAMERA2:
+ switchCameraMode(value);
+ return;
+ case SettingsManager.KEY_CAMERA_ID:
+ case SettingsManager.KEY_DUAL_CAMERA:
+ case SettingsManager.KEY_CLEARSIGHT:
+ case SettingsManager.KEY_PICTURE_SIZE:
+ mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
+ return;
+ case SettingsManager.KEY_COLOR_EFFECT:
+ changeFilterModeControlIcon(value);
+ updateFilterModeIcon(values.overriddenValue == null);
+ break;
+ }
+ }
+ }
+
+ public void setPreviewSize(int width, int height) {
+ mSurfaceView.setAspectRatio(width, height);
+ }
+
+ private void switchCameraMode(String value) {
+ if (value.equals("enable")) {
+ mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
+ } else {
+ mActivity.onModuleSelected(ModuleSwitcher.PHOTO_MODULE_INDEX);
+ }
+ }
+
+ @Override
+ public void onSettingChanged(ListPreference pref) {
+ removeAllSettingMenu();
+ }
+
+ @Override
+ public void onPreferenceClicked(ListPreference pref) {
+ onPreferenceClicked(pref, 0);
+ }
+
+ @Override
+ public void onPreferenceClicked(ListPreference pref, int y) {
+ LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+ Context.LAYOUT_INFLATER_SERVICE);
+ removeSettingMenu(SETTING_MENU_LEVEL_TWO, false);
+ mSettingSubMenu = (ListSubMenu) inflater.inflate(R.layout.list_sub_menu, null, false);
+ mSettingSubMenu.initialize(pref, y);
+ mSettingSubMenu.setSettingChangedListener(mSettingMenu);
+ mSettingSubMenu.setAlpha(0f);
+
+ if (mSettingMenuState == SETTING_MENU_ON) {
+ if (mSettingMenuLevel == SETTING_MENU_LEVEL_TWO) {
+ showSettingMenu(SETTING_MENU_LEVEL_TWO, false);
+ } else if (mSettingMenuLevel == SETTING_MENU_LEVEL_ONE) {
+ showSettingMenu(SETTING_MENU_LEVEL_TWO, true);
+ }
+ }
+ }
+
+ @Override
+ public void onListMenuTouched() {
+ removeSettingMenu(SETTING_MENU_LEVEL_TWO, false);
+ }
+
+ @Override
+ public void onListPrefChanged(ListPreference pref) {
+ removeAllSettingMenu();
}
private class ZoomChangeListener implements ZoomRenderer.OnZoomChangedListener {
@Override
public void onZoomValueChanged(float mZoomValue) {
- mController.onZoomChanged(mZoomValue);
+ mModule.onZoomChanged(mZoomValue);
if (mZoomRenderer != null) {
mZoomRenderer.setZoom(mZoomValue);
}
diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java
index e5cf727..9e039bf 100644
--- a/src/com/android/camera/ComboPreferences.java
+++ b/src/com/android/camera/ComboPreferences.java
@@ -155,7 +155,11 @@ public class ComboPreferences implements
|| key.equals(CameraSettings.KEY_PHOTOSPHERE_PICTURESIZE)
|| key.equals(CameraSettings.KEY_CAMERA_SAVEPATH)
|| key.equals(CameraSettings.KEY_POWER_SHUTTER)
- || key.equals(CameraSettings.KEY_MAX_BRIGHTNESS);
+ || key.equals(CameraSettings.KEY_MAX_BRIGHTNESS
+ || key.equals(SettingsManager.KEY_CAMERA2)
+ || key.equals(SettingsManager.KEY_DUAL_CAMERA)
+ || key.equals(SettingsManager.KEY_MONO_PREVIEW)
+ || key.equals(SettingsManager.KEY_CLEARSIGHT);
}
@Override
diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java
index 1abda7c..9b8fd68 100644
--- a/src/com/android/camera/ListPreference.java
+++ b/src/com/android/camera/ListPreference.java
@@ -42,6 +42,7 @@ public class ListPreference extends CameraPreference {
private CharSequence[] mEntries;
private CharSequence[] mEntryValues;
+ private CharSequence[] mDependencyList;
private CharSequence[] mLabels;
private boolean mLoaded = false;
@@ -73,6 +74,8 @@ public class ListPreference extends CameraPreference {
R.styleable.ListPreference_entryValues));
setLabels(a.getTextArray(
R.styleable.ListPreference_labelList));
+ setDependencyList(a.getTextArray(
+ R.styleable.ListPreference_dependencyList));
a.recycle();
}
@@ -92,6 +95,10 @@ public class ListPreference extends CameraPreference {
return mLabels;
}
+ public CharSequence[] getDependencyList() {
+ return mDependencyList;
+ }
+
public void setEntries(CharSequence entries[]) {
mEntries = entries == null ? new CharSequence[0] : entries;
}
@@ -104,6 +111,10 @@ public class ListPreference extends CameraPreference {
mLabels = labels == null ? new CharSequence[0] : labels;
}
+ public void setDependencyList(CharSequence dependencyList[]) {
+ mDependencyList = dependencyList == null ? new CharSequence[0] : dependencyList;
+ }
+
public String getValue() {
if (!mLoaded) {
mValue = getSharedPreferences().getString(mKey,
@@ -113,6 +124,10 @@ public class ListPreference extends CameraPreference {
return mValue;
}
+ public String getOffValue() {
+ return mEntryValues[0].toString();
+ }
+
// Find the first value in mDefaultValues which is supported.
private String findSupportedDefaultValue() {
for (int i = 0; i < mDefaultValues.length; i++) {
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index 0c09ede..9984a52 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -213,7 +213,7 @@ public class PhotoMenu extends MenuController
CameraSettings.KEY_MANUAL_EXPOSURE,
CameraSettings.KEY_MANUAL_WB,
CameraSettings.KEY_MANUAL_FOCUS,
- CameraSettings.KEY_CAMERA2
+ SettingsManager.KEY_CAMERA2
};
initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher);
@@ -1206,17 +1206,9 @@ public class PhotoMenu extends MenuController
}
super.onSettingChanged(pref);
- if (same(pref, CameraSettings.KEY_CAMERA2, "enable")) {
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(mActivity);
- prefs.edit().putBoolean(CameraSettings.KEY_CAMERA2, true).apply();
- CameraActivity.CAMERA_2_ON = true;
+ if (same(pref, SettingsManager.KEY_CAMERA2, "enable")) {
mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX);
- } else if (notSame(pref, CameraSettings.KEY_CAMERA2, "enable")) {
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(mActivity);
- prefs.edit().putBoolean(CameraSettings.KEY_CAMERA2, false).apply();
- CameraActivity.CAMERA_2_ON = false;
+ } else if (notSame(pref, SettingsManager.KEY_CAMERA2, "enable")) {
mActivity.onModuleSelected(ModuleSwitcher.PHOTO_MODULE_INDEX);
}
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 3e7b9e6..b7f3d8a 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -892,8 +892,7 @@ public class PhotoModule
}
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
mUI.initializeFirstTime();
@@ -916,8 +915,7 @@ public class PhotoModule
// onResume.
private void initializeSecondTime() {
// Start location update if needed.
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
MediaSaveService s = mActivity.getMediaSaveService();
if (s != null) {
@@ -4528,8 +4526,7 @@ public class PhotoModule
// ignore the events after "onPause()"
if (mPaused) return;
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
if(needRestart()){
Log.v(TAG, "Restarting Preview... Camera Mode Changed");
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
index f4262ba..bdf4c56 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -55,7 +55,7 @@ public class PreviewGestures
private boolean mEnabled;
private boolean mZoomOnly;
private GestureDetector mGestureDetector;
- private CaptureMenu mCaptureMenu;
+ private CaptureUI mCaptureUI;
private PhotoMenu mPhotoMenu;
private VideoMenu mVideoMenu;
private boolean waitUntilNextDown;
@@ -95,8 +95,8 @@ public class PreviewGestures
orientation = mPhotoMenu.getOrientation();
else if (mVideoMenu != null)
orientation = mVideoMenu.getOrientation();
- else if (mCaptureMenu != null)
- orientation = mCaptureMenu.getOrientation();
+ else if (mCaptureUI != null)
+ orientation = mCaptureUI.getOrientation();
if (isSwipeForMenu(orientation, deltaX, deltaY)) {
waitUntilNextDown = true;
@@ -104,8 +104,8 @@ public class PreviewGestures
mPhotoMenu.openFirstLevel();
else if (mVideoMenu != null && !mVideoMenu.isMenuBeingShown())
mVideoMenu.openFirstLevel();
- else if (mCaptureMenu != null && !mCaptureMenu.isMenuBeingShown())
- mCaptureMenu.openFirstLevel();
+ else if (mCaptureUI != null && !mCaptureUI.isMenuBeingShown())
+ mCaptureUI.showSettingMenu();
return true;
}
return false;
@@ -169,8 +169,8 @@ public class PreviewGestures
return mEnabled;
}
- public void setCaptureMenu(CaptureMenu menu) {
- mCaptureMenu = menu;
+ public void setCaptureUI(CaptureUI ui) {
+ mCaptureUI = ui;
}
public void setPhotoMenu(PhotoMenu menu) {
@@ -181,10 +181,6 @@ public class PreviewGestures
mVideoMenu = menu;
}
- public CaptureMenu getCaptureMenu() {
- return mCaptureMenu;
- }
-
public PhotoMenu getPhotoMenu() {
return mPhotoMenu;
}
@@ -221,16 +217,17 @@ public class PreviewGestures
return sendToPie(m);
}
- if (mCaptureMenu != null) {
- if (mCaptureMenu.isMenuBeingShown()) {
- if (!mCaptureMenu.isMenuBeingAnimated()) {
+ if (mCaptureUI != null) {
+ if (mCaptureUI.isMenuBeingShown()) {
+ if (!mCaptureUI.isMenuBeingAnimated()) {
waitUntilNextDown = true;
- mCaptureMenu.closeView();
+ mCaptureUI.removeAllSettingMenu(true);
}
return true;
}
- if (mCaptureMenu.isPreviewMenuBeingShown()) {
+ if (mCaptureUI.isPreviewMenuBeingShown()) {
waitUntilNextDown = true;
+ mCaptureUI.removeSceneAndFilterMenu(true);
return true;
}
}
diff --git a/src/com/android/camera/RecordLocationPreference.java b/src/com/android/camera/RecordLocationPreference.java
index 9992afa..b88f5e4 100644
--- a/src/com/android/camera/RecordLocationPreference.java
+++ b/src/com/android/camera/RecordLocationPreference.java
@@ -40,11 +40,10 @@ public class RecordLocationPreference extends IconListPreference {
@Override
public String getValue() {
- return get(getSharedPreferences(), mResolver) ? VALUE_ON : VALUE_OFF;
+ return get(getSharedPreferences()) ? VALUE_ON : VALUE_OFF;
}
- public static boolean get(
- SharedPreferences pref, ContentResolver resolver) {
+ public static boolean get(SharedPreferences pref) {
String value = pref.getString(
CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE);
return VALUE_ON.equals(value);
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
new file mode 100644
index 0000000..09bee5e
--- /dev/null
+++ b/src/com/android/camera/SettingsManager.java
@@ -0,0 +1,539 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.camera;
+
+import android.content.Context;
+import android.graphics.ImageFormat;
+import android.graphics.Rect;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.util.Log;
+import android.util.Size;
+
+import com.android.camera.ui.ListMenu;
+
+import org.codeaurora.snapcam.R;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class SettingsManager implements ListMenu.SettingsListener {
+ public static final int RESOURCE_TYPE_THUMBNAIL = 0;
+ public static final int RESOURCE_TYPE_LARGEICON = 1;
+ public static final String KEY_CAMERA_SAVEPATH = "pref_camera2_savepath_key";
+ public static final String KEY_RECORD_LOCATION = "pref_camera2_recordlocation_key";
+ public static final String KEY_JPEG_QUALITY = "pref_camera2_jpegquality_key";
+ public static final String KEY_FOCUS_MODE = "pref_camera2_focusmode_key";
+ public static final String KEY_FLASH_MODE = "pref_camera2_flashmode_key";
+ public static final String KEY_WHITE_BALANCE = "pref_camera2_whitebalance_key";
+ public static final String KEY_CAMERA2 = "pref_camera2_camera2_key";
+ public static final String KEY_DUAL_CAMERA = "pref_camera2_dual_camera_key";
+ public static final String KEY_MONO_PREVIEW = "pref_camera2_mono_preview_key";
+ public static final String KEY_CLEARSIGHT = "pref_camera2_clearsight_key";
+ public static final String KEY_FILTER_MODE = "pref_camera2_filter_mode_key";
+ public static final String KEY_COLOR_EFFECT = "pref_camera2_coloreffect_key";
+ public static final String KEY_SCENE_MODE = "pref_camera2_scenemode_key";
+ public static final String KEY_REDEYE_REDUCTION = "pref_camera2_redeyereduction_key";
+ public static final String KEY_CAMERA_ID = "pref_camera2_id_key";
+ public static final String KEY_PICTURE_SIZE = "pref_camera2_picturesize_key";
+ public static final String KEY_ISO = "pref_camera2_iso_key";
+ public static final String KEY_EXPOSURE = "pref_camera2_exposure_key";
+ public static final String KEY_TIMER = "pref_camera2_timer_key";
+ public static final String KEY_LONGSHOT = "pref_camera2_longshot_key";
+ private static final String TAG = "SnapCam_SettingsManager";
+ private static final List<CameraCharacteristics> mCharacteristics = new ArrayList<>();
+ private static final int NOT_FOUND = -1;
+
+ private static SettingsManager sInstance;
+
+ private ArrayList<Listener> mListeners;
+ private Map<String, Values> mValuesMap;
+ private Context mContext;
+ private PreferenceGroup mPreferenceGroup;
+ private ComboPreferences mPreferences;
+ private Map<String, List<String>> mDependendsOnMap;
+
+ private SettingsManager(Context context) {
+ mListeners = new ArrayList<>();
+ mValuesMap = new HashMap<>();
+ mDependendsOnMap = new HashMap<>();
+ mContext = context;
+ mPreferences = new ComboPreferences(mContext);
+ CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(), mContext);
+
+ CameraManager manager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
+ try {
+ String[] cameraIdList = manager.getCameraIdList();
+ for (int i = 0; i < cameraIdList.length; i++) {
+ //TODO: determine front/back/bayer/mono and their ids
+ String cameraId = cameraIdList[i];
+ CameraCharacteristics characteristics
+ = manager.getCameraCharacteristics(cameraId);
+ mCharacteristics.add(i, characteristics);
+ }
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static SettingsManager createInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new SettingsManager(context);
+ }
+ return sInstance;
+ }
+
+ public static SettingsManager getInstance() {
+ return sInstance;
+ }
+
+ public List<String> getDisabledList() {
+ List<String> list = new ArrayList<>();
+ Set<String> keySet = mValuesMap.keySet();
+ for (String key : keySet) {
+ Values value = mValuesMap.get(key);
+ if (value.overriddenValue != null) {
+ list.add(key);
+ }
+ }
+ return list;
+ }
+
+ @Override
+ public void onSettingChanged(ListPreference pref) {
+ String key = pref.getKey();
+ List changed = checkDependencyAndUpdate(key);
+ notifyListeners(changed);
+ }
+
+ public void init() {
+ Log.d(TAG, "SettingsManager init");
+ int cameraId = CameraSettings.getInitialCameraId(mPreferences);
+ setLocalIdAndInitialize(cameraId);
+ }
+
+ public void reinit(int cameraId) {
+ Log.d(TAG, "SettingsManager reinit " + cameraId);
+ setLocalIdAndInitialize(cameraId);
+ }
+
+ private void setLocalIdAndInitialize(int cameraId) {
+ mPreferences.setLocalId(mContext, cameraId);
+ CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
+
+ PreferenceInflater inflater = new PreferenceInflater(mContext);
+ mPreferenceGroup =
+ (PreferenceGroup) inflater.inflate(R.xml.capture_preferences);
+
+ filterPreferences(cameraId);
+ initDepedencyTable();
+ initializeValueMap();
+ }
+
+ private void initDepedencyTable() {
+ for (int i = 0; i < mPreferenceGroup.size(); i++) {
+ ListPreference pref = (ListPreference) mPreferenceGroup.get(i);
+ String baseKey = pref.getKey();
+ CharSequence[] dependencyList = pref.getDependencyList();
+ if (dependencyList != null) {
+ for (int j = 0; j < dependencyList.length; j++) {
+ String key = dependencyList[j].toString();
+ pref = mPreferenceGroup.findPreference(key);
+ if (pref == null) continue; //filtered?
+ List list = mDependendsOnMap.get(key);
+ if (list == null) {
+ list = new ArrayList<String>();
+ }
+ list.add(baseKey);
+ mDependendsOnMap.put(key, list);
+ }
+ }
+ }
+ }
+
+ private void initializeValueMap() {
+ List<String> processLater = new ArrayList<String>();
+ for (int i = 0; i < mPreferenceGroup.size(); i++) {
+ ListPreference pref = (ListPreference) mPreferenceGroup.get(i);
+ String key = pref.getKey();
+ if (mDependendsOnMap.get(key) != null) {
+ processLater.add(key);
+ continue;
+ }
+ Values values = new Values(pref.getValue(), null);
+ mValuesMap.put(pref.getKey(), values);
+ }
+
+ for (String keyToProcess : processLater) {
+ List<String> dependsOnList = mDependendsOnMap.get(keyToProcess);
+ boolean active = true;
+ for (String s : dependsOnList) {
+ if (isOptionOn(s)) active = false;
+ break;
+ }
+ ListPreference pref = mPreferenceGroup.findPreference(keyToProcess);
+ Values values = new Values(pref.getValue(), null);
+ if (!active) {
+ values.overriddenValue = pref.getOffValue();
+ }
+ mValuesMap.put(keyToProcess, values);
+ }
+ }
+
+ private List<SettingState> checkDependencyAndUpdate(String changedPrefKey) {
+ ListPreference changedPref = mPreferenceGroup.findPreference(changedPrefKey);
+ if (changedPref == null) return null;
+
+ String key = changedPref.getKey();
+ String value = changedPref.getValue();
+ boolean turnedOff = value.equals(changedPref.getOffValue());
+ List<SettingState> changed = new ArrayList();
+ Values values = new Values(value, null);
+ mValuesMap.put(key, values);
+ changed.add(new SettingState(key, values));
+ CharSequence[] dependencyList = changedPref.getDependencyList();
+
+ if (!turnedOff) { // turned on
+ if (dependencyList != null) {
+ for (int j = 0; j < dependencyList.length; j++) {
+ key = dependencyList[j].toString();
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ if (pref == null) continue;
+ values = mValuesMap.get(key);
+ if (values != null && values.overriddenValue != null) continue;
+ Values newValue = new Values(pref.getValue(), pref.getOffValue());
+ mValuesMap.put(key, newValue);
+ changed.add(new SettingState(key, newValue));
+ }
+ }
+ } else {
+ if (dependencyList != null) {
+ for (int j = 0; j < dependencyList.length; j++) {
+ key = dependencyList[j].toString();
+ List<String> dependsOnList = mDependendsOnMap.get(key);
+ if (dependsOnList == null) continue;
+ boolean active = true;
+ for (String s : dependsOnList) {
+ if (isOptionOn(s)) active = false;
+ break;
+ }
+ if (active) {
+ values = mValuesMap.get(key);
+ values.overriddenValue = null;
+ mValuesMap.put(key, values);
+ changed.add(new SettingState(key, values));
+ }
+ }
+ }
+ }
+ return changed;
+ }
+
+ public void registerListener(Listener listener) {
+ mListeners.add(listener);
+ }
+
+ private void notifyListeners(List<SettingState> changes) {
+ for (Listener listener : mListeners) {
+ listener.onSettingsChanged(changes);
+ }
+ }
+
+ public boolean isCamera2On() {
+ return mPreferences.getString(KEY_CAMERA2, "disable").equals("enable");
+ }
+
+ public String getValue(String key) {
+ Values values = mValuesMap.get(key);
+ if (values == null) return null;
+ if (values.overriddenValue == null) return values.value;
+ else return values.overriddenValue;
+ }
+
+ public int getValueIndex(String key) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ String value = getValue(key);
+ if (value == null) return -1;
+ return pref.findIndexOfValue(value);
+ }
+
+ public boolean isOverriden(String key) {
+ Values values = mValuesMap.get(key);
+ return values.overriddenValue != null;
+ }
+
+ public void setValue(String key, String value) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ pref.setValue(value);
+ updateMapAndNotify(pref);
+ }
+
+ public void setValueIndex(String key, int index) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ pref.setValueIndex(index);
+ updateMapAndNotify(pref);
+ }
+
+ private void updateMapAndNotify(ListPreference pref) {
+ String key = pref.getKey();
+ Values values = mValuesMap.get(key);
+ values.overriddenValue = null;
+ values.value = pref.getValue();
+ mValuesMap.put(key, values);
+ List changed = checkDependencyAndUpdate(key);
+ notifyListeners(changed);
+ }
+
+ private boolean isOptionOn(String key) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ Values values = mValuesMap.get(key);
+ return (values.overriddenValue == null && !pref.getValue().equals(pref.getOffValue()));
+ }
+
+ public PreferenceGroup getPreferenceGroup() {
+ return mPreferenceGroup;
+ }
+
+ public CharSequence[] getEntries(String key) {
+ ListPreference pref = mPreferenceGroup.findPreference(key);
+ return pref.getEntries();
+ }
+
+ public int[] getResource(String key, int type) {
+ IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(key);
+ switch (type) {
+ case RESOURCE_TYPE_THUMBNAIL:
+ return pref.getThumbnailIds();
+ case RESOURCE_TYPE_LARGEICON:
+ return pref.getLargeIconIds();
+ }
+ return null;
+ }
+
+ private void filterPreferences(int cameraId) {
+ // filter unsupported preferences
+ ListPreference whiteBalance = mPreferenceGroup.findPreference(KEY_WHITE_BALANCE);
+ ListPreference flashMode = mPreferenceGroup.findPreference(KEY_FLASH_MODE);
+ ListPreference colorEffect = mPreferenceGroup.findPreference(KEY_COLOR_EFFECT);
+ ListPreference sceneMode = mPreferenceGroup.findPreference(KEY_SCENE_MODE);
+ ListPreference cameraIdPref = mPreferenceGroup.findPreference(KEY_CAMERA_ID);
+ ListPreference pictureSize = mPreferenceGroup.findPreference(KEY_PICTURE_SIZE);
+
+ if (whiteBalance != null) {
+ CameraSettings.filterUnsupportedOptions(mPreferenceGroup,
+ whiteBalance, getSupportedWhiteBalanceModes(cameraId));
+ }
+ if (flashMode != null) {
+ CameraSettings.filterUnsupportedOptions(mPreferenceGroup,
+ flashMode, getSupportedFlashModes(cameraId));
+ }
+
+ if (colorEffect != null) {
+ CameraSettings.filterUnsupportedOptions(mPreferenceGroup,
+ colorEffect, getSupportedColorEffects(cameraId));
+ }
+
+ if (sceneMode != null) {
+ CameraSettings.filterUnsupportedOptions(mPreferenceGroup,
+ sceneMode, getSupportedSceneModes(cameraId));
+ }
+
+ if (cameraIdPref != null) buildCameraId();
+
+ if (pictureSize != null) {
+ CameraSettings.filterUnsupportedOptions(mPreferenceGroup,
+ pictureSize, getSupportedPictureSize(cameraId));
+ }
+ }
+
+ private void buildCameraId() {
+ int numOfCameras = mCharacteristics.size();
+ if (numOfCameras < 2) {
+ removePreference(mPreferenceGroup, KEY_CAMERA_ID);
+ }
+
+ CharSequence[] entryValues = new CharSequence[numOfCameras];
+ //TODO: Modify this after bayer/mono/front/back determination is done
+ entryValues[0] = "" + CaptureModule.BAYER_ID;
+ entryValues[1] = "" + CaptureModule.FRONT_ID;
+ ListPreference cameraIdPref = mPreferenceGroup.findPreference(KEY_CAMERA_ID);
+ cameraIdPref.setEntryValues(entryValues);
+ }
+
+ private boolean removePreference(PreferenceGroup group, String key) {
+ for (int i = 0, n = group.size(); i < n; i++) {
+ CameraPreference child = group.get(i);
+ if (child instanceof PreferenceGroup) {
+ if (removePreference((PreferenceGroup) child, key)) {
+ return true;
+ }
+ }
+ if (child instanceof ListPreference &&
+ ((ListPreference) child).getKey().equals(key)) {
+ group.removePreference(i);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public float getMaxZoom(int id) {
+ return mCharacteristics.get(id).get(CameraCharacteristics
+ .SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
+ }
+
+ public Rect getSensorActiveArraySize(int id) {
+ return mCharacteristics.get(id).get(CameraCharacteristics
+ .SENSOR_INFO_ACTIVE_ARRAY_SIZE);
+ }
+
+ public float getMaxZoom(List<Integer> ids) {
+ float zoomMax = Float.MAX_VALUE;
+ for (int id : ids) {
+ zoomMax = Math.min(getMaxZoom(id), zoomMax);
+ }
+ return zoomMax;
+ }
+
+ public boolean isZoomSupported(int id) {
+ return mCharacteristics.get(id).get(CameraCharacteristics
+ .SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) > 1f;
+ }
+
+ public boolean isAutoFocusSupported(List<Integer> ids) {
+ for (int id : ids) {
+ if (!isAutoFocusSupported(id))
+ return false;
+ }
+ return true;
+ }
+
+
+ public boolean isZoomSupported(List<Integer> ids) {
+ for (int id : ids) {
+ if (!isZoomSupported(id))
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isAutoFocusSupported(int id) {
+ Integer maxAfRegions = mCharacteristics.get(id).get(
+ CameraCharacteristics.CONTROL_MAX_REGIONS_AF);
+ return maxAfRegions != null && maxAfRegions > 0;
+ }
+
+ public boolean isFlashSupported(int id) {
+ return mCharacteristics.get(id).get(CameraCharacteristics.FLASH_INFO_AVAILABLE) &&
+ mValuesMap.get(KEY_FLASH_MODE) != null;
+ }
+
+ private List<String> getSupportedPictureSize(int cameraId) {
+ StreamConfigurationMap map = mCharacteristics.get(cameraId).get(
+ CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ Size[] sizes = map.getOutputSizes(ImageFormat.JPEG);
+ List<String> res = new ArrayList<>();
+ for (int i = 0; i < sizes.length; i++) {
+ res.add(sizes[i].toString());
+ }
+ return res;
+ }
+
+ private List<String> getSupportedWhiteBalanceModes(int cameraId) {
+ int[] whiteBalanceModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
+ .CONTROL_AWB_AVAILABLE_MODES);
+ List<String> modes = new ArrayList<>();
+ for (int mode : whiteBalanceModes) {
+ modes.add("" + mode);
+ }
+ return modes;
+ }
+
+ private List<String> getSupportedSceneModes(int cameraId) {
+ int[] sceneModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
+ .CONTROL_AVAILABLE_SCENE_MODES);
+ List<String> modes = new ArrayList<>();
+ modes.add("0"); // need special case handle for auto scene mode
+ for (int mode : sceneModes) {
+ modes.add("" + mode);
+ }
+ return modes;
+ }
+
+ private List<String> getSupportedFlashModes(int cameraId) {
+ int[] flashModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
+ .CONTROL_AE_AVAILABLE_MODES);
+ List<String> modes = new ArrayList<>();
+ for (int mode : flashModes) {
+ modes.add("" + mode);
+ }
+ return modes;
+ }
+
+ public List<String> getSupportedColorEffects(int cameraId) {
+ int[] flashModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
+ .CONTROL_AVAILABLE_EFFECTS);
+ List<String> modes = new ArrayList<>();
+ for (int mode : flashModes) {
+ modes.add("" + mode);
+ }
+ return modes;
+ }
+
+ public interface Listener {
+ void onSettingsChanged(List<SettingState> settings);
+ }
+
+ static class Values {
+ String value;
+ String overriddenValue;
+
+ Values(String value, String overriddenValue) {
+ this.value = value;
+ this.overriddenValue = overriddenValue;
+ }
+ }
+
+ static class SettingState {
+ String key;
+ Values values;
+
+ SettingState(String key, Values values) {
+ this.key = key;
+ this.values = values;
+ }
+ }
+
+}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index af72a29..4ac9bce 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1183,8 +1183,7 @@ public class VideoModule implements CameraModule,
mOrientationManager.resume();
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences,
- mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
if (mPreviewing) {
@@ -2752,8 +2751,7 @@ public class VideoModule implements CameraModule,
// startPreview().
if (mCameraDevice == null) return;
- boolean recordLocation = RecordLocationPreference.get(
- mPreferences, mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
readVideoPreferences();
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 6068ef2..8e28f81 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -1036,8 +1036,7 @@ public class WideAnglePanoramaModule
mOrientationManager.resume();
// Initialize location service.
- boolean recordLocation = RecordLocationPreference.get(mPreferences,
- mContentResolver);
+ boolean recordLocation = RecordLocationPreference.get(mPreferences);
mLocationManager.recordLocation(recordLocation);
mUI.initDisplayChangeListener();
UsageStatistics.onContentViewChanged(
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 1f9c8d9..e6e00ad 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -37,7 +37,6 @@ import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.Scroller;
-import com.android.camera.CaptureMenu;
import com.android.camera.PhotoMenu;
import com.android.camera.VideoMenu;
import com.android.camera.PreviewGestures;
@@ -1832,7 +1831,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return true;
PhotoMenu pMenu = mPreviewGestures.getPhotoMenu();
VideoMenu vMenu = mPreviewGestures.getVideoMenu();
- CaptureMenu cMenu = mPreviewGestures.getCaptureMenu();
+
if (pMenu != null) {
if (pMenu.isMenuBeingShown()) {
if (pMenu.isMenuBeingAnimated()) {
@@ -1850,23 +1849,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
}
}
- if (cMenu != null) {
- if (cMenu.isMenuBeingShown()) {
- if (cMenu.isMenuBeingAnimated()) {
- if (cMenu.isOverMenu(ev)) {
- mSendToMenu = true;
- return true;
- }
- }
- }
- if (cMenu.isPreviewMenuBeingShown()) {
- if (cMenu.isOverPreviewMenu(ev)) {
- mSendToPreviewMenu = true;
- return true;
- }
- }
- }
if (vMenu != null) {
if (vMenu.isMenuBeingShown()) {
if (vMenu.isMenuBeingAnimated()) {
@@ -1903,7 +1886,6 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
}
PhotoMenu pMenu = mPreviewGestures.getPhotoMenu();
VideoMenu vMenu = mPreviewGestures.getVideoMenu();
- CaptureMenu cMenu = mPreviewGestures.getCaptureMenu();
if (pMenu != null) {
if (mSendToPreviewMenu)
return pMenu.sendTouchToPreviewMenu(ev);
@@ -1917,19 +1899,7 @@ public class FilmStripView extends ViewGroup implements BottomControlsListener {
return pMenu.sendTouchToPreviewMenu(ev);
}
}
- if (cMenu != null) {
- if (mSendToPreviewMenu)
- return cMenu.sendTouchToPreviewMenu(ev);
- if (mSendToMenu)
- return cMenu.sendTouchToMenu(ev);
- if (cMenu.isMenuBeingShown()) {
- return cMenu.sendTouchToMenu(ev);
- }
- if (cMenu.isPreviewMenuBeingShown()) {
- return cMenu.sendTouchToPreviewMenu(ev);
- }
- }
if (vMenu != null) {
if (mSendToPreviewMenu)
return vMenu.sendTouchToPreviewMenu(ev);
diff --git a/src/com/android/camera/ui/ListMenu.java b/src/com/android/camera/ui/ListMenu.java
index bb21f7e..4cb3598 100644
--- a/src/com/android/camera/ui/ListMenu.java
+++ b/src/com/android/camera/ui/ListMenu.java
@@ -19,8 +19,6 @@
package com.android.camera.ui;
-import java.util.ArrayList;
-
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
@@ -36,21 +34,42 @@ import android.widget.Space;
import com.android.camera.ListPreference;
import com.android.camera.PreferenceGroup;
+import com.android.camera.SettingsManager;
+
import org.codeaurora.snapcam.R;
+import java.util.ArrayList;
+import java.util.List;
+
/* A popup window that contains several camera settings. */
public class ListMenu extends ListView
- implements ListMenuItem.Listener, AdapterView.OnItemClickListener, RotateLayout.Child {
+ implements ListMenuItem.Listener,
+ RotateLayout.Child {
+ AdapterView.OnItemClickListener,
+ ListSubMenu.Listener {
@SuppressWarnings("unused")
private static final String TAG = "ListMenu";
private int mHighlighted = -1;
private Listener mListener;
+ private SettingsManager mSettingsManager;
private ArrayList<ListPreference> mListItem = new ArrayList<ListPreference>();
private View mHeader, mFooter;
// Keep track of which setting items are disabled
// e.g. White balance will be disabled when scene mode is set to non-auto
private boolean[] mEnabled;
+ private boolean mForCamera2 = false;
+
+ @Override
+ public void onListPrefChanged(ListPreference pref) {
+ // listen from ListSubMenu
+ if (mListener != null) {
+ mListener.onSettingChanged(pref);
+ }
+ if (mSettingsManager != null) {
+ mSettingsManager.onSettingChanged(pref);
+ }
+ }
static public interface Listener {
public void onSettingChanged(ListPreference pref);
@@ -62,6 +81,11 @@ public class ListMenu extends ListView
public void onListMenuTouched();
}
+ static public interface SettingsListener {
+ // notify SettingsManager
+ public void onSettingChanged(ListPreference pref);
+ }
+
private class MoreSettingAdapter extends ArrayAdapter<ListPreference> {
LayoutInflater mInflater;
String mOnString;
@@ -92,6 +116,9 @@ public class ListMenu extends ListView
view.setSettingChangedListener(ListMenu.this);
if (position >= 0 && position < mEnabled.length) {
view.setEnabled(mEnabled[position]);
+ if (mForCamera2 && !mEnabled[position]) {
+ view.overrideSettings(pref.getOffValue());
+ }
} else {
Log.w(TAG, "Invalid input: enabled list length, " + mEnabled.length
+ " position " + position);
@@ -135,6 +162,10 @@ public class ListMenu extends ListView
view.setLayoutParams(lp);
}
+ public void setSettingsManager(SettingsManager settingsManager) {
+ mSettingsManager = settingsManager;
+ }
+
public void setSettingChangedListener(Listener listener) {
mListener = listener;
}
@@ -143,6 +174,32 @@ public class ListMenu extends ListView
super(context, attrs);
}
+ public void initializeForCamera2(String[] keys) {
+ mForCamera2 = true;
+ PreferenceGroup group = mSettingsManager.getPreferenceGroup();
+ List<String> disabledList = mSettingsManager.getDisabledList();
+ // Prepare the setting items.
+ for (int i = 0; i < keys.length; ++i) {
+ ListPreference pref = group.findPreference(keys[i]);
+ if (pref != null)
+ mListItem.add(pref);
+ }
+
+ ArrayAdapter<ListPreference> mListItemAdapter = new MoreSettingAdapter();
+ setAdapter(mListItemAdapter);
+ setOnItemClickListener(this);
+ setSelector(android.R.color.transparent);
+ // Initialize mEnabled
+ mEnabled = new boolean[mListItem.size()];
+ for (int i = 0; i < mEnabled.length; i++) {
+ mEnabled[i] = true;
+ }
+
+ for (String s: disabledList) {
+ setPreferenceEnabled(s, false);
+ }
+ }
+
public void initialize(PreferenceGroup group, String[] keys) {
// Prepare the setting items.
for (int i = 0; i < keys.length; ++i) {
diff --git a/src/com/android/camera/ui/ListMenuItem.java b/src/com/android/camera/ui/ListMenuItem.java
index f3c7f01..b051fdd 100644
--- a/src/com/android/camera/ui/ListMenuItem.java
+++ b/src/com/android/camera/ui/ListMenuItem.java
@@ -159,4 +159,26 @@ public class ListMenuItem extends RelativeLayout {
setAlpha(0.3f);
}
}
+
+ public void setEnabled(boolean enable, String value) {
+ super.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ if (mTitle != null) {
+ mTitle.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ }
+ if (mEntry != null) {
+ mEntry.setEnabled(enable);
+ if (enable)
+ setAlpha(1f);
+ else
+ setAlpha(0.3f);
+ }
+ }
}
diff --git a/src/com/android/camera/ui/ListSubMenu.java b/src/com/android/camera/ui/ListSubMenu.java
index 3501af3..a425c76 100644
--- a/src/com/android/camera/ui/ListSubMenu.java
+++ b/src/com/android/camera/ui/ListSubMenu.java
@@ -136,8 +136,9 @@ public class ListSubMenu extends ListView implements
public void onItemClick(AdapterView<?> parent, View view,
int index, long id) {
mPreference.setValueIndex(index);
- if (mListener != null)
+ if (mListener != null) {
mListener.onListPrefChanged(mPreference);
+ }
}
@Override
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index a83714f..9b728b6 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -35,7 +35,6 @@ import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
-import android.hardware.camera2.CameraCharacteristics;
import android.location.Location;
import android.net.Uri;
import android.os.Handler;
@@ -1224,32 +1223,4 @@ public class CameraUtil {
return retRatio;
}
- public static boolean isZoomSupported(CameraCharacteristics[] characteristics, List<Integer>
- characteristicsIndex) {
- for (int i = 0; i < characteristicsIndex.size(); i++) {
- if (!isZoomSupported(characteristics[characteristicsIndex.get(i)]))
- return false;
- }
- return true;
- }
-
- public static boolean isZoomSupported(CameraCharacteristics characteristic) {
- return characteristic.get(CameraCharacteristics
- .SCALER_AVAILABLE_MAX_DIGITAL_ZOOM) > 1f;
- }
-
- public static boolean isAutoFocusSupported(CameraCharacteristics[] characteristics, List<Integer>
- characteristicsIndex) {
- for (int i = 0; i < characteristicsIndex.size(); i++) {
- if (!isAutoFocusSupported(characteristics[characteristicsIndex.get(i)]))
- return false;
- }
- return true;
- }
-
- public static boolean isAutoFocusSupported(CameraCharacteristics characteristic) {
- Integer maxAfRegions = characteristic.get(
- CameraCharacteristics.CONTROL_MAX_REGIONS_AF);
- return maxAfRegions != null && maxAfRegions > 0;
- }
}