summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2009-09-01 14:51:53 +0800
committerOwen Lin <owenlin@google.com>2009-09-07 18:56:20 +0800
commit2c6c6174e2363fccb4e4f29b76290e99234fe140 (patch)
tree4de545668415f066488ee1a0016a05a9cbeeb556
parentc0a98e8814a39e6c6b6e87425d9fbd0585009f3f (diff)
downloadLegacyCamera-2c6c6174e2363fccb4e4f29b76290e99234fe140.zip
LegacyCamera-2c6c6174e2363fccb4e4f29b76290e99234fe140.tar.gz
LegacyCamera-2c6c6174e2363fccb4e4f29b76290e99234fe140.tar.bz2
First version of on-screen settings for Camera.
Change-Id: I6e608b5b2d02abf3d1901160adba188399b03542
-rw-r--r--res/layout/detailsview.xml367
-rw-r--r--res/layout/on_screen_menu.xml32
-rw-r--r--res/layout/on_screen_menu_checkbox_item.xml42
-rw-r--r--res/layout/on_screen_menu_header.xml24
-rw-r--r--res/layout/on_screen_menu_list_item.xml38
-rw-r--r--res/layout/on_screen_submenu_cancel.xml29
-rw-r--r--res/layout/on_screen_submenu_header.xml25
-rw-r--r--res/layout/on_screen_submenu_item.xml39
-rw-r--r--res/values/ids.xml22
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/android/camera/Camera.java93
-rw-r--r--src/com/android/camera/CameraSettingsHelper.java140
-rw-r--r--src/com/android/camera/OnScreenSettings.java433
-rw-r--r--src/com/android/camera/Util.java57
14 files changed, 1094 insertions, 250 deletions
diff --git a/res/layout/detailsview.xml b/res/layout/detailsview.xml
index d38ec3b..ff32f91 100644
--- a/res/layout/detailsview.xml
+++ b/res/layout/detailsview.xml
@@ -19,225 +19,182 @@
android:layout_width="300dip"
android:layout_height="fill_parent">
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="5dip"
- android:paddingRight="5dip"
- android:paddingBottom="10dp">
-
- <LinearLayout
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content">
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="5dip"
+ android:paddingRight="5dip"
+ android:paddingBottom="10dp">
- <LinearLayout
- android:orientation="horizontal"
- android:gravity="center_vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/detail_photo_border">
- <ImageView
- android:id="@+id/details_thumbnail_image"
- android:layout_width="64dip"
- android:layout_height="64dip"/>
- </LinearLayout>
+ <LinearLayout android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
- <TextView
- android:id="@+id/details_image_title"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:paddingLeft="6dip"
- android:layout_weight="1"/>
-
- </LinearLayout>
+ <LinearLayout android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/detail_photo_border">
+ <ImageView android:id="@+id/details_thumbnail_image"
+ android:layout_width="64dip"
+ android:layout_height="64dip"/>
+ </LinearLayout>
+ <TextView android:id="@+id/details_image_title"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:paddingLeft="6dip"
+ android:layout_weight="1"/>
+
+ </LinearLayout>
+ <TableLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="5dip"
+ android:layout_marginTop="10dip">
+
+ <TableRow>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_file_size"/>
+ <TextView android:id="@+id/details_file_size_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
- <TableLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingLeft="5dip"
- android:layout_marginTop="10dip">
-
- <TableRow>
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_file_size"/>
- <TextView
- android:id="@+id/details_file_size_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
-
- <TableRow android:id="@+id/details_resolution_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_resolution"/>
- <TextView
- android:id="@+id/details_resolution_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
+ <TableRow android:id="@+id/details_resolution_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_resolution"/>
+ <TextView android:id="@+id/details_resolution_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
<TableRow android:id="@+id/details_make_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_make"/>
- <TextView
- android:id="@+id/details_make_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_make"/>
+ <TextView android:id="@+id/details_make_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
<TableRow android:id="@+id/details_model_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_model"/>
- <TextView
- android:id="@+id/details_model_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_model"/>
+ <TextView android:id="@+id/details_model_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
<TableRow android:id="@+id/details_whitebalance_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_whitebalance"/>
- <TextView
- android:id="@+id/details_whitebalance_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_whitebalance"/>
+ <TextView android:id="@+id/details_whitebalance_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
<TableRow android:id="@+id/details_latitude_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_latitude"/>
- <TextView
- android:id="@+id/details_latitude_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_latitude"/>
+ <TextView android:id="@+id/details_latitude_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
<TableRow android:id="@+id/details_longitude_row"> <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_longitude"/>
- <TextView
- android:id="@+id/details_longitude_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_longitude"/>
+ <TextView android:id="@+id/details_longitude_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
<TableRow android:id="@+id/details_location_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_image_location"/>
- <TextView
- android:id="@+id/details_location_value"
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_image_location"/>
+ <TextView android:id="@+id/details_location_value"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ <TableRow android:id="@+id/details_duration_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_duration"/>
+ <TextView android:id="@+id/details_duration_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ <TableRow android:id="@+id/details_frame_rate_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_frame_rate"/>
+ <TextView android:id="@+id/details_frame_rate_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
</TableRow>
- <TableRow
- android:id="@+id/details_duration_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_duration"/>
- <TextView
- android:id="@+id/details_duration_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
- <TableRow
- android:id="@+id/details_frame_rate_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_frame_rate"/>
- <TextView
- android:id="@+id/details_frame_rate_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
-
- <TableRow
- android:id="@+id/details_bit_rate_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_bit_rate"/>
- <TextView
- android:id="@+id/details_bit_rate_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
- <TableRow
- android:id="@+id/details_format_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_format"/>
- <TextView
- android:id="@+id/details_format_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
- <TableRow
- android:id="@+id/details_codec_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_codec"/>
- <TextView
- android:id="@+id/details_codec_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
- <TableRow
- android:id="@+id/details_date_taken_row">
- <TextView
- android:gravity="right"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/details_date_taken"/>
- <TextView
- android:id="@+id/details_date_taken_value"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:paddingLeft="5dip"
- android:textColor="?android:attr/textColorPrimary"/>
- </TableRow>
- </TableLayout>
-
- </LinearLayout>
+ <TableRow android:id="@+id/details_bit_rate_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_bit_rate"/>
+ <TextView android:id="@+id/details_bit_rate_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ <TableRow android:id="@+id/details_format_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_format"/>
+ <TextView android:id="@+id/details_format_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ <TableRow android:id="@+id/details_codec_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_codec"/>
+ <TextView android:id="@+id/details_codec_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ <TableRow android:id="@+id/details_date_taken_row">
+ <TextView android:gravity="right"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:text="@string/details_date_taken"/>
+ <TextView android:id="@+id/details_date_taken_value"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:paddingLeft="5dip"
+ android:textColor="?android:attr/textColorPrimary"/>
+ </TableRow>
+ </TableLayout>
+ </LinearLayout>
</ScrollView>
diff --git a/res/layout/on_screen_menu.xml b/res/layout/on_screen_menu.xml
new file mode 100644
index 0000000..26a9400
--- /dev/null
+++ b/res/layout/on_screen_menu.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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:padding="10dip"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <ListView android:id="@+id/menu_view"
+ android:background="#88333333"
+ android:cacheColorHint="#00000000"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ <ListView android:id="@+id/sub_menu"
+ android:background="#88333333"
+ android:visibility="invisible"
+ android:cacheColorHint="#00000000"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+</FrameLayout>
diff --git a/res/layout/on_screen_menu_checkbox_item.xml b/res/layout/on_screen_menu_checkbox_item.xml
new file mode 100644
index 0000000..5de3be0
--- /dev/null
+++ b/res/layout/on_screen_menu_checkbox_item.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp" >
+
+ <TextView android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <CheckBox android:id="@+id/check_box"
+ android:layout_weight="0"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:clickable="false"
+ android:focusable="false" />
+</LinearLayout>
+
+
+
diff --git a/res/layout/on_screen_menu_header.xml b/res/layout/on_screen_menu_header.xml
new file mode 100644
index 0000000..d960419
--- /dev/null
+++ b/res/layout/on_screen_menu_header.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/title"
+ android:background="#88111111"
+ android:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true" />
diff --git a/res/layout/on_screen_menu_list_item.xml b/res/layout/on_screen_menu_list_item.xml
new file mode 100644
index 0000000..f862d01
--- /dev/null
+++ b/res/layout/on_screen_menu_list_item.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingLeft="10dp"
+ android:paddingRight="5dp" >
+
+ <TextView android:id="@+id/title"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+
+ <TextView android:id="@+id/summary"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/title"
+ android:layout_alignLeft="@id/title"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true" />
+</RelativeLayout>
diff --git a/res/layout/on_screen_submenu_cancel.xml b/res/layout/on_screen_submenu_cancel.xml
new file mode 100644
index 0000000..9bcf8a3
--- /dev/null
+++ b/res/layout/on_screen_submenu_cancel.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center">
+ <TextView android:id="@+id/cancel"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:layout_marginBottom="5dp"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="@string/on_screen_menu_back" />
+</LinearLayout>
diff --git a/res/layout/on_screen_submenu_header.xml b/res/layout/on_screen_submenu_header.xml
new file mode 100644
index 0000000..860f3ee
--- /dev/null
+++ b/res/layout/on_screen_submenu_header.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/title"
+ android:background="#88222222"
+ android:gravity="center"
+ android:layout_marginRight="5dp"
+ android:layout_marginLeft="5dp"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true" />
diff --git a/res/layout/on_screen_submenu_item.xml b/res/layout/on_screen_submenu_item.xml
new file mode 100644
index 0000000..fb28438
--- /dev/null
+++ b/res/layout/on_screen_submenu_item.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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:paddingLeft="5dp"
+ android:paddingRight="5dp"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical" >
+ <TextView android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:ellipsize="marquee"
+ android:fadingEdge="horizontal" />
+ <RadioButton android:id="@+id/radio_button"
+ android:focusable="false"
+ android:clickable="false"
+ android:layout_weight="0"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+</LinearLayout>
+
+
+
diff --git a/res/values/ids.xml b/res/values/ids.xml
deleted file mode 100644
index 44dfd1a..0000000
--- a/res/values/ids.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-**
-** Copyright 2007, 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.
-*/
--->
-<resources>
-</resources>
-
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1bdb3a6..7e0920e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -585,4 +585,7 @@
<!-- The messsage shown when video record reaches size limit. -->
<string name="video_reach_size_limit">Size limit reached.</string>
+ <!-- The title of the menu item for users to go back to the main menu from the sub menu -->
+ <string name="on_screen_menu_back">Back</string>
+
</resources>
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 2755f34..abd1257 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -44,6 +45,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
import android.provider.MediaStore;
import android.text.format.DateFormat;
import android.util.AttributeSet;
@@ -74,14 +76,14 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
/**
* Activity of the Camera which used to see preview and take pictures.
*/
public class Camera extends Activity implements View.OnClickListener,
ShutterButton.OnShutterButtonListener, SurfaceHolder.Callback,
- Switcher.OnSwitchListener, FlashButton.ModeChangeListener {
+ Switcher.OnSwitchListener, FlashButton.ModeChangeListener,
+ OnSharedPreferenceChangeListener {
private static final String TAG = "camera";
@@ -219,6 +221,7 @@ public class Camera extends Activity implements View.OnClickListener,
private String mFocusMode;
private final Handler mHandler = new MainHandler();
+ private OnScreenSettings mSettings;
/**
* This Handler is used to post message back onto the main thread of the
@@ -860,6 +863,7 @@ public class Camera extends Activity implements View.OnClickListener,
mViewFinderWidth = mSurfaceView.getLayoutParams().width;
mViewFinderHeight = mSurfaceView.getLayoutParams().height;
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ mPreferences.registerOnSharedPreferenceChangeListener(this);
/*
* To reduce startup time, we start the preview in another thread.
@@ -1181,6 +1185,10 @@ public class Camera extends Activity implements View.OnClickListener,
// Close the camera now because other activities may need to use it.
closeCamera();
+ if (mSettings != null && mSettings.isVisible()) {
+ mSettings.setVisible(false);
+ }
+
if (mFirstTimeInitialized) {
mOrientationListener.disable();
mGpsIndicator.setVisibility(View.INVISIBLE);
@@ -1547,20 +1555,10 @@ public class Camera extends Activity implements View.OnClickListener,
mParameters.setPreviewSize(mViewFinderWidth, mViewFinderHeight);
// Set picture size.
- List<Size> pictureSizes = mParameters.getSupportedPictureSizes();
- if (pictureSizes != null) {
- String str = mPreferences.getString(
- CameraSettings.KEY_PICTURE_SIZE,
- getString(R.string.pref_camera_picturesize_default));
- int width = Integer.parseInt(str.substring(0, str.indexOf('x')));
- int height = Integer.parseInt(str.substring(str.indexOf('x') + 1));
- for (Size size: pictureSizes) {
- if (size.width == width && size.height == height) {
- mParameters.setPictureSize(width, height);
- break;
- }
- }
- }
+ String pictureSize = mPreferences.getString(
+ CameraSettings.KEY_PICTURE_SIZE,
+ getString(R.string.pref_camera_picturesize_default));
+ setCameraPictureSizeIfSupported(pictureSize);
// Set JPEG quality.
String jpegQuality = mPreferences.getString(
@@ -1749,13 +1747,15 @@ public class Camera extends Activity implements View.OnClickListener,
0, R.string.settings)
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
- // Keep the camera instance for a while.
- // This avoids re-opening the camera and saves time.
- CameraHolder.instance().keep();
-
- Intent intent = new Intent();
- intent.setClass(Camera.this, CameraSettings.class);
- startActivity(intent);
+ if (mSettings == null) {
+ mSettings = new OnScreenSettings(
+ findViewById(R.id.camera_preview));
+ CameraSettingsHelper helper =
+ new CameraSettingsHelper(Camera.this, mParameters);
+ PreferenceScreen screen = helper.getPreferenceScreen();
+ mSettings.setPreferenceScreen(screen);
+ }
+ mSettings.setVisible(true);
return true;
}
});
@@ -1778,6 +1778,53 @@ public class Camera extends Activity implements View.OnClickListener,
editor.putString(CameraSettings.KEY_FLASH_MODE, modeString);
editor.commit();
}
+
+ private void setCameraPictureSizeIfSupported(String sizeString) {
+ List<Size> pictureSizes = mParameters.getSupportedPictureSizes();
+ if (pictureSizes != null) {
+ int index = sizeString.indexOf('x');
+ int width = Integer.parseInt(sizeString.substring(0, index));
+ int height = Integer.parseInt(sizeString.substring(index + 1));
+ for (Size size: pictureSizes) {
+ if (size.width == width && size.height == height) {
+ mParameters.setPictureSize(width, height);
+ break;
+ }
+ }
+ }
+ }
+
+ public void onSharedPreferenceChanged(
+ SharedPreferences preferences, String key) {
+ // ignore the events after "onPause()"
+ if (mPausing) return;
+
+ if (CameraSettingsHelper.KEY_FLASH_MODE.equals(key)) {
+ mParameters.setFlashMode(preferences.getString(key, "auto"));
+ mCameraDevice.setParameters(mParameters);
+ } else if (CameraSettingsHelper.KEY_FOCUS_MODE.equals(key)) {
+ mFocusMode = preferences.getString(key,
+ getString(R.string.pref_camera_focusmode_default));
+ } else if (CameraSettingsHelper.KEY_PICTURE_SIZE.equals(key)) {
+ String pictureSize = preferences.getString(key,
+ getString(R.string.pref_camera_picturesize_default));
+ setCameraPictureSizeIfSupported(pictureSize);
+ mCameraDevice.setParameters(mParameters);
+ } else if (CameraSettingsHelper.KEY_JPEG_QUALITY.equals(key)) {
+ String jpegQuality = preferences.getString(key,
+ getString(R.string.pref_camera_jpegquality_default));
+ mParameters.setJpegQuality(Integer.parseInt(jpegQuality));
+ mCameraDevice.setParameters(mParameters);
+ } else if (CameraSettingsHelper.KEY_RECORD_LOCATION.equals(key)) {
+ mRecordLocation = preferences.getBoolean(key, false);
+ if (mRecordLocation) {
+ startReceivingLocationUpdates();
+ } else {
+ stopReceivingLocationUpdates();
+ }
+ }
+ }
+
}
class FocusRectangle extends View {
diff --git a/src/com/android/camera/CameraSettingsHelper.java b/src/com/android/camera/CameraSettingsHelper.java
new file mode 100644
index 0000000..6b86d8b
--- /dev/null
+++ b/src/com/android/camera/CameraSettingsHelper.java
@@ -0,0 +1,140 @@
+package com.android.camera;
+
+import android.app.Activity;
+import android.content.Context;
+import android.hardware.Camera.Parameters;
+import android.hardware.Camera.Size;
+import android.os.SystemProperties;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceGroup;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CameraSettingsHelper {
+ private static final int FIRST_REQUEST_CODE = 100;
+ public static final String KEY_RECORD_LOCATION =
+ "pref_camera_recordlocation_key";
+ public static final String KEY_VIDEO_QUALITY =
+ "pref_camera_videoquality_key";
+ public static final String KEY_VIDEO_DURATION =
+ "pref_camera_video_duration_key";
+ public static final String KEY_PICTURE_SIZE = "pref_camera_picturesize_key";
+ public static final String KEY_JPEG_QUALITY = "pref_camera_jpegquality_key";
+ public static final String KEY_FOCUS_MODE = "pref_camera_focusmode_key";
+ public static final String KEY_FLASH_MODE = "pref_camera_flashmode_key";
+
+ // max mms video duration in seconds.
+ public static final int MMS_VIDEO_DURATION =
+ SystemProperties.getInt("ro.media.enc.lprof.duration", 60);
+
+ private static final boolean DEFAULT_VIDEO_QUALITY_VALUE = true;
+
+ //MMS video length
+ private static final int DEFAULT_VIDEO_DURATION_VALUE = -1;
+ private static final String TAG = "CameraSettingsHelper";
+
+
+ private final Context mContext;
+ private final Parameters mParameters;
+ private final PreferenceScreen mScreen;
+
+ public CameraSettingsHelper(Activity activity, Parameters parameters) {
+ mContext = activity;
+ mParameters = parameters;
+ PreferenceManager manager =
+ new PreferenceManager(activity, FIRST_REQUEST_CODE);
+ mScreen = manager.createPreferenceScreen(activity);
+ manager.inflateFromResource(
+ activity, R.xml.camera_preferences, mScreen);
+ initPreference(mScreen);
+ }
+
+ public PreferenceScreen getPreferenceScreen() {
+ return mScreen;
+ }
+
+ private void setDefault(String key, int strRes) {
+ ListPreference pref = (ListPreference) mScreen.findPreference(key);
+ if (pref.getValue() == null) pref.setValue(mContext.getString(strRes));
+ }
+
+ private void initPreference(PreferenceScreen screen) {
+
+ ListPreference videoDuration =
+ (ListPreference) screen.findPreference(KEY_VIDEO_DURATION);
+
+ // Modify video duration settings.
+ // The first entry is for MMS video duration, and we need to fill in the
+ // device-dependent value (in seconds).
+ CharSequence[] entries = videoDuration.getEntries();
+ entries[0] = String.format(entries[0].toString(), MMS_VIDEO_DURATION);
+
+ // Create picture size settings.
+ filterSupportedSizes(screen);
+ setDefault(KEY_JPEG_QUALITY, R.string.pref_camera_jpegquality_default);
+ setDefault(KEY_FOCUS_MODE, R.string.pref_camera_focusmode_default);
+ }
+
+ private boolean removePreference(PreferenceGroup group, Preference remove) {
+ if (group.removePreference(remove)) return true;
+
+ for (int i = 0; i < group.getPreferenceCount(); i++) {
+ final Preference child = group.getPreference(i);
+ if (child instanceof PreferenceGroup) {
+ if (removePreference((PreferenceGroup) child, remove)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean isSupported(List<Size> supported, String required) {
+ int index = required.indexOf('x');
+ int width = Integer.parseInt(required.substring(0, index));
+ int height = Integer.parseInt(required.substring(index + 1));
+ for (Size size : supported) {
+ if (size.width == width && size.height == height) return true;
+ }
+ return false;
+ }
+
+ private void filterSupportedSizes(PreferenceScreen screen) {
+ ListPreference pref =
+ (ListPreference) screen.findPreference(KEY_PICTURE_SIZE);
+
+ // Remove the preference if the parameter is not supported.
+ List<Size> supportedSizes = mParameters.getSupportedPictureSizes();
+ if (supportedSizes == null) {
+ removePreference(screen, pref);
+ return;
+ }
+
+ // Prepare setting entries and entry values.
+ CharSequence[] allEntries = pref.getEntries();
+ CharSequence[] allEntryValues = pref.getEntryValues();
+ ArrayList<CharSequence> entries = new ArrayList<CharSequence>();
+ ArrayList<CharSequence> entryValues = new ArrayList<CharSequence>();
+ for (int i = 0, len = allEntryValues.length; i < len; i++) {
+ if (isSupported(supportedSizes, allEntryValues[i].toString())) {
+ entries.add(allEntries[i]);
+ entryValues.add(allEntryValues[i]);
+ }
+ }
+
+ // Set entries and entry values to list preference.
+ pref.setEntries(entries.toArray(new CharSequence[entries.size()]));
+ pref.setEntryValues(entryValues.toArray(
+ new CharSequence[entryValues.size()]));
+
+ // Set the value to the first entry if it is invalid.
+ String value = pref.getValue();
+ if (pref.findIndexOfValue(value) == -1) {
+ pref.setValueIndex(0);
+ }
+ }
+}
diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java
new file mode 100644
index 0000000..b465f85
--- /dev/null
+++ b/src/com/android/camera/OnScreenSettings.java
@@ -0,0 +1,433 @@
+package com.android.camera;
+
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.os.Handler;
+import android.os.Message;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceGroup;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+import android.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.CheckBox;
+import android.widget.FrameLayout;
+import android.widget.ListView;
+import android.widget.RadioButton;
+import android.widget.TextView;
+import android.widget.AdapterView.OnItemClickListener;
+
+import java.util.ArrayList;
+
+// Please reference to {@link android.widget.ZoomButtonsController} for detail
+// information about adding window to WindowManager.
+public class OnScreenSettings {
+ private static final String TAG = "OnScreenSettings";
+ private static final int MSG_POST_SET_VISIBLE = 1;
+
+ private LayoutParams mContainerLayoutParams;
+ private final Context mContext;
+ private final Container mContainer;
+ private final WindowManager mWindowManager;
+ private final View mOwnerView;
+ private ListView mMainMenu;
+ private ListView mSubMenu;
+ private boolean mIsVisible = false;
+
+ /**
+ * When showing the on-screen settings, we add the view as a new window.
+ * However, there is logic that needs to know the size of the zoom which
+ * is determined after it's laid out. Therefore, we must post this logic
+ * onto the UI thread so it will be exceuted AFTER the layout. This is
+ * the logic.
+ */
+ private Runnable mPostedVisibleInitializer;
+ private final LayoutInflater mInflater;
+
+ private final Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_POST_SET_VISIBLE:
+ setVisible(true);
+ break;
+ }
+ }
+ };
+
+ public OnScreenSettings(View ownerView) {
+ mContext = ownerView.getContext();
+ mInflater = (LayoutInflater)
+ mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+ mWindowManager = (WindowManager)
+ mContext.getSystemService(Context.WINDOW_SERVICE);
+ mOwnerView = ownerView;
+ mContainer = createContainer();
+ }
+
+ public boolean isVisible() {
+ return mIsVisible;
+ }
+
+ public void setVisible(boolean visible) {
+ if (visible) {
+ if (mOwnerView.getWindowToken() == null) {
+ /*
+ * We need a window token to show ourselves, maybe the owner's
+ * window hasn't been created yet but it will have been by the
+ * time the looper is idle, so post the setVisible(true) call.
+ */
+ if (!mHandler.hasMessages(MSG_POST_SET_VISIBLE)) {
+ mHandler.sendEmptyMessage(MSG_POST_SET_VISIBLE);
+ }
+ return;
+ }
+ }
+
+ if (mIsVisible == visible) {
+ return;
+ }
+ mIsVisible = visible;
+
+ if (visible) {
+ if (mContainerLayoutParams.token == null) {
+ mContainerLayoutParams.token = mOwnerView.getWindowToken();
+ }
+ if (mPostedVisibleInitializer == null) {
+ mPostedVisibleInitializer = new Runnable() {
+ public void run() {
+ refreshPositioningVariables();
+ }
+ };
+ }
+ mWindowManager.addView(mContainer, mContainerLayoutParams);
+ mHandler.post(mPostedVisibleInitializer);
+ } else {
+ mWindowManager.removeView(mContainer);
+ mHandler.removeCallbacks(mPostedVisibleInitializer);
+ }
+ }
+
+ private void refreshPositioningVariables() {
+ // if the mOwnerView is detached from window then skip.
+ if (mOwnerView.getWindowToken() == null) return;
+
+ // Position the zoom controls on the bottom of the owner view.
+ int ownerHeight = mOwnerView.getHeight();
+ int ownerWidth = mOwnerView.getWidth();
+ // The gap between the top of the owner and the top of the container
+ int containerOwnerYOffset = ownerHeight - mContainer.getHeight();
+
+ // Calculate the owner view's bounds
+ int[] mOwnerViewRawLocation = new int[2];
+ mOwnerView.getLocationOnScreen(mOwnerViewRawLocation);
+
+ // lp.x and lp.y should be relative to the owner's window top-left
+ mContainerLayoutParams.x = mOwnerViewRawLocation[0];
+ mContainerLayoutParams.y = mOwnerViewRawLocation[1];
+
+ mContainerLayoutParams.width = ownerWidth * 4 / 5;
+ mContainerLayoutParams.height = ownerHeight - 10;
+
+ if (mIsVisible) {
+ mWindowManager.updateViewLayout(mContainer, mContainerLayoutParams);
+ }
+ }
+
+ private void showSubMenu() {
+ Util.slideOut(mMainMenu, Util.DIRECTION_LEFT);
+ Util.slideIn(mSubMenu, Util.DIRECTION_RIGHT);
+ }
+
+ private void closeSubMenu() {
+ Util.slideOut(mSubMenu, Util.DIRECTION_RIGHT);
+ Util.slideIn(mMainMenu, Util.DIRECTION_LEFT);
+
+ // The data could be changed in the sub menu, so we update the summary
+ // in the main menu here
+ ((MainMenuAdapter) mMainMenu.getAdapter()).notifyDataSetChanged();
+ }
+
+ private Container createContainer() {
+ LayoutParams lp = new LayoutParams(
+ LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
+ lp.flags = 0;
+ lp.gravity = Gravity.TOP | Gravity.LEFT;
+ lp.height = LayoutParams.WRAP_CONTENT;
+ lp.width = LayoutParams.WRAP_CONTENT;
+ lp.type = LayoutParams.TYPE_APPLICATION_PANEL;
+ lp.format = PixelFormat.TRANSPARENT;
+
+ mContainerLayoutParams = lp;
+
+ Container container = new Container(mContext);
+ container.setLayoutParams(lp);
+
+ mInflater.inflate(R.layout.on_screen_menu, container);
+
+ mMainMenu = (ListView) container.findViewById(R.id.menu_view);
+ mSubMenu = (ListView) container.findViewById(R.id.sub_menu);
+ return container;
+ }
+
+ private boolean onContainerKey(KeyEvent event) {
+ switch (event.getKeyCode()) {
+ case KeyEvent.KEYCODE_BACK:
+ if (event.getAction() == KeyEvent.ACTION_UP) {
+ setVisible(false);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Add the preference and it's children recursively to the given list. So
+ // that we can show the preference (and it's children) in the list view.
+ private static void addPreference(
+ Preference preference, ArrayList<Preference> list) {
+ list.add(preference);
+ if (preference instanceof PreferenceGroup) {
+ PreferenceGroup group = (PreferenceGroup) preference;
+ for (int i = 0, n = group.getPreferenceCount(); i < n; ++i) {
+ Preference child = group.getPreference(i);
+ addPreference(child, list);
+ }
+ }
+ }
+
+ public void setPreferenceScreen(PreferenceScreen screen) {
+ ArrayList<Preference> list = new ArrayList<Preference>();
+
+ // We don't want the screen add to the list, we add the first level
+ // preference here.
+ for (int i = 0, n = screen.getPreferenceCount(); i < n; ++i) {
+ addPreference(screen.getPreference(i), list);
+ }
+ MainMenuAdapter mainAdapter = new MainMenuAdapter(mContext, list);
+ mMainMenu.setAdapter(mainAdapter);
+ mMainMenu.setOnItemClickListener(mainAdapter);
+ }
+
+ private View inflateIfNeed(
+ View view, int resource, ViewGroup root, boolean attachToRoot) {
+ if (view != null) return view;
+ return mInflater.inflate(resource, root, attachToRoot);
+ }
+
+ private class MainMenuAdapter extends BaseAdapter
+ implements OnItemClickListener {
+ private final ArrayList<Preference> mPreferences;
+
+ public MainMenuAdapter(
+ Context context, ArrayList<Preference> preferences) {
+ mPreferences = preferences;
+ }
+
+ public void onItemClick(
+ AdapterView<?> parent, View view, int position, long id) {
+ Preference preference = mPreferences.get(position);
+ if (preference instanceof CheckBoxPreference) {
+ CheckBoxPreference ckPref = (CheckBoxPreference) preference;
+ ((CheckBox) view.findViewById(
+ R.id.check_box)).setChecked(!ckPref.isChecked());
+ ckPref.setChecked(!ckPref.isChecked());
+ } else if (preference instanceof ListPreference) {
+ SubMenuAdapter adapter = new SubMenuAdapter(
+ mContext, (ListPreference) preference);
+ mSubMenu.setAdapter(adapter);
+ mSubMenu.setOnItemClickListener(adapter);
+ showSubMenu();
+ }
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ Preference preference = mPreferences.get(position);
+
+ if (preference instanceof PreferenceGroup) {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_menu_header, parent, false);
+ PreferenceGroup group = (PreferenceGroup) preference;
+ ((TextView) convertView.findViewById(
+ R.id.title)).setText(group.getTitle());
+ } else if (preference instanceof CheckBoxPreference) {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_menu_checkbox_item, parent, false);
+ ((TextView) convertView.findViewById(
+ R.id.title)).setText(preference.getTitle());
+ CheckBox checkBox = ((CheckBox)
+ convertView.findViewById(R.id.check_box));
+ checkBox.setChecked(
+ ((CheckBoxPreference) preference).isChecked());
+ } else if (preference instanceof ListPreference) {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_menu_list_item, parent, false);
+ ((TextView) convertView.findViewById(
+ R.id.title)).setText(preference.getTitle());
+ ((TextView) convertView.findViewById(R.id.summary))
+ .setText(((ListPreference) preference).getEntry());
+ }
+ return convertView;
+ }
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ Preference preference = mPreferences.get(position);
+ return !(preference instanceof PreferenceGroup);
+ }
+
+ public int getCount() {
+ return mPreferences.size();
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ Preference pref = mPreferences.get(position);
+ if (pref instanceof PreferenceGroup) return 0;
+ if (pref instanceof ListPreference) return 1;
+ if (pref instanceof CheckBoxPreference) return 2;
+ throw new IllegalStateException();
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ // we have three type, see getItemViewType()
+ return 3;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return mPreferences.isEmpty();
+ }
+ }
+
+ private class SubMenuAdapter extends BaseAdapter
+ implements OnItemClickListener {
+ private final ListPreference mPreference;
+
+ public SubMenuAdapter(Context context, ListPreference preference) {
+ mPreference = preference;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ CharSequence entry[] = mPreference.getEntries();
+ if (position == 0) {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_submenu_header, parent, false);
+ ((TextView) convertView.findViewById(
+ R.id.title)).setText(mPreference.getDialogTitle());
+ } else if (position == entry.length + 1) {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_submenu_cancel, parent, false);
+ } else {
+ convertView = inflateIfNeed(convertView,
+ R.layout.on_screen_submenu_item, parent, false);
+ boolean checked = mPreference.getValue().equals(
+ mPreference.getEntryValues()[position - 1]);
+ ((TextView) convertView.findViewById(
+ R.id.title)).setText(entry[position - 1]);
+ RadioButton radio = ((RadioButton)
+ convertView.findViewById(R.id.radio_button));
+ radio.setChecked(checked);
+ }
+ return convertView;
+ }
+
+ @Override
+ public boolean areAllItemsEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isEnabled(int position) {
+ return getItemViewType(position) != 0;
+ }
+
+ public int getCount() {
+ // add one header and one cancel
+ return mPreference.getEntries().length + 2;
+ }
+
+ public Object getItem(int position) {
+ return null;
+ }
+
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (position == 0) return 0;
+ if (position == getCount() - 1) return 1;
+ return 2;
+ }
+
+ @Override
+ public int getViewTypeCount() {
+ return 3;
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return true;
+ }
+
+ public void onItemClick(
+ AdapterView<?> parent, View view, int position, long id) {
+ CharSequence entry[] = mPreference.getEntries();
+ if (position <= entry.length) {
+ mPreference.setValue(
+ mPreference.getEntryValues()[position - 1].toString());
+ notifyDataSetChanged();
+ }
+ closeSubMenu();
+ }
+ }
+
+ private class Container extends FrameLayout {
+ public Container(Context context) {
+ super(context);
+ }
+
+ /*
+ * Need to override this to intercept the key events. Otherwise, we
+ * would attach a key listener to the container but its superclass
+ * ViewGroup gives it to the focused View instead of calling the key
+ * listener, and so we wouldn't get the events.
+ */
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ return onContainerKey(event)
+ ? true
+ : super.dispatchKeyEvent(event);
+ }
+ }
+}
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index b1ad8d2..da9caf6 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -34,6 +34,8 @@ import android.os.ParcelFileDescriptor;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.animation.Animation;
+import android.view.animation.TranslateAnimation;
import com.android.camera.gallery.IImage;
@@ -47,6 +49,10 @@ import java.io.IOException;
*/
public class Util {
private static final String TAG = "Util";
+ public static final int DIRECTION_LEFT = 0;
+ public static final int DIRECTION_RIGHT = 1;
+ public static final int DIRECTION_UP = 2;
+ public static final int DIRECTION_DOWN = 3;
private static OnClickListener sNullOnClickListener;
@@ -532,4 +538,55 @@ public class Util {
.setNeutralButton(R.string.details_ok, buttonListener)
.show();
}
+
+ public static void slideOut(View view, int to) {
+ view.setVisibility(View.INVISIBLE);
+ Animation anim;
+ switch (to) {
+ case DIRECTION_LEFT:
+ anim = new TranslateAnimation(0, -view.getWidth(), 0, 0);
+ break;
+ case DIRECTION_RIGHT:
+ anim = new TranslateAnimation(0, view.getWidth(), 0, 0);
+ break;
+ case DIRECTION_UP:
+ anim = new TranslateAnimation(0, 0, 0, -view.getHeight());
+ break;
+ case DIRECTION_DOWN:
+ anim = new TranslateAnimation(0, 0, 0, view.getHeight());
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(to));
+ }
+ anim.setDuration(500);
+ view.startAnimation(anim);
+ }
+
+ public static void slideIn(View view, int from) {
+ view.setVisibility(View.VISIBLE);
+ Animation anim;
+ switch (from) {
+ case DIRECTION_LEFT:
+ anim = new TranslateAnimation(-view.getWidth(), 0, 0, 0);
+ break;
+ case DIRECTION_RIGHT:
+ anim = new TranslateAnimation(view.getWidth(), 0, 0, 0);
+ break;
+ case DIRECTION_UP:
+ anim = new TranslateAnimation(0, 0, -view.getHeight(), 0);
+ break;
+ case DIRECTION_DOWN:
+ anim = new TranslateAnimation(0, 0, view.getHeight(), 0);
+ break;
+ default:
+ throw new IllegalArgumentException(Integer.toString(from));
+ }
+ anim.setDuration(500);
+ view.startAnimation(anim);
+ }
+
+ public static <T> T checkNotNull(T object) {
+ if (object == null) throw new NullPointerException();
+ return object;
+ }
}