diff options
author | Chung-yih Wang <cywang@google.com> | 2010-12-17 16:27:23 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2010-12-20 17:28:40 +0800 |
commit | 222cc95121fa2f645257e55f208d23558f570e65 (patch) | |
tree | 2b3b0b703c5c29e1106b159a4296c6723872a893 | |
parent | 1afe2a1ff266f1ccd7fccf2c37e97d2136384896 (diff) | |
download | packages_apps_LegacyCamera-222cc95121fa2f645257e55f208d23558f570e65.zip packages_apps_LegacyCamera-222cc95121fa2f645257e55f208d23558f570e65.tar.gz packages_apps_LegacyCamera-222cc95121fa2f645257e55f208d23558f570e65.tar.bz2 |
Use ListView for basic setting popup windows.
bug:3278543
Change-Id: I4a1a31113dd5614eabb6ed5ebb0b2857f930b135
-rw-r--r-- | res/drawable-hdpi/list_pressed_holo.9.png | bin | 0 -> 1061 bytes | |||
-rw-r--r-- | res/drawable-hdpi/setting_picker_pressed.9.png | bin | 152 -> 0 bytes | |||
-rw-r--r-- | res/drawable-mdpi/list_pressed_holo.9.png | bin | 0 -> 1057 bytes | |||
-rw-r--r-- | res/drawable-mdpi/setting_picker_pressed.9.png | bin | 152 -> 0 bytes | |||
-rw-r--r-- | res/drawable/setting_picker.xml | 4 | ||||
-rw-r--r-- | res/layout-xlarge/basic_setting_popup.xml | 24 | ||||
-rw-r--r-- | res/layout-xlarge/setting_item.xml | 13 | ||||
-rw-r--r-- | res/values/styles.xml | 3 | ||||
-rw-r--r-- | src/com/android/camera/ui/BasicSettingPopup.java | 79 |
9 files changed, 51 insertions, 72 deletions
diff --git a/res/drawable-hdpi/list_pressed_holo.9.png b/res/drawable-hdpi/list_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..9eae8f4 --- /dev/null +++ b/res/drawable-hdpi/list_pressed_holo.9.png diff --git a/res/drawable-hdpi/setting_picker_pressed.9.png b/res/drawable-hdpi/setting_picker_pressed.9.png Binary files differdeleted file mode 100644 index 806fe28..0000000 --- a/res/drawable-hdpi/setting_picker_pressed.9.png +++ /dev/null diff --git a/res/drawable-mdpi/list_pressed_holo.9.png b/res/drawable-mdpi/list_pressed_holo.9.png Binary files differnew file mode 100644 index 0000000..e3344b6 --- /dev/null +++ b/res/drawable-mdpi/list_pressed_holo.9.png diff --git a/res/drawable-mdpi/setting_picker_pressed.9.png b/res/drawable-mdpi/setting_picker_pressed.9.png Binary files differdeleted file mode 100644 index 806fe28..0000000 --- a/res/drawable-mdpi/setting_picker_pressed.9.png +++ /dev/null diff --git a/res/drawable/setting_picker.xml b/res/drawable/setting_picker.xml index 8763ff3..de225e3 100644 --- a/res/drawable/setting_picker.xml +++ b/res/drawable/setting_picker.xml @@ -15,7 +15,7 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_selected="true" - android:drawable="@drawable/setting_picker_pressed" /> + <item android:state_activated="true" + android:drawable="@drawable/list_pressed_holo" /> <item android:drawable="@android:color/transparent" /> </selector> diff --git a/res/layout-xlarge/basic_setting_popup.xml b/res/layout-xlarge/basic_setting_popup.xml index 47ea4a8..f1ffdd2 100644 --- a/res/layout-xlarge/basic_setting_popup.xml +++ b/res/layout-xlarge/basic_setting_popup.xml @@ -18,7 +18,7 @@ --> <com.android.camera.ui.BasicSettingPopup xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" + android:layout_width="359dp" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_alignParentRight="true" @@ -33,20 +33,16 @@ <TextView android:id="@+id/title" style="@style/SettingTitleText" /> </FrameLayout> - <FrameLayout android:paddingTop="10dp" - android:layout_width="match_parent" + <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/dialog_bottom_holo_dark"> - <ScrollView android:orientation="vertical" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_gravity="center" - android:layout_width="fill_parent" - android:layout_height="wrap_content"> - <LinearLayout android:id="@+id/contentPanel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" /> - </ScrollView> + <ListView android:id="@+id/contentPanel" + android:orientation="vertical" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:paddingBottom="3dp" + android:layout_gravity="center" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> </FrameLayout> </com.android.camera.ui.BasicSettingPopup> diff --git a/res/layout-xlarge/setting_item.xml b/res/layout-xlarge/setting_item.xml index 3db0f2d..da54ddc 100644 --- a/res/layout-xlarge/setting_item.xml +++ b/res/layout-xlarge/setting_item.xml @@ -17,25 +17,14 @@ */ --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical"> - <ImageView android:layout_width="match_parent" - android:layout_height="wrap_content" - android:src="@drawable/divider_horizontal_holo_dark" - android:scaleType="fitXY" /> - <LinearLayout android:id="@+id/setting_row" style="@style/SettingRow"> <TextView android:id="@+id/text" - style="@style/SettingPickerText" - android:textColor="@drawable/btn_setting_picker" /> + style="@style/SettingPickerText"/> <ImageView android:id="@+id/image" android:layout_width="35dp" android:layout_height="35dp" - android:layout_marginRight="35dp" android:gravity="center" android:scaleType="fitCenter" android:adjustViewBounds="true" /> - </LinearLayout> </LinearLayout> diff --git a/res/values/styles.xml b/res/values/styles.xml index da32dbc..d6519f3 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -87,6 +87,7 @@ <item name="android:gravity">left|center_vertical</item> <item name="android:layout_width">200dp</item> <item name="android:layout_height">match_parent</item> + <item name="android:textColor">@android:color/white</item> <item name="android:singleLine">true</item> </style> <style name="SettingRow"> @@ -94,6 +95,8 @@ <item name="android:orientation">horizontal</item> <item name="android:layout_width">match_parent</item> <item name="android:layout_height">48dp</item> + <item name="android:paddingLeft">16dp</item> + <item name="android:paddingRight">16dp</item> <item name="android:background">@drawable/setting_picker</item> </style> <style name="OnScreenGpsIndicator"> diff --git a/src/com/android/camera/ui/BasicSettingPopup.java b/src/com/android/camera/ui/BasicSettingPopup.java index 455ad14..982472e 100644 --- a/src/com/android/camera/ui/BasicSettingPopup.java +++ b/src/com/android/camera/ui/BasicSettingPopup.java @@ -17,31 +17,26 @@ package com.android.camera.ui; import android.content.Context; -import android.content.res.Resources.Theme; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.util.AttributeSet; -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.AdapterView; import android.widget.LinearLayout; -import android.widget.PopupWindow; -import android.widget.ScrollView; -import android.widget.TextView; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.SimpleAdapter; import com.android.camera.IconListPreference; import com.android.camera.R; import com.android.camera.Util; +import java.util.ArrayList; +import java.util.HashMap; + // 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.OnClickListener { - private static final String TAG = "BasicSettingPopup"; + AdapterView.OnItemClickListener { private IconListPreference mPreference; private Listener mListener; @@ -56,39 +51,31 @@ public class BasicSettingPopup extends AbstractSettingPopup implements public void initialize(IconListPreference preference) { mPreference = preference; Context context = getContext(); - LayoutInflater inflater = (LayoutInflater) context.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); CharSequence[] entries = mPreference.getEntries(); - CharSequence[] values = mPreference.getEntryValues(); int[] iconIds = mPreference.getImageIds(); if (iconIds == null) { iconIds = mPreference.getLargeIconIds(); } - 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) { - LinearLayout row = (LinearLayout) inflater.inflate( - R.layout.setting_item, this, false); - // Initialize the text. - TextView text = (TextView) row.findViewById(R.id.text); - text.setText(entries[i].toString()); - text.setClickable(false); - row.setSelected(index == i); - - // Initialize the icon. - if (iconIds != null) { - Drawable drawable = context.getResources().getDrawable(iconIds[i]); - ImageView image = (ImageView) row.findViewById(R.id.image); - image.setImageDrawable(drawable); - image.setClickable(false); - } - row.setOnClickListener(this); - mContentPanel.addView(row); + // Prepare the ListView. + ArrayList<HashMap<String, Object>> listItem = + new ArrayList<HashMap<String, Object>>(); + for(int i = 0; i < entries.length; ++i) { + HashMap<String, Object> map = new HashMap<String, Object>(); + map.put("text", entries[i].toString()); + if (iconIds != null) map.put("image", iconIds[i]); + listItem.add(map); } + SimpleAdapter listItemAdapter = new SimpleAdapter(context, listItem, + R.layout.setting_item, + new String[] {"text", "image"}, + new int[] {R.id.text, R.id.image}); + ((ListView) mContentPanel).setAdapter(listItemAdapter); + ((ListView) mContentPanel).setOnItemClickListener(this); + ((ListView) mContentPanel).setSelector(android.R.color.transparent); } public void setSettingChangedListener(Listener listener) { @@ -96,22 +83,26 @@ public class BasicSettingPopup extends AbstractSettingPopup implements } @Override - protected void onFinishInflate() { - super.onFinishInflate(); + public void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + int index = mPreference.findIndexOfValue(mPreference.getValue()); + View selected = ((ListView) mContentPanel).getChildAt(index); + if (selected != null) selected.setActivated(true); } - public void onClick(View view) { + @Override + public void onItemClick(AdapterView<?> parent, View view, + int index, long id) { // If popup window is dismissed, ignore the event. This may happen when // users press home and then select a setting immediately. if (getVisibility() == View.INVISIBLE) return; - int i = mContentPanel.indexOfChild(view); int oldIndex = mPreference.findIndexOfValue(mPreference.getValue()); - if ((i != -1) && (oldIndex != i)) { - mContentPanel.getChildAt(oldIndex).setSelected(false); - view.setSelected(true); - mPreference.setValueIndex(i); + if (oldIndex != index) { + ((LinearLayout) parent.getChildAt(oldIndex)).setActivated(false); + mPreference.setValueIndex(index); if (mListener != null) mListener.onSettingChanged(); } + view.setActivated(true); } } |