am a41f9cfb: am 53d49f17: am 17f05497: am c2469500: Merge "Touch action bar title text: you will go to space today!" into jb-mr1.1-dev
# Via Android Git Automerger (3) and others * commit 'a41f9cfbbd1d137bf1baab49e0d453a40a0ecd33': Touch action bar title text: you will go to space today!
This commit is contained in:
@@ -131,6 +131,12 @@ public abstract class ActionBar {
|
|||||||
*/
|
*/
|
||||||
public static final int DISPLAY_SHOW_CUSTOM = 0x10;
|
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
|
* Set the action bar into custom navigation mode, supplying a view
|
||||||
* for custom navigation.
|
* for custom navigation.
|
||||||
@@ -679,6 +685,15 @@ public abstract class ActionBar {
|
|||||||
*/
|
*/
|
||||||
public Context getThemedContext() { return null; }
|
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.
|
* Listener interface for ActionBar navigation events.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -801,6 +801,11 @@ public class ActionBarImpl extends ActionBar {
|
|||||||
return mThemedContext;
|
return mThemedContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTitleTruncated() {
|
||||||
|
return mActionView != null && mActionView.isTitleTruncated();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import android.graphics.Rect;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.text.Layout;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -49,7 +50,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.TouchDelegate;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
@@ -83,7 +83,8 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
ActionBar.DISPLAY_USE_LOGO |
|
ActionBar.DISPLAY_USE_LOGO |
|
||||||
ActionBar.DISPLAY_HOME_AS_UP |
|
ActionBar.DISPLAY_HOME_AS_UP |
|
||||||
ActionBar.DISPLAY_SHOW_CUSTOM |
|
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;
|
private static final int DEFAULT_CUSTOM_GRAVITY = Gravity.START | Gravity.CENTER_VERTICAL;
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
private TextView mTitleView;
|
private TextView mTitleView;
|
||||||
private TextView mSubtitleView;
|
private TextView mSubtitleView;
|
||||||
private View mTitleUpView;
|
private View mTitleUpView;
|
||||||
|
private ViewGroup mUpGoerFive;
|
||||||
|
|
||||||
private Spinner mSpinner;
|
private Spinner mSpinner;
|
||||||
private LinearLayout mListNavLayout;
|
private LinearLayout mListNavLayout;
|
||||||
@@ -137,10 +139,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
|
|
||||||
Window.Callback mWindowCallback;
|
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 =
|
private final AdapterView.OnItemSelectedListener mNavItemSelectedListener =
|
||||||
new AdapterView.OnItemSelectedListener() {
|
new AdapterView.OnItemSelectedListener() {
|
||||||
public void onItemSelected(AdapterView parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView parent, View view, int position, long id) {
|
||||||
@@ -219,9 +217,11 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
com.android.internal.R.styleable.ActionBar_homeLayout,
|
com.android.internal.R.styleable.ActionBar_homeLayout,
|
||||||
com.android.internal.R.layout.action_bar_home);
|
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.setUp(true);
|
||||||
mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
|
mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
|
||||||
mExpandedHomeLayout.setContentDescription(getResources().getText(
|
mExpandedHomeLayout.setContentDescription(getResources().getText(
|
||||||
@@ -250,16 +250,14 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
|
mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
|
||||||
mHomeLayout.setOnClickListener(mUpClickListener);
|
|
||||||
mHomeLayout.setClickable(true);
|
mUpGoerFive.setOnClickListener(mUpClickListener);
|
||||||
mHomeLayout.setFocusable(true);
|
mUpGoerFive.setClickable(true);
|
||||||
|
mUpGoerFive.setFocusable(true);
|
||||||
|
|
||||||
if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
|
if (getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
|
||||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaxHomeSlop =
|
|
||||||
(int) (MAX_HOME_SLOP * context.getResources().getDisplayMetrics().density + 0.5f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -269,8 +267,8 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
mTitleView = null;
|
mTitleView = null;
|
||||||
mSubtitleView = null;
|
mSubtitleView = null;
|
||||||
mTitleUpView = null;
|
mTitleUpView = null;
|
||||||
if (mTitleLayout != null && mTitleLayout.getParent() == this) {
|
if (mTitleLayout != null && mTitleLayout.getParent() == mUpGoerFive) {
|
||||||
removeView(mTitleLayout);
|
mUpGoerFive.removeView(mTitleLayout);
|
||||||
}
|
}
|
||||||
mTitleLayout = null;
|
mTitleLayout = null;
|
||||||
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
|
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
|
||||||
@@ -551,19 +549,19 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHomeButtonEnabled(boolean enable) {
|
public void setHomeButtonEnabled(boolean enable) {
|
||||||
mHomeLayout.setEnabled(enable);
|
mUpGoerFive.setEnabled(enable);
|
||||||
mHomeLayout.setFocusable(enable);
|
mUpGoerFive.setFocusable(enable);
|
||||||
// Make sure the home button has an accurate content description for accessibility.
|
// Make sure the home button has an accurate content description for accessibility.
|
||||||
if (!enable) {
|
if (!enable) {
|
||||||
mHomeLayout.setContentDescription(null);
|
mUpGoerFive.setContentDescription(null);
|
||||||
mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
} else {
|
} else {
|
||||||
mHomeLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO);
|
mUpGoerFive.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_AUTO);
|
||||||
if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
|
if ((mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
|
||||||
mHomeLayout.setContentDescription(mContext.getResources().getText(
|
mUpGoerFive.setContentDescription(mContext.getResources().getText(
|
||||||
R.string.action_bar_up_description));
|
R.string.action_bar_up_description));
|
||||||
} else {
|
} else {
|
||||||
mHomeLayout.setContentDescription(mContext.getResources().getText(
|
mUpGoerFive.setContentDescription(mContext.getResources().getText(
|
||||||
R.string.action_bar_home_description));
|
R.string.action_bar_home_description));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,7 +598,7 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
|
if ((options & ActionBar.DISPLAY_SHOW_TITLE) != 0) {
|
||||||
initTitle();
|
initTitle();
|
||||||
} else {
|
} else {
|
||||||
removeView(mTitleLayout);
|
mUpGoerFive.removeView(mTitleLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,8 +606,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
|
(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME)) != 0) {
|
||||||
final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
|
final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0;
|
||||||
mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
|
mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
|
||||||
mTitleLayout.setEnabled(!showHome && homeAsUp);
|
|
||||||
mTitleLayout.setClickable(!showHome && homeAsUp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
|
if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
|
||||||
@@ -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();
|
requestLayout();
|
||||||
} else {
|
} else {
|
||||||
invalidate();
|
invalidate();
|
||||||
@@ -754,7 +761,8 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
addView(mHomeLayout);
|
mUpGoerFive.addView(mHomeLayout, 0);
|
||||||
|
addView(mUpGoerFive);
|
||||||
|
|
||||||
if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
|
if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
|
||||||
final ViewParent parent = mCustomNavView.getParent();
|
final ViewParent parent = mCustomNavView.getParent();
|
||||||
@@ -776,8 +784,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
|
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
|
||||||
mTitleUpView = (View) mTitleLayout.findViewById(R.id.up);
|
mTitleUpView = (View) mTitleLayout.findViewById(R.id.up);
|
||||||
|
|
||||||
mTitleLayout.setOnClickListener(mUpClickListener);
|
|
||||||
|
|
||||||
if (mTitleStyleRes != 0) {
|
if (mTitleStyleRes != 0) {
|
||||||
mTitleView.setTextAppearance(mContext, mTitleStyleRes);
|
mTitleView.setTextAppearance(mContext, mTitleStyleRes);
|
||||||
}
|
}
|
||||||
@@ -797,11 +803,9 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
|
final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0;
|
||||||
final boolean showTitleUp = !showHome;
|
final boolean showTitleUp = !showHome;
|
||||||
mTitleUpView.setVisibility(showTitleUp ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
|
mTitleUpView.setVisibility(showTitleUp ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE);
|
||||||
mTitleLayout.setEnabled(homeAsUp && showTitleUp);
|
|
||||||
mTitleLayout.setClickable(homeAsUp && showTitleUp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addView(mTitleLayout);
|
mUpGoerFive.addView(mTitleLayout);
|
||||||
if (mExpandedActionView != null ||
|
if (mExpandedActionView != null ||
|
||||||
(TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
|
(TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
|
||||||
// Don't show while in expanded mode or with empty text
|
// Don't show while in expanded mode or with empty text
|
||||||
@@ -821,6 +825,28 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
return mIsCollapsed;
|
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
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
final int childCount = getChildCount();
|
final int childCount = getChildCount();
|
||||||
@@ -829,7 +855,16 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
final View child = getChildAt(i);
|
final View child = getChildAt(i);
|
||||||
if (child.getVisibility() != GONE &&
|
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++;
|
visibleChildren++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -873,7 +908,8 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
|
|
||||||
HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
|
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();
|
final ViewGroup.LayoutParams lp = homeLayout.getLayoutParams();
|
||||||
int homeWidthSpec;
|
int homeWidthSpec;
|
||||||
if (lp.width < 0) {
|
if (lp.width < 0) {
|
||||||
@@ -881,10 +917,18 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
} else {
|
} else {
|
||||||
homeWidthSpec = MeasureSpec.makeMeasureSpec(lp.width, MeasureSpec.EXACTLY);
|
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);
|
homeLayout.measure(homeWidthSpec, exactHeightSpec);
|
||||||
final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getStartOffset();
|
homeWidth = homeLayout.getMeasuredWidth();
|
||||||
availableWidth = Math.max(0, availableWidth - homeWidth);
|
final int homeOffsetWidth = homeWidth + homeLayout.getStartOffset();
|
||||||
leftOfCenter = Math.max(0, availableWidth - homeWidth);
|
availableWidth = Math.max(0, availableWidth - homeOffsetWidth);
|
||||||
|
leftOfCenter = Math.max(0, availableWidth - homeOffsetWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMenuView != null && mMenuView.getParent() == this) {
|
if (mMenuView != null && mMenuView.getParent() == this) {
|
||||||
@@ -986,9 +1030,13 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
availableWidth -= horizontalMargin + customView.getMeasuredWidth();
|
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.
|
||||||
MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.EXACTLY), 0);
|
* (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());
|
leftOfCenter = Math.max(0, leftOfCenter - mTitleLayout.getMeasuredWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,25 +1083,17 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
final int y = getPaddingTop();
|
final int y = getPaddingTop();
|
||||||
|
|
||||||
HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
|
HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout;
|
||||||
boolean needsTouchDelegate = false;
|
final int startOffset = homeLayout.getVisibility() != GONE &&
|
||||||
int homeSlop = mMaxHomeSlop;
|
homeLayout.getParent() == mUpGoerFive ? homeLayout.getStartOffset() : 0;
|
||||||
int homeRight = 0;
|
|
||||||
if (homeLayout.getVisibility() != GONE) {
|
// Position the up container based on where the edge of the home layout should go.
|
||||||
final int startOffset = homeLayout.getStartOffset();
|
x += positionChild(mUpGoerFive,
|
||||||
x += positionChild(homeLayout,
|
next(x, startOffset, isLayoutRtl), y, contentHeight, isLayoutRtl);
|
||||||
next(x, startOffset, isLayoutRtl), y, contentHeight, isLayoutRtl);
|
x = next(x, startOffset, isLayoutRtl);
|
||||||
x = next(x, startOffset, isLayoutRtl);
|
|
||||||
needsTouchDelegate = homeLayout == mHomeLayout;
|
|
||||||
homeRight = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mExpandedActionView == null) {
|
if (mExpandedActionView == null) {
|
||||||
final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
|
final boolean showTitle = mTitleLayout != null && mTitleLayout.getVisibility() != GONE &&
|
||||||
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
|
(mDisplayOptions & ActionBar.DISPLAY_SHOW_TITLE) != 0;
|
||||||
if (showTitle) {
|
|
||||||
x += positionChild(mTitleLayout, x, y, contentHeight, isLayoutRtl);
|
|
||||||
homeSlop = mTitleLayout.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (mNavigationMode) {
|
switch (mNavigationMode) {
|
||||||
case ActionBar.NAVIGATION_MODE_STANDARD:
|
case ActionBar.NAVIGATION_MODE_STANDARD:
|
||||||
@@ -1063,7 +1103,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
if (showTitle) {
|
if (showTitle) {
|
||||||
x = next(x, mItemPadding, isLayoutRtl);
|
x = next(x, mItemPadding, isLayoutRtl);
|
||||||
}
|
}
|
||||||
homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0));
|
|
||||||
x += positionChild(mListNavLayout, x, y, contentHeight, isLayoutRtl);
|
x += positionChild(mListNavLayout, x, y, contentHeight, isLayoutRtl);
|
||||||
x = next(x, mItemPadding, isLayoutRtl);
|
x = next(x, mItemPadding, isLayoutRtl);
|
||||||
}
|
}
|
||||||
@@ -1071,7 +1110,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
case ActionBar.NAVIGATION_MODE_TABS:
|
case ActionBar.NAVIGATION_MODE_TABS:
|
||||||
if (mTabScrollView != null) {
|
if (mTabScrollView != null) {
|
||||||
if (showTitle) x = next(x, mItemPadding, isLayoutRtl);
|
if (showTitle) x = next(x, mItemPadding, isLayoutRtl);
|
||||||
homeSlop = Math.min(homeSlop, Math.max(x - homeRight, 0));
|
|
||||||
x += positionChild(mTabScrollView, x, y, contentHeight, isLayoutRtl);
|
x += positionChild(mTabScrollView, x, y, contentHeight, isLayoutRtl);
|
||||||
x = next(x, mItemPadding, isLayoutRtl);
|
x = next(x, mItemPadding, isLayoutRtl);
|
||||||
}
|
}
|
||||||
@@ -1176,7 +1214,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
final int customWidth = customView.getMeasuredWidth();
|
final int customWidth = customView.getMeasuredWidth();
|
||||||
customView.layout(xpos, ypos, xpos + customWidth,
|
customView.layout(xpos, ypos, xpos + customWidth,
|
||||||
ypos + customView.getMeasuredHeight());
|
ypos + customView.getMeasuredHeight());
|
||||||
homeSlop = Math.min(homeSlop, Math.max(xpos - homeRight, 0));
|
|
||||||
x = next(x, customWidth, isLayoutRtl);
|
x = next(x, customWidth, isLayoutRtl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1186,14 +1223,6 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
|
mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
|
||||||
mProgressBarPadding + mProgressView.getMeasuredWidth(), 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
|
@Override
|
||||||
@@ -1493,8 +1522,8 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
if (mExpandedActionView.getParent() != ActionBarView.this) {
|
if (mExpandedActionView.getParent() != ActionBarView.this) {
|
||||||
addView(mExpandedActionView);
|
addView(mExpandedActionView);
|
||||||
}
|
}
|
||||||
if (mExpandedHomeLayout.getParent() != ActionBarView.this) {
|
if (mExpandedHomeLayout.getParent() != mUpGoerFive) {
|
||||||
addView(mExpandedHomeLayout);
|
mUpGoerFive.addView(mExpandedHomeLayout);
|
||||||
}
|
}
|
||||||
mHomeLayout.setVisibility(GONE);
|
mHomeLayout.setVisibility(GONE);
|
||||||
if (mTitleLayout != null) mTitleLayout.setVisibility(GONE);
|
if (mTitleLayout != null) mTitleLayout.setVisibility(GONE);
|
||||||
@@ -1520,7 +1549,7 @@ public class ActionBarView extends AbsActionBarView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeView(mExpandedActionView);
|
removeView(mExpandedActionView);
|
||||||
removeView(mExpandedHomeLayout);
|
mUpGoerFive.removeView(mExpandedHomeLayout);
|
||||||
mExpandedActionView = null;
|
mExpandedActionView = null;
|
||||||
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
|
if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0) {
|
||||||
mHomeLayout.setVisibility(VISIBLE);
|
mHomeLayout.setVisibility(VISIBLE);
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
<view xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
class="com.android.internal.widget.ActionBarView$HomeView"
|
class="com.android.internal.widget.ActionBarView$HomeView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="?android:attr/actionBarItemBackground"
|
|
||||||
android:animateLayoutChanges="true">
|
|
||||||
<ImageView android:id="@android:id/up"
|
<ImageView android:id="@android:id/up"
|
||||||
android:src="?android:attr/homeAsUpIndicator"
|
android:src="?android:attr/homeAsUpIndicator"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
|
|||||||
@@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingEnd="8dip"
|
android:paddingEnd="8dip"
|
||||||
android:background="?android:attr/actionBarItemBackground"
|
|
||||||
android:enabled="false">
|
android:enabled="false">
|
||||||
|
|
||||||
<ImageView android:id="@android:id/up"
|
<ImageView android:id="@android:id/up"
|
||||||
|
|||||||
23
core/res/res/layout/action_bar_up_container.xml
Normal file
23
core/res/res/layout/action_bar_up_container.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2013 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?android:attr/actionBarItemBackground"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:enabled="false">
|
||||||
|
</LinearLayout>
|
||||||
@@ -1113,6 +1113,7 @@
|
|||||||
<java-symbol type="layout" name="keyguard_multi_user_selector_widget" />
|
<java-symbol type="layout" name="keyguard_multi_user_selector_widget" />
|
||||||
<java-symbol type="layout" name="sms_short_code_confirmation_dialog" />
|
<java-symbol type="layout" name="sms_short_code_confirmation_dialog" />
|
||||||
<java-symbol type="layout" name="keyguard_add_widget" />
|
<java-symbol type="layout" name="keyguard_add_widget" />
|
||||||
|
<java-symbol type="layout" name="action_bar_up_container" />
|
||||||
|
|
||||||
<java-symbol type="anim" name="slide_in_child_bottom" />
|
<java-symbol type="anim" name="slide_in_child_bottom" />
|
||||||
<java-symbol type="anim" name="slide_in_right" />
|
<java-symbol type="anim" name="slide_in_right" />
|
||||||
|
|||||||
Reference in New Issue
Block a user