diff options
author | Adam Powell <adamp@google.com> | 2011-08-22 17:42:12 -0700 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2011-08-22 17:43:30 -0700 |
commit | b1e2f25b7e6d20caa233113b892ec46685f08bb6 (patch) | |
tree | 78745960deeccbe9f8089a5b5899c9a3ce1ffeb9 /core/java/com/android/internal/widget/ActionBarView.java | |
parent | 77eb57fc7717ba286cda3ce460166b7f51001d6e (diff) | |
download | frameworks_base-b1e2f25b7e6d20caa233113b892ec46685f08bb6.zip frameworks_base-b1e2f25b7e6d20caa233113b892ec46685f08bb6.tar.gz frameworks_base-b1e2f25b7e6d20caa233113b892ec46685f08bb6.tar.bz2 |
Fix bug 5143392 - Add padding to left of action bar app icon to
prevent icon from moving when drilling into hierarchy
Fix up the layout of home/up/titles in the action bar such that showing/hiding
the "up" indicator never changes the position of the icon, logo, or title.
Change-Id: Ic2117babe3a54619a4b787d5374295955a58fb34
Diffstat (limited to 'core/java/com/android/internal/widget/ActionBarView.java')
-rw-r--r-- | core/java/com/android/internal/widget/ActionBarView.java | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java index 28181ba..4efb29f 100644 --- a/core/java/com/android/internal/widget/ActionBarView.java +++ b/core/java/com/android/internal/widget/ActionBarView.java @@ -550,10 +550,9 @@ public class ActionBarView extends AbsActionBarView { if (mTitleLayout != null && (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); + final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(!showHome && homeAsUp); } if ((flagsChanged & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) { @@ -730,10 +729,9 @@ public class ActionBarView extends AbsActionBarView { } final boolean homeAsUp = (mDisplayOptions & ActionBar.DISPLAY_HOME_AS_UP) != 0; - final boolean titleUp = homeAsUp && - (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) == 0; - mTitleUpView.setVisibility(titleUp ? VISIBLE : GONE); - mTitleLayout.setEnabled(titleUp); + final boolean showHome = (mDisplayOptions & ActionBar.DISPLAY_SHOW_HOME) != 0; + mTitleUpView.setVisibility(!showHome ? (homeAsUp ? VISIBLE : INVISIBLE) : GONE); + mTitleLayout.setEnabled(homeAsUp && !showHome); } addView(mTitleLayout); @@ -805,7 +803,7 @@ public class ActionBarView extends AbsActionBarView { int leftOfCenter = availableWidth / 2; int rightOfCenter = leftOfCenter; - View homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; if (homeLayout.getVisibility() != GONE) { final LayoutParams lp = homeLayout.getLayoutParams(); @@ -817,7 +815,7 @@ public class ActionBarView extends AbsActionBarView { } homeLayout.measure(homeWidthSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); - final int homeWidth = homeLayout.getMeasuredWidth(); + final int homeWidth = homeLayout.getMeasuredWidth() + homeLayout.getLeftOffset(); availableWidth = Math.max(0, availableWidth - homeWidth); leftOfCenter = Math.max(0, availableWidth - homeWidth); } @@ -962,9 +960,10 @@ public class ActionBarView extends AbsActionBarView { return; } - View homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; + HomeView homeLayout = mExpandedActionView != null ? mExpandedHomeLayout : mHomeLayout; if (homeLayout.getVisibility() != GONE) { - x += positionChild(homeLayout, x, y, contentHeight); + final int leftOffset = homeLayout.getLeftOffset(); + x += positionChild(homeLayout, x + leftOffset, y, contentHeight) + leftOffset; } if (mExpandedActionView == null) { @@ -1171,6 +1170,7 @@ public class ActionBarView extends AbsActionBarView { private static class HomeView extends FrameLayout { private View mUpView; private ImageView mIconView; + private int mUpWidth; public HomeView(Context context) { this(context, null); @@ -1194,15 +1194,16 @@ public class ActionBarView extends AbsActionBarView { mIconView = (ImageView) findViewById(com.android.internal.R.id.home); } - public int getVerticalIconPadding() { - return mIconView.getPaddingTop() + mIconView.getPaddingBottom(); + public int getLeftOffset() { + return mUpView.getVisibility() == GONE ? mUpWidth : 0; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { measureChildWithMargins(mUpView, widthMeasureSpec, 0, heightMeasureSpec, 0); final LayoutParams upLp = (LayoutParams) mUpView.getLayoutParams(); - int width = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin; + mUpWidth = upLp.leftMargin + mUpView.getMeasuredWidth() + upLp.rightMargin; + int width = mUpView.getVisibility() == GONE ? 0 : mUpWidth; int height = upLp.topMargin + mUpView.getMeasuredHeight() + upLp.bottomMargin; measureChildWithMargins(mIconView, widthMeasureSpec, width, heightMeasureSpec, 0); final LayoutParams iconLp = (LayoutParams) mIconView.getLayoutParams(); |