diff options
72 files changed, 1802 insertions, 817 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c2f80cda9..383f696cb 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -70,6 +70,26 @@ android:value="com.android.camera.CameraActivity" /> </activity> + <activity + android:theme="@style/Theme.OneUISettings" + android:name="com.android.camera.SettingsActivity" + android:clearTaskOnLaunch="true" + android:configChanges="orientation|screenSize|keyboardHidden" + android:icon="@mipmap/ic_launcher_camera" + android:label="@string/snapcam_app_name" + android:launchMode="singleTop" > + </activity> + + <activity + android:theme="@android:style/Theme.Material.Light.NoActionBar.Fullscreen" + android:name="com.android.camera.SceneModeActivity" + android:clearTaskOnLaunch="true" + android:configChanges="orientation|screenSize|keyboardHidden" + android:icon="@mipmap/ic_launcher_camera" + android:label="@string/snapcam_app_name" + android:launchMode="singleTop" > + </activity> + <activity-alias android:name="com.android.camera.CameraLauncher" android:icon="@mipmap/ic_launcher_camera" diff --git a/assets/dependency.json b/assets/dependency.json index 39f9f91b0..afe682119 100644 --- a/assets/dependency.json +++ b/assets/dependency.json @@ -31,7 +31,7 @@ ], "default": {"pref_camera2_coloreffect_key":"0", - "pref_camera2_flashmode_key":"2", + "pref_camera2_flashmode_key":"off", "pref_camera2_whitebalance_key":"1", "pref_camera2_exposure_key":"0", "pref_camera2_clearsight_key":"off", @@ -41,7 +41,7 @@ "100": {"pref_camera2_longshot_key":"off", "pref_camera2_mono_only_key":"off", - "pref_camera2_flashmode_key":"1"} + "pref_camera2_flashmode_key":"off"} , "0": {"pref_camera2_clearsight_key":"off", diff --git a/res/drawable/audio_encoding.png b/res/drawable/audio_encoding.png Binary files differnew file mode 100644 index 000000000..0cb04c62a --- /dev/null +++ b/res/drawable/audio_encoding.png diff --git a/res/drawable/auto.png b/res/drawable/auto.png Binary files differnew file mode 100644 index 000000000..48a510e1d --- /dev/null +++ b/res/drawable/auto.png diff --git a/res/drawable/auto_snapshot_size.png b/res/drawable/auto_snapshot_size.png Binary files differnew file mode 100644 index 000000000..0c8a05652 --- /dev/null +++ b/res/drawable/auto_snapshot_size.png diff --git a/res/drawable/backlight.png b/res/drawable/backlight.png Binary files differnew file mode 100644 index 000000000..3460a3f07 --- /dev/null +++ b/res/drawable/backlight.png diff --git a/res/drawable/beach.png b/res/drawable/beach.png Binary files differnew file mode 100644 index 000000000..bbd7773c7 --- /dev/null +++ b/res/drawable/beach.png diff --git a/res/drawable/beautify.png b/res/drawable/beautify.png Binary files differnew file mode 100644 index 000000000..c9db3f01b --- /dev/null +++ b/res/drawable/beautify.png diff --git a/res/drawable/blur.png b/res/drawable/blur.png Binary files differnew file mode 100644 index 000000000..6b25cee2f --- /dev/null +++ b/res/drawable/blur.png diff --git a/res/drawable/candlelight.png b/res/drawable/candlelight.png Binary files differnew file mode 100644 index 000000000..a2c24ae14 --- /dev/null +++ b/res/drawable/candlelight.png diff --git a/res/drawable/clock.png b/res/drawable/clock.png Binary files differnew file mode 100644 index 000000000..50d0e2a4e --- /dev/null +++ b/res/drawable/clock.png diff --git a/res/drawable/continuous_shot.png b/res/drawable/continuous_shot.png Binary files differnew file mode 100644 index 000000000..74cfc8fa8 --- /dev/null +++ b/res/drawable/continuous_shot.png diff --git a/res/drawable/countdown_timer.png b/res/drawable/countdown_timer.png Binary files differnew file mode 100644 index 000000000..ddd0175ef --- /dev/null +++ b/res/drawable/countdown_timer.png diff --git a/res/drawable/exposure.png b/res/drawable/exposure.png Binary files differnew file mode 100644 index 000000000..85f3b4e72 --- /dev/null +++ b/res/drawable/exposure.png diff --git a/res/drawable/face_detection.png b/res/drawable/face_detection.png Binary files differnew file mode 100644 index 000000000..7081cec41 --- /dev/null +++ b/res/drawable/face_detection.png diff --git a/res/drawable/filters.png b/res/drawable/filters.png Binary files differnew file mode 100644 index 000000000..e9527a3aa --- /dev/null +++ b/res/drawable/filters.png diff --git a/res/drawable/flash.png b/res/drawable/flash.png Binary files differnew file mode 100644 index 000000000..09d400487 --- /dev/null +++ b/res/drawable/flash.png diff --git a/res/drawable/flash_off.png b/res/drawable/flash_off.png Binary files differnew file mode 100644 index 000000000..af122bb7e --- /dev/null +++ b/res/drawable/flash_off.png diff --git a/res/drawable/flower.png b/res/drawable/flower.png Binary files differnew file mode 100644 index 000000000..c035b80f4 --- /dev/null +++ b/res/drawable/flower.png diff --git a/res/drawable/front_back_camera.png b/res/drawable/front_back_camera.png Binary files differnew file mode 100644 index 000000000..1e13a8410 --- /dev/null +++ b/res/drawable/front_back_camera.png diff --git a/res/drawable/gps_location.png b/res/drawable/gps_location.png Binary files differnew file mode 100644 index 000000000..09e011ab3 --- /dev/null +++ b/res/drawable/gps_location.png diff --git a/res/drawable/hdr.png b/res/drawable/hdr.png Binary files differnew file mode 100644 index 000000000..45f27d721 --- /dev/null +++ b/res/drawable/hdr.png diff --git a/res/drawable/image_stabilization.png b/res/drawable/image_stabilization.png Binary files differnew file mode 100644 index 000000000..80ddebcf8 --- /dev/null +++ b/res/drawable/image_stabilization.png diff --git a/res/drawable/iso.png b/res/drawable/iso.png Binary files differnew file mode 100644 index 000000000..3667a8b3f --- /dev/null +++ b/res/drawable/iso.png diff --git a/res/drawable/landscape.png b/res/drawable/landscape.png Binary files differnew file mode 100644 index 000000000..59e977867 --- /dev/null +++ b/res/drawable/landscape.png diff --git a/res/drawable/more_options.png b/res/drawable/more_options.png Binary files differnew file mode 100644 index 000000000..5dca7f1e5 --- /dev/null +++ b/res/drawable/more_options.png diff --git a/res/drawable/night.png b/res/drawable/night.png Binary files differnew file mode 100644 index 000000000..7d89a48f7 --- /dev/null +++ b/res/drawable/night.png diff --git a/res/drawable/noise_reduction.png b/res/drawable/noise_reduction.png Binary files differnew file mode 100644 index 000000000..ab5860e38 --- /dev/null +++ b/res/drawable/noise_reduction.png diff --git a/res/drawable/optizoom.png b/res/drawable/optizoom.png Binary files differnew file mode 100644 index 000000000..63f627a05 --- /dev/null +++ b/res/drawable/optizoom.png diff --git a/res/drawable/photo_capture.png b/res/drawable/photo_capture.png Binary files differnew file mode 100644 index 000000000..89cdb9a8f --- /dev/null +++ b/res/drawable/photo_capture.png diff --git a/res/drawable/picture_quality.png b/res/drawable/picture_quality.png Binary files differnew file mode 100644 index 000000000..eaafcc557 --- /dev/null +++ b/res/drawable/picture_quality.png diff --git a/res/drawable/picture_size.png b/res/drawable/picture_size.png Binary files differnew file mode 100644 index 000000000..bea524a74 --- /dev/null +++ b/res/drawable/picture_size.png diff --git a/res/drawable/portrait.png b/res/drawable/portrait.png Binary files differnew file mode 100644 index 000000000..c378bdb5f --- /dev/null +++ b/res/drawable/portrait.png diff --git a/res/drawable/settings.png b/res/drawable/settings.png Binary files differnew file mode 100644 index 000000000..a6c699e0c --- /dev/null +++ b/res/drawable/settings.png diff --git a/res/drawable/shutter_sound.png b/res/drawable/shutter_sound.png Binary files differnew file mode 100644 index 000000000..675ff31a4 --- /dev/null +++ b/res/drawable/shutter_sound.png diff --git a/res/drawable/snow.png b/res/drawable/snow.png Binary files differnew file mode 100644 index 000000000..5d115413c --- /dev/null +++ b/res/drawable/snow.png diff --git a/res/drawable/sports.png b/res/drawable/sports.png Binary files differnew file mode 100644 index 000000000..741635a45 --- /dev/null +++ b/res/drawable/sports.png diff --git a/res/drawable/storage.png b/res/drawable/storage.png Binary files differnew file mode 100644 index 000000000..d17cf73a4 --- /dev/null +++ b/res/drawable/storage.png diff --git a/res/drawable/sunset.png b/res/drawable/sunset.png Binary files differnew file mode 100644 index 000000000..1c5fe61c1 --- /dev/null +++ b/res/drawable/sunset.png diff --git a/res/drawable/tracking_focus.png b/res/drawable/tracking_focus.png Binary files differnew file mode 100644 index 000000000..5e1744fcc --- /dev/null +++ b/res/drawable/tracking_focus.png diff --git a/res/drawable/ubifocus.png b/res/drawable/ubifocus.png Binary files differnew file mode 100644 index 000000000..3af770723 --- /dev/null +++ b/res/drawable/ubifocus.png diff --git a/res/drawable/video_capture.png b/res/drawable/video_capture.png Binary files differnew file mode 100644 index 000000000..f0c7c2289 --- /dev/null +++ b/res/drawable/video_capture.png diff --git a/res/drawable/video_duration.png b/res/drawable/video_duration.png Binary files differnew file mode 100644 index 000000000..0cd1b5af3 --- /dev/null +++ b/res/drawable/video_duration.png diff --git a/res/drawable/video_encoding.png b/res/drawable/video_encoding.png Binary files differnew file mode 100644 index 000000000..b4d0a7439 --- /dev/null +++ b/res/drawable/video_encoding.png diff --git a/res/drawable/video_quality.png b/res/drawable/video_quality.png Binary files differnew file mode 100644 index 000000000..eaafcc557 --- /dev/null +++ b/res/drawable/video_quality.png diff --git a/res/drawable/video_rotation.png b/res/drawable/video_rotation.png Binary files differnew file mode 100644 index 000000000..1caed7142 --- /dev/null +++ b/res/drawable/video_rotation.png diff --git a/res/drawable/video_stop.png b/res/drawable/video_stop.png Binary files differnew file mode 100644 index 000000000..e3c4eecaf --- /dev/null +++ b/res/drawable/video_stop.png diff --git a/res/drawable/white_balance.png b/res/drawable/white_balance.png Binary files differnew file mode 100644 index 000000000..31e8dda70 --- /dev/null +++ b/res/drawable/white_balance.png diff --git a/res/drawable/x.png b/res/drawable/x.png Binary files differnew file mode 100644 index 000000000..2174df77b --- /dev/null +++ b/res/drawable/x.png diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml index 41757c535..4b9a178c0 100644 --- a/res/layout/capture_module.xml +++ b/res/layout/capture_module.xml @@ -93,6 +93,6 @@ <include style="@style/CameraControls" - layout="@layout/camera_controls" + layout="@layout/one_ui_layout" android:layout_gravity="center" /> </merge> diff --git a/res/layout/one_ui_layout.xml b/res/layout/one_ui_layout.xml new file mode 100644 index 000000000..22c2c42e3 --- /dev/null +++ b/res/layout/one_ui_layout.xml @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved. + Not a Contribution. + + Copyright (C) 2013 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. +--> +<com.android.camera.ui.OneUICameraControls xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/camera_controls" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.android.camera.ui.FlashToggleButton + android:id="@+id/flash_button" + style="@style/OneUIMenuButton" + android:src="@drawable/flash" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/mute_button" + style="@style/OneUIMenuButton" + android:contentDescription="@string/mute_button_desc" + android:src="@drawable/ic_unmuted_button" + android:visibility="gone" /> + + <com.android.camera.ShutterButton + android:id="@+id/shutter_button" + android:layout_width="70dp" + android:layout_height="70dp" + android:clickable="true" + android:contentDescription="@string/accessibility_shutter_button" + android:focusable="true" + android:scaleType="fitCenter" + android:src="@drawable/photo_capture" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/video_button" + android:layout_width="55dp" + android:layout_height="55dp" + android:clickable="true" + android:contentDescription="@string/accessibility_shutter_button" + android:focusable="true" + android:scaleType="fitCenter" + android:src="@drawable/video_capture" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/preview_thumb" + android:layout_width="@dimen/capture_size" + android:layout_height="@dimen/capture_size" + android:layout_gravity="top|right" + android:background="@android:color/transparent" + android:contentDescription="@string/switch_photo_filmstrip" + android:scaleType="fitCenter" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/front_back_switcher" + style="@style/OneUIMenuButton" + android:src="@drawable/front_back_camera" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/hdr_switcher" + style="@style/OneUIMenuButton" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/scene_mode_switcher" + style="@style/OneUIMenuButton" + android:src="@drawable/more_options" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/filter_mode_switcher" + style="@style/OneUIMenuButton" + android:src="@drawable/filters" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/ts_makeup_switcher" + style="@style/OneUIMenuButton" + android:src="@drawable/beautify" /> + + <LinearLayout + android:id="@+id/remaining_photos" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="@android:color/transparent" + android:orientation="horizontal" + android:visibility="gone"> + + <TextView + android:id="@+id/remaining_photos_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="@android:color/transparent" + android:textColor="@android:color/white" + android:visibility="gone" /> + + <ImageView + android:id="@+id/remaining_photos_image" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/remaining_sheets" + android:visibility="gone" /> + </LinearLayout> + +</com.android.camera.ui.OneUICameraControls> diff --git a/res/layout/preference.xml b/res/layout/preference.xml new file mode 100644 index 000000000..68b931fbb --- /dev/null +++ b/res/layout/preference.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved. + Not a Contribution. + + Copyright (C) 2006 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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="50dp" + android:background="?android:attr/selectableItemBackground" + android:gravity="center_vertical" + android:paddingEnd="?android:attr/scrollbarSize"> + + <ImageView + android:id="@+android:id/icon" + android:layout_width="25dp" + android:layout_height="25dp" + android:layout_gravity="center" + android:layout_marginEnd="30dp" + android:layout_marginStart="15dp" + android:scaleType="fitCenter" /> + + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginBottom="6dip" + android:layout_marginEnd="6dip" + android:layout_marginTop="6dip" + android:layout_weight="1"> + + <TextView + android:id="@+android:id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:ellipsize="marquee" + android:fadingEdge="horizontal" + android:singleLine="true" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textSize="14sp" /> + + <TextView + android:id="@+android:id/summary" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignStart="@android:id/title" + android:layout_below="@android:id/title" + android:maxLines="4" + android:textAppearance="?android:attr/textAppearanceSmall" + android:textColor="#ff2d82e2" + android:textSize="11sp" /> + + </RelativeLayout> + + <!-- Preference should place its actual preference widget here. --> + <LinearLayout + android:id="@+android:id/widget_frame" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:orientation="vertical" /> + +</LinearLayout> diff --git a/res/layout/preferences_category.xml b/res/layout/preferences_category.xml new file mode 100644 index 000000000..3dae03b0a --- /dev/null +++ b/res/layout/preferences_category.xml @@ -0,0 +1,39 @@ +<?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. +--> +<TextView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/title" + android:layout_width="match_parent" + android:layout_height="50dp" + android:gravity="center_vertical" + android:paddingLeft="15dp" + android:paddingTop="15dp" + android:textAllCaps="true" + android:textColor="#ff999999" + android:textSize="14sp" + android:textStyle="bold" /> diff --git a/res/layout/scene_mode_grid.xml b/res/layout/scene_mode_grid.xml new file mode 100644 index 000000000..b149b4cfe --- /dev/null +++ b/res/layout/scene_mode_grid.xml @@ -0,0 +1,43 @@ +<?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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <GridView + android:id="@+id/grid" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:columnWidth="@dimen/scene_mode_width" + android:horizontalSpacing="10dp" + android:numColumns="auto_fit" + android:stretchMode="columnWidth" + android:verticalSpacing="10dp"></GridView> +</LinearLayout>
\ No newline at end of file diff --git a/res/layout/scene_mode_menu_layout.xml b/res/layout/scene_mode_menu_layout.xml new file mode 100644 index 000000000..9c10bd73e --- /dev/null +++ b/res/layout/scene_mode_menu_layout.xml @@ -0,0 +1,69 @@ +<?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. +--> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/blur" + android:padding="5dp"> + + <ImageView + android:id="@+id/close_button" + android:layout_width="40dp" + android:layout_height="40dp" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:padding="10dp" + android:scaleType="fitCenter" + android:src="@drawable/x" /> + + <android.support.v4.view.ViewPager + android:id="@+id/pager" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_above="@+id/page_indicator" + android:layout_below="@+id/close_button" /> + + <com.android.camera.ui.DotsView + android:id="@+id/page_indicator" + android:layout_width="80dp" + android:layout_height="25dp" + android:layout_above="@+id/setting_button" + android:layout_centerHorizontal="true" + android:layout_margin="5dp" /> + + <com.android.camera.ui.RotateImageView + android:id="@+id/setting_button" + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_alignParentBottom="true" + android:layout_centerHorizontal="true" + android:layout_margin="10dp" + android:scaleType="fitCenter" + android:src="@drawable/settings" /> +</RelativeLayout> diff --git a/res/layout/scene_mode_menu_view.xml b/res/layout/scene_mode_menu_view.xml new file mode 100644 index 000000000..cfa0dba9c --- /dev/null +++ b/res/layout/scene_mode_menu_view.xml @@ -0,0 +1,62 @@ +<?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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="90dp" + android:layout_height="90dp" + android:layout_gravity="center" + android:orientation="vertical" + android:padding="5dp"> + + <LinearLayout + android:id="@+id/border" + android:layout_width="80dp" + android:layout_height="80dp" + android:layout_gravity="center" + android:gravity="center" + android:orientation="vertical" + android:padding="2dp"> + + <ImageView + android:id="@+id/image" + android:layout_width="30dp" + android:layout_height="30dp" + android:layout_gravity="center" + android:scaleType="fitCenter" /> + + <TextView + android:id="@+id/label" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:textColor="@android:color/white" + android:textSize="12sp" /> + </LinearLayout> + +</LinearLayout> diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml index 1f590fc32..e5fcb7fdf 100644 --- a/res/values/camera2arrays.xml +++ b/res/values/camera2arrays.xml @@ -34,8 +34,8 @@ </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> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <string-array name="pref_camera2_mono_only_entries" translatable="true"> @@ -44,8 +44,8 @@ </string-array> <string-array name="pref_camera2_mono_only_entryvalues" translatable="false"> - <item>on</item> - <item>off</item> + <item>@string/setting_on_value</item> + <item>@string/setting_off_value</item> </string-array> <string-array name="pref_camera2_initial_camera_entries" translatable="true"> @@ -86,8 +86,8 @@ </string-array> <string-array name="pref_camera2_mono_preview_entryvalues" translatable="false"> - <item>@string/pref_camera2_mono_preview_value_on</item> - <item>@string/pref_camera2_mono_preview_value_off</item> + <item>@string/setting_on_value</item> + <item>@string/setting_off_value</item> </string-array> <string-array name="pref_camera2_clearsight_entries" translatable="true"> @@ -96,8 +96,8 @@ </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> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <string-array name="pref_camera2_mpo_entries" translatable="true"> @@ -158,21 +158,21 @@ </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_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/auto</item> + <item>@drawable/hdr</item> + <item>@drawable/hdr</item> + <item>@drawable/ubifocus</item> + <item>@drawable/optizoom</item> + <item>@drawable/portrait</item> + <item>@drawable/landscape</item> + <item>@drawable/sports</item> + <item>@drawable/flower</item> + <item>@drawable/backlight</item> + <item>@drawable/candlelight</item> + <item>@drawable/sunset</item> + <item>@drawable/night</item> + <item>@drawable/beach</item> + <item>@drawable/snow</item> <item>@drawable/ic_scene_mode_smartauto</item> <item>@drawable/pick_the_best_photo</item> </array> @@ -297,31 +297,26 @@ <!-- 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>1</item> - <item>2</item> - <item>3</item> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</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> @@ -431,8 +426,8 @@ </string-array> <string-array name="pref_camera2_recordlocation_entryvalues" translatable="false"> - <item>off</item> - <item>on</item> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <array name="pref_camera2_recordlocation_entries" translatable="false"> @@ -566,8 +561,8 @@ </string-array> <string-array name="pref_camera2_redeyereduction_entryvalues" translatable="false"> - <item>disable</item> - <item>enable</item> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <!-- Camera Preferences Long Shot dialog box entries --> @@ -586,8 +581,8 @@ <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> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <string-array name="pref_camera2_filter_mode_icons" translatable="false"> @@ -668,8 +663,8 @@ </string-array> <string-array name="pref_camera2_dis_entryvalues" translatable="false"> - <item>@string/pref_camera_dis_value_disable</item> - <item>@string/pref_camera_dis_value_enable</item> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <string-array name="pref_camera2_noise_reduction_entries" translatable="false"> @@ -816,8 +811,8 @@ for time lapse recording --> </string-array> <string-array name="pref_camera2_facedetection_entryvalues" translatable="false"> - <item>off</item> - <item>on</item> + <item>@string/setting_off_value</item> + <item>@string/setting_on_value</item> </string-array> <string-array name="pref_camera2_videosnap_entries" translatable="true"> @@ -826,8 +821,22 @@ for time lapse recording --> </string-array> <string-array name="pref_camera2_videosnap_entryvalues" translatable="false"> - <item>@string/pref_camera2_videosnap_value_enable</item> - <item>@string/pref_camera2_videosnap_value_disable</item> + <item>@string/setting_on_value</item> + <item>@string/setting_off_value</item> + </string-array> + + <string-array name="pref_camera2_timer_entries" translatable="false"> + <item>@string/pref_camera2_timer_entry_off</item> + <item>@string/pref_camera2_timer_entry_2sec</item> + <item>@string/pref_camera2_timer_entry_5sec</item> + <item>@string/pref_camera2_timer_entry_10sec</item> + </string-array> + + <string-array name="pref_camera2_timer_entryvalues" translatable="false"> + <item>@string/pref_camera2_timer_value_off</item> + <item>@string/pref_camera2_timer_value_2sec</item> + <item>@string/pref_camera2_timer_value_5sec</item> + <item>@string/pref_camera2_timer_value_10sec</item> </string-array> <string-array name="pref_camera2_shutter_sound_entries" translatable="true"> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 96394ad66..2a58a33e2 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -165,7 +165,7 @@ <dimen name="scene_mode_padding">10dp</dimen> <dimen name="filter_mode_height">100dp</dimen> <dimen name="filter_mode_width">100dp</dimen> - <dimen name="filter_mode_padding">10dp</dimen> + <dimen name="filter_mode_padding">0dp</dimen> <dimen name="remaining_photos_margin">67dp</dimen> <dimen name="tsmakeup_mode_paddingBottom">96dp</dimen> diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index 330cb8979..9d87cb1ce 100644 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -999,7 +999,7 @@ <string name="pref_camera2_scenemode_default" translatable="false">0</string> <string name="pref_camera2_whitebalance_default" translatable="false">1</string> <string name="pref_camera2_coloreffect_default" translatable="false">0</string> - <string name="pref_camera2_flashmode_default" translatable="false">2</string> + <string name="pref_camera2_flashmode_default" translatable="false">@string/setting_off_value</string> <string name="pref_camera2_makeup_title" translatable="true">Makeup</string> @@ -1034,5 +1034,15 @@ <string name="pref_camera2_shutter_sound_entry_on" translatable="true">On</string> <string name="pref_camera2_shutter_sound_entry_off" translatable="true">Off</string> <string name="pref_camera2_shutter_sound_title" translatable="true">Shutter Sound</string> + + <string name="pref_camera2_timer_entry_off" translatable="false">Off</string> + <string name="pref_camera2_timer_entry_2sec" translatable="false">2 seconds</string> + <string name="pref_camera2_timer_entry_5sec" translatable="false">5 seconds</string> + <string name="pref_camera2_timer_entry_10sec" translatable="false">10 seconds</string> + + <string name="pref_camera2_timer_value_off" translatable="false">0</string> + <string name="pref_camera2_timer_value_2sec" translatable="false">2</string> + <string name="pref_camera2_timer_value_5sec" translatable="false">5</string> + <string name="pref_camera2_timer_value_10sec" translatable="false">10</string> </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index 4a7284874..765210fe2 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -19,6 +19,10 @@ <style name="Theme.ProxyLauncher" parent="@android:Theme.Translucent.NoTitleBar"> </style> + <style name="Theme.OneUISettings" parent="@android:style/Theme.Material.Light.NoActionBar.Fullscreen"> + <item name="android:colorAccent">#5999e1</item> + </style> + <style name="Theme.Camera" parent="Theme.CameraBase"> <item name="android:windowFullscreen">true</item> <item name="android:windowActionBar">false</item> @@ -262,6 +266,12 @@ <item name="android:layout_height">@dimen/toggle_outer_size</item> <item name="android:scaleType">center</item> </style> + <style name="OneUIMenuButton"> + <item name="android:layout_width">45dp</item> + <item name="android:layout_height">45dp</item> + <item name="android:padding">10dp</item> + <item name="android:scaleType">fitCenter</item> + </style> <style name="MenuIndicator"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml index 742c09d33..a9540550b 100644 --- a/res/xml/camera_preferences.xml +++ b/res/xml/camera_preferences.xml @@ -382,7 +382,7 @@ <ListPreference camera:key="pref_camera2_camera2_key" - camera:defaultValue="@string/pref_camera2_camera2_default" + camera:defaultValue="@string/setting_off_value" camera:title="@string/pref_camera2_camera2_title" camera:entries="@array/pref_camera2_camera2_entries" camera:entryValues="@array/pref_camera2_camera2_entryvalues" /> diff --git a/res/xml/capture_preferences.xml b/res/xml/capture_preferences.xml index 29a12281f..5ddb60c89 100644 --- a/res/xml/capture_preferences.xml +++ b/res/xml/capture_preferences.xml @@ -80,21 +80,21 @@ camera:title="@string/pref_camera_savepath_title"/> <ListPreference - camera:defaultValue="@string/pref_camera2_mono_only_default" + camera:defaultValue="@string/setting_off_value" camera:entries="@array/pref_camera2_mono_only_entries" camera:entryValues="@array/pref_camera2_mono_only_entryvalues" camera:key="pref_camera2_mono_only_key" camera:title="@string/pref_camera2_mono_only_title"/> <ListPreference - camera:defaultValue="@string/pref_camera2_mono_preview_default" + camera:defaultValue="@string/setting_off_value" 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:defaultValue="@string/setting_on_value" camera:entries="@array/pref_camera2_clearsight_entries" camera:entryValues="@array/pref_camera2_clearsight_entryvalues" camera:key="pref_camera2_clearsight_key" @@ -127,7 +127,7 @@ camera:title="@string/pref_camera_scenemode_title"/> <IconListPreference - camera:defaultValue="@string/pref_camera_redeyereduction_default" + camera:defaultValue="@string/setting_off_value" camera:entries="@array/pref_camera2_redeyereduction_entries" camera:entryValues="@array/pref_camera2_redeyereduction_entryvalues" camera:key="pref_camera2_redeyereduction_key" @@ -165,7 +165,7 @@ camera:title="@string/pref_camera_iso_title"/> <IconListPreference - camera:defaultValue="@string/pref_camera_longshot_default" + camera:defaultValue="@string/setting_off_value" camera:entries="@array/pref_camera2_longshot_entries" camera:entryValues="@array/pref_camera2_longshot_entryvalues" camera:key="pref_camera2_longshot_key" @@ -220,7 +220,7 @@ camera:title="@string/pref_camera_audioencoder_title"/> <IconListPreference - camera:defaultValue="@string/pref_camera_dis_default" + camera:defaultValue="@string/setting_off_value" camera:entries="@array/pref_camera2_dis_entries" camera:entryValues="@array/pref_camera2_dis_entryvalues" camera:key="pref_camera2_dis_key" @@ -234,17 +234,6 @@ camera:key="pref_camera2_noise_reduction_key" camera:title="@string/pref_camera_noise_reduction_title"/> - <IconListPreference - camera:defaultValue="@string/pref_camera_video_flashmode_default" - camera:entries="@array/pref_camera2_video_flashmode_entries" - camera:entryValues="@array/pref_camera2_video_flashmode_entryvalues" - camera:icons="@array/video_flashmode_icons" - camera:key="pref_camera2_video_flashmode_key" - camera:labelList="@array/pref_camera2_video_flashmode_labels" - camera:largeIcons="@array/video_flashmode_largeicons" - camera:singleIcon="@drawable/ic_settings_flash" - camera:title="@string/pref_camera_flashmode_title"/> - <ListPreference camera:defaultValue="@string/pref_camera_video_rotation_default" camera:entries="@array/pref_camera2_video_rotation_entries" @@ -260,7 +249,7 @@ camera:title="@string/pref_video_time_lapse_frame_interval_title"/> <IconListPreference - camera:defaultValue="@string/pref_camera_facedetection_default" + camera:defaultValue="@string/setting_off_value" camera:entries="@array/pref_camera2_facedetection_entries" camera:entryValues="@array/pref_camera2_facedetection_entryvalues" camera:key="pref_camera2_facedetection_key" @@ -268,7 +257,7 @@ camera:title="@string/pref_camera_facedetection_title"/> <ListPreference - camera:defaultValue="@string/pref_camera2_videosnap_default" + camera:defaultValue="@string/setting_on_value" camera:entries="@array/pref_camera2_videosnap_entries" camera:entryValues="@array/pref_camera2_videosnap_entryvalues" camera:key="pref_camera2_videosnap_key" diff --git a/res/xml/setting_menu_preferences.xml b/res/xml/setting_menu_preferences.xml new file mode 100644 index 000000000..a606b342c --- /dev/null +++ b/res/xml/setting_menu_preferences.xml @@ -0,0 +1,268 @@ +<?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. +--> +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" + android:key="screen"> + <PreferenceCategory + android:key="general" + android:layout="@layout/preferences_category" + android:title="GENERAL"> + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/gps_location" + android:key="pref_camera2_recordlocation_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_recordlocation_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/face_detection" + android:key="pref_camera2_facedetection_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_facedetection_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_savepath_default" + android:entries="@array/pref_camera2_savepath_entries" + android:entryValues="@array/pref_camera2_savepath_entryvalues" + android:icon="@drawable/storage" + android:key="pref_camera2_savepath_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_savepath_title" /> + </PreferenceCategory> + + <PreferenceCategory + android:key="photo" + android:layout="@layout/preferences_category" + android:title="STILL CAMERA"> + <ListPreference + android:defaultValue="@string/pref_camera2_timer_value_off" + android:entries="@array/pref_camera2_timer_entries" + android:entryValues="@array/pref_camera2_timer_entryvalues" + android:icon="@drawable/countdown_timer" + android:key="pref_camera2_timer_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_timer_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/continuous_shot" + android:key="pref_camera2_longshot_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_longshot_title" /> + + <ListPreference + android:entries="@array/pref_camera2_picturesize_entries" + android:entryValues="@array/pref_camera2_picturesize_entryvalues" + android:icon="@drawable/picture_size" + android:key="pref_camera2_picturesize_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_picturesize_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_jpegquality_default" + android:entries="@array/pref_camera2_jpegquality_entries" + android:entryValues="@array/pref_camera2_jpegquality_entryvalues" + android:icon="@drawable/picture_quality" + android:key="pref_camera2_jpegquality_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_jpegquality_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/ic_settings_redeye" + android:key="pref_camera2_redeyereduction_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_redeyereduction_title" /> + + <ListPreference + android:defaultValue="@string/pref_exposure_default" + android:icon="@drawable/exposure" + android:key="pref_camera2_exposure_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_exposure_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera2_whitebalance_default" + android:entries="@array/pref_camera2_whitebalance_entries" + android:entryValues="@array/pref_camera2_whitebalance_entryvalues" + android:icon="@drawable/white_balance" + android:key="pref_camera2_whitebalance_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_whitebalance_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/ic_settings_flash" + android:key="pref_selfie_flash_key" + android:layout="@layout/preference" + android:title="@string/pref_selfie_flash_title" /> + + <SwitchPreference + android:defaultValue="true" + android:icon="@drawable/shutter_sound" + android:key="pref_camera2_shutter_sound_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_shutter_sound_title" /> + + <SwitchPreference + android:defaultValue="false" + android:key="pref_camera2_mono_only_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_mono_only_title" /> + + <SwitchPreference + android:defaultValue="false" + android:key="pref_camera2_mono_preview_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_mono_preview_title" /> + + <SwitchPreference + android:defaultValue="false" + android:key="pref_camera2_clearsight_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_clearsight_title" /> + + <ListPreference + android:defaultValue="false" + android:key="pref_camera2_mpo_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_mpo_title" /> + </PreferenceCategory> + + <PreferenceCategory + android:key="video" + android:layout="@layout/preferences_category" + android:title="VIDEO CAMERA"> + <ListPreference + android:entries="@array/pref_camera2_video_quality_entries" + android:entryValues="@array/pref_camera2_video_quality_entryvalues" + android:icon="@drawable/video_quality" + android:key="pref_camera2_video_quality_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_video_quality_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_video_duration_default" + android:entries="@array/pref_camera2_video_duration_entries" + android:entryValues="@array/pref_camera2_video_duration_entryvalues" + android:icon="@drawable/video_duration" + android:key="pref_camera2_video_duration_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_video_duration_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/image_stabilization" + android:key="pref_camera2_dis_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_dis_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/noise_reduction" + android:key="pref_camera2_noise_reduction_key" + android:layout="@layout/preference" + android:title="@string/pref_camera_noise_reduction_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_videoencoder_default" + android:entries="@array/pref_camera2_videoencoder_entries" + android:entryValues="@array/pref_camera2_videoencoder_entryvalues" + android:icon="@drawable/video_encoding" + android:key="pref_camera2_videoencoder_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_videoencoder_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_audioencoder_default" + android:entries="@array/pref_camera2_audioencoder_entries" + android:entryValues="@array/pref_camera2_audioencoder_entryvalues" + android:icon="@drawable/audio_encoding" + android:key="pref_camera2_audioencoder_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_audioencoder_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_video_rotation_default" + android:entries="@array/pref_camera2_video_rotation_entries" + android:entryValues="@array/pref_camera2_video_rotation_entryvalues" + android:icon="@drawable/video_rotation" + android:key="pref_camera2_video_rotation_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_video_rotation_title" /> + + <ListPreference + android:defaultValue="@string/pref_video_time_lapse_frame_interval_default" + android:entries="@array/pref_camera2_video_time_lapse_frame_interval_entries" + android:entryValues="@array/pref_camera2_video_time_lapse_frame_interval_entryvalues" + android:icon="@drawable/clock" + android:key="pref_camera2_video_time_lapse_frame_interval_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_video_time_lapse_frame_interval_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera2_videosnap_default" + android:entries="@array/pref_camera2_videosnap_entries" + android:entryValues="@array/pref_camera2_videosnap_entryvalues" + android:icon="@drawable/auto_snapshot_size" + android:key="pref_camera2_videosnap_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera2_videosnap_title" /> + + <ListPreference + android:defaultValue="@string/pref_camera_hfr_default" + android:entries="@array/pref_camera_hfr_entries" + android:entryValues="@array/pref_camera_hfr_entryvalues" + android:icon="@drawable/ic_settings_fps" + android:key="pref_camera2_hfr_key" + android:layout="@layout/preference" + android:summary="%s" + android:title="@string/pref_camera_hfr_title" /> + + <SwitchPreference + android:defaultValue="false" + android:icon="@drawable/tracking_focus" + android:key="pref_camera2_trackingfocus_key" + android:layout="@layout/preference" + android:title="@string/pref_camera2_trackingfocus_title" /> + </PreferenceCategory> +</PreferenceScreen>
\ No newline at end of file diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index b09d147bf..7ca4d9c45 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -1041,33 +1041,35 @@ public class CameraSettings { return false; } - public static void filterUnsupportedOptions(PreferenceGroup group, + public static boolean filterUnsupportedOptions(PreferenceGroup group, ListPreference pref, List<String> supported) { // Remove the preference if the parameter is not supported or there is // only one options for the settings. if (supported == null || supported.size() <= 1) { removePreference(group, pref.getKey()); - return; + return true; } pref.filterUnsupported(supported); if (pref.getEntries().length <= 1) { removePreference(group, pref.getKey()); - return; + return true; } resetIfInvalid(pref); + return false; } - public static void filterSimilarPictureSize(PreferenceGroup group, + public static boolean filterSimilarPictureSize(PreferenceGroup group, ListPreference pref) { pref.filterDuplicated(); if (pref.getEntries().length <= 1) { removePreference(group, pref.getKey()); - return; + return true; } resetIfInvalid(pref); + return false; } private static void resetIfInvalid(ListPreference pref) { diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index bc69b584e..6e18ad1a1 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -1568,18 +1568,21 @@ public class CaptureModule implements CameraModule, PhotoController, applyAERegions(builder, id); applyCommonSettings(builder, id); applyFaceDetect(builder, id); + applyFlash(builder, id); } private void applySettingsForCapture(CaptureRequest.Builder builder, int id) { builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_IDLE); applyJpegQuality(builder); applyCommonSettings(builder, id); + applyFlash(builder, id); } private void applySettingsForPrecapture(CaptureRequest.Builder builder, int id) { builder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START); applyCommonSettings(builder, id); + applyFlash(builder, id); applyFaceDetect(builder, id); } @@ -1609,7 +1612,6 @@ public class CaptureModule implements CameraModule, PhotoController, private void applyVideoSnapshot(CaptureRequest.Builder builder, int id) { builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); - applyWhiteBalance(builder); applyColorEffect(builder); applyVideoFlash(builder); } @@ -1618,7 +1620,6 @@ public class CaptureModule implements CameraModule, PhotoController, builder.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO); builder.set(CaptureRequest.CONTROL_AF_MODE, mControlAFMode); applyFaceDetection(builder); - applyFlash(builder, id); applyWhiteBalance(builder); applyExposure(builder); applyIso(builder); @@ -1853,7 +1854,6 @@ public class CaptureModule implements CameraModule, PhotoController, initializeValues(); updatePreviewSize(); mUI.showSurfaceView(); - mUI.setSwitcherIndex(); mCameraIdList = new ArrayList<>(); if (mSound == null) { @@ -2047,6 +2047,7 @@ public class CaptureModule implements CameraModule, PhotoController, } Log.d(TAG, "onSingleTapUp " + x + " " + y); int[] newXY = {x, y}; + if (mUI.isOverControlRegion(newXY)) return; if (!mUI.isOverSurfaceView(newXY)) return; mUI.setFocusPosition(x, y); x = newXY[0]; @@ -2482,15 +2483,15 @@ public class CaptureModule implements CameraModule, PhotoController, applyVideoStabilization(builder); applyNoiseReduction(builder); applyColorEffect(builder); - applyWhiteBalance(builder); applyVideoFlash(builder); } private void applyVideoFlash(CaptureRequest.Builder builder) { - String value = mSettingsManager.getValue(SettingsManager.KEY_VIDEO_FLASH_MODE); + String value = mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE); if (value == null) return; + boolean flashOn = value.equals("on"); - if (value.equals("torch")) { + if (flashOn) { builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH); } else { builder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF); @@ -2982,16 +2983,15 @@ public class CaptureModule implements CameraModule, PhotoController, updatePreview = true; applyExposure(mPreviewRequestBuilder[cameraId]); break; - case SettingsManager.KEY_FLASH_MODE: - updatePreview = true; - applyFlash(mPreviewRequestBuilder[cameraId], cameraId); - break; case SettingsManager.KEY_ISO: updatePreview = true; applyIso(mPreviewRequestBuilder[cameraId]); break; + case SettingsManager.KEY_FACE_DETECTION: + updatePreview = true; + applyFaceDetect(mPreviewRequestBuilder[cameraId], cameraId); + break; } - applyFaceDetect(mPreviewRequestBuilder[cameraId], cameraId); return updatePreview; } @@ -3079,24 +3079,24 @@ public class CaptureModule implements CameraModule, PhotoController, } private void applyFlash(CaptureRequest.Builder request, String value) { - int mode = Integer.parseInt(value); + boolean flashOn = value.equals("on"); 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 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 != null && redeye.equals("disable")) { - request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest - .CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE); - } - break; + boolean redeyeOn = redeye != null && redeye.equals("on"); + + if (redeyeOn) { + request.set(CaptureRequest.CONTROL_AE_MODE, + CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE); + } else { + if (flashOn) { + request.set(CaptureRequest.CONTROL_AE_MODE, + CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH); + request.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_SINGLE); + } else { + request.set(CaptureRequest.CONTROL_AE_MODE, + CaptureRequest.CONTROL_AE_MODE_ON); + request.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF); + } + } } @@ -3407,14 +3407,6 @@ public class CaptureModule implements CameraModule, PhotoController, onResumeAfterSuper(); } - private void switchCameraMode(String value) { - if (value.equals("enable")) { - mActivity.onModuleSelected(ModuleSwitcher.CAPTURE_MODULE_INDEX); - } else { - mActivity.onModuleSelected(ModuleSwitcher.PHOTO_MODULE_INDEX); - } - } - private Size getOptimalPreviewSize(Size pictureSize, Size[] prevSizes, int screenW, int screenH) { if (pictureSize.getWidth() <= screenH && pictureSize.getHeight() <= screenW) { diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index b96902f81..ac4a1a090 100644 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -21,13 +21,12 @@ package com.android.camera; import android.animation.Animator; import android.content.Context; +import android.content.Intent; import android.content.res.Resources; import android.graphics.ImageFormat; import android.graphics.Point; import android.graphics.Rect; -import android.graphics.drawable.AnimationDrawable; import android.hardware.Camera.Face; -import android.media.ImageReader; import android.renderscript.Allocation; import android.renderscript.Element; import android.renderscript.RenderScript; @@ -36,7 +35,6 @@ import android.renderscript.Type; 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.Surface; @@ -53,16 +51,13 @@ import android.widget.TextView; import com.android.camera.imageprocessor.ScriptC_YuvToRgb; import com.android.camera.imageprocessor.ScriptC_rotator; -import com.android.camera.imageprocessor.filter.BeautificationFilter; -import com.android.camera.imageprocessor.filter.TrackingFocusFrameListener; import com.android.camera.ui.AutoFitSurfaceView; import com.android.camera.ui.Camera2FaceView; import com.android.camera.ui.CameraControls; +import com.android.camera.ui.OneUICameraControls; import com.android.camera.ui.CountDownView; +import com.android.camera.ui.FlashToggleButton; 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.RenderOverlay; import com.android.camera.ui.RotateImageView; @@ -75,66 +70,21 @@ import com.android.camera.util.CameraUtil; import org.codeaurora.snapcam.R; -import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.Set; public class CaptureUI implements FocusOverlayManager.FocusUI, PreviewGestures.SingleTapListener, CameraManager.CameraFaceDetectionCallback, SettingsManager.Listener, - ListMenu.Listener, - ListSubMenu.Listener, PauseButton.OnPauseButtonListener { 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 FILTER_MENU_NONE = 0; + private static final int FILTER_MENU_IN_ANIMATION = 1; + private static final int FILTER_MENU_ON = 2; private static final int ANIMATION_DURATION = 300; private static final int CLICK_THRESHOLD = 200; - String[] mSettingKeys = new String[]{ - SettingsManager.KEY_SELFIE_FLASH, - SettingsManager.KEY_FLASH_MODE, - SettingsManager.KEY_RECORD_LOCATION, - SettingsManager.KEY_PICTURE_SIZE, - SettingsManager.KEY_JPEG_QUALITY, - SettingsManager.KEY_TIMER, - SettingsManager.KEY_CAMERA_SAVEPATH, - SettingsManager.KEY_LONGSHOT, - SettingsManager.KEY_EXPOSURE, - SettingsManager.KEY_WHITE_BALANCE, - SettingsManager.KEY_FACE_DETECTION, - SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE, - SettingsManager.KEY_VIDEO_FLASH_MODE, - SettingsManager.KEY_VIDEO_DURATION, - SettingsManager.KEY_VIDEO_QUALITY, - SettingsManager.KEY_TRACKINGFOCUS, - SettingsManager.KEY_MAKEUP, - SettingsManager.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, - SettingsManager.KEY_SHUTTER_SOUND - }; - String[] mDeveloperKeys = new String[]{ - SettingsManager.KEY_REDEYE_REDUCTION, - SettingsManager.KEY_MONO_ONLY, - SettingsManager.KEY_CLEARSIGHT, - SettingsManager.KEY_MONO_PREVIEW, - SettingsManager.KEY_MPO, - SettingsManager.KEY_NOISE_REDUCTION, - SettingsManager.KEY_DIS, - SettingsManager.KEY_VIDEO_ENCODER, - SettingsManager.KEY_AUDIO_ENCODER, - SettingsManager.KEY_VIDEO_ROTATION, - SettingsManager.KEY_AUTO_VIDEOSNAP_SIZE - }; private CameraActivity mActivity; private View mRootView; private View mPreviewCover; @@ -144,14 +94,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private SurfaceHolder mSurfaceHolder; private SurfaceHolder mSurfaceHolderMono; 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 int mFilterMenuStatus; private PreviewGestures mGestures; private boolean mUIhidden = false; private SettingsManager mSettingsManager; @@ -208,10 +151,9 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private ShutterButton mShutterButton; private ImageView mVideoButton; private RenderOverlay mRenderOverlay; - private View mMenuButton; - private ModuleSwitcher mSwitcher; + private FlashToggleButton mFlashButton; private CountDownView mCountDownView; - private CameraControls mCameraControls; + private OneUICameraControls mCameraControls; private PieRenderer mPieRenderer; private ZoomRenderer mZoomRenderer; private Allocation mMonoDummyAllocation; @@ -221,14 +163,13 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private int mScreenRatio = CameraUtil.RATIO_UNKNOWN; private int mTopMargin = 0; private int mBottomMargin = 0; - private LinearLayout mSceneAndFilterLayout; - private int mSceneAndFilterMenuSize; + private ViewGroup mFilterLayout; private View mFilterModeSwitcher; private View mSceneModeSwitcher; private View mFrontBackSwitcher; + private View mMakeupButton; private TextView mRecordingTimeView; - private LinearLayout mLabelsLinearLayout; private View mTimeLapseLabel; private RotateLayout mRecordingTimeRect; private PauseButton mPauseButton; @@ -293,9 +234,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mFilterModeSwitcher = mRootView.findViewById(R.id.filter_mode_switcher); mSceneModeSwitcher = mRootView.findViewById(R.id.scene_mode_switcher); mFrontBackSwitcher = mRootView.findViewById(R.id.front_back_switcher); + mMakeupButton = mRootView.findViewById(R.id.ts_makeup_switcher); + mFlashButton = (FlashToggleButton) mRootView.findViewById(R.id.flash_button); initFilterModeButton(); initSceneModeButton(); initSwitchCamera(); + initFlashButton(); mTrackingFocusRenderer = new TrackingFocusRenderer(mActivity, mModule, this); mRenderOverlay.addRenderer(mTrackingFocusRenderer); @@ -306,25 +250,10 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mTrackingFocusRenderer.setVisible(false); } - mSwitcher = (ModuleSwitcher) mRootView.findViewById(R.id.camera_switcher); - mSwitcher.setCurrentIndex(ModuleSwitcher.PHOTO_MODULE_INDEX); - mSwitcher.setSwitchListener(mActivity); - mSwitcher.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (mModule.getCameraState() == PhotoController.LONGSHOT) { - return; - } - mSwitcher.showPopup(); - mSwitcher.setOrientation(mOrientation, false); - } - }); - mMenuButton = mRootView.findViewById(R.id.menu); mRecordingTimeView = (TextView) mRootView.findViewById(R.id.recording_time); mRecordingTimeRect = (RotateLayout) mRootView.findViewById(R.id.recording_time_rect); mTimeLapseLabel = mRootView.findViewById(R.id.time_lapse_label); - mLabelsLinearLayout = (LinearLayout) mRootView.findViewById(R.id.labels); mPauseButton = (PauseButton) mRootView.findViewById(R.id.video_pause); mPauseButton.setOnPauseButtonListener(this); @@ -350,7 +279,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, RotateImageView muteButton = (RotateImageView) mRootView.findViewById(R.id.mute_button); muteButton.setVisibility(View.GONE); - mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls); + mCameraControls = (OneUICameraControls) mRootView.findViewById(R.id.camera_controls); mFaceView = (Camera2FaceView) mRootView.findViewById(R.id.face_view); mActivity.getWindowManager().getDefaultDisplay().getSize(mDisplaySize); @@ -362,7 +291,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mTopMargin = l / 4 * tm / (tm + bm); mBottomMargin = l / 4 - mTopMargin; } - mCameraControls.setMargins(mTopMargin, mBottomMargin); if (mPieRenderer == null) { mPieRenderer = new PieRenderer(mActivity); @@ -384,7 +312,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mRenderOverlay.requestLayout(); ((ViewGroup)mRootView).removeView(mRecordingTimeRect); - mCameraControls.setPreviewRatio(0, true); } public void onCameraOpened(List<Integer> cameraIds) { @@ -394,14 +321,10 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mActivity.setPreviewGestures(mGestures); } - public ViewGroup getSceneAndFilterLayout() { - return mSceneAndFilterLayout; - } - public void reInitUI() { - initializeSettingMenu(); initSceneModeButton(); initFilterModeButton(); + initFlashButton(); if (mTrackingFocusRenderer != null) { mTrackingFocusRenderer.setVisible(true); } @@ -418,24 +341,16 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, // called from onResume but only the first time public void initializeFirstTime() { // Initialize shutter button. - mShutterButton.setImageResource(R.drawable.shutter_button_anim); - mShutterButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (!CameraControls.isAnimating()) - doShutterAnimation(); - } - }); mShutterButton.setOnShutterButtonListener(mModule); mShutterButton.setVisibility(View.VISIBLE); mVideoButton.setVisibility(View.VISIBLE); mVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + cancelCountDown(); mModule.onVideoButtonClick(); } }); - mCameraControls.setPreviewRatio(0, true); } public void initializeZoom(List<Integer> ids) { @@ -455,17 +370,17 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public boolean isPreviewMenuBeingShown() { - return mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_ON; + return mFilterMenuStatus == FILTER_MENU_ON; } - public void removeSceneAndFilterMenu(boolean animate) { + public void removeFilterMenu(boolean animate) { if (animate) { - animateSlideOut(mSceneAndFilterLayout); + animateSlideOut(mFilterLayout); } else { - mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_NONE; - if (mSceneAndFilterLayout != null) { - ((ViewGroup) mRootView).removeView(mSceneAndFilterLayout); - mSceneAndFilterLayout = null; + mFilterMenuStatus = FILTER_MENU_NONE; + if (mFilterLayout != null) { + ((ViewGroup) mRootView).removeView(mFilterLayout); + mFilterLayout = null; } } } @@ -476,10 +391,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, 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 @@ -494,29 +405,26 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, index = (index + 1) % entries.length; } while (entries[index] == null); mSettingsManager.setValueIndex(SettingsManager.KEY_CAMERA_ID, index); - int[] largeIcons = mSettingsManager.getResource(SettingsManager.KEY_CAMERA_ID, - SettingsManager.RESOURCE_TYPE_LARGEICON); - ((ImageView) v).setImageResource(largeIcons[index]); } }); } + public void initFlashButton() { + mFlashButton.init(); + } + 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); - } + clearFocus(); + removeFilterMenu(false); + Intent intent = new Intent(mActivity, SceneModeActivity.class); + mActivity.startActivity(intent); } }); } @@ -525,20 +433,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, 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); - } } }); } @@ -550,16 +450,14 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public void showRecordingUI(boolean recording) { - mMenuButton.setVisibility(recording ? View.GONE : View.VISIBLE); + mFlashButton.setVisibility(recording ? View.GONE : View.VISIBLE); if (recording) { - mVideoButton.setImageResource(R.drawable.shutter_button_video_stop); - hideSwitcher(); + mVideoButton.setImageResource(R.drawable.video_stop); mRecordingTimeView.setText(""); ((ViewGroup)mRootView).addView(mRecordingTimeRect); mMuteButton.setVisibility(View.VISIBLE); } else { - mVideoButton.setImageResource(R.drawable.btn_new_shutter_video); - showSwitcher(); + mVideoButton.setImageResource(R.drawable.video_capture); ((ViewGroup)mRootView).removeView(mRecordingTimeRect); mMuteButton.setVisibility(View.INVISIBLE); } @@ -579,141 +477,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mSceneModeSwitcher.setVisibility(View.VISIBLE); } - public void hideSwitcher() { - mSwitcher.closePopup(); - mSwitcher.setVisibility(View.INVISIBLE); - } - - public void showSwitcher() { - mSwitcher.setVisibility(View.VISIBLE); - } - - 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) { - 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); - updateSceneModeIcon(j); - mSettingsManager.setValueIndex(SettingsManager.KEY_SCENE_MODE, j); - 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); - } - - 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 void updateSceneModeIcon(int idx) { - int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_SCENE_MODE, - SettingsManager.RESOURCE_TYPE_THUMBNAIL); - int thumbnail = thumbnails[idx]; - if (thumbnail == -1) - thumbnail = 0; - ((ImageView) mSceneModeSwitcher).setImageResource(thumbnail); - } - public void addFilterMode() { if (mSettingsManager.getValue(SettingsManager.KEY_COLOR_EFFECT) == null) return; @@ -736,14 +499,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, int gridRes; boolean portrait = (rotation == 0) || (rotation == 180); int size = height; - if (portrait) { + if (!portrait) { gridRes = R.layout.vertical_grid; size = width; } else { gridRes = R.layout.horiz_grid; } - mSceneAndFilterMenuSize = size; - hideUI(); int[] thumbnails = mSettingsManager.getResource(SettingsManager.KEY_COLOR_EFFECT, SettingsManager.RESOURCE_TYPE_THUMBNAIL); @@ -751,22 +512,21 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, 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); + gridOuterLayout.setBackgroundColor(android.R.color.transparent); + removeFilterMenu(false); + mFilterMenuStatus = FILTER_MENU_ON; + mFilterLayout = new LinearLayout(mActivity); ViewGroup.LayoutParams params = null; - if (portrait) { + if (!portrait) { params = new ViewGroup.LayoutParams(size, FrameLayout.LayoutParams.MATCH_PARENT); - mSceneAndFilterLayout.setLayoutParams(params); - ((ViewGroup) mRootView).addView(mSceneAndFilterLayout); + mFilterLayout.setLayoutParams(params); + ((ViewGroup) mRootView).addView(mFilterLayout); } else { params = new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, size); - mSceneAndFilterLayout.setLayoutParams(params); - ((ViewGroup) mRootView).addView(mSceneAndFilterLayout); - mSceneAndFilterLayout.setY(display.getHeight() - size); + mFilterLayout.setLayoutParams(params); + ((ViewGroup) mRootView).addView(mFilterLayout); + mFilterLayout.setY(display.getHeight() - 2 * size); } gridOuterLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams .MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); @@ -811,137 +571,11 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, label.setText(entries[i]); gridLayout.addView(filterBox); } - mSceneAndFilterLayout.addView(gridOuterLayout); - } - - private void changeFilterModeControlIcon(String value) { - int index; - if (value.equals("0")) { - index = 0; - } else { - index = 1; - } - ImageView iv = (ImageView) mFilterModeSwitcher; - iv.setImageResource(mSettingsManager.getResource(SettingsManager - .KEY_COLOR_EFFECT, SettingsManager.RESOURCE_TYPE_LARGEICON)[index]); + mFilterLayout.addView(gridOuterLayout); } - 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 { - 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; - } - } - 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); - } - } - - private void finishScenceAndFilterMenuAnimateOut() { - removeSceneAndFilterMenu(false); + public void removeAndCleanUpFilterMenu() { + removeFilterMenu(false); cleanUpMenus(); } @@ -952,9 +586,9 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } private void animateSlideOut(final View v) { - if (v == null || mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_IN_ANIMATION) + if (v == null || mFilterMenuStatus == FILTER_MENU_IN_ANIMATION) return; - mSceneAndFilterMenuStatus = SCENE_AND_FILTER_MENU_IN_ANIMATION; + mFilterMenuStatus = FILTER_MENU_IN_ANIMATION; ViewPropertyAnimator vp = v.animate(); if (View.LAYOUT_DIRECTION_RTL == TextUtils @@ -975,12 +609,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, @Override public void onAnimationEnd(Animator animation) { - finishScenceAndFilterMenuAnimateOut(); + removeAndCleanUpFilterMenu(); } @Override public void onAnimationCancel(Animator animation) { - finishScenceAndFilterMenuAnimateOut(); + removeAndCleanUpFilterMenu(); } }); vp.start(); @@ -1044,119 +678,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, vp.setDuration(ANIMATION_DURATION).start(); } - 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()) { - String[] combined = new String[mSettingKeys.length + mDeveloperKeys.length]; - int idx = 0; - for (String key: mSettingKeys) { - combined[idx++] = key; - } - for (String key: mDeveloperKeys) { - combined[idx++] = key; - } - keys = combined; - } - mSettingMenu.initializeForCamera2(keys); - } - - public boolean isMenuBeingShown() { - return mSettingMenuState != SETTING_MENU_NONE; - } - - 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(); - - 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, - FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP); - } else { - 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(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, - FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP); - } else { - 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 = mSettingSubMenu.getPreCalculatedHeight(); - int yBase = mSettingSubMenu.getYBase(); - int y = Math.max(0, yBase); - if (yBase + height > screenHeight) - y = Math.max(0, screenHeight - height); - if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) { - params.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0); - } else { - params.setMargins(0, y, CameraActivity.SETTING_LIST_WIDTH_1, 0); - } - - mSubMenuLayout.setLayoutParams(params); - - mSubMenuLayout.addView(mSettingSubMenu); - mSubMenuLayout.setOrientation(mOrientation, true); - } - if (animate) { - 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 hideUIWhileCountDown() { hideCameraControls(true); mGestures.setZoomOnly(true); @@ -1169,11 +690,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, public void hideCameraControls(boolean hide) { final int status = (hide) ? View.INVISIBLE : View.VISIBLE; - if (mMenuButton != null) mMenuButton.setVisibility(status); + if (mFlashButton != null) mFlashButton.setVisibility(status); if (mFrontBackSwitcher != null) mFrontBackSwitcher.setVisibility(status); if (mSceneModeSwitcher != null) mSceneModeSwitcher.setVisibility(status); if (mFilterModeSwitcher != null) mFilterModeSwitcher.setVisibility(status); - if (mSwitcher != null) mSwitcher.setVisibility(status); + if (mFilterModeSwitcher != null) mFilterModeSwitcher.setVisibility(status); + if (mMakeupButton != null) mMakeupButton.setVisibility(status); } public void initializeControlByIntent() { @@ -1186,33 +708,24 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mActivity.gotoGallery(); } }); - mMenuButton = mRootView.findViewById(R.id.menu); - mMenuButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showSettingMenu(); - } - }); } public void doShutterAnimation() { - AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getDrawable(); - frameAnimation.stop(); - frameAnimation.start(); } public void showUI() { - if (!mUIhidden || isMenuBeingShown()) + if (!mUIhidden) return; mUIhidden = false; + mPieRenderer.setBlockFocus(false); mCameraControls.showUI(); } public void hideUI() { - mSwitcher.closePopup(); if (mUIhidden) return; mUIhidden = true; + mPieRenderer.setBlockFocus(true); mCameraControls.hideUI(); } @@ -1226,54 +739,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public void onOrientationChanged() { - removeSettingMenu(SETTING_MENU_LEVEL_TWO, false); - if (mSettingMenu != null) - mSettingMenu.resetHighlight(); - } - - public void removeAllSettingMenu(boolean animate) { - removeSettingMenu(SETTING_MENU_LEVEL_TWO, false); - removeSettingMenu(SETTING_MENU_LEVEL_ONE, animate); - } - - public void removeAllSettingMenu() { - removeAllSettingMenu(false); - } - - 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); - } - } - } - public void removeAllMenu() { - removeAllSettingMenu(); } /** @@ -1286,16 +752,11 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } private boolean handleBackKeyOnMenu() { - if (mSceneAndFilterMenuStatus == SCENE_AND_FILTER_MENU_ON) { - removeSceneAndFilterMenu(true); + if (mFilterMenuStatus == FILTER_MENU_ON) { + removeFilterMenu(true); return true; } - if (mSettingMenuState == SETTING_MENU_NONE) - return false; - if (mSettingMenuState == SETTING_MENU_ON) { - removeSettingMenu(mSettingMenuLevel, true); - } - return true; + return false; } public boolean onBackPressed() { @@ -1309,12 +770,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, // ignore backs while we're taking a picture return true; } - if (mSwitcher != null && mSwitcher.showsPopup()) { - mSwitcher.closePopup(); - return true; - } else { - return false; - } + return false; } public SurfaceHolder getSurfaceHolder() { @@ -1433,10 +889,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, } public boolean collapseCameraControls() { - mSwitcher.closePopup(); // Remove all the popups/dialog boxes boolean ret = false; - removeAllMenu(); mCameraControls.showRefocusToast(false); return ret; } @@ -1547,12 +1001,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, public void setOrientation(int orientation, boolean animation) { mOrientation = orientation; mCameraControls.setOrientation(orientation, animation); - if (mMenuLayout != null) - mMenuLayout.setOrientation(orientation, animation); - if (mSubMenuLayout != null) - mSubMenuLayout.setOrientation(orientation, animation); - if (mSceneAndFilterLayout != null) { - ViewGroup vg = (ViewGroup) mSceneAndFilterLayout.getChildAt(0); + if (mFilterLayout != null) { + ViewGroup vg = (ViewGroup) mFilterLayout.getChildAt(0); if (vg != null) vg = (ViewGroup) vg.getChildAt(0); if (vg != null) { @@ -1591,6 +1041,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mModule.onSingleTapUp(view, x, y); } + public boolean isOverControlRegion(int[] xy) { + int x = xy[0]; + int y = xy[1]; + return mCameraControls.isControlRegion(x, y); + } + public boolean isOverSurfaceView(int[] xy) { int x = xy[0]; int y = xy[1]; @@ -1626,10 +1082,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, if (!previewFocused && mCountDownView != null) mCountDownView.cancelCountDown(); } - public ViewGroup getMenuLayout() { - return mMenuLayout; - } - public boolean isShutterPressed() { return mShutterButton.isPressed(); } @@ -1673,17 +1125,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, @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_COLOR_EFFECT: - changeFilterModeControlIcon(value); - updateFilterModeIcon(values.overriddenValue == null); - break; - } - } } public void startSelfieFlash() { @@ -1730,45 +1171,6 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, return changed; } - @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) { diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java index 0ac6ce01c..ef6266f23 100644 --- a/src/com/android/camera/PreviewGestures.java +++ b/src/com/android/camera/PreviewGestures.java @@ -20,7 +20,6 @@ import android.view.GestureDetector; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; -import android.util.Log; import com.android.camera.ui.PieRenderer; import com.android.camera.ui.RenderOverlay; @@ -189,16 +188,9 @@ public class PreviewGestures } if (mCaptureUI != null) { - if (mCaptureUI.isMenuBeingShown()) { - if (!mCaptureUI.isMenuBeingAnimated()) { - waitUntilNextDown = true; - mCaptureUI.removeAllSettingMenu(true); - } - return true; - } if (mCaptureUI.isPreviewMenuBeingShown()) { waitUntilNextDown = true; - mCaptureUI.removeSceneAndFilterMenu(true); + mCaptureUI.removeFilterMenu(true); return true; } } diff --git a/src/com/android/camera/SceneModeActivity.java b/src/com/android/camera/SceneModeActivity.java new file mode 100644 index 000000000..09ad391c1 --- /dev/null +++ b/src/com/android/camera/SceneModeActivity.java @@ -0,0 +1,284 @@ +/* + * 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.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.GridView; +import android.widget.ImageView; +import android.widget.TextView; + +import org.codeaurora.snapcam.R; + +import com.android.camera.ui.DotsView; +import com.android.camera.ui.DotsViewItem; +import com.android.camera.ui.RotateImageView; + +public class SceneModeActivity extends Activity { + private ViewPager mPager; + private View mCloseButton; + private RotateImageView mButton; + private DotsView mDotsView; + private MyPagerAdapter mAdapter; + private SettingsManager mSettingsManager; + private CharSequence[] mEntries; + private int[] mThumbnails; + private int mCurrentScene; + private int mNumElement; + private int mElemPerPage = 12; + private int mNumPage; + + private static class PageItems implements DotsViewItem { + int number; + + public PageItems(int number) { + this.number = number; + } + + @Override + public int getTotalItemNums() { + return number; + } + + @Override + public boolean isChosen(int index) { + return true; + } + + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.scene_mode_menu_layout); + mSettingsManager = SettingsManager.getInstance(); + + + mCurrentScene = mSettingsManager.getValueIndex(SettingsManager.KEY_SCENE_MODE); + + mEntries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE); + + mThumbnails = mSettingsManager.getResource(SettingsManager.KEY_SCENE_MODE, + SettingsManager.RESOURCE_TYPE_THUMBNAIL); + + mNumElement = mThumbnails.length; + int pages = mNumElement / mElemPerPage; + if (mNumElement % mElemPerPage != 0) pages++; + mNumPage = pages; + + mAdapter = new MyPagerAdapter(this); + + mPager = (ViewPager) findViewById(R.id.pager); + mPager.setOverScrollMode(ViewPager.OVER_SCROLL_NEVER); + mPager.setAdapter(mAdapter); + + mCloseButton = findViewById(R.id.close_button); + mCloseButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + + int pageCount = mAdapter.getCount(); + mDotsView = (DotsView) findViewById(R.id.page_indicator); + mPager.setCurrentItem(mCurrentScene / mElemPerPage); + mDotsView.update(mCurrentScene / mElemPerPage, 0f); + if (pageCount > 1) { + mDotsView.setItems(new PageItems(pageCount)); + mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + mDotsView.update(position, positionOffset); + } + }); + } else { + mDotsView.setVisibility(View.GONE); + } + + mButton = (RotateImageView) findViewById(R.id.setting_button); + mButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(getBaseContext(), SettingsActivity.class); + startActivity(intent); + finish(); + } + }); + } + + public int getElmentPerPage() { + return mElemPerPage; + } + + public int getNumberOfPage() { + return mNumPage; + } + + public int getNumberOfElement() { + return mNumElement; + } + + public int getCurrentPage() { + return mPager.getCurrentItem(); + } + + public CharSequence[] getEntries() { + return mEntries; + } + + + public int[] getThumbnails() { + return mThumbnails; + } + + public int getCurrentScene() { + return mCurrentScene; + } +} + +class MyPagerAdapter extends PagerAdapter { + + private SceneModeActivity mActivity; + private ViewGroup mRootView; + + public MyPagerAdapter(SceneModeActivity activity) { + mActivity = activity; + } + + public Object instantiateItem(ViewGroup viewGroup, int i) { + mRootView = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.scene_mode_grid, null); + GridView mGridView = (GridView) mRootView.findViewById(R.id.grid); + mGridView.setAdapter(new GridAdapter(mActivity, i)); + viewGroup.addView(mRootView); + + mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + int page = mActivity.getCurrentPage(); + int index = page * mActivity.getElmentPerPage() + position; + for (int i = 0; i < parent.getChildCount(); i++) { + View v = parent.getChildAt(i); + if (v != null) { + v.setBackground(null); + } + } + view.setBackgroundResource(R.drawable.scene_mode_view_border_selected); + SettingsManager.getInstance().setValueIndex(SettingsManager.KEY_SCENE_MODE, index); + mActivity.finish(); + } + }); + return mRootView; + } + + @Override + public void destroyItem(ViewGroup container, int position, Object object) { + } + + @Override + public int getCount() { + return mActivity.getNumberOfPage(); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view == object; + } + +} + +class GridAdapter extends BaseAdapter { + private SceneModeActivity mActivity; + private LayoutInflater mInflater; + private int mPage; + + public GridAdapter(SceneModeActivity activity, int i) { + mActivity = activity; + mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + mPage = i; + } + + @Override + public int getCount() { + int elem = mActivity.getElmentPerPage(); + if (mPage == mActivity.getNumberOfPage() - 1) { + elem = mActivity.getNumberOfElement() - mPage * elem; + } + return elem; + } + + @Override + public Object getItem(int position) { + return null; + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View view = convertView; + ViewHolder viewHolder; + + if (view == null) { + viewHolder = new ViewHolder(); + view = mInflater.inflate(R.layout.scene_mode_menu_view, parent, false); + viewHolder.imageView = (ImageView) view.findViewById(R.id.image); + viewHolder.textTitle = (TextView) view.findViewById(R.id.label); + view.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + int idx = position + mPage * mActivity.getElmentPerPage(); + viewHolder.imageView.setImageResource(mActivity.getThumbnails()[idx]); + viewHolder.textTitle.setText(mActivity.getEntries()[position + mPage * mActivity.getElmentPerPage()]); + if (idx == mActivity.getCurrentScene()) { + view.setBackgroundResource(R.drawable.scene_mode_view_border_selected); + } + + return view; + } + + private class ViewHolder { + public ImageView imageView; + public TextView textTitle; + } +} diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java new file mode 100644 index 000000000..a098b8a7f --- /dev/null +++ b/src/com/android/camera/SettingsActivity.java @@ -0,0 +1,132 @@ +/* + * 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.SharedPreferences; +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.PreferenceGroup; +import android.preference.PreferenceActivity; +import android.preference.SwitchPreference; + +import org.codeaurora.snapcam.R; + +import java.util.Map; +import java.util.Set; + +public class SettingsActivity extends PreferenceActivity { + private SettingsManager mSettingsManager; + private SharedPreferences mSharedPreferences; + + private SharedPreferences.OnSharedPreferenceChangeListener mSharedPreferenceChangeListener + = new SharedPreferences.OnSharedPreferenceChangeListener() { + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, + String key) { + Preference p = findPreference(key); + String value; + if (p instanceof SwitchPreference) { + boolean checked = ((SwitchPreference) p).isChecked(); + value = checked ? "on" : "off"; + } else { + value = ((ListPreference) p).getValue(); + } + mSettingsManager.setValue(key, value); + } + }; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mSettingsManager = SettingsManager.getInstance(); + addPreferencesFromResource(R.xml.setting_menu_preferences); + + filterPreferences(); + initializePreferences(); + + mSharedPreferences = getPreferenceManager().getSharedPreferences(); + mSharedPreferences.registerOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); + } + + private void filterPreferences() { + String[] categories = {"photo", "video", "general"}; + Set<String> set = mSettingsManager.getFilteredKeys(); + for (String key : set) { + Preference p = findPreference(key); + if (p == null) continue; + + for (int i = 0; i < categories.length; i++) { + PreferenceGroup group = (PreferenceGroup) findPreference(categories[i]); + if (group.removePreference(p)) break; + } + } + ListPreference pictureSize = (ListPreference) findPreference(SettingsManager.KEY_PICTURE_SIZE); + if (pictureSize != null) { + pictureSize.setEntryValues(mSettingsManager.getEntryValues(SettingsManager.KEY_PICTURE_SIZE)); + pictureSize.setEntries(mSettingsManager.getEntries(SettingsManager.KEY_PICTURE_SIZE)); + } + } + + private void initializePreferences() { + ListPreference pref = (ListPreference) findPreference(SettingsManager.KEY_EXPOSURE); + pref.setEntries(mSettingsManager.getExposureCompensationEntries()); + pref.setEntryValues(mSettingsManager.getExposureCompensationEntryValues()); + + Map<String, SettingsManager.Values> map = mSettingsManager.getValuesMap(); + Set<Map.Entry<String, SettingsManager.Values>> set = map.entrySet(); + + for (Map.Entry<String, SettingsManager.Values> entry : set) { + String key = entry.getKey(); + Preference p = findPreference(key); + if (p == null) continue; + + SettingsManager.Values values = entry.getValue(); + boolean disabled = values.overriddenValue != null; + String value = disabled ? values.overriddenValue : values.value; + if (p instanceof SwitchPreference) { + ((SwitchPreference) p).setChecked(isOn(value)); + } else if (p instanceof ListPreference) { + ((ListPreference) p).setValue(value); + } + if (disabled) p.setEnabled(false); + } + } + + private boolean isOn(String value) { + return value.equals("on") || value.equals("enable"); + } + + @Override + protected void onStop() { + super.onStop(); + mSharedPreferences.unregisterOnSharedPreferenceChangeListener(mSharedPreferenceChangeListener); + } +}
\ No newline at end of file diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index f2266d6bb..5c4273fae 100644 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -109,7 +109,6 @@ public class SettingsManager implements ListMenu.SettingsListener { public static final String KEY_AUDIO_ENCODER = "pref_camera2_audioencoder_key"; public static final String KEY_DIS = "pref_camera2_dis_key"; public static final String KEY_NOISE_REDUCTION = "pref_camera2_noise_reduction_key"; - public static final String KEY_VIDEO_FLASH_MODE = "pref_camera2_video_flashmode_key"; public static final String KEY_VIDEO_ROTATION = "pref_camera2_video_rotation_key"; public static final String KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL = "pref_camera2_video_time_lapse_frame_interval_key"; @@ -132,6 +131,15 @@ public class SettingsManager implements ListMenu.SettingsListener { private boolean mIsFrontCameraPresent = false; private JSONObject mDependency; private int mCameraId; + private Set<String> mFilteredKeys; + + public Map<String, Values> getValuesMap() { + return mValuesMap; + } + + public Set<String> getFilteredKeys() { + return mFilteredKeys; + } private SettingsManager(Context context) { mListeners = new ArrayList<>(); @@ -232,6 +240,7 @@ public class SettingsManager implements ListMenu.SettingsListener { (PreferenceGroup) inflater.inflate(R.xml.capture_preferences); mValuesMap = new HashMap<>(); mDependendsOnMap = new HashMap<>(); + mFilteredKeys = new HashSet<>(); filterPreferences(cameraId); initDepedencyTable(); initializeValueMap(); @@ -452,6 +461,11 @@ public class SettingsManager implements ListMenu.SettingsListener { return pref.getEntries(); } + public CharSequence[] getEntryValues(String key) { + ListPreference pref = mPreferenceGroup.findPreference(key); + return pref.getEntryValues(); + } + public int[] getResource(String key, int type) { IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(key); switch (type) { @@ -505,44 +519,54 @@ public class SettingsManager implements ListMenu.SettingsListener { ListPreference videoEncoder = mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER); ListPreference audioEncoder = mPreferenceGroup.findPreference(KEY_AUDIO_ENCODER); ListPreference noiseReduction = mPreferenceGroup.findPreference(KEY_NOISE_REDUCTION); - ListPreference videoFlash = mPreferenceGroup.findPreference(KEY_VIDEO_FLASH_MODE); ListPreference faceDetection = mPreferenceGroup.findPreference(KEY_FACE_DETECTION); ListPreference makeup = mPreferenceGroup.findPreference(KEY_MAKEUP); ListPreference trackingfocus = mPreferenceGroup.findPreference(KEY_TRACKINGFOCUS); ListPreference hfr = mPreferenceGroup.findPreference(KEY_VIDEO_HIGH_FRAME_RATE); if (whiteBalance != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - whiteBalance, getSupportedWhiteBalanceModes(cameraId)); + if (filterUnsupportedOptions(whiteBalance, getSupportedWhiteBalanceModes(cameraId))) { + mFilteredKeys.add(whiteBalance.getKey()); + } } + if (flashMode != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - flashMode, getSupportedFlashModes(cameraId)); + if (!isFlashAvailable(mCameraId)) { + removePreference(mPreferenceGroup, KEY_FLASH_MODE); + mFilteredKeys.add(flashMode.getKey()); + } } if (colorEffect != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - colorEffect, getSupportedColorEffects(cameraId)); + if (filterUnsupportedOptions(colorEffect, getSupportedColorEffects(cameraId))) { + mFilteredKeys.add(colorEffect.getKey()); + } } if (sceneMode != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - sceneMode, getSupportedSceneModes(cameraId)); + if (filterUnsupportedOptions(sceneMode, getSupportedSceneModes(cameraId))) { + mFilteredKeys.add(sceneMode.getKey()); + } } if (cameraIdPref != null) buildCameraId(); if (pictureSize != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - pictureSize, getSupportedPictureSize(cameraId)); - CameraSettings.filterSimilarPictureSize(mPreferenceGroup, pictureSize); + if (filterUnsupportedOptions(pictureSize, getSupportedPictureSize(cameraId))) { + mFilteredKeys.add(pictureSize.getKey()); + } else { + if (CameraSettings.filterSimilarPictureSize(mPreferenceGroup, pictureSize)) { + mFilteredKeys.add(pictureSize.getKey()); + } + } } if (exposure != null) buildExposureCompensation(cameraId); if (iso != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - iso, getSupportedIso(cameraId)); + if (filterUnsupportedOptions(iso, getSupportedIso(cameraId))) { + mFilteredKeys.add(iso.getKey()); + } } if (videoQuality != null) { @@ -550,6 +574,12 @@ public class SettingsManager implements ListMenu.SettingsListener { videoQuality, getSupportedVideoSize(cameraId)); } + if (iso != null) { + if (filterUnsupportedOptions(videoQuality, getSupportedVideoSize(cameraId))) { + mFilteredKeys.add(redeyeReduction.getKey()); + } + } + if (!mIsMonoCameraPresent) { if (clearsight != null) removePreference(mPreferenceGroup, KEY_CLEARSIGHT); if (monoPreview != null) removePreference(mPreferenceGroup, KEY_MONO_PREVIEW); @@ -558,33 +588,36 @@ public class SettingsManager implements ListMenu.SettingsListener { } if (redeyeReduction != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, - redeyeReduction, getSupportedRedeyeReduction(cameraId)); + if (filterUnsupportedOptions(redeyeReduction, getSupportedRedeyeReduction(cameraId))) { + mFilteredKeys.add(redeyeReduction.getKey()); + } } if (videoEncoder != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, videoEncoder, - getSupportedVideoEncoders(videoEncoder.getEntryValues())); + if (filterUnsupportedOptions(videoEncoder, + getSupportedVideoEncoders(videoEncoder.getEntryValues()))) { + mFilteredKeys.add(videoEncoder.getKey()); + } } if (audioEncoder != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, audioEncoder, - getSupportedAudioEncoders(audioEncoder.getEntryValues())); + if (filterUnsupportedOptions(audioEncoder, + getSupportedAudioEncoders(audioEncoder.getEntryValues()))) { + mFilteredKeys.add(audioEncoder.getKey()); + } } if (noiseReduction != null) { - CameraSettings.filterUnsupportedOptions(mPreferenceGroup, noiseReduction, - getSupportedNoiseReductionModes(cameraId)); - } - - if (videoFlash != null) { - if (!isFlashAvailable(cameraId)) - removePreference(mPreferenceGroup, KEY_VIDEO_FLASH_MODE); + if (filterUnsupportedOptions(noiseReduction, + getSupportedNoiseReductionModes(cameraId))) { + mFilteredKeys.add(noiseReduction.getKey()); + } } if (faceDetection != null) { - if (!isFaceDetectionSupported(cameraId)) + if (!isFaceDetectionSupported(cameraId)) { removePreference(mPreferenceGroup, KEY_FACE_DETECTION); + } } if (makeup != null) { @@ -645,6 +678,18 @@ public class SettingsManager implements ListMenu.SettingsListener { pref.setEntryValues(entryValues); } + public CharSequence[] getExposureCompensationEntries() { + ListPreference pref = mPreferenceGroup.findPreference(KEY_EXPOSURE); + if (pref == null) return null; + return pref.getEntries(); + } + + public CharSequence[] getExposureCompensationEntryValues() { + ListPreference pref = mPreferenceGroup.findPreference(KEY_EXPOSURE); + if (pref == null) return null; + return pref.getEntryValues(); + } + private void buildCameraId() { int numOfCameras = mCharacteristics.size(); if (!mIsFrontCameraPresent) { @@ -747,6 +792,7 @@ public class SettingsManager implements ListMenu.SettingsListener { } private boolean removePreference(PreferenceGroup group, String key) { + mFilteredKeys.add(key); for (int i = 0, n = group.size(); i < n; i++) { CameraPreference child = group.get(i); if (child instanceof PreferenceGroup) { @@ -938,8 +984,8 @@ public class SettingsManager implements ListMenu.SettingsListener { List<String> modes = new ArrayList<>(); for (int i = 0; i < flashModes.length; i++) { if (flashModes[i] == CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE) { - modes.add("disable"); - modes.add("enable"); + modes.add("off"); + modes.add("on"); break; } } @@ -1042,6 +1088,10 @@ public class SettingsManager implements ListMenu.SettingsListener { return modes; } + private boolean filterUnsupportedOptions(ListPreference pref, List<String> supported) { + return CameraSettings.filterUnsupportedOptions(mPreferenceGroup, pref, supported); + } + public interface Listener { void onSettingsChanged(List<SettingState> settings); } diff --git a/src/com/android/camera/ui/FlashToggleButton.java b/src/com/android/camera/ui/FlashToggleButton.java new file mode 100644 index 000000000..d429996f9 --- /dev/null +++ b/src/com/android/camera/ui/FlashToggleButton.java @@ -0,0 +1,79 @@ +/* + * 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.ui; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; + +import com.android.camera.SettingsManager; + +import org.codeaurora.snapcam.R; + +public class FlashToggleButton extends RotateImageView { + private SettingsManager mSettingsManager; + private int[] iconResId = {R.drawable.flash_off, R.drawable.flash}; + private int mIndex; + + public FlashToggleButton(Context context) { + super(context); + } + + public FlashToggleButton(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public void init() { + mSettingsManager = SettingsManager.getInstance(); + mIndex = mSettingsManager.getValueIndex(SettingsManager.KEY_FLASH_MODE); + if (mIndex == -1) { + setVisibility(GONE); + return; + } else { + setVisibility(VISIBLE); + } + + update(); + this.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mIndex = (mIndex + 1) % 2; + mSettingsManager.setValueIndex(SettingsManager.KEY_FLASH_MODE, mIndex); + update(); + } + }); + } + + private void update() { + setImageResource(iconResId[mIndex]); + } +} diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java new file mode 100644 index 000000000..54be47881 --- /dev/null +++ b/src/com/android/camera/ui/OneUICameraControls.java @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + * Not a Contribution. + * + * Copyright (C) 2013 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.ui; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Path; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.codeaurora.snapcam.R; + +import com.android.camera.Storage; + +public class OneUICameraControls extends RotatableLayout { + + private static final String TAG = "CAM_Controls"; + + private View mShutter; + private View mVideoShutter; + private View mFlashButton; + private View mMute; + private View mFrontBackSwitcher; + private View mTsMakeupSwitcher; + private View mPreview; + private View mSceneModeSwitcher; + private View mFilterModeSwitcher; + + private ArrowTextView mRefocusToast; + + private static final int WIDTH_GRID = 5; + private static final int HEIGHT_GRID = 7; + private View[] mViews; + private boolean mHideRemainingPhoto = false; + private LinearLayout mRemainingPhotos; + private TextView mRemainingPhotosText; + private int mCurrentRemaining = -1; + private int mOrientation; + + private static int mTop = 0; + private static int mBottom = 0; + + private Paint mPaint; + + private static final int LOW_REMAINING_PHOTOS = 20; + private static final int HIGH_REMAINING_PHOTOS = 1000000; + private int mWidth; + private int mHeight; + private boolean mVisible; + + public OneUICameraControls(Context context, AttributeSet attrs) { + super(context, attrs); + + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + setWillNotDraw(false); + + mRefocusToast = new ArrowTextView(context); + addView(mRefocusToast); + setClipChildren(false); + + setMeasureAllChildren(true); + mPaint.setColor(getResources().getColor(R.color.camera_control_bg_transparent)); + + mTop = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics()); + mBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); + mVisible = true; + } + + public OneUICameraControls(Context context) { + this(context, null); + } + + @Override + public void onFinishInflate() { + super.onFinishInflate(); + mShutter = findViewById(R.id.shutter_button); + mVideoShutter = findViewById(R.id.video_button); + mFrontBackSwitcher = findViewById(R.id.front_back_switcher); + mTsMakeupSwitcher = findViewById(R.id.ts_makeup_switcher); + mFlashButton = findViewById(R.id.flash_button); + mMute = findViewById(R.id.mute_button); + mPreview = findViewById(R.id.preview_thumb); + mSceneModeSwitcher = findViewById(R.id.scene_mode_switcher); + mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher); + mRemainingPhotos = (LinearLayout) findViewById(R.id.remaining_photos); + mRemainingPhotosText = (TextView) findViewById(R.id.remaining_photos_text); + mViews = new View[]{ + mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher, + mTsMakeupSwitcher, mFlashButton, mShutter, mPreview, mVideoShutter + }; + } + + @Override + public void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + r = r - l; + b = b - t; + l = 0; + t = 0; + mWidth = r; + mHeight = b; + setLocation(r - l, b - t); + + layoutRemaingPhotos(); + } + + public boolean isControlRegion(int x, int y) { + return y <= mTop || y >= (mHeight - mBottom); + } + + @Override + protected void onDraw(Canvas canvas) { + if (mVisible) { + int rotation = getUnifiedRotation(); + int w = canvas.getWidth(), h = canvas.getHeight(); + switch (rotation) { + case 90: + canvas.drawRect(0, 0, mTop, h, mPaint); + canvas.drawRect(w - mBottom, 0, w, h, mPaint); + break; + case 180: + canvas.drawRect(0, 0, w, mBottom, mPaint); + canvas.drawRect(0, h - mTop, w, h, mPaint); + break; + case 270: + canvas.drawRect(0, 0, mBottom, h, mPaint); + canvas.drawRect(w - mTop, 0, w, h, mPaint); + break; + default: + canvas.drawRect(0, 0, w, mTop, mPaint); + canvas.drawRect(0, h - mBottom, w, h, mPaint); + break; + } + } + } + + private void setLocation(View v, boolean top, float idx) { + int w = v.getMeasuredWidth(); + int h = v.getMeasuredHeight(); + if (top) { + v.setY((mTop - h) / 2); + } else { + v.setY(mHeight - mBottom + (mBottom - h) / 2); + } + int bW = mWidth / 5; + + v.setX(bW * idx + (bW - w) / 2); + } + + private void setLocation(int w, int h) { + int rotation = getUnifiedRotation(); + setLocation(mSceneModeSwitcher, true, 0); + setLocation(mFilterModeSwitcher, true, 1); + setLocation(mFrontBackSwitcher, true, 2); + setLocation(mTsMakeupSwitcher, true, 3); + setLocation(mFlashButton, true, 4); + setLocation(mPreview, false, 0); + setLocation(mShutter, false, 2); + setLocation(mVideoShutter, false, 3.15f); + + layoutToast(mRefocusToast, w, h, rotation); + } + + private void layoutToast(final View v, int w, int h, int rotation) { + int tw = v.getMeasuredWidth(); + int th = v.getMeasuredHeight(); + int l, t, r, b, c; + switch (rotation) { + case 90: + c = (int) (h / WIDTH_GRID * (WIDTH_GRID - 0.5)); + t = c - th / 2; + b = c + th / 2; + r = (int) (w / HEIGHT_GRID * (HEIGHT_GRID - 1.25)); + l = r - tw; + mRefocusToast.setArrow(tw, th / 2, tw + th / 2, th, tw, th); + break; + case 180: + t = (int) (h / HEIGHT_GRID * 1.25); + b = t + th; + r = (int) (w / WIDTH_GRID * (WIDTH_GRID - 0.25)); + l = r - tw; + mRefocusToast.setArrow(tw - th / 2, 0, tw, 0, tw, -th / 2); + break; + case 270: + c = (int) (h / WIDTH_GRID * 0.5); + t = c - th / 2; + b = c + th / 2; + l = (int) (w / HEIGHT_GRID * 1.25); + r = l + tw; + mRefocusToast.setArrow(0, 0, 0, th / 2, -th / 2, 0); + break; + default: + l = w / WIDTH_GRID / 4; + b = (int) (h / HEIGHT_GRID * (HEIGHT_GRID - 1.25)); + r = l + tw; + t = b - th; + mRefocusToast.setArrow(0, th, th / 2, th, 0, th * 3 / 2); + break; + } + mRefocusToast.layout(l, t, r, b); + } + + public void hideUI() { + for (View v : mViews) { + if (v != null) + v.setVisibility(View.INVISIBLE); + } + mVisible = false; + } + + public void showUI() { + for (View v : mViews) { + if (v != null) + v.setVisibility(View.VISIBLE); + } + mVisible = true; + } + + private void layoutRemaingPhotos() { + int rl = mPreview.getLeft(); + int rt = mPreview.getTop(); + int rr = mPreview.getRight(); + int rb = mPreview.getBottom(); + int w = mRemainingPhotos.getMeasuredWidth(); + int h = mRemainingPhotos.getMeasuredHeight(); + int m = getResources().getDimensionPixelSize(R.dimen.remaining_photos_margin); + + int hc = (rl + rr) / 2; + int vc = (rt + rb) / 2 - m; + if (mOrientation == 90 || mOrientation == 270) { + vc -= w / 2; + } + if (hc < w / 2) { + mRemainingPhotos.layout(0, vc - h / 2, w, vc + h / 2); + } else { + mRemainingPhotos.layout(hc - w / 2, vc - h / 2, hc + w / 2, vc + h / 2); + } + mRemainingPhotos.setRotation(-mOrientation); + } + + public void updateRemainingPhotos(int remaining) { + long remainingStorage = Storage.getAvailableSpace() - Storage.LOW_STORAGE_THRESHOLD_BYTES; + if ((remaining < 0 && remainingStorage <= 0) || mHideRemainingPhoto) { + mRemainingPhotos.setVisibility(View.GONE); + } else { + for (int i = mRemainingPhotos.getChildCount() - 1; i >= 0; --i) { + mRemainingPhotos.getChildAt(i).setVisibility(View.VISIBLE); + } + if (remaining < LOW_REMAINING_PHOTOS) { + mRemainingPhotosText.setText("<" + LOW_REMAINING_PHOTOS + " "); + } else if (remaining >= HIGH_REMAINING_PHOTOS) { + mRemainingPhotosText.setText(">" + HIGH_REMAINING_PHOTOS); + } else { + mRemainingPhotosText.setText(remaining + " "); + } + } + mCurrentRemaining = remaining; + } + + public void showRefocusToast(boolean show) { + mRefocusToast.setVisibility(show ? View.VISIBLE : View.GONE); + if ((mCurrentRemaining > 0) && !mHideRemainingPhoto) { + mRemainingPhotos.setVisibility(show ? View.GONE : View.VISIBLE); + } + } + + public void setOrientation(int orientation, boolean animation) { + mOrientation = orientation; + View[] views = { + mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher, + mTsMakeupSwitcher, mFlashButton, mPreview, mMute, mShutter, mVideoShutter + }; + + for (View v : views) { + if (v != null) { + ((RotateImageView) v).setOrientation(orientation, animation); + } + } + layoutRemaingPhotos(); + } + + private class ArrowTextView extends TextView { + private static final int TEXT_SIZE = 14; + private static final int PADDING_SIZE = 18; + private static final int BACKGROUND = 0x80000000; + + private Paint mPaint; + private Path mPath; + + public ArrowTextView(Context context) { + super(context); + + setText(context.getString(R.string.refocus_toast)); + setBackgroundColor(BACKGROUND); + setVisibility(View.GONE); + setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT)); + setTextSize(TEXT_SIZE); + setPadding(PADDING_SIZE, PADDING_SIZE, PADDING_SIZE, PADDING_SIZE); + + mPaint = new Paint(); + mPaint.setStyle(Paint.Style.FILL); + mPaint.setColor(BACKGROUND); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + if (mPath != null) { + canvas.drawPath(mPath, mPaint); + } + } + + public void setArrow(float x1, float y1, float x2, float y2, float x3, float y3) { + mPath = new Path(); + mPath.reset(); + mPath.moveTo(x1, y1); + mPath.lineTo(x2, y2); + mPath.lineTo(x3, y3); + mPath.lineTo(x1, y1); + } + } +} |