Merge "Allow the action bar title to take on the role of "up" in the absence of a standard "home" icon."
This commit is contained in:
@ -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);
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user