Bug 816114: Awesomebar tabs title color should change with the themes. [r=mfinkle]

--HG--
extra : rebase_source : d544d0e2ee3925b89596296fdb18877215c4b7b4
This commit is contained in:
Sriram Ramasubramanian 2012-12-26 11:10:43 -08:00
parent 7d913f06d9
commit 8b4843d99f
2 changed files with 50 additions and 9 deletions

View File

@ -20,10 +20,13 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.TabHost; import android.widget.TabHost;
import android.widget.TabWidget; import android.widget.TabWidget;
public class AwesomeBarTabs extends TabHost { public class AwesomeBarTabs extends TabHost
implements LightweightTheme.OnChangeListener {
private static final String LOGTAG = "GeckoAwesomeBarTabs"; private static final String LOGTAG = "GeckoAwesomeBarTabs";
private Context mContext; private Context mContext;
private GeckoActivity mActivity;
private boolean mInflated; private boolean mInflated;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private OnUrlOpenListener mUrlOpenListener; private OnUrlOpenListener mUrlOpenListener;
@ -105,6 +108,8 @@ public class AwesomeBarTabs extends TabHost {
Log.d(LOGTAG, "Creating AwesomeBarTabs"); Log.d(LOGTAG, "Creating AwesomeBarTabs");
mContext = context; mContext = context;
mActivity = (GeckoActivity) context;
mInflated = false; mInflated = false;
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }
@ -174,20 +179,50 @@ public class AwesomeBarTabs extends TabHost {
filter(""); 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() { private void styleSelectedTab() {
int selIndex = mViewPager.getCurrentItem(); int selIndex = mViewPager.getCurrentItem();
TabWidget tabWidget = getTabWidget(); 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++) { for (int i = 0; i < tabWidget.getTabCount(); i++) {
GeckoTextView view = (GeckoTextView) tabWidget.getChildTabViewAt(i); GeckoTextView view = (GeckoTextView) tabWidget.getChildTabViewAt(i);
if (mTarget != null && mTarget.equals(AwesomeBar.Target.CURRENT_TAB.name())) { if (isPrivate) {
Tab tab = Tabs.getInstance().getSelectedTab(); view.setPrivateMode((i == selIndex) ? false : true);
if (tab != null && tab.isPrivate()) { } else {
if (i == selIndex) if (i == selIndex)
view.setPrivateMode(false); view.resetTheme();
else else if (mActivity.getLightweightTheme().isEnabled())
view.setPrivateMode(true); view.setTheme(mActivity.getLightweightTheme().isLightTheme());
} else
view.resetTheme();
} }
if (i == selIndex) if (i == selIndex)

View File

@ -10,6 +10,12 @@
<!-- private browsing mode --> <!-- private browsing mode -->
<item gecko:state_private="true" android:color="#FFDDDDDD" /> <item gecko:state_private="true" android:color="#FFDDDDDD" />
<!-- dark theme -->
<item gecko:state_dark="true" android:color="#FFDDDDDD"/>
<!-- light theme -->
<item gecko:state_light="true" android:color="#FF222222"/>
<!-- normal mode --> <!-- normal mode -->
<item android:color="#FF222222"/> <item android:color="#FF222222"/>