summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-11-17 15:53:32 +0800
committerWu-cheng Li <wuchengli@google.com>2010-11-26 11:48:15 +0800
commit9b7bfbc8ac25f1df20b7ed0aa79bf1f36299e981 (patch)
tree740aa1b58c30aaedb5cc42dccfe976d8cfb0f0b2
parent59ddc8c1add2fcffe523e3877baad1b6cc5ba2fb (diff)
downloadLegacyCamera-9b7bfbc8ac25f1df20b7ed0aa79bf1f36299e981.zip
LegacyCamera-9b7bfbc8ac25f1df20b7ed0aa79bf1f36299e981.tar.gz
LegacyCamera-9b7bfbc8ac25f1df20b7ed0aa79bf1f36299e981.tar.bz2
Add title and its holo background for settings.
bug:3226752 Change-Id: I10d2430fb2db9283fa080284f9ad6c043d056865
-rw-r--r--res/layout-xlarge/basic_setting_popup.xml20
-rw-r--r--res/layout-xlarge/other_setting_popup.xml44
-rw-r--r--src/com/android/camera/ui/AbstractSettingPopup.java66
-rw-r--r--src/com/android/camera/ui/BasicSettingPopup.java50
-rw-r--r--src/com/android/camera/ui/ControlPanel.java2
-rw-r--r--src/com/android/camera/ui/OtherSettingsPopup.java16
6 files changed, 150 insertions, 48 deletions
diff --git a/res/layout-xlarge/basic_setting_popup.xml b/res/layout-xlarge/basic_setting_popup.xml
index 1fb658d..d26fd06 100644
--- a/res/layout-xlarge/basic_setting_popup.xml
+++ b/res/layout-xlarge/basic_setting_popup.xml
@@ -23,5 +23,23 @@
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="40dp"
- android:orientation="vertical" />
+ android:orientation="vertical">
+ <FrameLayout android:id="@+id/topPanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="48dip">
+ <TextView android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|bottom"
+ android:layout_marginLeft="16dp"
+ android:layout_marginBottom="10dp"
+ android:textColor="@android:color/white"
+ style="@style/SettingPickerText" />
+ </FrameLayout>
+ <LinearLayout android:id="@+id/contentPanel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical" />
+</com.android.camera.ui.BasicSettingPopup>
diff --git a/res/layout-xlarge/other_setting_popup.xml b/res/layout-xlarge/other_setting_popup.xml
index 5fd345d..b9eb587 100644
--- a/res/layout-xlarge/other_setting_popup.xml
+++ b/res/layout-xlarge/other_setting_popup.xml
@@ -26,16 +26,36 @@
android:layout_marginRight="40dp"
android:orientation="vertical">
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_recordlocation_key"
- style="@style/SettingRow" />
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_focusmode_key"
- style="@style/SettingRow" />
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_exposure_key"
- style="@style/SettingRow" />
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_picturesize_key"
- style="@style/SettingRow" />
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_jpegquality_key"
- style="@style/SettingRow" />
- <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_scenemode_key"
- style="@style/SettingRow" />
+ <FrameLayout android:id="@+id/topPanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="48dip">
+ <TextView android:id="@+id/title"
+ android:text="@string/pref_camera_settings_category"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|bottom"
+ android:layout_marginLeft="16dp"
+ android:layout_marginBottom="10dp"
+ android:textColor="@android:color/white"
+ style="@style/SettingPickerText" />
+ </FrameLayout>
+
+ <LinearLayout android:id="@+id/contentPanel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_recordlocation_key"
+ style="@style/SettingRow" />
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_focusmode_key"
+ style="@style/SettingRow" />
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_exposure_key"
+ style="@style/SettingRow" />
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_picturesize_key"
+ style="@style/SettingRow" />
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_jpegquality_key"
+ style="@style/SettingRow" />
+ <com.android.camera.ui.InLineSettingPicker camera:prefKey="pref_camera_scenemode_key"
+ style="@style/SettingRow" />
+ </LinearLayout>
</com.android.camera.ui.OtherSettingsPopup>
diff --git a/src/com/android/camera/ui/AbstractSettingPopup.java b/src/com/android/camera/ui/AbstractSettingPopup.java
new file mode 100644
index 0000000..314dcab
--- /dev/null
+++ b/src/com/android/camera/ui/AbstractSettingPopup.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.content.res.Resources.Theme;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.camera.R;
+
+// A popup window that shows one or more camera settings.
+abstract public class AbstractSettingPopup extends LinearLayout {
+ protected ViewGroup mContentPanel;
+ protected TextView mTitle;
+
+ public AbstractSettingPopup(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+
+ mTitle = (TextView) findViewById(R.id.title);
+ View topPanel = findViewById(R.id.topPanel);
+ mContentPanel = (ViewGroup) findViewById(R.id.contentPanel);
+
+ // Use system holo background for now.
+ // TODO: We need to add alpha to the background.
+ Context context = getContext();
+ Theme dialogTheme = context.getResources().newTheme();
+ dialogTheme.applyStyle(android.R.style.Theme_Holo, true);
+ TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] {
+ android.R.attr.alertDialogStyle });
+ int resourceId = ta.getResourceId(0, 0);
+ TypedArray ta2 = context.obtainStyledAttributes(resourceId, new int[] {
+ android.R.attr.topDark,
+ android.R.attr.bottomDark});
+
+ topPanel.setBackgroundDrawable(ta2.getDrawable(0));
+ mContentPanel.setBackgroundDrawable(ta2.getDrawable(1));
+
+ ta.recycle();
+ ta2.recycle();
+ }
+}
diff --git a/src/com/android/camera/ui/BasicSettingPopup.java b/src/com/android/camera/ui/BasicSettingPopup.java
index e27c1c4..d2725f6 100644
--- a/src/com/android/camera/ui/BasicSettingPopup.java
+++ b/src/com/android/camera/ui/BasicSettingPopup.java
@@ -25,6 +25,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
@@ -33,12 +34,14 @@ import android.widget.TextView;
import com.android.camera.IconListPreference;
import com.android.camera.R;
import com.android.camera.Util;
-import com.android.camera.ui.GLListView.OnItemSelectedListener;
-public class BasicSettingPopup extends LinearLayout {
+// A popup window that shows one camera setting. The title is the name of the
+// setting (ex: white-balance). The entries are the supported values (ex:
+// daylight, incandescent, etc).
+public class BasicSettingPopup extends AbstractSettingPopup implements
+ View.OnTouchListener {
private static final String TAG = "BasicSettingPopup";
private IconListPreference mPreference;
- private final Context mContext;
private Listener mListener;
static public interface Listener {
@@ -47,25 +50,20 @@ public class BasicSettingPopup extends LinearLayout {
public BasicSettingPopup(Context context, AttributeSet attrs) {
super(context, attrs);
- mContext = context;
-
- // Use system holo background.
- Theme dialogTheme = getResources().newTheme();
- dialogTheme.applyStyle(android.R.style.Theme_Holo_Dialog, true);
- TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] {
- android.R.attr.windowBackground });
- setBackgroundDrawable(ta.getDrawable(0));
- ta.recycle();
}
public void initialize(IconListPreference preference) {
mPreference = preference;
- LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
+ Context context = getContext();
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
CharSequence[] entries = mPreference.getEntries();
CharSequence[] values = mPreference.getEntryValues();
int[] imageIds = mPreference.getImageIds();
- int index = preference.findIndexOfValue(preference.getValue());
+ int index = mPreference.findIndexOfValue(mPreference.getValue());
+
+ // Set title.
+ mTitle.setText(mPreference.getTitle());
int pos = 0;
for (int i = 0, n = entries.length; i < n; ++i) {
@@ -78,11 +76,11 @@ public class BasicSettingPopup extends LinearLayout {
if (index == i) text.setPressed(true);
// Initialize the image.
- Drawable drawable = mContext.getResources().getDrawable(imageIds[i]);
+ Drawable drawable = context.getResources().getDrawable(imageIds[i]);
ImageView image = (ImageView) row.findViewById(R.id.image);
image.setImageDrawable(drawable);
image.setClickable(false);
- addView(row);
+ mContentPanel.addView(row);
}
}
@@ -91,25 +89,33 @@ public class BasicSettingPopup extends LinearLayout {
}
@Override
- public boolean onTouchEvent(MotionEvent event) {
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ mContentPanel.setOnTouchListener(this);
+ }
+
+ public boolean onTouch(View view, MotionEvent event) {
int action = event.getAction();
+ ViewGroup group = (ViewGroup) view;
if (action == MotionEvent.ACTION_MOVE
|| action == MotionEvent.ACTION_DOWN) {
int y = (int) event.getY();
+ int childCount = group.getChildCount();
// Check which child is pressed.
- for (int i = 0; i < getChildCount(); i++) {
- View v = getChildAt(i);
- if (y >= v.getTop() && y <= v.getBottom()) {
+ for (int i = 0; i < childCount; i++) {
+ View child = group.getChildAt(i);
+ if (y >= child.getTop() && y <= child.getBottom()) {
int oldIndex = mPreference.findIndexOfValue(mPreference.getValue());
if (oldIndex != i) {
- View oldRow = getChildAt(oldIndex);
+ View oldRow = group.getChildAt(oldIndex);
oldRow.findViewById(R.id.text).setPressed(false);
- v.findViewById(R.id.text).setPressed(true);
+ child.findViewById(R.id.text).setPressed(true);
mPreference.setValueIndex(i);
if (mListener != null) {
mListener.onSettingChanged();
}
}
+ break;
}
}
return true;
diff --git a/src/com/android/camera/ui/ControlPanel.java b/src/com/android/camera/ui/ControlPanel.java
index 4026bd3..f33cae7 100644
--- a/src/com/android/camera/ui/ControlPanel.java
+++ b/src/com/android/camera/ui/ControlPanel.java
@@ -42,7 +42,7 @@ import java.util.ArrayList;
public class ControlPanel extends RelativeLayout
implements BasicSettingPopup.Listener, IndicatorWheel.Listener,
- OtherSettingsPopup.Listener, PopupWindow.OnDismissListener {
+ OtherSettingsPopup.Listener,PopupWindow.OnDismissListener {
private static final String TAG = "ControlPanel";
private Context mContext;
private ComboPreferences mSharedPrefs;
diff --git a/src/com/android/camera/ui/OtherSettingsPopup.java b/src/com/android/camera/ui/OtherSettingsPopup.java
index 099bae4..e5dc7ec 100644
--- a/src/com/android/camera/ui/OtherSettingsPopup.java
+++ b/src/com/android/camera/ui/OtherSettingsPopup.java
@@ -29,7 +29,7 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
/* A popup window that contains several camera settings. */
-public class OtherSettingsPopup extends LinearLayout
+public class OtherSettingsPopup extends AbstractSettingPopup
implements InLineSettingPicker.Listener {
private static final String TAG = "OtherSettingsPopup";
private Listener mListener;
@@ -44,26 +44,18 @@ public class OtherSettingsPopup extends LinearLayout
public OtherSettingsPopup(Context context, AttributeSet attrs) {
super(context, attrs);
-
- // Use system holo background.
- Theme dialogTheme = getResources().newTheme();
- dialogTheme.applyStyle(android.R.style.Theme_Holo_Dialog, true);
- TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] {
- android.R.attr.windowBackground });
- setBackgroundDrawable(ta.getDrawable(0));
- ta.recycle();
}
public void initialize(PreferenceGroup group) {
// Initialize each camera setting.
- for (int i = getChildCount() - 1; i >= 0; i--) {
- InLineSettingPicker picker = (InLineSettingPicker) getChildAt(i);
+ for (int i = mContentPanel.getChildCount() - 1; i >= 0; i--) {
+ InLineSettingPicker picker = (InLineSettingPicker) mContentPanel.getChildAt(i);
ListPreference pref = group.findPreference(picker.getKey());
if (pref != null) {
picker.setSettingChangedListener(this);
picker.initialize(pref);
} else { // remove the row if the preference is not supported
- removeViewAt(i);
+ mContentPanel.removeViewAt(i);
}
}
requestLayout();