Loading core/java/android/app/ActionBar.java +15 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,12 @@ public abstract class ActionBar { */ public static final int DISPLAY_SHOW_CUSTOM = 0x10; /** * Allow the title to wrap onto multiple lines if space is available * @hide pending API approval */ public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20; /** * Set the action bar into custom navigation mode, supplying a view * for custom navigation. Loading Loading @@ -679,6 +685,15 @@ public abstract class ActionBar { */ public Context getThemedContext() { return null; } /** * Returns true if the Title field has been truncated during layout for lack * of available space. * * @return true if the Title field has been truncated * @hide pending API approval */ public boolean isTitleTruncated() { return false; } /** * Listener interface for ActionBar navigation events. */ Loading core/java/com/android/internal/app/ActionBarImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -801,6 +801,11 @@ public class ActionBarImpl extends ActionBar { return mThemedContext; } @Override public boolean isTitleTruncated() { return mActionView != null && mActionView.isTitleTruncated(); } /** * @hide */ Loading core/java/com/android/internal/widget/ActionBarView.java +98 −69 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.text.Layout; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; Loading @@ -49,7 +50,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.TouchDelegate; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; Loading Loading @@ -83,7 +83,8 @@ public class ActionBarView extends AbsActionBarView { ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE; ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_TITLE_MULTIPLE_LINES; private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.START | Gravity.CENTER_VERTICAL; Loading @@ -100,6 +101,7 @@ public class ActionBarView extends AbsActionBarView { private TextView mTitleView; private TextView mSubtitleView; private View mTitleUpView; private ViewGroup mUpGoerFive; private Spinner mSpinner; private LinearLayout mListNavLayout; Loading Loading @@ -137,10 +139,6 @@ public class ActionBarView extends AbsActionBarView { Window.Callback mWindowCallback; private final Rect mTempRect = new Rect(); private int mMaxHomeSlop; private static final int MAX_HOME_SLOP = 32; // dp private final AdapterView.OnItemSelectedListener mNavItemSelectedListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, int position, long id) { Loading Loading @@ -219,9 +217,11 @@ public class ActionBarView extends AbsActionBarView { com.android.internal.R.styleable.ActionBar_homeLayout, com.android.internal.R.layout.action_bar_home); mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mUpGoerFive = (ViewGroup) inflater.inflate( com.android.internal.R.layout.action_bar_up_container, this, false); mHomeLayout = (HomeView) inflater.inflate(homeResId, mUpGoerFive, false); mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, mUpGoerFive, false); mExpandedHomeLayout.setUp(true); mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); mExpandedHomeLayout.setContentDescription(getResources().getText( Loading Loading @@ -250,16 +250,14 @@ public class ActionBarView extends AbsActionBarView { a.recycle(); mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); mHomeLayout.setOnClickListener(mUpClickListener); mHomeLayout.setClickable(true); mHomeLayout.setFocusable(true); mUpGoerFive.setOnClickListener(mUpClickListener); mUpGoerFive.setClickable(true); mUpGoerFive.setFocusable(true); if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); } mMaxHomeSlop = (int) (MAX_HOME_SLOP * context.getResources().getDisplayMetrics().density + 0.5f); } @Override Loading @@ -269,8 +267,8 @@ public class ActionBarView extends AbsActionBarView { mTitleView = null; mSubtitleView = null; mTitleUpView = null; if (mTitleLayout != null && mTitleLayout.getParent() == this) { removeView(mTitleLayout); if (mTitleLayout != null && mTitleLayout.getParent() == mUpGoerFive) { mUpGoerFive.removeView(mTitleLayout); } mTitleLayout = null; if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { Loading Loading @@ -551,19 +549,19 @@ public class ActionBarView extends AbsActionBarView { } public void setHomeButtonEnabled(boolean enable) { mHomeLayout.setEnabled(enable); mHomeLayout.setFocusable(enable); mUpGoerFive.setEnabled(enable); mUpGoerFive.setFocusable(enable); // Make sure the home button has an accurate content description for accessibility. if (!enable) { mHomeLayout.setContentDescription(null); mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); mUpGoerFive.setContentDescription(null); mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } else { mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO); mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO); if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) { mHomeLayout.setContentDescription(mContext.getResources().getText( mUpGoerFive.setContentDescription(mContext.getResources().getText( R.string.action_bar_up_description)); } else { mHomeLayout.setContentDescription(mContext.getResources().getText( mUpGoerFive.setContentDescription(mContext.getResources().getText( R.string.action_bar_home_description)); } } Loading Loading @@ -600,7 +598,7 @@ public class ActionBarView extends AbsActionBarView { if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { initTitle(); } else { removeView(mTitleLayout); mUpGoerFive.removeView(mTitleLayout); } } Loading @@ -608,8 +606,6 @@ public class ActionBarView extends AbsActionBarView { (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); mTitleLayout.setEnabled(!showHome && homeAsUp); mTitleLayout.setClickable(!showHome && homeAsUp); } if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { Loading @@ -620,6 +616,17 @@ public class ActionBarView extends AbsActionBarView { } } if (mTitleLayout != null && (flagsChanged & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) { if ((options & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) { mTitleView.setSingleLine(false); mTitleView.setMaxLines(2); } else { mTitleView.setMaxLines(1); mTitleView.setSingleLine(true); } } requestLayout(); } else { invalidate(); Loading Loading @@ -753,7 +760,8 @@ public class ActionBarView extends AbsActionBarView { protected void onFinishInflate() { super.onFinishInflate(); addView(mHomeLayout); mUpGoerFive.addView(mHomeLayout, 0); addView(mUpGoerFive); if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { final ViewParent parent = mCustomNavView.getParent(); Loading @@ -775,8 +783,6 @@ public class ActionBarView extends AbsActionBarView { 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); } Loading @@ -796,11 +802,9 @@ public class ActionBarView extends AbsActionBarView { final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; final boolean showTitleUp = !showHome; mTitleUpView.setVisibility(showTitleUp ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); mTitleLayout.setEnabled(homeAsUp && showTitleUp); mTitleLayout.setClickable(homeAsUp && showTitleUp); } addView(mTitleLayout); mUpGoerFive.addView(mTitleLayout); if (mExpandedActionView != null || (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) { // Don't show while in expanded mode or with empty text Loading @@ -820,6 +824,28 @@ public class ActionBarView extends AbsActionBarView { return mIsCollapsed; } /** * @return True if any characters in the title were truncated */ public boolean isTitleTruncated() { if (mTitleView == null) { return false; } final Layout titleLayout = mTitleView.getLayout(); if (titleLayout == null) { return false; } final int lineCount = titleLayout.getLineCount(); for (int i = 0; i < lineCount; i++) { if (titleLayout.getEllipsisCount(i) > 0) { return true; } } return false; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int childCount = getChildCount(); Loading @@ -828,7 +854,16 @@ public class ActionBarView extends AbsActionBarView { for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE && !(child == mMenuView && mMenuView.getChildCount() == 0)) { !(child == mMenuView && mMenuView.getChildCount() == 0) && child != mUpGoerFive) { visibleChildren++; } } final int upChildCount = mUpGoerFive.getChildCount(); for (int i = 0; i < upChildCount; i++) { final View child = mUpGoerFive.getChildAt(i); if (child.getVisibility() != GONE) { visibleChildren++; } } Loading Loading @@ -872,7 +907,8 @@ public class ActionBarView extends AbsActionBarView { HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; if (homeLayout.getVisibility() != GONE) { int homeWidth = 0; if (homeLayout.getVisibility() != GONE && homeLayout.getParent() == mUpGoerFive) { final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams(); int homeWidthSpec; if (lp.width < 0) { Loading @@ -880,10 +916,18 @@ public class ActionBarView extends AbsActionBarView { } else { homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); } /* * This is a little weird. * We're only measuring the *home* affordance within the Up container here * on purpose, because we want to give the available space to all other views before * the title text. We'll remeasure the whole up container again later. */ homeLayout.measure(homeWidthSpec, exactHeightSpec); final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getStartOffset(); availableWidth = Math.max(0, availableWidth - homeWidth); leftOfCenter = Math.max(0, availableWidth - homeWidth); homeWidth = homeLayout.getMeasuredWidth(); final int homeOffsetWidth = homeWidth + homeLayout.getStartOffset(); availableWidth = Math.max(0, availableWidth - homeOffsetWidth); leftOfCenter = Math.max(0, availableWidth - homeOffsetWidth); } if (mMenuView != null && mMenuView.getParent() == this) { Loading Loading @@ -985,9 +1029,13 @@ public class ActionBarView extends AbsActionBarView { availableWidth -= horizontalMargin + customView.getMeasuredWidth(); } if (mExpandedActionView == null && showTitle) { availableWidth = measureChildView(mTitleLayout, availableWidth, /* * Measure the whole up container now, allowing for the full home+title sections. * (This will re-measure the home view.) */ availableWidth = measureChildView(mUpGoerFive, availableWidth + homeWidth, MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0); if (mTitleLayout != null) { leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth()); } Loading Loading @@ -1034,25 +1082,17 @@ public class ActionBarView extends AbsActionBarView { final int y = getPaddingTop(); HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; boolean needsTouchDelegate = false; int homeSlop = mMaxHomeSlop; int homeRight = 0; if (homeLayout.getVisibility() != GONE) { final int startOffset = homeLayout.getStartOffset(); x += positionChild(homeLayout, final int startOffset = homeLayout.getVisibility() != GONE && homeLayout.getParent() == mUpGoerFive ? homeLayout.getStartOffset() : 0; // Position the up container based on where the edge of the home layout should go. x += positionChild(mUpGoerFive, next(x, startOffset, isLayoutRtl), y, contentHeight, isLayoutRtl); x = next(x, startOffset, isLayoutRtl); needsTouchDelegate = homeLayout == mHomeLayout; homeRight = x; } if (mExpandedActionView == null) { final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; if (showTitle) { x += positionChild(mTitleLayout, x, y, contentHeight, isLayoutRtl); homeSlop = mTitleLayout.getWidth(); } switch (mNavigationMode) { case ActionBar.NAVIGATION_MODE_STANDARD: Loading @@ -1062,7 +1102,6 @@ public class ActionBarView extends AbsActionBarView { if (showTitle) { x = next(x, mItemPadding, isLayoutRtl); } homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0)); x += positionChild(mListNavLayout, x, y, contentHeight, isLayoutRtl); x = next(x, mItemPadding, isLayoutRtl); } Loading @@ -1070,7 +1109,6 @@ public class ActionBarView extends AbsActionBarView { case ActionBar.NAVIGATION_MODE_TABS: if (mTabScrollView != null) { if (showTitle) x = next(x, mItemPadding, isLayoutRtl); homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0)); x += positionChild(mTabScrollView, x, y, contentHeight, isLayoutRtl); x = next(x, mItemPadding, isLayoutRtl); } Loading Loading @@ -1175,7 +1213,6 @@ public class ActionBarView extends AbsActionBarView { final int customWidth = customView.getMeasuredWidth(); customView.layout(xpos, ypos, xpos + customWidth, ypos + customView.getMeasuredHeight()); homeSlop = Math.min(homeSlop, Math.max(xpos - homeRight, 0)); x = next(x, customWidth, isLayoutRtl); } Loading @@ -1185,14 +1222,6 @@ public class ActionBarView extends AbsActionBarView { mProgressView.layout(mProgressBarPadding, -halfProgressHeight, mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight); } if (needsTouchDelegate) { mTempRect.set(homeLayout.getLeft(), homeLayout.getTop(), homeLayout.getRight() + homeSlop, homeLayout.getBottom()); setTouchDelegate(new TouchDelegate(mTempRect, homeLayout)); } else { setTouchDelegate(null); } } @Override Loading Loading @@ -1492,8 +1521,8 @@ public class ActionBarView extends AbsActionBarView { if (mExpandedActionView.getParent() != ActionBarView.this) { addView(mExpandedActionView); } if (mExpandedHomeLayout.getParent() != ActionBarView.this) { addView(mExpandedHomeLayout); if (mExpandedHomeLayout.getParent() != mUpGoerFive) { mUpGoerFive.addView(mExpandedHomeLayout); } mHomeLayout.setVisibility(GONE); if (mTitleLayout != null) mTitleLayout.setVisibility(GONE); Loading @@ -1519,7 +1548,7 @@ public class ActionBarView extends AbsActionBarView { } removeView(mExpandedActionView); removeView(mExpandedHomeLayout); mUpGoerFive.removeView(mExpandedHomeLayout); mExpandedActionView = null; if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) { mHomeLayout.setVisibility(VISIBLE); Loading core/res/res/layout/action_bar_home.xml +1 −3 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ <view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.internal.widget.ActionBarView$HomeView" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/actionBarItemBackground" android:animateLayoutChanges="true"> android:layout_height="match_parent"> <ImageView android:id="@android:id/up" android:src="?android:attr/homeAsUpIndicator" android:layout_gravity="center_vertical|start" Loading core/res/res/layout/action_bar_title_item.xml +1 −2 Original line number Diff line number Diff line Loading @@ -16,10 +16,9 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" android:paddingEnd="8dip" android:background="?android:attr/actionBarItemBackground" android:enabled="false"> <ImageView android:id="@android:id/up" Loading Loading
core/java/android/app/ActionBar.java +15 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,12 @@ public abstract class ActionBar { */ public static final int DISPLAY_SHOW_CUSTOM = 0x10; /** * Allow the title to wrap onto multiple lines if space is available * @hide pending API approval */ public static final int DISPLAY_TITLE_MULTIPLE_LINES = 0x20; /** * Set the action bar into custom navigation mode, supplying a view * for custom navigation. Loading Loading @@ -679,6 +685,15 @@ public abstract class ActionBar { */ public Context getThemedContext() { return null; } /** * Returns true if the Title field has been truncated during layout for lack * of available space. * * @return true if the Title field has been truncated * @hide pending API approval */ public boolean isTitleTruncated() { return false; } /** * Listener interface for ActionBar navigation events. */ Loading
core/java/com/android/internal/app/ActionBarImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -801,6 +801,11 @@ public class ActionBarImpl extends ActionBar { return mThemedContext; } @Override public boolean isTitleTruncated() { return mActionView != null && mActionView.isTitleTruncated(); } /** * @hide */ Loading
core/java/com/android/internal/widget/ActionBarView.java +98 −69 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.text.Layout; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; Loading @@ -49,7 +50,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.TouchDelegate; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; Loading Loading @@ -83,7 +83,8 @@ public class ActionBarView extends AbsActionBarView { ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE; ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_TITLE_MULTIPLE_LINES; private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.START | Gravity.CENTER_VERTICAL; Loading @@ -100,6 +101,7 @@ public class ActionBarView extends AbsActionBarView { private TextView mTitleView; private TextView mSubtitleView; private View mTitleUpView; private ViewGroup mUpGoerFive; private Spinner mSpinner; private LinearLayout mListNavLayout; Loading Loading @@ -137,10 +139,6 @@ public class ActionBarView extends AbsActionBarView { Window.Callback mWindowCallback; private final Rect mTempRect = new Rect(); private int mMaxHomeSlop; private static final int MAX_HOME_SLOP = 32; // dp private final AdapterView.OnItemSelectedListener mNavItemSelectedListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View view, int position, long id) { Loading Loading @@ -219,9 +217,11 @@ public class ActionBarView extends AbsActionBarView { com.android.internal.R.styleable.ActionBar_homeLayout, com.android.internal.R.layout.action_bar_home); mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mUpGoerFive = (ViewGroup) inflater.inflate( com.android.internal.R.layout.action_bar_up_container, this, false); mHomeLayout = (HomeView) inflater.inflate(homeResId, mUpGoerFive, false); mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false); mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, mUpGoerFive, false); mExpandedHomeLayout.setUp(true); mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener); mExpandedHomeLayout.setContentDescription(getResources().getText( Loading Loading @@ -250,16 +250,14 @@ public class ActionBarView extends AbsActionBarView { a.recycle(); mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle); mHomeLayout.setOnClickListener(mUpClickListener); mHomeLayout.setClickable(true); mHomeLayout.setFocusable(true); mUpGoerFive.setOnClickListener(mUpClickListener); mUpGoerFive.setClickable(true); mUpGoerFive.setFocusable(true); if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); } mMaxHomeSlop = (int) (MAX_HOME_SLOP * context.getResources().getDisplayMetrics().density + 0.5f); } @Override Loading @@ -269,8 +267,8 @@ public class ActionBarView extends AbsActionBarView { mTitleView = null; mSubtitleView = null; mTitleUpView = null; if (mTitleLayout != null && mTitleLayout.getParent() == this) { removeView(mTitleLayout); if (mTitleLayout != null && mTitleLayout.getParent() == mUpGoerFive) { mUpGoerFive.removeView(mTitleLayout); } mTitleLayout = null; if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) { Loading Loading @@ -551,19 +549,19 @@ public class ActionBarView extends AbsActionBarView { } public void setHomeButtonEnabled(boolean enable) { mHomeLayout.setEnabled(enable); mHomeLayout.setFocusable(enable); mUpGoerFive.setEnabled(enable); mUpGoerFive.setFocusable(enable); // Make sure the home button has an accurate content description for accessibility. if (!enable) { mHomeLayout.setContentDescription(null); mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); mUpGoerFive.setContentDescription(null); mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); } else { mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO); mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO); if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) { mHomeLayout.setContentDescription(mContext.getResources().getText( mUpGoerFive.setContentDescription(mContext.getResources().getText( R.string.action_bar_up_description)); } else { mHomeLayout.setContentDescription(mContext.getResources().getText( mUpGoerFive.setContentDescription(mContext.getResources().getText( R.string.action_bar_home_description)); } } Loading Loading @@ -600,7 +598,7 @@ public class ActionBarView extends AbsActionBarView { if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) { initTitle(); } else { removeView(mTitleLayout); mUpGoerFive.removeView(mTitleLayout); } } Loading @@ -608,8 +606,6 @@ public class ActionBarView extends AbsActionBarView { (ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) { final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); mTitleLayout.setEnabled(!showHome && homeAsUp); mTitleLayout.setClickable(!showHome && homeAsUp); } if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { Loading @@ -620,6 +616,17 @@ public class ActionBarView extends AbsActionBarView { } } if (mTitleLayout != null && (flagsChanged & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) { if ((options & ActionBar.DISPLAY_TITLE_MULTIPLE_LINES) != 0) { mTitleView.setSingleLine(false); mTitleView.setMaxLines(2); } else { mTitleView.setMaxLines(1); mTitleView.setSingleLine(true); } } requestLayout(); } else { invalidate(); Loading Loading @@ -753,7 +760,8 @@ public class ActionBarView extends AbsActionBarView { protected void onFinishInflate() { super.onFinishInflate(); addView(mHomeLayout); mUpGoerFive.addView(mHomeLayout, 0); addView(mUpGoerFive); if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { final ViewParent parent = mCustomNavView.getParent(); Loading @@ -775,8 +783,6 @@ public class ActionBarView extends AbsActionBarView { 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); } Loading @@ -796,11 +802,9 @@ public class ActionBarView extends AbsActionBarView { final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; final boolean showTitleUp = !showHome; mTitleUpView.setVisibility(showTitleUp ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); mTitleLayout.setEnabled(homeAsUp && showTitleUp); mTitleLayout.setClickable(homeAsUp && showTitleUp); } addView(mTitleLayout); mUpGoerFive.addView(mTitleLayout); if (mExpandedActionView != null || (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) { // Don't show while in expanded mode or with empty text Loading @@ -820,6 +824,28 @@ public class ActionBarView extends AbsActionBarView { return mIsCollapsed; } /** * @return True if any characters in the title were truncated */ public boolean isTitleTruncated() { if (mTitleView == null) { return false; } final Layout titleLayout = mTitleView.getLayout(); if (titleLayout == null) { return false; } final int lineCount = titleLayout.getLineCount(); for (int i = 0; i < lineCount; i++) { if (titleLayout.getEllipsisCount(i) > 0) { return true; } } return false; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int childCount = getChildCount(); Loading @@ -828,7 +854,16 @@ public class ActionBarView extends AbsActionBarView { for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); if (child.getVisibility() != GONE && !(child == mMenuView && mMenuView.getChildCount() == 0)) { !(child == mMenuView && mMenuView.getChildCount() == 0) && child != mUpGoerFive) { visibleChildren++; } } final int upChildCount = mUpGoerFive.getChildCount(); for (int i = 0; i < upChildCount; i++) { final View child = mUpGoerFive.getChildAt(i); if (child.getVisibility() != GONE) { visibleChildren++; } } Loading Loading @@ -872,7 +907,8 @@ public class ActionBarView extends AbsActionBarView { HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; if (homeLayout.getVisibility() != GONE) { int homeWidth = 0; if (homeLayout.getVisibility() != GONE && homeLayout.getParent() == mUpGoerFive) { final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams(); int homeWidthSpec; if (lp.width < 0) { Loading @@ -880,10 +916,18 @@ public class ActionBarView extends AbsActionBarView { } else { homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY); } /* * This is a little weird. * We're only measuring the *home* affordance within the Up container here * on purpose, because we want to give the available space to all other views before * the title text. We'll remeasure the whole up container again later. */ homeLayout.measure(homeWidthSpec, exactHeightSpec); final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getStartOffset(); availableWidth = Math.max(0, availableWidth - homeWidth); leftOfCenter = Math.max(0, availableWidth - homeWidth); homeWidth = homeLayout.getMeasuredWidth(); final int homeOffsetWidth = homeWidth + homeLayout.getStartOffset(); availableWidth = Math.max(0, availableWidth - homeOffsetWidth); leftOfCenter = Math.max(0, availableWidth - homeOffsetWidth); } if (mMenuView != null && mMenuView.getParent() == this) { Loading Loading @@ -985,9 +1029,13 @@ public class ActionBarView extends AbsActionBarView { availableWidth -= horizontalMargin + customView.getMeasuredWidth(); } if (mExpandedActionView == null && showTitle) { availableWidth = measureChildView(mTitleLayout, availableWidth, /* * Measure the whole up container now, allowing for the full home+title sections. * (This will re-measure the home view.) */ availableWidth = measureChildView(mUpGoerFive, availableWidth + homeWidth, MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0); if (mTitleLayout != null) { leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth()); } Loading Loading @@ -1034,25 +1082,17 @@ public class ActionBarView extends AbsActionBarView { final int y = getPaddingTop(); HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; boolean needsTouchDelegate = false; int homeSlop = mMaxHomeSlop; int homeRight = 0; if (homeLayout.getVisibility() != GONE) { final int startOffset = homeLayout.getStartOffset(); x += positionChild(homeLayout, final int startOffset = homeLayout.getVisibility() != GONE && homeLayout.getParent() == mUpGoerFive ? homeLayout.getStartOffset() : 0; // Position the up container based on where the edge of the home layout should go. x += positionChild(mUpGoerFive, next(x, startOffset, isLayoutRtl), y, contentHeight, isLayoutRtl); x = next(x, startOffset, isLayoutRtl); needsTouchDelegate = homeLayout == mHomeLayout; homeRight = x; } if (mExpandedActionView == null) { final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE && (mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0; if (showTitle) { x += positionChild(mTitleLayout, x, y, contentHeight, isLayoutRtl); homeSlop = mTitleLayout.getWidth(); } switch (mNavigationMode) { case ActionBar.NAVIGATION_MODE_STANDARD: Loading @@ -1062,7 +1102,6 @@ public class ActionBarView extends AbsActionBarView { if (showTitle) { x = next(x, mItemPadding, isLayoutRtl); } homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0)); x += positionChild(mListNavLayout, x, y, contentHeight, isLayoutRtl); x = next(x, mItemPadding, isLayoutRtl); } Loading @@ -1070,7 +1109,6 @@ public class ActionBarView extends AbsActionBarView { case ActionBar.NAVIGATION_MODE_TABS: if (mTabScrollView != null) { if (showTitle) x = next(x, mItemPadding, isLayoutRtl); homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0)); x += positionChild(mTabScrollView, x, y, contentHeight, isLayoutRtl); x = next(x, mItemPadding, isLayoutRtl); } Loading Loading @@ -1175,7 +1213,6 @@ public class ActionBarView extends AbsActionBarView { final int customWidth = customView.getMeasuredWidth(); customView.layout(xpos, ypos, xpos + customWidth, ypos + customView.getMeasuredHeight()); homeSlop = Math.min(homeSlop, Math.max(xpos - homeRight, 0)); x = next(x, customWidth, isLayoutRtl); } Loading @@ -1185,14 +1222,6 @@ public class ActionBarView extends AbsActionBarView { mProgressView.layout(mProgressBarPadding, -halfProgressHeight, mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight); } if (needsTouchDelegate) { mTempRect.set(homeLayout.getLeft(), homeLayout.getTop(), homeLayout.getRight() + homeSlop, homeLayout.getBottom()); setTouchDelegate(new TouchDelegate(mTempRect, homeLayout)); } else { setTouchDelegate(null); } } @Override Loading Loading @@ -1492,8 +1521,8 @@ public class ActionBarView extends AbsActionBarView { if (mExpandedActionView.getParent() != ActionBarView.this) { addView(mExpandedActionView); } if (mExpandedHomeLayout.getParent() != ActionBarView.this) { addView(mExpandedHomeLayout); if (mExpandedHomeLayout.getParent() != mUpGoerFive) { mUpGoerFive.addView(mExpandedHomeLayout); } mHomeLayout.setVisibility(GONE); if (mTitleLayout != null) mTitleLayout.setVisibility(GONE); Loading @@ -1519,7 +1548,7 @@ public class ActionBarView extends AbsActionBarView { } removeView(mExpandedActionView); removeView(mExpandedHomeLayout); mUpGoerFive.removeView(mExpandedHomeLayout); mExpandedActionView = null; if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) { mHomeLayout.setVisibility(VISIBLE); Loading
core/res/res/layout/action_bar_home.xml +1 −3 Original line number Diff line number Diff line Loading @@ -17,9 +17,7 @@ <view xmlns:android="http://schemas.android.com/apk/res/android" class="com.android.internal.widget.ActionBarView$HomeView" android:layout_width="wrap_content" android:layout_height="match_parent" android:background="?android:attr/actionBarItemBackground" android:animateLayoutChanges="true"> android:layout_height="match_parent"> <ImageView android:id="@android:id/up" android:src="?android:attr/homeAsUpIndicator" android:layout_gravity="center_vertical|start" Loading
core/res/res/layout/action_bar_title_item.xml +1 −2 Original line number Diff line number Diff line Loading @@ -16,10 +16,9 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" android:paddingEnd="8dip" android:background="?android:attr/actionBarItemBackground" android:enabled="false"> <ImageView android:id="@android:id/up" Loading