From 034637c74e84153bd1f7cdd922daaeb9f6af9b8e Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 11 Aug 2011 11:34:44 -0700 Subject: Tabs UI updated Bug: 5153985 Change-Id: Icbe235f1c09a58199581c55bfb2d82318f13f7f7 --- res/layout-sw600dp/title_bar_nav.xml | 6 ++-- res/values-w720dp/dimensions.xml | 4 +-- res/values/dimensions.xml | 5 +-- src/com/android/browser/NavigationBarTablet.java | 23 +++++++++++-- src/com/android/browser/TabBar.java | 44 ++++-------------------- src/com/android/browser/XLargeUi.java | 34 ++++++++++++++++++ 6 files changed, 66 insertions(+), 50 deletions(-) diff --git a/res/layout-sw600dp/title_bar_nav.xml b/res/layout-sw600dp/title_bar_nav.xml index 37bea35..3ef6d35 100644 --- a/res/layout-sw600dp/title_bar_nav.xml +++ b/res/layout-sw600dp/title_bar_nav.xml @@ -58,11 +58,12 @@ android:background="@drawable/url_background"> + android:scaleType="center" + style="@style/HoloButton" /> - 280dp - - 240dp + 240dp diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml index 8fca68a..fa372e4 100644 --- a/res/values/dimensions.xml +++ b/res/values/dimensions.xml @@ -12,10 +12,7 @@ --> - - 200dp - - 160dp + 180dp 44dp 8dp 14dp diff --git a/src/com/android/browser/NavigationBarTablet.java b/src/com/android/browser/NavigationBarTablet.java index e3059ea..7f6992a 100644 --- a/src/com/android/browser/NavigationBarTablet.java +++ b/src/com/android/browser/NavigationBarTablet.java @@ -22,6 +22,7 @@ import android.animation.ObjectAnimator; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; +import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.AttributeSet; @@ -53,6 +54,7 @@ public class NavigationBarTablet extends NavigationBarBase { private Drawable mFocusDrawable; private Drawable mUnfocusDrawable; private boolean mHideNavButtons; + private Drawable mFaviconDrawable; public NavigationBarTablet(Context context) { super(context); @@ -191,10 +193,25 @@ public class NavigationBarTablet extends NavigationBarBase { } } + @Override + public void setFavicon(Bitmap icon) { + mFaviconDrawable = mBaseUi.getFaviconDrawable(icon); + updateUrlIcon(); + } + void updateUrlIcon() { - mUrlIcon.setImageResource(mInVoiceMode ? - R.drawable.ic_search_holo_dark - : R.drawable.ic_web_holo_dark); + if (mUrlInput.hasFocus()) { + mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); + } else { + if (mInVoiceMode) { + mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); + } else { + if (mFaviconDrawable == null) { + mFaviconDrawable = mBaseUi.getFaviconDrawable(null); + } + mUrlIcon.setImageDrawable(mFaviconDrawable); + } + } } @Override diff --git a/src/com/android/browser/TabBar.java b/src/com/android/browser/TabBar.java index d1652dd..d549ac3 100644 --- a/src/com/android/browser/TabBar.java +++ b/src/com/android/browser/TabBar.java @@ -35,10 +35,8 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.PaintDrawable; -import android.view.ContextMenu; import android.view.Gravity; import android.view.LayoutInflater; -import android.view.MenuInflater; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton; @@ -62,8 +60,7 @@ public class TabBar extends LinearLayout implements OnClickListener { private TabControl mTabControl; private XLargeUi mUi; - private int mTabWidthSelected; - private int mTabWidthUnselected; + private int mTabWidth; private TabScrollView mTabs; @@ -72,8 +69,6 @@ public class TabBar extends LinearLayout implements OnClickListener { private Map mTabMap; - private Drawable mGenericFavicon; - private int mCurrentTextureWidth = 0; private int mCurrentTextureHeight = 0; @@ -101,8 +96,7 @@ public class TabBar extends LinearLayout implements OnClickListener { mTabControl = mUiController.getTabControl(); mUi = ui; Resources res = activity.getResources(); - mTabWidthSelected = (int) res.getDimension(R.dimen.tab_width_selected); - mTabWidthUnselected = (int) res.getDimension(R.dimen.tab_width_unselected); + mTabWidth = (int) res.getDimension(R.dimen.tab_width); mActiveDrawable = res.getDrawable(R.drawable.bg_urlbar); mInactiveDrawable = res.getDrawable(R.drawable.browsertab_inactive); @@ -113,7 +107,6 @@ public class TabBar extends LinearLayout implements OnClickListener { mTabs = (TabScrollView) findViewById(R.id.tabs); mNewTab = (ImageButton) findViewById(R.id.newtab); mNewTab.setOnClickListener(this); - mGenericFavicon = res.getDrawable(R.drawable.app_web_browser_sm); updateTabs(mUiController.getTabs()); mButtonWidth = -1; @@ -138,8 +131,7 @@ public class TabBar extends LinearLayout implements OnClickListener { public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); Resources res = mActivity.getResources(); - mTabWidthSelected = (int) res.getDimension(R.dimen.tab_width_selected); - mTabWidthUnselected = (int) res.getDimension(R.dimen.tab_width_unselected); + mTabWidth = (int) res.getDimension(R.dimen.tab_width); // force update of tab bar mTabs.updateLayout(); } @@ -309,7 +301,7 @@ public class TabBar extends LinearLayout implements OnClickListener { setDisplayTitle(displayTitle); setProgress(mTab.getLoadProgress()); if (mTab.getFavicon() != null) { - setFavicon(renderFavicon(mTab.getFavicon())); + setFavicon(mUi.getFaviconDrawable(mTab.getFavicon())); } updateTabIcons(); } @@ -326,6 +318,7 @@ public class TabBar extends LinearLayout implements OnClickListener { public void setActivated(boolean selected) { mSelected = selected; mClose.setVisibility(mSelected ? View.VISIBLE : View.GONE); + mIconView.setVisibility(mSelected ? View.GONE : View.VISIBLE); mTitle.setTextAppearance(mActivity, mSelected ? R.style.TabTitleSelected : R.style.TabTitleUnselected); setHorizontalFadingEdgeEnabled(!mSelected); @@ -337,7 +330,7 @@ public class TabBar extends LinearLayout implements OnClickListener { public void updateLayoutParams() { LayoutParams lp = (LinearLayout.LayoutParams) getLayoutParams(); - lp.width = mSelected ? mTabWidthSelected : mTabWidthUnselected; + lp.width = mTabWidth; lp.height = LayoutParams.MATCH_PARENT; setLayoutParams(lp); } @@ -447,29 +440,6 @@ public class TabBar extends LinearLayout implements OnClickListener { } - static Drawable createFaviconBackground(Context context) { - PaintDrawable faviconBackground = new PaintDrawable(); - Resources res = context.getResources(); - faviconBackground.getPaint().setColor(context.getResources() - .getColor(R.color.tabFaviconBackground)); - faviconBackground.setCornerRadius( - res.getDimension(R.dimen.tab_favicon_corner_radius)); - return faviconBackground; - } - - private Drawable renderFavicon(Bitmap icon) { - Drawable[] array = new Drawable[2]; - array[0] = createFaviconBackground(getContext()); - if (icon == null) { - array[1] = mGenericFavicon; - } else { - array[1] = new BitmapDrawable(icon); - } - LayerDrawable d = new LayerDrawable(array); - d.setLayerInset(1, 2, 2, 2, 2); - return d; - } - private void animateTabOut(final Tab tab, final TabView tv) { ObjectAnimator scalex = ObjectAnimator.ofFloat(tv, "scaleX", 1.0f, 0.0f); ObjectAnimator scaley = ObjectAnimator.ofFloat(tv, "scaleY", 1.0f, 0.0f); @@ -542,7 +512,7 @@ public class TabBar extends LinearLayout implements OnClickListener { public void onFavicon(Tab tab, Bitmap favicon) { TabView tv = mTabMap.get(tab); if (tv != null) { - tv.setFavicon(renderFavicon(favicon)); + tv.setFavicon(mUi.getFaviconDrawable(favicon)); } } diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index 5c11b58..724708b 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -18,6 +18,12 @@ package com.android.browser; import android.app.ActionBar; import android.app.Activity; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; +import android.graphics.drawable.PaintDrawable; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -38,6 +44,8 @@ public class XLargeUi extends BaseUi { private static final String LOGTAG = "XLargeUi"; + private PaintDrawable mFaviconBackground; + private ActionBar mActionBar; private TabBar mTabBar; @@ -348,4 +356,30 @@ public class XLargeUi extends BaseUi { return mUseQuickControls; } + private Drawable getFaviconBackground() { + if (mFaviconBackground == null) { + mFaviconBackground = new PaintDrawable(); + Resources res = mActivity.getResources(); + mFaviconBackground.getPaint().setColor( + res.getColor(R.color.tabFaviconBackground)); + mFaviconBackground.setCornerRadius( + res.getDimension(R.dimen.tab_favicon_corner_radius)); + } + return mFaviconBackground; + } + + @Override + public Drawable getFaviconDrawable(Bitmap icon) { + Drawable[] array = new Drawable[2]; + array[0] = getFaviconBackground(); + if (icon == null) { + array[1] = mGenericFavicon; + } else { + array[1] = new BitmapDrawable(mActivity.getResources(), icon); + } + LayerDrawable d = new LayerDrawable(array); + d.setLayerInset(1, 2, 2, 2, 2); + return d; + } + } -- cgit v1.1