diff options
author | Owen Lin <owenlin@google.com> | 2009-11-11 11:21:46 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2009-12-01 14:20:05 +0800 |
commit | ba4a1f660c8e7ca16dc5b2fabbf9d7466810a0d7 (patch) | |
tree | 2ee03447d13672757ed4ecdb0e79564ac335d306 /src | |
parent | 4ddee78a1507b3c067745023bd2330b866b8aaf9 (diff) | |
download | LegacyCamera-ba4a1f660c8e7ca16dc5b2fabbf9d7466810a0d7.zip LegacyCamera-ba4a1f660c8e7ca16dc5b2fabbf9d7466810a0d7.tar.gz LegacyCamera-ba4a1f660c8e7ca16dc5b2fabbf9d7466810a0d7.tar.bz2 |
Layout the menu item of second level on-screen menu.
http://b/issue?id=2203704
Change-Id: I4e7f455eb037cb1cf60e85b338229c83d62a99f2
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/OnScreenSettings.java | 30 |
1 files changed, 28 insertions, 2 deletions
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) |