summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2011-06-17 20:30:13 -0700
committerAdam Powell <adamp@google.com>2011-06-17 20:31:10 -0700
commit54c7d7e61cd975d73b7eb0a5a0c75d21b6a7a12b (patch)
tree00affb512670419bc434e9e165bea82b338fda23
parentec08cacd78c4b746ac385c874f41833fc06ebc2f (diff)
downloadframeworks_base-54c7d7e61cd975d73b7eb0a5a0c75d21b6a7a12b.zip
frameworks_base-54c7d7e61cd975d73b7eb0a5a0c75d21b6a7a12b.tar.gz
frameworks_base-54c7d7e61cd975d73b7eb0a5a0c75d21b6a7a12b.tar.bz2
Allow the action bar title to take on the role of "up" in the absence
of a standard "home" icon. Change-Id: Ie1a9adca674500a29da36956455667bbb55a616f
-rw-r--r--core/java/com/android/internal/widget/ActionBarView.java36
-rw-r--r--core/res/res/layout/action_bar_title_item.xml41
2 files changed, 54 insertions, 23 deletions
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 9d8d361..290f90d 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -96,6 +96,8 @@ public class ActionBarView extends AbsActionBarView {
private LinearLayout mTitleLayout;
private TextView mTitleView;
private TextView mSubtitleView;
+ private View mTitleUpView;
+
private Spinner mSpinner;
private LinearLayout mListNavLayout;
private ScrollingTabContainerView mTabScrollView;
@@ -152,6 +154,16 @@ public class ActionBarView extends AbsActionBarView {
}
};
+ private final OnClickListener mUpClickListener = new OnClickListener() {
+ public void onClick(View v) {
+ Context context = getContext();
+ if (context instanceof Activity) {
+ Activity activity = (Activity) context;
+ activity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
+ }
+ }
+ };
+
public ActionBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -230,15 +242,7 @@ public class ActionBarView extends AbsActionBarView {
a.recycle();
mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
- mHomeLayout.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Context context = getContext();
- if (context instanceof Activity) {
- Activity activity = (Activity) context;
- activity.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
- }
- }
- });
+ mHomeLayout.setOnClickListener(mUpClickListener);
mHomeLayout.setClickable(true);
mHomeLayout.setFocusable(true);
}
@@ -438,7 +442,8 @@ public class ActionBarView extends AbsActionBarView {
}
if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
- final int vis = (options & ActionBar.DISPLAY_SHOW_HOME) != 0 ? VISIBLE : GONE;
+ final boolean showHome = (options & ActionBar.DISPLAY_SHOW_HOME) != 0;
+ final int vis = showHome ? VISIBLE : GONE;
mHomeLayout.setVisibility(vis);
if ((flagsChanged & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
@@ -458,6 +463,14 @@ public class ActionBarView extends AbsActionBarView {
}
}
+ if ((flagsChanged &
+ (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
+ final boolean homeAsUp = (options & ActionBar.DISPLAY_HOME_AS_UP) != 0;
+ final boolean titleUp = homeAsUp && !showHome;
+ mTitleUpView.setVisibility(titleUp ? VISIBLE : GONE);
+ mTitleLayout.setEnabled(titleUp);
+ }
+
if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
if ((options & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
addView(mCustomNavView);
@@ -641,6 +654,9 @@ public class ActionBarView extends AbsActionBarView {
mTitleLayout = (LinearLayout) inflater.inflate(R.layout.action_bar_title_item, null);
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
+ mTitleUpView = (View) mTitleLayout.findViewById(R.id.up);
+
+ mTitleLayout.setOnClickListener(mUpClickListener);
if (mTitleStyleRes != 0) {
mTitleView.setTextAppearance(mContext, mTitleStyleRes);
diff --git a/core/res/res/layout/action_bar_title_item.xml b/core/res/res/layout/action_bar_title_item.xml
index d8b729d..e803b26 100644
--- a/core/res/res/layout/action_bar_title_item.xml
+++ b/core/res/res/layout/action_bar_title_item.xml
@@ -17,17 +17,32 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingRight="32dip" >
- <TextView android:id="@+id/action_bar_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="end" />
- <TextView android:id="@+id/action_bar_subtitle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="end"
- android:visibility="gone" />
+ android:orientation="horizontal"
+ android:paddingRight="16dip"
+ android:background="?android:attr/selectableItemBackground"
+ android:enabled="false">
+
+ <ImageView android:id="@android:id/up"
+ android:src="?android:attr/homeAsUpIndicator"
+ android:layout_gravity="center_vertical|left"
+ android:visibility="gone"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical|left"
+ android:orientation="vertical">
+ <TextView android:id="@+id/action_bar_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end" />
+ <TextView android:id="@+id/action_bar_subtitle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:visibility="gone" />
+ </LinearLayout>
</LinearLayout>