diff options
author | Owen Lin <owenlin@google.com> | 2009-12-01 09:13:43 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-12-01 09:13:43 -0800 |
commit | 4be7857e0df3d8d18e87c107b4d81e1e814ecf2c (patch) | |
tree | 6218bdf588d785551689c21323ad763a3ad63cce | |
parent | 4660f40661d073bcc800fd1aced8e1114306773f (diff) | |
parent | 7511b6160862d21b8f511198f25b3fb9f3bd3b3a (diff) | |
download | LegacyCamera-4be7857e0df3d8d18e87c107b4d81e1e814ecf2c.zip LegacyCamera-4be7857e0df3d8d18e87c107b4d81e1e814ecf2c.tar.gz LegacyCamera-4be7857e0df3d8d18e87c107b4d81e1e814ecf2c.tar.bz2 |
am 7511b616: am ba4a1f66: Layout the menu item of second level on-screen menu.
Merge commit '7511b6160862d21b8f511198f25b3fb9f3bd3b3a'
* commit '7511b6160862d21b8f511198f25b3fb9f3bd3b3a':
Layout the menu item of second level on-screen menu.
-rw-r--r-- | res/layout/on_screen_submenu_item.xml | 25 | ||||
-rw-r--r-- | src/com/android/camera/OnScreenSettings.java | 30 |
2 files changed, 47 insertions, 8 deletions
diff --git a/res/layout/on_screen_submenu_item.xml b/res/layout/on_screen_submenu_item.xml index 8e0470e..0cb6660 100644 --- a/res/layout/on_screen_submenu_item.xml +++ b/res/layout/on_screen_submenu_item.xml @@ -26,14 +26,27 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" /> - <TextView android:id="@+id/title" - android:layout_width="wrap_content" + <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:maxLines="2" - android:textAppearance="?android:attr/textAppearanceLarge" - android:ellipsize="end" - android:fadingEdge="horizontal" /> + android:gravity="center_vertical" + android:minHeight="?android:attr/listPreferredItemHeight"> + <TextView android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:maxLines="2" + android:textAppearance="?android:attr/textAppearanceLarge" + android:ellipsize="end" + android:fadingEdge="horizontal" /> + <TextView android:id="@+id/summary" + android:visibility='gone' + 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> <RadioButton android:id="@+id/radio_button" android:focusable="false" android:clickable="false" diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java index 55294b1..937b298 100644 --- a/src/com/android/camera/OnScreenSettings.java +++ b/src/com/android/camera/OnScreenSettings.java @@ -44,6 +44,8 @@ import android.widget.AdapterView.OnItemClickListener; import java.util.ArrayList; import java.util.HashMap; +import java.util.regex.Pattern; +import java.util.regex.Matcher; /** * The on-screen setting menu. @@ -56,6 +58,9 @@ public class OnScreenSettings { private static final String TAG = "OnScreenSettings"; private static final int MSG_POST_SET_VISIBLE = 1; + private static final Pattern TITLE_PATTERN = + Pattern.compile("(.*)\\s*\\((.+)\\)"); + /** * A callback to be invoked when the on-screen menu's visibility changes. */ @@ -410,8 +415,29 @@ public class OnScreenSettings { R.layout.on_screen_submenu_item, parent, false); boolean checked = mPreference.getValue().equals( mPreference.getEntryValues()[index]); - ((TextView) convertView.findViewById( - R.id.title)).setText(entry[index]); + String title = entry[index].toString(); + String detail = null; + + // Handle the title of format "Title (details)". We extract the + // details from the title message for better UI layout. The + // detail will be shown in second line with a smaller font. + Matcher matcher = TITLE_PATTERN.matcher(title); + if (matcher.matches()) { + title = matcher.group(1); + detail = matcher.group(2); + } + + ((TextView) convertView + .findViewById(R.id.title)).setText(title); + TextView detailView = (TextView) + convertView.findViewById(R.id.summary); + if (detail == null) { + detailView.setVisibility(View.GONE); + } else { + detailView.setVisibility(View.VISIBLE); + detailView.setText(detail); + } + ((RadioButton) convertView.findViewById( R.id.radio_button)).setChecked(checked); ImageView icon = (ImageView) |