зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1185002 - Add custom active/inactive colors. r=sebastian
--HG-- extra : commitid : 16iZrBqxWtb extra : rebase_source : 4580a0364846e6703bc3d5f6b04d81ea66067c6a
This commit is contained in:
Родитель
8c8e94258e
Коммит
7db4641a5e
|
@ -5,8 +5,10 @@
|
||||||
|
|
||||||
package org.mozilla.gecko.home;
|
package org.mozilla.gecko.home;
|
||||||
|
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import org.mozilla.gecko.R;
|
import org.mozilla.gecko.R;
|
||||||
import org.mozilla.gecko.util.ColorUtils;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
@ -17,7 +19,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +42,8 @@ class TabMenuStripLayout extends LinearLayout
|
||||||
// This variable is used to predict the direction of scroll.
|
// This variable is used to predict the direction of scroll.
|
||||||
private float prevProgress;
|
private float prevProgress;
|
||||||
private int tabContentStart;
|
private int tabContentStart;
|
||||||
|
private int activeTextColor;
|
||||||
|
private ColorStateList inactiveTextColor;
|
||||||
|
|
||||||
TabMenuStripLayout(Context context, AttributeSet attrs) {
|
TabMenuStripLayout(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@ -48,6 +51,8 @@ class TabMenuStripLayout extends LinearLayout
|
||||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabMenuStrip);
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabMenuStrip);
|
||||||
final int stripResId = a.getResourceId(R.styleable.TabMenuStrip_strip, -1);
|
final int stripResId = a.getResourceId(R.styleable.TabMenuStrip_strip, -1);
|
||||||
tabContentStart = a.getDimensionPixelSize(R.styleable.TabMenuStrip_tabContentStart, 0);
|
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();
|
a.recycle();
|
||||||
|
|
||||||
if (stripResId != -1) {
|
if (stripResId != -1) {
|
||||||
|
@ -60,7 +65,7 @@ class TabMenuStripLayout extends LinearLayout
|
||||||
void onAddPagerView(String title) {
|
void onAddPagerView(String title) {
|
||||||
final TextView button = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.tab_menu_strip, this, false);
|
final TextView button = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.tab_menu_strip, this, false);
|
||||||
button.setText(title.toUpperCase());
|
button.setText(title.toUpperCase());
|
||||||
button.setTextColor(getResources().getColorStateList(R.color.tab_text_color));
|
button.setTextColor(inactiveTextColor);
|
||||||
|
|
||||||
if (getChildCount() == 0) {
|
if (getChildCount() == 0) {
|
||||||
button.setPadding(button.getPaddingLeft() + tabContentStart,
|
button.setPadding(button.getPaddingLeft() + tabContentStart,
|
||||||
|
@ -76,11 +81,11 @@ class TabMenuStripLayout extends LinearLayout
|
||||||
|
|
||||||
void onPageSelected(final int position) {
|
void onPageSelected(final int position) {
|
||||||
if (selectedView != null) {
|
if (selectedView != null) {
|
||||||
selectedView.setTextColor(getResources().getColorStateList(R.color.tab_text_color));
|
selectedView.setTextColor(inactiveTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedView = (TextView) getChildAt(position);
|
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.
|
// Callback to measure and draw the strip after the view is visible.
|
||||||
ViewTreeObserver vto = selectedView.getViewTreeObserver();
|
ViewTreeObserver vto = selectedView.getViewTreeObserver();
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
android:background="@color/firstrun_tabstrip"
|
android:background="@color/firstrun_tabstrip"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
android:layout_gravity="top"
|
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" />
|
||||||
|
|
||||||
</org.mozilla.gecko.firstrun.FirstrunPager>
|
</org.mozilla.gecko.firstrun.FirstrunPager>
|
||||||
</org.mozilla.gecko.firstrun.FirstrunPane>
|
</org.mozilla.gecko.firstrun.FirstrunPane>
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
android:background="@color/about_page_header_grey"
|
android:background="@color/about_page_header_grey"
|
||||||
android:layout_gravity="top"
|
android:layout_gravity="top"
|
||||||
gecko:strip="@drawable/home_tab_menu_strip"
|
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" />
|
gecko:tabContentStart="@dimen/tab_strip_content_start" />
|
||||||
|
|
||||||
</org.mozilla.gecko.home.HomePager>
|
</org.mozilla.gecko.home.HomePager>
|
||||||
|
|
|
@ -167,6 +167,8 @@
|
||||||
<declare-styleable name="TabMenuStrip">
|
<declare-styleable name="TabMenuStrip">
|
||||||
<attr name="strip" format="reference"/>
|
<attr name="strip" format="reference"/>
|
||||||
<attr name="tabContentStart" format="dimension" />
|
<attr name="tabContentStart" format="dimension" />
|
||||||
|
<attr name="activeTextColor" format="color" />
|
||||||
|
<attr name="inactiveTextColor" format="color" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="TabPanelBackButton">
|
<declare-styleable name="TabPanelBackButton">
|
||||||
|
|
Загрузка…
Ссылка в новой задаче