From 8b4843d99f6851ffa99ef4867de28764545d739d Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Wed, 26 Dec 2012 11:10:43 -0800 Subject: [PATCH] Bug 816114: Awesomebar tabs title color should change with the themes. [r=mfinkle] --HG-- extra : rebase_source : d544d0e2ee3925b89596296fdb18877215c4b7b4 --- mobile/android/base/AwesomeBarTabs.java | 53 +++++++++++++++---- .../resources/color/awesome_bar_title.xml.in | 6 +++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/AwesomeBarTabs.java b/mobile/android/base/AwesomeBarTabs.java index c14605212e1..9eb31266041 100644 --- a/mobile/android/base/AwesomeBarTabs.java +++ b/mobile/android/base/AwesomeBarTabs.java @@ -20,10 +20,13 @@ import android.view.inputmethod.InputMethodManager; import android.widget.TabHost; import android.widget.TabWidget; -public class AwesomeBarTabs extends TabHost { +public class AwesomeBarTabs extends TabHost + implements LightweightTheme.OnChangeListener { private static final String LOGTAG = "GeckoAwesomeBarTabs"; private Context mContext; + private GeckoActivity mActivity; + private boolean mInflated; private LayoutInflater mInflater; private OnUrlOpenListener mUrlOpenListener; @@ -105,6 +108,8 @@ public class AwesomeBarTabs extends TabHost { Log.d(LOGTAG, "Creating AwesomeBarTabs"); mContext = context; + mActivity = (GeckoActivity) context; + mInflated = false; mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @@ -174,20 +179,50 @@ public class AwesomeBarTabs extends TabHost { filter(""); } + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + mActivity.getLightweightTheme().addListener(this); + } + + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mActivity.getLightweightTheme().removeListener(this); + } + + @Override + public void onLightweightThemeChanged() { + styleSelectedTab(); + } + + @Override + public void onLightweightThemeReset() { + styleSelectedTab(); + } + private void styleSelectedTab() { int selIndex = mViewPager.getCurrentItem(); TabWidget tabWidget = getTabWidget(); + boolean isPrivate = false; + + if (mTarget != null && mTarget.equals(AwesomeBar.Target.CURRENT_TAB.name())) { + Tab tab = Tabs.getInstance().getSelectedTab(); + if (tab != null) + isPrivate = tab.isPrivate(); + } for (int i = 0; i < tabWidget.getTabCount(); i++) { GeckoTextView view = (GeckoTextView) tabWidget.getChildTabViewAt(i); - if (mTarget != null && mTarget.equals(AwesomeBar.Target.CURRENT_TAB.name())) { - Tab tab = Tabs.getInstance().getSelectedTab(); - if (tab != null && tab.isPrivate()) { - if (i == selIndex) - view.setPrivateMode(false); - else - view.setPrivateMode(true); - } + if (isPrivate) { + view.setPrivateMode((i == selIndex) ? false : true); + } else { + if (i == selIndex) + view.resetTheme(); + else if (mActivity.getLightweightTheme().isEnabled()) + view.setTheme(mActivity.getLightweightTheme().isLightTheme()); + else + view.resetTheme(); } if (i == selIndex) diff --git a/mobile/android/base/resources/color/awesome_bar_title.xml.in b/mobile/android/base/resources/color/awesome_bar_title.xml.in index fa58614b3c1..f84b70cc7cc 100644 --- a/mobile/android/base/resources/color/awesome_bar_title.xml.in +++ b/mobile/android/base/resources/color/awesome_bar_title.xml.in @@ -10,6 +10,12 @@ + + + + + +