summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheng-Ru Lin <owenlin@google.com>2009-09-26 04:46:06 +0800
committerCheng-Ru Lin <owenlin@google.com>2009-09-26 09:50:02 +0800
commita8bbcd7ce25aada705561852ea9f356dc38c0f43 (patch)
tree77e5030b3f1b167ecac9515f3c0612e70b481fdb
parentc801d7371323d59f584d8dddaae104d8775f48cd (diff)
downloadLegacyCamera-a8bbcd7ce25aada705561852ea9f356dc38c0f43.zip
LegacyCamera-a8bbcd7ce25aada705561852ea9f356dc38c0f43.tar.gz
LegacyCamera-a8bbcd7ce25aada705561852ea9f356dc38c0f43.tar.bz2
Change the checkbox style to list style for record location preference.
Change-Id: Ie209887169623f090df0ee7a85f2709b4a54e202
-rw-r--r--res/layout/on_screen_menu_checkbox_item.xml42
-rw-r--r--res/values/arrays.xml10
-rw-r--r--res/values/strings.xml7
-rw-r--r--res/xml/camera_preferences.xml7
-rw-r--r--src/com/android/camera/BooleanListPreference.java57
-rw-r--r--src/com/android/camera/CameraSettings.java7
-rw-r--r--src/com/android/camera/OnScreenSettings.java31
7 files changed, 87 insertions, 74 deletions
diff --git a/res/layout/on_screen_menu_checkbox_item.xml b/res/layout/on_screen_menu_checkbox_item.xml
deleted file mode 100644
index 5e8dab5..0000000
--- a/res/layout/on_screen_menu_checkbox_item.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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:maxLines="2"
- android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceLarge"
- 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/values/arrays.xml b/res/values/arrays.xml
index 1aecca5..2b035bb 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -103,6 +103,16 @@
<item>@drawable/ic_dialog_flash_on</item>
</array>
+ <string-array name="pref_camera_recordlocation_entryvalues" translatable="false">
+ <item>false</item>
+ <item>true</item>
+ </string-array>
+
+ <array name="pref_camera_recordlocation_entries" translatable="false">
+ <item>@string/pref_camera_recordlocation_entry_off</item>
+ <item>@string/pref_camera_recordlocation_entry_on</item>
+ </array>
+
<array name="flash_icons">
<item>@drawable/ic_viewfinder_flash_auto</item>
<item>@drawable/ic_viewfinder_flash_on</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 16c3682..e19fcfc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -318,8 +318,11 @@
<!-- Settings screen, setting title text -->
<string name="pref_camera_recordlocation_title">Store location</string>
- <!-- Settings screen, setting summary text -->
- <string name="pref_camera_recordlocation_summary">Record location in picture data</string>
+ <string name="pref_camera_recordlocation_default" translatable="false">false</string>
+
+ <!-- Settings screen, Record location dialog choices -->
+ <string name="pref_camera_recordlocation_entry_off">Off</string>
+ <string name="pref_camera_recordlocation_entry_on">On</string>
<!-- Default video quality setting. A numerical value. -->
<string name="pref_camera_videoquality_default" translatable="false">1</string>
diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml
index 273ff30..6f632e4 100644
--- a/res/xml/camera_preferences.xml
+++ b/res/xml/camera_preferences.xml
@@ -17,11 +17,12 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:camera="http://schemas.android.com/apk/res/com.android.camera">
<PreferenceCategory android:title="@string/pref_camera_settings_category">
- <CheckBoxPreference
+ <com.android.camera.BooleanListPreference
android:key="pref_camera_recordlocation_key"
+ android:defaultValue="@string/pref_camera_recordlocation_default"
android:title="@string/pref_camera_recordlocation_title"
- android:summary="@string/pref_camera_recordlocation_summary"
- android:defaultValue="false"/>
+ android:entries="@array/pref_camera_recordlocation_entries"
+ android:entryValues="@array/pref_camera_recordlocation_entryvalues" />
<com.android.camera.IconListPreference
android:key="pref_camera_flashmode_key"
android:defaultValue="@string/pref_camera_flashmode_default"
diff --git a/src/com/android/camera/BooleanListPreference.java b/src/com/android/camera/BooleanListPreference.java
new file mode 100644
index 0000000..94ec1cb
--- /dev/null
+++ b/src/com/android/camera/BooleanListPreference.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package com.android.camera;
+
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.preference.ListPreference;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.AttributeSet;
+
+/** {@code BooleanListPreference} is used for those {@code SharedPreference}
+ * which stores value in the type of {@code Boolean} but would like to be shown
+ * as two radio buttons instead of a checkbox.
+ */
+public class BooleanListPreference extends ListPreference {
+
+ public BooleanListPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ CharSequence values[] = getEntryValues();
+ if (values.length == 2) {
+ boolean x = Boolean.valueOf(values[0].toString());
+ boolean y = Boolean.valueOf(values[1].toString());
+ if (x != y) return;
+ }
+ throw new IllegalStateException(
+ "EntryValues should be boolean strings");
+ }
+
+ @Override
+ protected boolean persistString(String value) {
+ return persistBoolean(Boolean.valueOf(value));
+ }
+
+ @Override
+ protected String getPersistedString(String defaultValue) {
+ return Boolean.toString(
+ getPersistedBoolean(Boolean.valueOf(defaultValue)));
+ }
+}
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index a8d44ae..d84dec8 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -221,15 +221,16 @@ public class CameraSettings {
} catch (Exception ex) {
version = 0;
}
+ if (version == CURRENT_VERSION) return;
+ SharedPreferences.Editor editor = pref.edit();
if (version == 0) {
- SharedPreferences.Editor editor = pref.edit();
// For old version, change 1 to -1 for video duration preference.
if (pref.getString(KEY_VIDEO_DURATION, "1").equals("1")) {
editor.putString(KEY_VIDEO_DURATION, "-1");
}
- editor.putInt(KEY_VERSION, CURRENT_VERSION);
- editor.commit();
}
+ editor.putInt(KEY_VERSION, CURRENT_VERSION);
+ editor.commit();
}
}
diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java
index cebd4d9..06818b2 100644
--- a/src/com/android/camera/OnScreenSettings.java
+++ b/src/com/android/camera/OnScreenSettings.java
@@ -282,18 +282,11 @@ public class OnScreenSettings {
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();
- }
+ SubMenuAdapter adapter = new SubMenuAdapter(
+ mContext, (ListPreference) preference);
+ mSubMenu.setAdapter(adapter);
+ mSubMenu.setOnItemClickListener(adapter);
+ showSubMenu();
}
public View getView(int position, View convertView, ViewGroup parent) {
@@ -305,15 +298,6 @@ public class OnScreenSettings {
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);
@@ -353,14 +337,13 @@ public class OnScreenSettings {
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;
+ // we have two types, see getItemViewType()
+ return 2;
}
@Override