From 7db4641a5e9784bfa4455e2b5d53d4f586e9d9e0 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Tue, 29 Sep 2015 17:10:32 -0400 Subject: [PATCH] Bug 1185002 - Add custom active/inactive colors. r=sebastian --HG-- extra : commitid : 16iZrBqxWtb extra : rebase_source : 4580a0364846e6703bc3d5f6b04d81ea66067c6a --- mobile/android/base/home/TabMenuStripLayout.java | 15 ++++++++++----- .../base/resources/layout/firstrun_pane.xml | 4 +++- .../android/base/resources/layout/home_pager.xml | 2 ++ mobile/android/base/resources/values/attrs.xml | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mobile/android/base/home/TabMenuStripLayout.java b/mobile/android/base/home/TabMenuStripLayout.java index 59256062dca3..645a402ea52e 100644 --- a/mobile/android/base/home/TabMenuStripLayout.java +++ b/mobile/android/base/home/TabMenuStripLayout.java @@ -5,8 +5,10 @@ package org.mozilla.gecko.home; +import android.widget.LinearLayout; + +import android.content.res.ColorStateList; import org.mozilla.gecko.R; -import org.mozilla.gecko.util.ColorUtils; import android.content.Context; import android.content.res.TypedArray; @@ -17,7 +19,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityEvent; -import android.widget.LinearLayout; import android.widget.TextView; /** @@ -41,6 +42,8 @@ class TabMenuStripLayout extends LinearLayout // This variable is used to predict the direction of scroll. private float prevProgress; private int tabContentStart; + private int activeTextColor; + private ColorStateList inactiveTextColor; TabMenuStripLayout(Context context, AttributeSet attrs) { super(context, attrs); @@ -48,6 +51,8 @@ class TabMenuStripLayout extends LinearLayout TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabMenuStrip); final int stripResId = a.getResourceId(R.styleable.TabMenuStrip_strip, -1); tabContentStart = a.getDimensionPixelSize(R.styleable.TabMenuStrip_tabContentStart, 0); + activeTextColor = a.getColor(R.styleable.TabMenuStrip_activeTextColor, R.color.text_and_tabs_tray_grey); + inactiveTextColor = a.getColorStateList(R.styleable.TabMenuStrip_inactiveTextColor); a.recycle(); if (stripResId != -1) { @@ -60,7 +65,7 @@ class TabMenuStripLayout extends LinearLayout void onAddPagerView(String title) { final TextView button = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.tab_menu_strip, this, false); button.setText(title.toUpperCase()); - button.setTextColor(getResources().getColorStateList(R.color.tab_text_color)); + button.setTextColor(inactiveTextColor); if (getChildCount() == 0) { button.setPadding(button.getPaddingLeft() + tabContentStart, @@ -76,11 +81,11 @@ class TabMenuStripLayout extends LinearLayout void onPageSelected(final int position) { if (selectedView != null) { - selectedView.setTextColor(getResources().getColorStateList(R.color.tab_text_color)); + selectedView.setTextColor(inactiveTextColor); } selectedView = (TextView) getChildAt(position); - selectedView.setTextColor(ColorUtils.getColor(getContext(), R.color.placeholder_grey)); + selectedView.setTextColor(activeTextColor); // Callback to measure and draw the strip after the view is visible. ViewTreeObserver vto = selectedView.getViewTreeObserver(); diff --git a/mobile/android/base/resources/layout/firstrun_pane.xml b/mobile/android/base/resources/layout/firstrun_pane.xml index b3b8611cbbde..5d8f1557f1a3 100644 --- a/mobile/android/base/resources/layout/firstrun_pane.xml +++ b/mobile/android/base/resources/layout/firstrun_pane.xml @@ -21,7 +21,9 @@ android:background="@color/firstrun_tabstrip" android:visibility="visible" android:layout_gravity="top" - gecko:strip="@drawable/home_tab_menu_strip"/> + gecko:strip="@drawable/home_tab_menu_strip" + gecko:activeTextColor="@android:color/white" + gecko:inactiveTextColor="@color/divider_light" /> diff --git a/mobile/android/base/resources/layout/home_pager.xml b/mobile/android/base/resources/layout/home_pager.xml index 1edf147aa2f9..94dc7a2e3e71 100644 --- a/mobile/android/base/resources/layout/home_pager.xml +++ b/mobile/android/base/resources/layout/home_pager.xml @@ -18,6 +18,8 @@ android:background="@color/about_page_header_grey" android:layout_gravity="top" gecko:strip="@drawable/home_tab_menu_strip" + gecko:activeTextColor="@color/placeholder_grey" + gecko:inactiveTextColor="@color/tab_text_color" gecko:tabContentStart="@dimen/tab_strip_content_start" /> diff --git a/mobile/android/base/resources/values/attrs.xml b/mobile/android/base/resources/values/attrs.xml index 80d11509161d..f876b3e68a43 100644 --- a/mobile/android/base/resources/values/attrs.xml +++ b/mobile/android/base/resources/values/attrs.xml @@ -167,6 +167,8 @@ + +