summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/layout-land/camera_controls.xml134
-rw-r--r--res/layout-land/pano_preview_progress.xml119
-rw-r--r--res/layout-land/pano_review_control.xml34
-rw-r--r--res/layout-port/camera_controls.xml58
-rw-r--r--res/layout-port/pano_preview_progress.xml119
-rw-r--r--res/layout/filter_mode_view.xml56
-rw-r--r--res/layout/pano_module_capture.xml1
-rw-r--r--res/layout/pano_module_review.xml1
-rw-r--r--res/layout/scene_mode_view.xml4
-rw-r--r--res/values/dimens.xml2
-rw-r--r--res/values/styles.xml15
-rw-r--r--src/com/android/camera/CameraActivity.java15
-rw-r--r--src/com/android/camera/MenuController.java3
-rw-r--r--src/com/android/camera/PhotoMenu.java122
-rw-r--r--src/com/android/camera/PhotoModule.java48
-rw-r--r--src/com/android/camera/PhotoUI.java84
-rw-r--r--src/com/android/camera/PieController.java3
-rw-r--r--src/com/android/camera/PreviewGestures.java44
-rw-r--r--src/com/android/camera/ShutterButton.java4
-rw-r--r--src/com/android/camera/VideoMenu.java100
-rw-r--r--src/com/android/camera/VideoModule.java36
-rw-r--r--src/com/android/camera/VideoUI.java76
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java16
-rw-r--r--src/com/android/camera/WideAnglePanoramaUI.java98
-rw-r--r--src/com/android/camera/app/OrientationManager.java42
-rw-r--r--src/com/android/camera/ui/CameraControls.java42
-rw-r--r--src/com/android/camera/ui/CameraRootView.java3
-rw-r--r--src/com/android/camera/ui/CountDownView.java9
-rw-r--r--src/com/android/camera/ui/ListSubMenu.java20
-rw-r--r--src/com/android/camera/ui/RotateLayout.java49
-rw-r--r--src/com/android/camera/ui/RotateTextToast.java53
-rw-r--r--src/com/android/camera/util/CameraUtil.java6
33 files changed, 630 insertions, 787 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9ff2d16fc..677be80e5 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -58,6 +58,7 @@
android:label="@string/snapcam_app_name"
android:launchMode="singleTop"
android:logo="@mipmap/ic_launcher_gallery"
+ android:screenOrientation="portrait"
android:taskAffinity="com.android.camera.CameraActivity"
android:theme="@style/Theme.Camera"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" >
diff --git a/res/layout-land/camera_controls.xml b/res/layout-land/camera_controls.xml
deleted file mode 100644
index f10ae9271..000000000
--- a/res/layout-land/camera_controls.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.CameraControls xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/camera_controls"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <View
- android:id="@+id/blocker"
- android:layout_width="@dimen/switcher_size"
- android:layout_height="match_parent"
- android:layout_gravity="right"
- android:clickable="true" />
-
- <include
- android:layout_width="64dip"
- android:layout_height="64dip"
- android:layout_gravity="top|right"
- android:layout_marginRight="8dip"
- android:layout_marginTop="-8dip"
- layout="@layout/menu_indicators" />
-
- <com.android.camera.ui.RotatableLayout
- android:id="@+id/menu"
- style="@style/ToggleButtonOuter"
- android:layout_marginRight="2dip" >
-
- <ImageView
- style="@style/MenuButton"
- android:layout_gravity="center"
- android:contentDescription="@string/accessibility_menu_button"
- android:src="@drawable/ic_settings" />
- </com.android.camera.ui.RotatableLayout>
-
- <com.android.camera.ui.ModuleSwitcher
- android:id="@+id/camera_switcher"
- style="@style/SwitcherButton"
- android:layout_gravity="right|bottom"
- android:layout_marginRight="2dip"
- android:contentDescription="@string/accessibility_mode_picker" />
-
- <com.android.camera.ShutterButton
- android:id="@+id/shutter_button"
- android:layout_width="@dimen/shutter_size"
- android:layout_height="@dimen/shutter_size"
- android:layout_gravity="right|center_vertical"
- android:layout_marginRight="@dimen/shutter_offset"
- android:clickable="true"
- android:contentDescription="@string/accessibility_shutter_button"
- android:focusable="true"
- android:scaleType="fitCenter"
- android:src="@drawable/btn_new_shutter" />
-
- <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/black"
- android:contentDescription="@string/switch_photo_filmstrip"
- android:scaleType="fitCenter" />
-
- <com.android.camera.ui.RotatableLayout
- android:id="@+id/front_back_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
-
- <com.android.camera.ui.RotatableLayout
- android:id="@+id/hdr_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
-
- <com.android.camera.ui.RotatableLayout
- android:id="@+id/scene_mode_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
-
- <com.android.camera.ui.RotatableLayout
- android:id="@+id/filter_mode_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
-
- <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" />
-
- <ImageView
- android:id="@+id/remaining_photos_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/remaining_sheets" />
- </LinearLayout>
-
-</com.android.camera.ui.CameraControls> \ No newline at end of file
diff --git a/res/layout-land/pano_preview_progress.xml b/res/layout-land/pano_preview_progress.xml
deleted file mode 100644
index c6c131741..000000000
--- a/res/layout-land/pano_preview_progress.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/panorama_capture_layout"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- The top bar with capture indication -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <TextView
- android:id="@+id/pano_capture_indicator"
- android:text="@string/pano_capture_indication"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_gravity="center"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
-
- <FrameLayout
- android:layout_gravity="center"
- android:id="@+id/pano_preview_layout"
- android:layout_weight="@integer/SRI_pano_layout_weight"
- android:layout_width="match_parent"
- android:layout_height="0dp">
-
- <TextureView
- android:id="@+id/pano_preview_textureview"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <View
- android:id="@+id/pano_preview_area_border"
- android:visibility="gone"
- android:background="@drawable/ic_pan_border_fast"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </FrameLayout>
-
- <!-- The bottom bar with progress bar and direction indicators -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:paddingTop="20dp"
- android:gravity="top"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_pan_progress_bar"
- android:visibility="gone"
- android:src="@drawable/ic_pan_progression"
- android:layout_centerInParent="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_left_indicator"
- android:src="@drawable/pano_direction_left_indicator"
- android:visibility="gone"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_right_indicator"
- android:src="@drawable/pano_direction_right_indicator"
- android:visibility="gone"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
- </FrameLayout>
-
-
- </LinearLayout>
-
- <!-- The hint for "Too fast" text view -->
- <TextView
- android:id="@+id/pano_capture_too_fast_textview"
- android:text="@string/pano_too_fast_prompt"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:visibility="gone" />
-</FrameLayout>
diff --git a/res/layout-land/pano_review_control.xml b/res/layout-land/pano_review_control.xml
deleted file mode 100644
index 93c1020a8..000000000
--- a/res/layout-land/pano_review_control.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_saving_progress_bar"
- android:src="@drawable/ic_pan_progression"
- android:layout_gravity="center"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content" />
-
- <com.android.camera.ui.RotateImageView
- android:id="@+id/pano_review_cancel_button"
- android:scaleType="center"
- style="@style/ReviewControlIcon"
- android:contentDescription="@string/accessibility_review_cancel"
- android:layout_gravity="center_vertical|right"
- android:src="@drawable/ic_menu_cancel_holo_light" />
-</merge> \ No newline at end of file
diff --git a/res/layout-port/camera_controls.xml b/res/layout-port/camera_controls.xml
index ee24cfef2..121f25b6e 100644
--- a/res/layout-port/camera_controls.xml
+++ b/res/layout-port/camera_controls.xml
@@ -33,17 +33,11 @@
android:layout_marginRight="-8dip"
layout="@layout/menu_indicators" />
- <com.android.camera.ui.RotatableLayout
+ <com.android.camera.ui.RotateImageView
android:id="@+id/menu"
- style="@style/MenuButtonOuter"
- android:layout_marginRight="2dip" >
-
- <ImageView
- style="@style/MenuButton"
- android:layout_gravity="center"
- android:contentDescription="@string/accessibility_menu_button"
- android:src="@drawable/ic_settings" />
- </com.android.camera.ui.RotatableLayout>
+ style="@style/MenuButton"
+ android:contentDescription="@string/accessibility_menu_button"
+ android:src="@drawable/ic_settings" />
<com.android.camera.ui.ModuleSwitcher
android:id="@+id/camera_switcher"
@@ -73,41 +67,21 @@
android:contentDescription="@string/switch_photo_filmstrip"
android:scaleType="fitCenter" />
- <com.android.camera.ui.RotatableLayout
+ <com.android.camera.ui.RotateImageView
android:id="@+id/front_back_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
+ style="@style/ToggleButton" />
- <com.android.camera.ui.RotatableLayout
+ <com.android.camera.ui.RotateImageView
android:id="@+id/hdr_switcher"
- style="@style/ToggleButtonOuter" >
+ style="@style/ToggleButton" />
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
-
- <com.android.camera.ui.RotatableLayout
+ <com.android.camera.ui.RotateImageView
android:id="@+id/scene_mode_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
+ style="@style/ToggleButton" />
- <com.android.camera.ui.RotatableLayout
+ <com.android.camera.ui.RotateImageView
android:id="@+id/filter_mode_switcher"
- style="@style/ToggleButtonOuter" >
-
- <com.android.camera.ui.RotateImageView
- style="@style/ToggleButton"
- android:layout_gravity="center" />
- </com.android.camera.ui.RotatableLayout>
+ style="@style/ToggleButton" />
<LinearLayout
android:id="@+id/remaining_photos"
@@ -122,13 +96,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
- android:textColor="@android:color/white" />
+ 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:src="@drawable/remaining_sheets"
+ android:visibility="gone" />
</LinearLayout>
-</com.android.camera.ui.CameraControls> \ No newline at end of file
+</com.android.camera.ui.CameraControls>
diff --git a/res/layout-port/pano_preview_progress.xml b/res/layout-port/pano_preview_progress.xml
deleted file mode 100644
index c6c131741..000000000
--- a/res/layout-port/pano_preview_progress.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2012 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/panorama_capture_layout"
- android:layout_height="match_parent"
- android:layout_width="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <!-- The top bar with capture indication -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <TextView
- android:id="@+id/pano_capture_indicator"
- android:text="@string/pano_capture_indication"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_gravity="center"
- android:visibility="gone"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
-
- <FrameLayout
- android:layout_gravity="center"
- android:id="@+id/pano_preview_layout"
- android:layout_weight="@integer/SRI_pano_layout_weight"
- android:layout_width="match_parent"
- android:layout_height="0dp">
-
- <TextureView
- android:id="@+id/pano_preview_textureview"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- <View
- android:id="@+id/pano_preview_area_border"
- android:visibility="gone"
- android:background="@drawable/ic_pan_border_fast"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
- </FrameLayout>
-
- <!-- The bottom bar with progress bar and direction indicators -->
- <FrameLayout
- style="@style/PanoViewHorizontalBar"
- android:paddingTop="20dp"
- android:gravity="top"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <com.android.camera.PanoProgressBar
- android:id="@+id/pano_pan_progress_bar"
- android:visibility="gone"
- android:src="@drawable/ic_pan_progression"
- android:layout_centerInParent="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_left_indicator"
- android:src="@drawable/pano_direction_left_indicator"
- android:visibility="gone"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/pano_pan_right_indicator"
- android:src="@drawable/pano_direction_right_indicator"
- android:visibility="gone"
- android:layout_marginLeft="5dp"
- android:layout_toRightOf="@id/pano_pan_progress_bar"
- android:layout_centerVertical="true"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </RelativeLayout>
- </FrameLayout>
-
-
- </LinearLayout>
-
- <!-- The hint for "Too fast" text view -->
- <TextView
- android:id="@+id/pano_capture_too_fast_textview"
- android:text="@string/pano_too_fast_prompt"
- android:textAppearance="?android:textAppearanceMedium"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:visibility="gone" />
-</FrameLayout>
diff --git a/res/layout/filter_mode_view.xml b/res/layout/filter_mode_view.xml
index dfa036c1f..558d7ce77 100644
--- a/res/layout/filter_mode_view.xml
+++ b/res/layout/filter_mode_view.xml
@@ -26,32 +26,36 @@
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="@dimen/filter_mode_width"
- android:layout_height="@dimen/filter_mode_height"
- android:layout_gravity="center"
- android:orientation="vertical"
- android:padding="@dimen/filter_mode_padding" >
+<com.android.camera.ui.RotateLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="@dimen/filter_mode_padding">
- <ImageView
- android:id="@+id/image"
- android:layout_width="80dp"
- android:layout_height="80dp"
- android:layout_gravity="center"
- android:padding="2dp" />
+ <LinearLayout
+ android:layout_width="@dimen/filter_mode_width"
+ android:layout_height="@dimen/filter_mode_height"
+ android:orientation="vertical">
- <TextView
- android:id="@+id/label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:shadowColor="@android:color/black"
- android:shadowDx="1"
- android:shadowDy="1"
- android:shadowRadius="2"
- android:singleLine="true"
- android:textColor="@android:color/white"
- android:textSize="13sp"
- android:textStyle="bold" />
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="80dp"
+ android:layout_height="80dp"
+ android:layout_gravity="center"
+ android:padding="2dp" />
-</LinearLayout>
+ <TextView
+ android:id="@+id/label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:shadowColor="@android:color/black"
+ android:shadowDx="1"
+ android:shadowDy="1"
+ android:shadowRadius="2"
+ android:singleLine="true"
+ android:textColor="@android:color/white"
+ android:textSize="13sp"
+ android:textStyle="bold" />
+ </LinearLayout>
+</com.android.camera.ui.RotateLayout>
diff --git a/res/layout/pano_module_capture.xml b/res/layout/pano_module_capture.xml
index c6c131741..6ab8c9e4b 100644
--- a/res/layout/pano_module_capture.xml
+++ b/res/layout/pano_module_capture.xml
@@ -63,6 +63,7 @@
<!-- The bottom bar with progress bar and direction indicators -->
<FrameLayout
+ android:id="@+id/pano_progress_layout"
style="@style/PanoViewHorizontalBar"
android:paddingTop="20dp"
android:gravity="top"
diff --git a/res/layout/pano_module_review.xml b/res/layout/pano_module_review.xml
index 3f80e8af0..6aeaa753c 100644
--- a/res/layout/pano_module_review.xml
+++ b/res/layout/pano_module_review.xml
@@ -22,6 +22,7 @@
android:layout_width="match_parent">
<TextView
+ android:id="@+id/pano_review_indicator"
style="@style/PanoViewHorizontalBar"
android:layout_width="match_parent"
android:layout_height="0dp"
diff --git a/res/layout/scene_mode_view.xml b/res/layout/scene_mode_view.xml
index e8a9499d6..d4c2a259c 100644
--- a/res/layout/scene_mode_view.xml
+++ b/res/layout/scene_mode_view.xml
@@ -26,7 +26,7 @@
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"
+<com.android.camera.ui.RotateLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
@@ -64,4 +64,4 @@
android:textStyle="bold" />
</LinearLayout>
-</LinearLayout>
+</com.android.camera.ui.RotateLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 327b30bbd..64e55adc7 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -163,7 +163,7 @@
<dimen name="scene_mode_width">90dp</dimen>
<dimen name="scene_mode_padding">10dp</dimen>
<dimen name="filter_mode_height">100dp</dimen>
- <dimen name="filter_mode_width">80dp</dimen>
+ <dimen name="filter_mode_width">100dp</dimen>
<dimen name="filter_mode_padding">10dp</dimen>
<dimen name="remaining_photos_margin">67dp</dimen>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 682337fe9..bd971d5a2 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -248,22 +248,14 @@
<item name="android:background">@drawable/bg_pressed_exit_fading</item>
</style>
<style name="MenuButton">
- <item name="android:layout_width">@dimen/menu_size</item>
- <item name="android:layout_height">@dimen/menu_size</item>
- </style>
- <style name="MenuButtonOuter">
<item name="android:layout_width">@dimen/menu_outer_size</item>
<item name="android:layout_height">@dimen/menu_outer_size</item>
- <item name="android:background">@drawable/bg_pressed_exit_fading</item>
+ <item name="android:scaleType">center</item>
</style>
<style name="ToggleButton">
- <item name="android:layout_width">@dimen/toggle_size</item>
- <item name="android:layout_height">@dimen/toggle_size</item>
- </style>
- <style name="ToggleButtonOuter">
<item name="android:layout_width">@dimen/toggle_outer_size</item>
<item name="android:layout_height">@dimen/toggle_outer_size</item>
- <item name="android:background">@drawable/bg_pressed_exit_fading</item>
+ <item name="android:scaleType">center</item>
</style>
<style name="MenuIndicator">
<item name="android:layout_width">wrap_content</item>
@@ -308,7 +300,6 @@
<item name="android:background">@drawable/bg_pressed</item>
</style>
<style name="PanoViewHorizontalBar">
- <item name="android:background">#000000</item>
- <item name="android:alpha">1.0</item>
+ <item name="android:background">@android:color/transparent</item>
</style>
</resources>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index e9786431b..ca66babae 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -178,7 +178,6 @@ public class CameraActivity extends Activity
private Intent mResultDataForTesting;
private OnScreenHint mStorageHint;
private long mStorageSpaceBytes = Storage.LOW_STORAGE_THRESHOLD_BYTES;
- private boolean mAutoRotateScreen;
private boolean mSecureCamera;
// This is a hack to speed up the start of SecureCamera.
private static boolean sFirstStartAfterScreenOn = true;
@@ -1417,16 +1416,6 @@ public class CameraActivity extends Activity
public void onResume() {
if (mShutterVol >= 0 && mShutterVol <= 100)
mAudioManager.setMasterVolume(mShutterVol,0);
- // TODO: Handle this in OrientationManager.
- // Auto-rotate off
- if (Settings.System.getInt(getContentResolver(),
- Settings.System.ACCELEROMETER_ROTATION, 0) == 0) {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
- mAutoRotateScreen = false;
- } else {
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
- mAutoRotateScreen = true;
- }
UsageStatistics.onEvent(UsageStatistics.COMPONENT_CAMERA,
UsageStatistics.ACTION_FOREGROUNDED, this.getClass().getSimpleName());
@@ -1539,10 +1528,6 @@ public class CameraActivity extends Activity
mFilmStripView.setPreviewGestures(previewGestures);
}
- public boolean isAutoRotateScreen() {
- return mAutoRotateScreen;
- }
-
protected void updateStorageSpace() {
mStorageSpaceBytes = Storage.getAvailableSpace();
if (Storage.switchSavePath()) {
diff --git a/src/com/android/camera/MenuController.java b/src/com/android/camera/MenuController.java
index 79223e492..97240cb18 100644
--- a/src/com/android/camera/MenuController.java
+++ b/src/com/android/camera/MenuController.java
@@ -104,8 +104,7 @@ public class MenuController {
return;
}
}
- ImageView iv = (ImageView) ((FrameLayout) switcher).getChildAt(0);
- iv.setImageResource(pref.getLargeIconIds()[index]);
+ ((ImageView) switcher).setImageResource(pref.getLargeIconIds()[index]);
}
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index d10a679b3..f8d95b3f0 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -46,7 +46,9 @@ import com.android.camera.ui.CameraControls;
import com.android.camera.ui.CountdownTimerPopup;
import com.android.camera.ui.ListSubMenu;
import com.android.camera.ui.ListMenu;
+import com.android.camera.ui.RotateLayout;
import com.android.camera.ui.RotateImageView;
+import com.android.camera.ui.RotateTextToast;
import org.codeaurora.snapcam.R;
import android.widget.HorizontalScrollView;
import android.view.ViewGroup;
@@ -280,7 +282,20 @@ public class PhotoMenu extends MenuController
mPopupStatus = POPUP_IN_ANIMATION_SLIDE;
ViewPropertyAnimator vp = v.animate();
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+ switch (mUI.getOrientation()) {
+ case 0:
+ vp.translationXBy(-v.getWidth());
+ break;
+ case 90:
+ vp.translationYBy(2 * v.getHeight());
+ break;
+ case 180:
+ vp.translationXBy(2 * v.getWidth());
+ break;
+ case 270:
+ vp.translationYBy(-v.getHeight());
+ break;
+ }
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -320,7 +335,7 @@ public class PhotoMenu extends MenuController
}
});
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateFadeIn(final ListView v) {
@@ -329,27 +344,36 @@ public class PhotoMenu extends MenuController
vp.start();
}
- public void animateSlideIn(final View v, int delta, boolean settingMenu) {
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- if (settingMenu)
- portrait = true;
+ public void animateSlideIn(final View v, int delta, boolean forcePortrait) {
+ int orientation = mUI.getOrientation();
+ if (!forcePortrait)
+ orientation = 0;
+
ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- float dest = v.getX();
- v.setX(dest - delta);
- vp.translationX(dest).setDuration(ANIMATION_DURATION);
+ float dest;
+ switch (orientation) {
+ case 0:
+ dest = v.getX();
+ v.setX(dest - delta);
+ vp.translationX(dest);
+ break;
+ case 90:
+ dest = v.getY();
+ v.setY(dest + delta);
+ vp.translationY(dest);
+ break;
+ case 180:
+ dest = v.getX();
+ v.setX(dest + delta);
+ vp.translationX(dest);
+ break;
+ case 270:
+ dest = v.getY();
+ v.setY(dest - delta);
+ vp.translationY(dest);
+ break;
}
- else {
- float dest = v.getY();
- v.setY(dest + delta);
- vp.translationY(dest).setDuration(ANIMATION_DURATION);
- }
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateSlideOutPreviewMenu() {
@@ -362,20 +386,9 @@ public class PhotoMenu extends MenuController
if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
return;
mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-
- } else {
- vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
- }
+ ViewPropertyAnimator vp = v.animate();
+ vp.translationXBy(-v.getWidth()).setDuration(ANIMATION_DURATION);
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -646,8 +659,7 @@ public class PhotoMenu extends MenuController
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
}
- ImageView iv = (ImageView) ((FrameLayout) switcher).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) switcher).setImageResource(resid);
switcher.setVisibility(View.VISIBLE);
mPreferences.add(pref);
mPreferenceMap.put(pref, switcher);
@@ -662,8 +674,8 @@ public class PhotoMenu extends MenuController
CharSequence[] values = pref.getEntryValues();
index = (index + 1) % values.length;
pref.setValueIndex(index);
- ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
- iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
+ ((ImageView) v).setImageResource(
+ ((IconListPreference) pref).getLargeIconIds()[index]);
if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
mListener.onCameraPickerClicked(index);
reloadPreference(pref);
@@ -687,6 +699,7 @@ public class PhotoMenu extends MenuController
ViewGroup menuLayout = mUI.getPreviewMenuLayout();
if (menuLayout != null) {
View view = menuLayout.getChildAt(0);
+ mUI.adjustOrientation();
animateSlideIn(view, previewMenuSize, false);
}
}
@@ -766,7 +779,7 @@ public class PhotoMenu extends MenuController
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
- LinearLayout layout2 = (LinearLayout) inflater.inflate(
+ RotateLayout layout2 = (RotateLayout) inflater.inflate(
R.layout.scene_mode_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
@@ -810,12 +823,11 @@ public class PhotoMenu extends MenuController
}
public void updateSceneModeIcon(IconListPreference pref) {
- ImageView iv = (ImageView) ((FrameLayout) mSceneModeSwitcher).getChildAt(0);
int[] thumbnails = pref.getThumbnailIds();
int ind = pref.getCurrentIndex();
if (ind == -1)
ind = 0;
- iv.setImageResource(thumbnails[ind]);
+ ((ImageView) mSceneModeSwitcher).setImageResource(thumbnails[ind]);
}
public void initFilterModeButton(View button) {
@@ -829,8 +841,7 @@ public class PhotoMenu extends MenuController
int resid = -1;
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
- ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) button).setImageResource(resid);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(new OnClickListener() {
@Override
@@ -839,6 +850,7 @@ public class PhotoMenu extends MenuController
ViewGroup menuLayout = mUI.getPreviewMenuLayout();
if (menuLayout != null) {
View view = mUI.getPreviewMenuLayout().getChildAt(0);
+ mUI.adjustOrientation();
animateSlideIn(view, previewMenuSize, false);
}
}
@@ -907,7 +919,7 @@ public class PhotoMenu extends MenuController
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
- LinearLayout layout2 = (LinearLayout) inflater.inflate(
+ RotateLayout layout2 = (RotateLayout) inflater.inflate(
R.layout.filter_mode_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
final int j = i;
@@ -987,9 +999,8 @@ public class PhotoMenu extends MenuController
SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(mActivity);
prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
- Toast toast = Toast.makeText(mActivity,
- "Camera developer option is enabled now", Toast.LENGTH_SHORT);
- toast.show();
+ RotateTextToast.makeText(mActivity,
+ "Camera developer option is enabled now", Toast.LENGTH_SHORT).show();
}
} else {
privateCounter = 0;
@@ -1057,25 +1068,27 @@ public class PhotoMenu extends MenuController
mPreferenceGroup.findPreference(CameraSettings.KEY_SCENE_MODE);
if (scenePref != null && notSame(scenePref, CameraSettings.KEY_SCENE_MODE,
Parameters.SCENE_MODE_AUTO)) {
- Toast.makeText(mActivity, R.string.hdr_enable_message, Toast.LENGTH_LONG).show();
+ RotateTextToast.makeText(mActivity, R.string.hdr_enable_message,
+ Toast.LENGTH_LONG).show();
}
setPreference(CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO);
} else if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
ListPreference hdrPref =
mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_HDR);
if (hdrPref != null && notSame(hdrPref, CameraSettings.KEY_CAMERA_HDR, mSettingOff)) {
- Toast.makeText(mActivity, R.string.scene_enable_message, Toast.LENGTH_LONG).show();
+ RotateTextToast.makeText(mActivity, R.string.scene_enable_message,
+ Toast.LENGTH_LONG).show();
}
setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
} else if (notSame(pref,CameraSettings.KEY_AE_BRACKET_HDR,"Off")) {
- Toast.makeText(mActivity,
+ RotateTextToast.makeText(mActivity,
R.string.flash_aebracket_message,Toast.LENGTH_SHORT).show();
setPreference(CameraSettings.KEY_FLASH_MODE,Parameters.FLASH_MODE_OFF);
} else if (notSame(pref,CameraSettings.KEY_FLASH_MODE,"Off")) {
ListPreference aePref =
mPreferenceGroup.findPreference(CameraSettings.KEY_AE_BRACKET_HDR);
if (notSame(aePref,CameraSettings.KEY_AE_BRACKET_HDR,"Off")) {
- Toast.makeText(mActivity,
+ RotateTextToast.makeText(mActivity,
R.string.flash_aebracket_message,Toast.LENGTH_SHORT).show();
}
} else if (notSame(pref, CameraSettings.KEY_LONGSHOT, mSettingOff)) {
@@ -1084,7 +1097,7 @@ public class PhotoMenu extends MenuController
if (advancefeaturePref != null) {
if (notSame(advancefeaturePref, CameraSettings.KEY_ADVANCED_FEATURES,
mActivity.getString(R.string.pref_camera_advanced_feature_default))) {
- Toast.makeText(mActivity, R.string.longshot_enable_message,
+ RotateTextToast.makeText(mActivity, R.string.longshot_enable_message,
Toast.LENGTH_LONG).show();
}
setPreference(CameraSettings.KEY_ADVANCED_FEATURES,
@@ -1096,7 +1109,7 @@ public class PhotoMenu extends MenuController
mPreferenceGroup.findPreference(CameraSettings.KEY_LONGSHOT);
if (longshotPref != null ) {
if (notSame(longshotPref, CameraSettings.KEY_LONGSHOT, mSettingOff)) {
- Toast.makeText(mActivity, R.string.advance_feature_enable_msg,
+ RotateTextToast.makeText(mActivity, R.string.advance_feature_enable_msg,
Toast.LENGTH_LONG).show();
}
setPreference(CameraSettings.KEY_LONGSHOT, mSettingOff);
@@ -1122,4 +1135,7 @@ public class PhotoMenu extends MenuController
super.onSettingChanged(pref);
}
+ public int getOrientation() {
+ return mUI == null ? 0 : mUI.getOrientation();
+ }
}
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 370901834..2bd1ff729 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -787,7 +787,7 @@ public class PhotoModule
@Override
public void onSwitchSavePath() {
mUI.setPreference(CameraSettings.KEY_CAMERA_SAVEPATH, "1");
- Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ RotateTextToast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
Toast.LENGTH_SHORT).show();
}
@@ -934,7 +934,7 @@ public class PhotoModule
remainMemory <= LONGSHOT_CANCEL_THRESHOLD) {
Log.d(TAG, "memory used up, need cancel longshot.");
mLongshotActive = false;
- Toast.makeText(mActivity,R.string.msg_cancel_longshot_for_limited_memory,
+ RotateTextToast.makeText(mActivity,R.string.msg_cancel_longshot_for_limited_memory,
Toast.LENGTH_SHORT).show();
return true;
}
@@ -1492,14 +1492,7 @@ public class PhotoModule
}
// Set rotation and gps data.
- int orientation;
- // We need to be consistent with the framework orientation (i.e. the
- // orientation of the UI.) when the auto-rotate screen setting is on.
- if (mActivity.isAutoRotateScreen()) {
- orientation = (360 - mDisplayRotation) % 360;
- } else {
- orientation = mOrientation;
- }
+ int orientation = mOrientation;
mJpegRotation = CameraUtil.getJpegRotation(mCameraId, orientation);
mParameters.setRotation(mJpegRotation);
String pictureFormat = mParameters.get(KEY_PICTURE_FORMAT);
@@ -1726,7 +1719,7 @@ public class PhotoModule
null, null, null, colorEffect,
sceneMode, redeyeReduction, aeBracketing);
disableLongShot = true;
- Toast.makeText(mActivity, R.string.advanced_capture_disable_continuous_shot,
+ RotateTextToast.makeText(mActivity, R.string.advanced_capture_disable_continuous_shot,
Toast.LENGTH_LONG).show();
}
@@ -1857,6 +1850,7 @@ public class PhotoModule
setFlipValue();
mCameraDevice.setParameters(mParameters);
}
+ mUI.setOrientation(mOrientation, true);
}
// Show the toast after getting the first orientation changed.
@@ -3106,13 +3100,13 @@ public class PhotoModule
mFocusManager.overrideFocusMode(mFocusManager.getFocusMode());
}
- if(!pictureFormat.equals(PIXEL_FORMAT_JPEG)) {
- mActivity.runOnUiThread(new Runnable() {
- public void run() {
- Toast.makeText(mActivity, R.string.error_app_unsupported_raw,
- Toast.LENGTH_SHORT).show();
- }
- });
+ if (!pictureFormat.equals(PIXEL_FORMAT_JPEG)) {
+ mActivity.runOnUiThread(new Runnable() {
+ public void run() {
+ RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_raw,
+ Toast.LENGTH_SHORT).show();
+ }
+ });
}
} else if(zsl.equals("off")) {
mSnapshotMode = CameraInfo.CAMERA_SUPPORT_MODE_NONZSL;
@@ -3702,7 +3696,7 @@ public class PhotoModule
if (focusStr.length() > 0) {
focuspos = Double.parseDouble(focusStr);
} else {
- Toast.makeText(mActivity, "Invalid focus position",
+ RotateTextToast.makeText(mActivity, "Invalid focus position",
Toast.LENGTH_SHORT).show();
return;
}
@@ -3716,7 +3710,7 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid focus position",
+ RotateTextToast.makeText(mActivity, "Invalid focus position",
Toast.LENGTH_SHORT).show();
}
}
@@ -3793,7 +3787,8 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid CCT", Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity, "Invalid CCT", Toast.LENGTH_SHORT)
+ .show();
}
}
});
@@ -3855,11 +3850,11 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid RGB gains",
+ RotateTextToast.makeText(mActivity, "Invalid RGB gains",
Toast.LENGTH_SHORT).show();
}
} else {
- Toast.makeText(mActivity, "Invalid RGB gains",
+ RotateTextToast.makeText(mActivity, "Invalid RGB gains",
Toast.LENGTH_SHORT).show();
}
}
@@ -3947,7 +3942,7 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid ISO", Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity, "Invalid ISO", Toast.LENGTH_SHORT).show();
}
}
});
@@ -3978,7 +3973,7 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid exposure time",
+ RotateTextToast.makeText(mActivity, "Invalid exposure time",
Toast.LENGTH_SHORT).show();
}
}
@@ -4025,7 +4020,8 @@ public class PhotoModule
updateCommonManual3ASettings();
onSharedPreferenceChanged();
} else {
- Toast.makeText(mActivity, "Invalid input", Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity, "Invalid input", Toast.LENGTH_SHORT)
+ .show();
}
}
});
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index f6ddd94ff..bad7073a9 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -64,10 +64,13 @@ import com.android.camera.ui.CountDownView;
import com.android.camera.ui.CountDownView.OnCountDownFinishedListener;
import com.android.camera.ui.FaceView;
import com.android.camera.ui.FocusIndicator;
+import com.android.camera.ui.ListSubMenu;
import com.android.camera.ui.ModuleSwitcher;
import com.android.camera.ui.PieRenderer;
import com.android.camera.ui.PieRenderer.PieListener;
import com.android.camera.ui.RenderOverlay;
+import com.android.camera.ui.RotateLayout;
+import com.android.camera.ui.RotateTextToast;
import com.android.camera.ui.ZoomRenderer;
import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
@@ -113,7 +116,7 @@ public class PhotoUI implements PieListener,
private PieRenderer mPieRenderer;
private ZoomRenderer mZoomRenderer;
- private Toast mNotSelectableToast;
+ private RotateTextToast mNotSelectableToast;
private int mZoomMax;
private List<Integer> mZoomRatios;
@@ -139,8 +142,8 @@ public class PhotoUI implements PieListener,
private boolean mOrientationResize;
private boolean mPrevOrientationResize;
private View mPreviewCover;
- private LinearLayout mMenuLayout;
- private LinearLayout mSubMenuLayout;
+ private RotateLayout mMenuLayout;
+ private RotateLayout mSubMenuLayout;
private LinearLayout mPreviewMenuLayout;
private boolean mUIhidden = false;
private int mPreviewOrientation = -1;
@@ -149,6 +152,8 @@ public class PhotoUI implements PieListener,
private int mTopMargin = 0;
private int mBottomMargin = 0;
+ private int mOrientation;
+
public interface SurfaceTextureSizeChangedListener {
public void onSurfaceTextureSizeChanged(int uncroppedWidth, int uncroppedHeight);
}
@@ -274,6 +279,7 @@ public class PhotoUI implements PieListener,
return;
}
mSwitcher.showPopup();
+ mSwitcher.setOrientation(mOrientation, false);
}
});
mMenuButton = mRootView.findViewById(R.id.menu);
@@ -625,8 +631,7 @@ public class PhotoUI implements PieListener,
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
- mShutterButton.setImageBitmap(null);
- mShutterButton.setBackgroundResource(R.drawable.shutter_button_anim);
+ mShutterButton.setImageResource(R.drawable.shutter_button_anim);
mShutterButton.setOnClickListener(new OnClickListener()
{
@Override
@@ -641,7 +646,7 @@ public class PhotoUI implements PieListener,
}
public void doShutterAnimation() {
- AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getBackground();
+ AnimationDrawable frameAnimation = (AnimationDrawable) mShutterButton.getDrawable();
frameAnimation.stop();
frameAnimation.start();
}
@@ -823,28 +828,43 @@ public class PhotoUI implements PieListener,
popup.setVisibility(View.VISIBLE);
if (level == 1) {
if (mMenuLayout == null) {
- mMenuLayout = new LinearLayout(mActivity);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT);
+ mMenuLayout = new RotateLayout(mActivity, null);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT,
+ Gravity.LEFT | Gravity.TOP);
mMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mMenuLayout);
}
+ mMenuLayout.setOrientation(mOrientation, true);
mMenuLayout.addView(popup);
}
if (level == 2) {
if (mSubMenuLayout == null) {
- mSubMenuLayout = new LinearLayout(mActivity);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT);
- mSubMenuLayout.setLayoutParams(params);
+ mSubMenuLayout = new RotateLayout(mActivity, null);
((ViewGroup) mRootView).addView(mSubMenuLayout);
}
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT,
+ Gravity.LEFT | Gravity.TOP);
+
+ int screenHeight = (mOrientation == 0 || mOrientation == 180)
+ ? mRootView.getHeight() : mRootView.getWidth();
+ int height = ((ListSubMenu) popup).getPreCalculatedHeight();
+ int yBase = ((ListSubMenu) popup).getYBase();
+ int y = Math.max(0, yBase);
+ if (yBase + height > screenHeight)
+ y = Math.max(0, screenHeight - height);
+ params.setMargins(0, y, 0, 0);
+ params.setMarginStart(CameraActivity.SETTING_LIST_WIDTH_1);
+
+ mSubMenuLayout.setLayoutParams(params);
+
mSubMenuLayout.addView(popup);
- mSubMenuLayout.setX(CameraActivity.SETTING_LIST_WIDTH_1);
+ mSubMenuLayout.setOrientation(mOrientation, true);
}
if (animate) {
if (level == 1)
- mMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
+ mMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
if (level == 2)
mMenu.animateFadeIn(popup);
} else
@@ -1094,6 +1114,7 @@ public class PhotoUI implements PieListener,
mCountDownView = (CountDownView) (mRootView.findViewById(R.id.count_down_to_capture));
mCountDownView.setCountDownFinishedListener((OnCountDownFinishedListener) mController);
mCountDownView.bringToFront();
+ mCountDownView.setOrientation(mOrientation);
}
public boolean isCountingDown() {
@@ -1113,7 +1134,7 @@ public class PhotoUI implements PieListener,
public void showPreferencesToast() {
if (mNotSelectableToast == null) {
String str = mActivity.getResources().getString(R.string.not_selectable_in_scene_mode);
- mNotSelectableToast = Toast.makeText(mActivity, str, Toast.LENGTH_SHORT);
+ mNotSelectableToast = RotateTextToast.makeText(mActivity, str, Toast.LENGTH_SHORT);
}
mNotSelectableToast.show();
}
@@ -1232,4 +1253,35 @@ public class PhotoUI implements PieListener,
public void updateRemainingPhotos(int remaining) {
mCameraControls.updateRemainingPhotos(remaining);
}
+
+ 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 (mPreviewMenuLayout != null) {
+ ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0);
+ if (vg != null)
+ vg = (ViewGroup) vg.getChildAt(0);
+ if (vg != null) {
+ for (int i = vg.getChildCount() - 1; i >= 0; --i) {
+ RotateLayout l = (RotateLayout) vg.getChildAt(i);
+ l.setOrientation(orientation, animation);
+ }
+ }
+ }
+ if (mCountDownView != null)
+ mCountDownView.setOrientation(orientation);
+ RotateTextToast.setOrientation(orientation);
+ }
+
+ public int getOrientation() {
+ return mOrientation;
+ }
+
+ public void adjustOrientation() {
+ setOrientation(mOrientation, true);
+ }
}
diff --git a/src/com/android/camera/PieController.java b/src/com/android/camera/PieController.java
index cc4ad6552..f1973831b 100644
--- a/src/com/android/camera/PieController.java
+++ b/src/com/android/camera/PieController.java
@@ -26,6 +26,7 @@ import com.android.camera.drawable.TextDrawable;
import com.android.camera.ui.PieItem;
import com.android.camera.ui.PieItem.OnClickListener;
import com.android.camera.ui.PieRenderer;
+import com.android.camera.ui.RotateTextToast;
import org.codeaurora.snapcam.R;
import java.util.ArrayList;
@@ -172,7 +173,7 @@ public class PieController {
// when enable HDR,inform to disable Continuous Shot
if (index == 1 && prefKey == CameraSettings.KEY_CAMERA_HDR)
{
- Toast.makeText(mActivity, R.string.HDR_disable_continuous_shot,
+ RotateTextToast.makeText(mActivity, R.string.HDR_disable_continuous_shot,
Toast.LENGTH_LONG).show();
}
fitem.setLabel(pref.getLabels()[index]);
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
index ce461aadd..70a094c28 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -89,32 +89,36 @@ public class PreviewGestures
if (mZoomOnly || mMode == MODE_ZOOM) return false;
int deltaX = (int) (e1.getX() - e2.getX());
int deltaY = (int) (e1.getY() - e2.getY());
- if (deltaY > 2 * deltaX && deltaY > -2 * deltaX) {
- // Open pie on swipe up
- if (mPie != null && !mPie.showsItems()) {
- openPie();
- return true;
- }
- }
- if (deltaX < 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY)) {
- // Open menu on swipe left
- waitUntilNextDown = true;
- if (mPhotoMenu != null) {
- if (!mPhotoMenu.isMenuBeingShown()) {
- mPhotoMenu.openFirstLevel();
- }
- }
+ int orientation = 0;
+ if (mPhotoMenu != null)
+ orientation = mPhotoMenu.getOrientation();
+ else if (mVideoMenu != null)
+ orientation = mVideoMenu.getOrientation();
- if (mVideoMenu != null) {
- if (!mVideoMenu.isMenuBeingShown()) {
- mVideoMenu.openFirstLevel();
- }
- }
+ if (isLeftSwipe(orientation, deltaX, deltaY)) {
+ waitUntilNextDown = true;
+ if (mPhotoMenu != null && !mPhotoMenu.isMenuBeingShown())
+ mPhotoMenu.openFirstLevel();
+ else if (mVideoMenu != null && !mVideoMenu.isMenuBeingShown())
+ mVideoMenu.openFirstLevel();
return true;
}
return false;
}
+
+ private boolean isLeftSwipe(int orientation, int deltaX, int deltaY) {
+ switch (orientation) {
+ case 90:
+ return deltaY > 0 && Math.abs(deltaY) > 2 * Math.abs(deltaX);
+ case 180:
+ return deltaX > 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY);
+ case 270:
+ return deltaY < 0 && Math.abs(deltaY) > 2 * Math.abs(deltaX);
+ default:
+ return deltaX < 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY);
+ }
+ }
};
public interface SingleTapListener {
diff --git a/src/com/android/camera/ShutterButton.java b/src/com/android/camera/ShutterButton.java
index f1d969f9d..b35658070 100644
--- a/src/com/android/camera/ShutterButton.java
+++ b/src/com/android/camera/ShutterButton.java
@@ -22,12 +22,14 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
+import com.android.camera.ui.RotateImageView;
+
/**
* A button designed to be used for the on-screen shutter button.
* It's currently an {@code ImageView} that can call a delegate when the
* pressed state changes.
*/
-public class ShutterButton extends ImageView {
+public class ShutterButton extends RotateImageView {
private class LongClickListener implements View.OnLongClickListener {
public boolean onLongClick(View v) {
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index 1f9c6d1a0..b8cb5a1fe 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -47,6 +47,7 @@ import android.widget.HorizontalScrollView;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.Display;
+import com.android.camera.ui.RotateLayout;
import com.android.camera.util.CameraUtil;
public class VideoMenu extends MenuController
@@ -219,7 +220,21 @@ public class VideoMenu extends MenuController
mPopupStatus = POPUP_IN_ANIMATION_SLIDE;
ViewPropertyAnimator vp = v.animate();
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+ switch (mUI.getOrientation()) {
+ case 0:
+ vp.translationXBy(-v.getWidth());
+ break;
+ case 90:
+ vp.translationYBy(2 * v.getHeight());
+ break;
+ case 180:
+ vp.translationXBy(2 * v.getWidth());
+ break;
+ case 270:
+ vp.translationYBy(-v.getHeight());
+ break;
+ }
+
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -259,7 +274,7 @@ public class VideoMenu extends MenuController
}
});
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateFadeIn(final ListView v) {
@@ -268,27 +283,37 @@ public class VideoMenu extends MenuController
vp.start();
}
- public void animateSlideIn(final View v, int delta, boolean settingMenu) {
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- if (settingMenu)
- portrait = true;
+ public void animateSlideIn(final View v, int delta, boolean adjustOrientation) {
+ int orientation = mUI.getOrientation();
+ if (!adjustOrientation)
+ orientation = 0;
+
ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- float dest = v.getX();
- v.setX(dest - delta);
- vp.translationX(dest).setDuration(ANIMATION_DURATION);
+ float dest;
+ switch (orientation) {
+ case 0:
+ dest = v.getX();
+ v.setX(dest - delta);
+ vp.translationX(dest);
+ break;
+ case 90:
+ dest = v.getY();
+ v.setY(dest + delta);
+ vp.translationY(dest);
+ break;
+ case 180:
+ dest = v.getX();
+ v.setX(dest + delta);
+ vp.translationX(dest);
+ break;
+ case 270:
+ dest = v.getY();
+ v.setY(dest - delta);
+ vp.translationY(dest);
+ break;
}
- else {
- float dest = v.getY();
- v.setY(dest + delta);
- vp.translationY(dest).setDuration(ANIMATION_DURATION);
- }
- vp.start();
+
+ vp.setDuration(ANIMATION_DURATION).start();
}
public void animateSlideOutPreviewMenu() {
@@ -301,20 +326,9 @@ public class VideoMenu extends MenuController
if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
return;
mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
- int rotation = CameraUtil.getDisplayRotation(mActivity);
- boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
- if (!mIsDefaultToPortrait) {
- rotation = (rotation + 90) % 360;
- }
- boolean portrait = (rotation == 0) || (rotation == 180);
- ViewPropertyAnimator vp = v.animate();
- if (portrait) {
- vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-
- } else {
- vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
- }
+ ViewPropertyAnimator vp = v.animate();
+ vp.translationXBy(-v.getWidth()).setDuration(ANIMATION_DURATION);
vp.setListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -337,7 +351,7 @@ public class VideoMenu extends MenuController
mPreviewMenuStatus = PREVIEW_MENU_NONE;
}
});
- vp.start();
+ vp.setDuration(ANIMATION_DURATION).start();
}
public boolean isOverMenu(MotionEvent ev) {
@@ -404,8 +418,7 @@ public class VideoMenu extends MenuController
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
}
- ImageView iv = (ImageView) ((FrameLayout) switcher).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) switcher).setImageResource(resid);
switcher.setVisibility(View.VISIBLE);
mPreferences.add(pref);
mPreferenceMap.put(pref, switcher);
@@ -420,8 +433,8 @@ public class VideoMenu extends MenuController
CharSequence[] values = pref.getEntryValues();
index = (index + 1) % values.length;
pref.setValueIndex(index);
- ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
- iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
+ ((ImageView) v).setImageResource(
+ ((IconListPreference) pref).getLargeIconIds()[index]);
if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
mListener.onCameraPickerClicked(index);
reloadPreference(pref);
@@ -441,14 +454,14 @@ public class VideoMenu extends MenuController
int resid = -1;
// The preference only has a single icon to represent it.
resid = pref.getSingleIcon();
- ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
- iv.setImageResource(resid);
+ ((ImageView) button).setImageResource(resid);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
addFilterMode();
View view = mUI.getPreviewMenuLayout().getChildAt(0);
+ mUI.adjustOrientation();
animateSlideIn(view, previewMenuSize, false);
}
});
@@ -523,7 +536,7 @@ public class VideoMenu extends MenuController
final View[] views = new View[entries.length];
int init = pref.getCurrentIndex();
for (int i = 0; i < entries.length; i++) {
- LinearLayout layout2 = (LinearLayout) inflater.inflate(
+ RotateLayout layout2 = (RotateLayout) inflater.inflate(
R.layout.filter_mode_view, null, false);
ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
@@ -743,4 +756,7 @@ public class VideoMenu extends MenuController
super.onSettingChanged(pref);
}
+ public int getOrientation() {
+ return mUI == null ? 0 : mUI.getOrientation();
+ }
}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 59874dd81..e200de1bd 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -387,8 +387,9 @@ public class VideoModule implements CameraModule,
if (action.equals(Intent.ACTION_MEDIA_EJECT)) {
stopVideoRecording();
} else if (action.equals(Intent.ACTION_MEDIA_SCANNER_STARTED)) {
- Toast.makeText(mActivity,
- mActivity.getResources().getString(R.string.wait), Toast.LENGTH_LONG).show();
+ RotateTextToast.makeText(mActivity,
+ mActivity.getResources().getString(R.string.wait), Toast.LENGTH_LONG)
+ .show();
}
}
}
@@ -573,6 +574,7 @@ public class VideoModule implements CameraModule,
setFlipValue();
mCameraDevice.setParameters(mParameters);
}
+ mUI.setOrientation(newOrientation, true);
}
// Show the toast after getting the first orientation changed.
@@ -955,7 +957,7 @@ public class VideoModule implements CameraModule,
@Override
public void onSwitchSavePath() {
mUI.setPreference(CameraSettings.KEY_CAMERA_SAVEPATH, "1");
- Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ RotateTextToast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
Toast.LENGTH_SHORT).show();
}
@@ -1315,8 +1317,8 @@ public class VideoModule implements CameraModule,
"mMaxFrameWidth = " + videoEncoder.mMaxFrameWidth + " , " +
"mMaxFrameHeight = " + videoEncoder.mMaxFrameHeight);
mUnsupportedResolution = true;
- Toast.makeText(mActivity, R.string.error_app_unsupported,
- Toast.LENGTH_LONG).show();
+ RotateTextToast.makeText(mActivity, R.string.error_app_unsupported,
+ Toast.LENGTH_LONG).show();
return;
}
break;
@@ -1568,7 +1570,7 @@ public class VideoModule implements CameraModule,
if (mMediaRecorderRecording) onStopVideoRecording();
// Show the toast.
- Toast.makeText(mActivity, R.string.video_reach_size_limit,
+ RotateTextToast.makeText(mActivity, R.string.video_reach_size_limit,
Toast.LENGTH_LONG).show();
}
}
@@ -1607,22 +1609,24 @@ public class VideoModule implements CameraModule,
if( mUnsupportedHFRVideoSize == true) {
Log.e(TAG, "Unsupported HFR and video size combinations");
- Toast.makeText(mActivity,R.string.error_app_unsupported_hfr, Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity,R.string.error_app_unsupported_hfr,
+ Toast.LENGTH_SHORT).show();
mStartRecPending = false;
return;
}
if (mUnsupportedHSRVideoSize == true) {
Log.e(TAG, "Unsupported HSR and video size combinations");
- Toast.makeText(mActivity,R.string.error_app_unsupported_hsr, Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity,R.string.error_app_unsupported_hsr,
+ Toast.LENGTH_SHORT).show();
mStartRecPending = false;
return;
}
if( mUnsupportedHFRVideoCodec == true) {
Log.e(TAG, "Unsupported HFR and video codec combinations");
- Toast.makeText(mActivity, R.string.error_app_unsupported_hfr_codec,
- Toast.LENGTH_SHORT).show();
+ RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_hfr_codec,
+ Toast.LENGTH_SHORT).show();
mStartRecPending = false;
return;
}
@@ -1674,7 +1678,6 @@ public class VideoModule implements CameraModule,
mMediaRecorderRecording = true;
mMediaRecorderPausing = false;
mUI.resetPauseButton();
- mOrientationManager.lockOrientation();
mRecordingTotalTime = 0L;
mRecordingStartTime = SystemClock.uptimeMillis();
mUI.showRecordingUI(true);
@@ -1773,8 +1776,6 @@ public class VideoModule implements CameraModule,
mSnapshotInProgress = false;
showVideoSnapshotUI(false);
- mOrientationManager.unlockOrientation();
-
// If the activity is paused, this means activity is interrupted
// during recording. Release the camera as soon as possible because
// face unlock or other applications may need to use the camera.
@@ -2017,7 +2018,7 @@ public class VideoModule implements CameraModule,
mActivity.getString(R.string.pref_camera_dis_value_disable));
mUI.overrideSettings(CameraSettings.KEY_DIS,
mActivity.getString(R.string.pref_camera_dis_value_disable));
- Toast.makeText(mActivity, R.string.video_quality_4k_disable_IS,
+ RotateTextToast.makeText(mActivity, R.string.video_quality_4k_disable_IS,
Toast.LENGTH_LONG).show();
} else {
Log.e(TAG, "Not supported IS mode = " +
@@ -2247,7 +2248,7 @@ public class VideoModule implements CameraModule,
(disMode.equals("enable")) ||
((hdr != null) && (!hdr.equals("off"))) ) {
Log.v(TAG,"HDR/DIS/Time Lapse ON for HFR/HSR selection, turning HFR/HSR off");
- Toast.makeText(mActivity, R.string.error_app_unsupported_hfr_selection,
+ RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_hfr_selection,
Toast.LENGTH_LONG).show();
mParameters.setVideoHighFrameRate("off");
mParameters.set(CameraSettings.KEY_VIDEO_HSR, "off");
@@ -2262,7 +2263,7 @@ public class VideoModule implements CameraModule,
if (biggestSize.width <= videoWidth || biggestSize.height <= videoHeight) {
if (disMode.equals("enable")) {
Log.v(TAG,"DIS is not supported for this video quality");
- Toast.makeText(mActivity, R.string.error_app_unsupported_dis,
+ RotateTextToast.makeText(mActivity, R.string.error_app_unsupported_dis,
Toast.LENGTH_LONG).show();
mParameters.set(CameraSettings.KEY_QC_DIS_MODE, "disable");
mUI.overrideSettings(CameraSettings.KEY_DIS,"disable");
@@ -2631,8 +2632,7 @@ public class VideoModule implements CameraModule,
}
private void showTapToSnapshotToast() {
- new RotateTextToast(mActivity, R.string.video_snapshot_hint, 0)
- .show();
+ new RotateTextToast(mActivity, R.string.video_snapshot_hint, 0).show();
// Clear the preference.
Editor editor = mPreferences.edit();
editor.putBoolean(CameraSettings.KEY_VIDEO_FIRST_USE_HINT_SHOWN, false);
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 54a1bfcd4..13db502c5 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -51,10 +51,12 @@ import com.android.camera.CameraPreference.OnPreferenceChangedListener;
import com.android.camera.ui.AbstractSettingPopup;
import com.android.camera.ui.CameraControls;
import com.android.camera.ui.CameraRootView;
+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.RotateLayout;
+import com.android.camera.ui.RotateTextToast;
import com.android.camera.ui.ZoomRenderer;
import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
@@ -101,8 +103,8 @@ public class VideoUI implements PieRenderer.PieListener,
private boolean mOrientationResize;
private boolean mPrevOrientationResize;
private boolean mIsTimeLapse = false;
- private LinearLayout mMenuLayout;
- private LinearLayout mSubMenuLayout;
+ private RotateLayout mMenuLayout;
+ private RotateLayout mSubMenuLayout;
private LinearLayout mPreviewMenuLayout;
private View mPreviewCover;
@@ -117,6 +119,7 @@ public class VideoUI implements PieRenderer.PieListener,
private final AnimationManager mAnimationManager;
private boolean mUIhidden = false;
private int mPreviewOrientation = -1;
+ private int mOrientation;
// temporary variables for updating SurfaceView
private int mTempWidth;
@@ -243,6 +246,7 @@ public class VideoUI implements PieRenderer.PieListener,
@Override
public void onClick(View v) {
mSwitcher.showPopup();
+ mSwitcher.setOrientation(mOrientation, false);
}
});
@@ -532,7 +536,6 @@ public class VideoUI implements PieRenderer.PieListener,
mLabelsLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
}
}
- mRecordingTimeRect.setOrientation(0, animation);
}
public SurfaceHolder getSurfaceHolder() {
@@ -731,29 +734,46 @@ public class VideoUI implements PieRenderer.PieListener,
popup.setVisibility(View.VISIBLE);
if (level == 1) {
if (mMenuLayout == null) {
- mMenuLayout = new LinearLayout(mActivity);
- ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
- CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT);
+ mMenuLayout = new RotateLayout(mActivity, null);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT,
+ Gravity.LEFT | Gravity.TOP);
mMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mMenuLayout);
}
+ mMenuLayout.setOrientation(mOrientation, true);
mMenuLayout.addView(popup);
}
if (level == 2) {
if (mSubMenuLayout == null) {
- mSubMenuLayout = new LinearLayout(mActivity);
+ mSubMenuLayout = new RotateLayout(mActivity, null);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT);
mSubMenuLayout.setLayoutParams(params);
((ViewGroup) mRootView).addView(mSubMenuLayout);
}
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT,
+ Gravity.LEFT | Gravity.TOP);
+
+ int screenHeight = (mOrientation == 0 || mOrientation == 180)
+ ? mRootView.getHeight() : mRootView.getWidth();
+ int height = ((ListSubMenu) popup).getPreCalculatedHeight();
+ int yBase = ((ListSubMenu) popup).getYBase();
+ int y = Math.max(0, yBase);
+ if (yBase + height > screenHeight)
+ y = Math.max(0, screenHeight - height);
+ params.setMargins(0, y, 0, 0);
+ params.setMarginStart(CameraActivity.SETTING_LIST_WIDTH_1);
+
+ mSubMenuLayout.setLayoutParams(params);
mSubMenuLayout.addView(popup);
- mSubMenuLayout.setX(CameraActivity.SETTING_LIST_WIDTH_1);
+ mSubMenuLayout.setOrientation(mOrientation, true);
}
if (animate) {
if (level == 1)
- mVideoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
+ mVideoMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
if (level == 2)
mVideoMenu.animateFadeIn(popup);
}
@@ -1051,4 +1071,42 @@ public class VideoUI implements PieRenderer.PieListener,
}
return false;
}
+
+ public void setOrientation(int orientation, boolean animation) {
+ mCameraControls.setOrientation(orientation, animation);
+ if (mMenuLayout != null)
+ mMenuLayout.setOrientation(orientation, animation);
+ if (mSubMenuLayout != null)
+ mSubMenuLayout.setOrientation(orientation, animation);
+ if (mRecordingTimeRect != null) {
+ if (orientation == 180) {
+ mRecordingTimeRect.setOrientation(0, false);
+ mRecordingTimeView.setRotation(180);
+ } else {
+ mRecordingTimeView.setRotation(0);
+ mRecordingTimeRect.setOrientation(orientation, false);
+ }
+ }
+ if (mPreviewMenuLayout != null) {
+ ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0);
+ if (vg != null)
+ vg = (ViewGroup) vg.getChildAt(0);
+ if (vg != null) {
+ for (int i = vg.getChildCount() - 1; i >= 0; --i) {
+ RotateLayout l = (RotateLayout) vg.getChildAt(i);
+ l.setOrientation(orientation, animation);
+ }
+ }
+ }
+ RotateTextToast.setOrientation(orientation);
+ mOrientation = orientation;
+ }
+
+ public int getOrientation() {
+ return mOrientation;
+ }
+
+ public void adjustOrientation() {
+ setOrientation(mOrientation, false);
+ }
}
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 40878581e..900951d96 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -50,6 +50,7 @@ import com.android.camera.CameraManager.CameraProxy;
import com.android.camera.app.OrientationManager;
import com.android.camera.data.LocalData;
import com.android.camera.exif.ExifInterface;
+import com.android.camera.ui.RotateTextToast;
import com.android.camera.util.CameraUtil;
import com.android.camera.util.UsageStatistics;
import org.codeaurora.snapcam.R;
@@ -134,6 +135,7 @@ public class WideAnglePanoramaModule
private int mDeviceOrientationAtCapture;
private int mCameraOrientation;
private int mOrientationCompensation;
+ private boolean mOrientationLocked;
private SoundClips.Player mSoundPlayer;
@@ -192,6 +194,7 @@ public class WideAnglePanoramaModule
// the camera then point the camera to floor or sky, we still have
// the correct orientation.
if (orientation == ORIENTATION_UNKNOWN) return;
+ int oldOrientation = mDeviceOrientation;
mDeviceOrientation = CameraUtil.roundOrientation(orientation, mDeviceOrientation);
// When the screen is unlocked, display rotation may change. Always
// calculate the up-to-date orientationCompensation.
@@ -200,6 +203,11 @@ public class WideAnglePanoramaModule
if (mOrientationCompensation != orientationCompensation) {
mOrientationCompensation = orientationCompensation;
}
+ if (oldOrientation != mDeviceOrientation
+ && oldOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
+ if (!mOrientationLocked)
+ mUI.setOrientation(mDeviceOrientation, true);
+ }
}
}
@@ -555,8 +563,7 @@ public class WideAnglePanoramaModule
mUI.showCaptureProgress();
mDeviceOrientationAtCapture = mDeviceOrientation;
keepScreenOn();
- // TODO: mActivity.getOrientationManager().lockOrientation();
- mOrientationManager.lockOrientation();
+ mOrientationLocked = true;
int degrees = CameraUtil.getDisplayRotation(mActivity);
int cameraId = CameraHolder.instance().getBackCameraId();
int orientation = CameraUtil.getDisplayOrientation(degrees, cameraId);
@@ -744,7 +751,8 @@ public class WideAnglePanoramaModule
private void reset() {
mCaptureState = CAPTURE_STATE_VIEWFINDER;
- mOrientationManager.unlockOrientation();
+ mOrientationLocked = false;
+ mUI.setOrientation(mDeviceOrientation, true);
mUI.reset();
mActivity.setSwipingEnabled(true);
// Orientation change will trigger onLayoutChange->configMosaicPreview->
@@ -901,7 +909,7 @@ public class WideAnglePanoramaModule
@Override
public void onSwitchSavePath() {
mPreferences.edit().putString(CameraSettings.KEY_CAMERA_SAVEPATH, "1").apply();
- Toast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
+ RotateTextToast.makeText(mActivity, R.string.on_switch_save_path_to_sdcard,
Toast.LENGTH_SHORT).show();
}
diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java
index 9594ac0e6..53b1630b1 100644
--- a/src/com/android/camera/WideAnglePanoramaUI.java
+++ b/src/com/android/camera/WideAnglePanoramaUI.java
@@ -16,6 +16,8 @@
package com.android.camera;
+import java.lang.reflect.Method;
+
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
@@ -30,7 +32,9 @@ import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.Log;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.TextureView;
import android.view.View;
@@ -45,6 +49,7 @@ import com.android.camera.CameraActivity.UpdatePreviewThumbnail;
import com.android.camera.ui.CameraControls;
import com.android.camera.ui.CameraRootView;
import com.android.camera.ui.ModuleSwitcher;
+import com.android.camera.ui.RotateTextToast;
import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
@@ -94,6 +99,8 @@ public class WideAnglePanoramaUI implements
private SurfaceTexture mSurfaceTexture;
private View mPreviewCover;
+ private int mOrientation;
+
/** Constructor. */
public WideAnglePanoramaUI(
CameraActivity activity,
@@ -120,6 +127,7 @@ public class WideAnglePanoramaUI implements
@Override
public void onClick(View v) {
mSwitcher.showPopup();
+ mSwitcher.setOrientation(mOrientation, false);
}
});
}
@@ -582,4 +590,94 @@ public class WideAnglePanoramaUI implements
}
return false;
}
+
+ public void setOrientation(int orientation, boolean animation) {
+ mOrientation = orientation;
+ // '---------`
+ // | 0 |
+ // |---------| =t
+ // | | | |
+ // |1| |2|
+ // | | | |
+ // |---------| =b1
+ // | 3 |
+ // `---------' =b2
+ // =r
+ int t = mPreviewLayout.getTop();
+ int b1 = mPreviewLayout.getBottom();
+ int r = mPreviewLayout.getRight();
+ int b2 = mCaptureLayout.getBottom();
+
+ final FrameLayout progressLayout = (FrameLayout)
+ mRootView.findViewById(R.id.pano_progress_layout);
+ int pivotY = ((ViewGroup) progressLayout).getPaddingTop()
+ + progressLayout.getChildAt(0).getHeight() / 2;
+
+ int[] x = { r / 2, r / 10, r * 9 / 10, r / 2 };
+ int[] y = { t / 2, (t + b1) / 2, (t + b1) / 2, b1 + pivotY };
+
+ int idx1, idx2;
+ int g;
+ switch (orientation) {
+ case 90:
+ idx1 = 1;
+ idx2 = 2;
+ g = Gravity.TOP | Gravity.RIGHT;
+ break;
+ case 180:
+ idx1 = 3;
+ idx2 = 0;
+ g = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
+ break;
+ case 270:
+ idx1 = 2;
+ idx2 = 1;
+ g = Gravity.TOP | Gravity.RIGHT;
+ break;
+ default:
+ idx1 = 0;
+ idx2 = 3;
+ g = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
+ break;
+ }
+
+ final View[] views1 = {
+ (View) mCaptureIndicator.getParent(),
+ mRootView.findViewById(R.id.pano_review_indicator)
+ };
+ for (final View v : views1) {
+ v.setTranslationX(x[idx1] - x[0]);
+ v.setTranslationY(y[idx1]- y[0]);
+ // use relection here to build on Kitkat
+ if (Build.VERSION.SDK_INT >= 21) {
+ try {
+ final Class cls = Class.forName("android.view.View");
+ final Method method = cls.getMethod("setTranslationZ", float.class);
+ method.invoke(v, 1);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ v.setRotation(-orientation);
+ }
+
+ final View[] views2 = { progressLayout, mReviewControl };
+ for (final View v : views2) {
+ v.setPivotX(r / 2);
+ v.setPivotY(pivotY);
+ v.setTranslationX(x[idx2] - x[3]);
+ v.setTranslationY(y[idx2] - y[3]);
+ v.setRotation(-orientation);
+ }
+
+ final View button = mReviewControl.findViewById(R.id.pano_review_cancel_button);
+ FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) button.getLayoutParams();
+ lp.gravity = g;
+ button.setLayoutParams(lp);
+
+ mReview.setRotation(-orientation);
+ mTooFastPrompt.setRotation(-orientation);
+ mCameraControls.setOrientation(orientation, animation);
+ RotateTextToast.setOrientation(orientation);
+ }
}
diff --git a/src/com/android/camera/app/OrientationManager.java b/src/com/android/camera/app/OrientationManager.java
index ef03a0163..7dcd3064f 100644
--- a/src/com/android/camera/app/OrientationManager.java
+++ b/src/com/android/camera/app/OrientationManager.java
@@ -36,12 +36,6 @@ public class OrientationManager {
private Activity mActivity;
private MyOrientationEventListener mOrientationListener;
- // If the framework orientation is locked.
- private boolean mOrientationLocked = false;
-
- // This is true if "Settings -> Display -> Rotation Lock" is checked. We
- // don't allow the orientation to be unlocked if the value is true.
- private boolean mRotationLockedSetting = false;
public OrientationManager(Activity activity) {
mActivity = activity;
@@ -50,8 +44,6 @@ public class OrientationManager {
public void resume() {
ContentResolver resolver = mActivity.getContentResolver();
- mRotationLockedSetting = Settings.System.getInt(
- resolver, Settings.System.ACCELEROMETER_ROTATION, 0) != 1;
mOrientationListener.enable();
}
@@ -59,40 +51,6 @@ public class OrientationManager {
mOrientationListener.disable();
}
- ////////////////////////////////////////////////////////////////////////////
- // Orientation handling
- //
- // We can choose to lock the framework orientation or not. If we lock the
- // framework orientation, we calculate a a compensation value according to
- // current device orientation and send it to listeners. If we don't lock
- // the framework orientation, we always set the compensation value to 0.
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * Lock the framework orientation to the current device orientation
- * rotates. No effect if the system setting of auto-rotation is off.
- */
- public void lockOrientation() {
- if (mOrientationLocked || mRotationLockedSetting) return;
- mOrientationLocked = true;
- if (ApiHelper.HAS_ORIENTATION_LOCK) {
- mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
- } else {
- mActivity.setRequestedOrientation(calculateCurrentScreenOrientation());
- }
- }
-
- /**
- * Unlock the framework orientation, so it can change when the device
- * rotates. No effect if the system setting of auto-rotation is off.
- */
- public void unlockOrientation() {
- if (!mOrientationLocked || mRotationLockedSetting) return;
- mOrientationLocked = false;
- Log.d(TAG, "unlock orientation");
- mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
- }
-
private int calculateCurrentScreenOrientation() {
int displayRotation = getDisplayRotation();
// Display rotation >= 180 means we need to use the REVERSE landscape/portrait
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 0938ffc19..dedf3d583 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -39,6 +39,7 @@ import java.util.ArrayList;
import org.codeaurora.snapcam.R;
import com.android.camera.ui.ModuleSwitcher;
+import com.android.camera.ui.RotateImageView;
import com.android.camera.ShutterButton;
import com.android.camera.util.CameraUtil;
@@ -80,6 +81,7 @@ public class CameraControls extends RotatableLayout {
private LinearLayout mRemainingPhotos;
private TextView mRemainingPhotosText;
+ private int mOrientation;
private int mPreviewRatio;
private static int mTopMargin = 0;
@@ -776,34 +778,22 @@ public class CameraControls extends RotatableLayout {
int h = mRemainingPhotos.getMeasuredHeight();
int m = getResources().getDimensionPixelSize(R.dimen.remaining_photos_margin);
- int hc, vc;
- int rotation = getUnifiedRotation();
- switch (rotation) {
- case 90:
- hc = (rl + rr) / 2 - m;
- vc = (rt + rb) / 2;
- break;
- case 180:
- hc = (rl + rr) / 2;
- vc = (rt + rb) / 2 + m;
- break;
- case 270:
- hc = (rl + rr) / 2 + m;
- vc = (rt + rb) / 2;
- break;
- default:
- hc = (rl + rr) / 2;
- vc = (rt + rb) / 2 - m;
- break;
+ int hc = (rl + rr) / 2;
+ int vc = (rt + rb) / 2 - m;
+ if (mOrientation == 90 || mOrientation == 270) {
+ vc -= w / 2;
}
mRemainingPhotos.layout(hc - w / 2, vc - h / 2, hc + w / 2, vc + h / 2);
+ mRemainingPhotos.setRotation(-mOrientation);
}
public void updateRemainingPhotos(int remaining) {
if (remaining < 0) {
mRemainingPhotos.setVisibility(View.GONE);
} else {
- mRemainingPhotos.setVisibility(View.VISIBLE);
+ for (int i = mRemainingPhotos.getChildCount() - 1; i >= 0; --i) {
+ mRemainingPhotos.getChildAt(i).setVisibility(View.VISIBLE);
+ }
mRemainingPhotosText.setText(remaining + " ");
}
}
@@ -829,6 +819,18 @@ public class CameraControls extends RotatableLayout {
mRemainingPhotos.setVisibility(show ? View.GONE : View.VISIBLE);
}
+ public void setOrientation(int orientation, boolean animation) {
+ mOrientation = orientation;
+ View[] views = {
+ mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
+ mHdrSwitcher, mMenu, mShutter, mPreview, mSwitcher
+ };
+ for (View v : views) {
+ ((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;
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
index daaefc027..42eebaa98 100644
--- a/src/com/android/camera/ui/CameraRootView.java
+++ b/src/com/android/camera/ui/CameraRootView.java
@@ -118,7 +118,7 @@ public class CameraRootView extends FrameLayout {
.unregisterDisplayListener((DisplayListener) mDisplayListener);
}
}
-
+/*
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
@@ -191,4 +191,5 @@ public class CameraRootView extends FrameLayout {
}
}
}
+*/
}
diff --git a/src/com/android/camera/ui/CountDownView.java b/src/com/android/camera/ui/CountDownView.java
index d479b684a..f6d163624 100644
--- a/src/com/android/camera/ui/CountDownView.java
+++ b/src/com/android/camera/ui/CountDownView.java
@@ -147,4 +147,13 @@ public class CountDownView extends FrameLayout {
}
}
}
+
+ public void setOrientation(int orientation) {
+ mRemainingSecondsView.setRotation(-orientation);
+ if (orientation == 0) {
+ mCountDownTitle.setVisibility(View.VISIBLE);
+ } else {
+ mCountDownTitle.setVisibility(View.GONE);
+ }
+ }
}
diff --git a/src/com/android/camera/ui/ListSubMenu.java b/src/com/android/camera/ui/ListSubMenu.java
index af38b162a..3501af3bc 100644
--- a/src/com/android/camera/ui/ListSubMenu.java
+++ b/src/com/android/camera/ui/ListSubMenu.java
@@ -80,16 +80,6 @@ public class ListSubMenu extends ListView implements
}
}
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {
- int screenHeight = ((LinearLayout) getParent()).getHeight();
- super.onLayout(changed, l, t, r, b);
- setY(Math.max(0, mY));
- if (mY + (b - t) > screenHeight) {
- setY(Math.max(0, mY - (mY + (b - t) - screenHeight)));
- }
- }
-
public void initialize(ListPreference preference, int y) {
mPreference = preference;
Context context = getContext();
@@ -154,4 +144,14 @@ public class ListSubMenu extends ListView implements
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
+
+ public int getPreCalculatedHeight() {
+ int count = getAdapter().getCount();
+ return count * (int) getContext().getResources().getDimension(R.dimen.setting_row_height)
+ + (count - 1) * getDividerHeight();
+ }
+
+ public int getYBase() {
+ return mY;
+ }
}
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
index 8539eb64c..e394aba0b 100644
--- a/src/com/android/camera/ui/RotateLayout.java
+++ b/src/com/android/camera/ui/RotateLayout.java
@@ -22,6 +22,8 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
// A RotateLayout is designed to display a single item and provides the
// capabilities to rotate the item.
public class RotateLayout extends ViewGroup implements Rotatable {
@@ -42,9 +44,25 @@ public class RotateLayout extends ViewGroup implements Rotatable {
@Override
protected void onFinishInflate() {
- mChild = getChildAt(0);
- mChild.setPivotX(0);
- mChild.setPivotY(0);
+ setupChild(getChildAt(0));
+ }
+
+ private void setupChild(View child) {
+ if (child != null) {
+ mChild = child;
+ child.setPivotX(0);
+ child.setPivotY(0);
+ }
+ }
+
+ public void addView(View child) {
+ super.addView(child);
+ setupChild(child);
+ }
+
+ public void removeView(View v) {
+ super.removeView(v);
+ mOrientation = 0;
}
@Override
@@ -52,21 +70,22 @@ public class RotateLayout extends ViewGroup implements Rotatable {
boolean change, int left, int top, int right, int bottom) {
int width = right - left;
int height = bottom - top;
+ int p = getPaddingTop();
switch (mOrientation) {
case 0:
case 180:
- mChild.layout(0, 0, width, height);
+ mChild.layout(p, p, width - p, height - p);
break;
case 90:
case 270:
- mChild.layout(0, 0, height, width);
+ mChild.layout(p, p, height - p, width - p);
break;
}
}
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
- int w = 0, h = 0;
+ int w = 0, h = 0, p = getPaddingTop();
switch(mOrientation) {
case 0:
case 180:
@@ -81,7 +100,7 @@ public class RotateLayout extends ViewGroup implements Rotatable {
h = mChild.getMeasuredWidth();
break;
}
- setMeasuredDimension(w, h);
+ setMeasuredDimension(w + 2 * p, h + 2 * p);
switch (mOrientation) {
case 0:
@@ -109,13 +128,25 @@ public class RotateLayout extends ViewGroup implements Rotatable {
return false;
}
- // Rotate the view counter-clockwise
@Override
public void setOrientation(int orientation, boolean animation) {
orientation = orientation % 360;
if (mOrientation == orientation) return;
+
+ if (getParent() instanceof FrameLayout) {
+ int diff = (orientation - mOrientation + 360) % 360;
+ if (diff == 90) {
+ RotatableLayout.rotateCounterClockwise(this);
+ } else if (diff == 180) {
+ RotatableLayout.rotateClockwise(this);
+ RotatableLayout.rotateClockwise(this);
+ } else if (diff == 270) {
+ RotatableLayout.rotateClockwise(this);
+ }
+ }
mOrientation = orientation;
- requestLayout();
+ if (mChild != null)
+ requestLayout();
}
public int getOrientation() {
diff --git a/src/com/android/camera/ui/RotateTextToast.java b/src/com/android/camera/ui/RotateTextToast.java
index 10d97bf73..2bea5bbda 100644
--- a/src/com/android/camera/ui/RotateTextToast.java
+++ b/src/com/android/camera/ui/RotateTextToast.java
@@ -16,31 +16,51 @@
package com.android.camera.ui;
+import java.util.HashSet;
+
import android.app.Activity;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.widget.Toast;
import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
public class RotateTextToast {
- private static final int TOAST_DURATION = 5000; // milliseconds
- ViewGroup mLayoutRoot;
- RotateLayout mToast;
- Handler mHandler;
+ private static final int LONG_DELAY = 3500;
+ private static final int SHORT_DELAY = 2000;
+
+ private ViewGroup mLayoutRoot;
+ private RotateLayout mToast;
+ private Handler mHandler;
+ private int mDuration;
+
+ private static HashSet<RotateLayout> mToasts = new HashSet<RotateLayout>();
+ private static int mOrientation;
- public RotateTextToast(Activity activity, int textResourceId, int orientation) {
+ private RotateTextToast(Activity activity, int duration) {
mLayoutRoot = (ViewGroup) activity.getWindow().getDecorView();
LayoutInflater inflater = activity.getLayoutInflater();
View v = inflater.inflate(R.layout.rotate_text_toast, mLayoutRoot);
mToast = (RotateLayout) v.findViewById(R.id.rotate_toast);
+ mToast.setOrientation(mOrientation, false);
+ mHandler = new Handler();
+ mDuration = duration == Toast.LENGTH_LONG ? LONG_DELAY : SHORT_DELAY;
+ }
+
+ public RotateTextToast(Activity activity, CharSequence text, int duration) {
+ this(activity, duration);
+ TextView tv = (TextView) mToast.findViewById(R.id.message);
+ tv.setText(text);
+ }
+
+ public RotateTextToast(Activity activity, int textResourceId, int duration) {
+ this(activity, duration);
TextView tv = (TextView) mToast.findViewById(R.id.message);
tv.setText(textResourceId);
- mToast.setOrientation(orientation, false);
- mHandler = new Handler();
}
private final Runnable mRunnable = new Runnable() {
@@ -48,12 +68,29 @@ public class RotateTextToast {
public void run() {
CameraUtil.fadeOut(mToast);
mLayoutRoot.removeView(mToast);
+ mToasts.remove(mToast);
mToast = null;
}
};
public void show() {
+ mToasts.add(mToast);
mToast.setVisibility(View.VISIBLE);
- mHandler.postDelayed(mRunnable, TOAST_DURATION);
+ mHandler.postDelayed(mRunnable, mDuration);
+ }
+
+ public static RotateTextToast makeText(Activity activity, int textResourceId, int duration) {
+ return new RotateTextToast(activity, textResourceId, duration);
+ }
+
+ public static RotateTextToast makeText(Activity activity, CharSequence text, int duration) {
+ return new RotateTextToast(activity, text, duration);
+ }
+
+ public static void setOrientation(int orientation) {
+ mOrientation = orientation;
+ for (final RotateLayout toast: mToasts) {
+ toast.setOrientation(orientation, false);
+ }
}
}
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index dbd2cc36d..debc04939 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -57,6 +57,7 @@ import com.android.camera.CameraDisabledException;
import com.android.camera.CameraHolder;
import com.android.camera.CameraManager;
import com.android.camera.CameraSettings;
+import com.android.camera.ui.RotateTextToast;
import com.android.camera.util.IntentHelper;
import org.codeaurora.snapcam.R;
@@ -1009,7 +1010,7 @@ public class CameraUtil {
activity.finish();
}
} catch (ActivityNotFoundException e) {
- Toast.makeText(activity, activity.getString(R.string.video_err),
+ RotateTextToast.makeText(activity, activity.getString(R.string.video_err),
Toast.LENGTH_SHORT).show();
}
}
@@ -1044,7 +1045,8 @@ public class CameraUtil {
activity.startActivity(mapsIntent);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Map view activity not found!", ex);
- Toast.makeText(activity, activity.getString(R.string.map_activity_not_found_err),
+ RotateTextToast.makeText(activity,
+ activity.getString(R.string.map_activity_not_found_err),
Toast.LENGTH_SHORT).show();
}
}