Commit d9cff163 authored by Alexandre Perraud's avatar Alexandre Perraud

UI : Apply material theme to new SlidingTabLayout

parent 88aa6bfc
......@@ -12,5 +12,4 @@
android:typeface="normal"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="@android:color/white"
android:textAllCaps="true" />
android:textColor="?attr/font_actionbar" />
......@@ -7,6 +7,7 @@
<attr name="playlist_item_footer" format="reference|color" />
<attr name="background_default" format="reference|color" />
<attr name="background_default_darker" format="reference|color" />
<attr name="background_actionbar" format="reference|color" />
<attr name="background_menu_divider" format="reference|color" />
<attr name="background_menu" format="reference|color" />
<attr name="background_header" format="reference|color" />
......@@ -14,6 +15,8 @@
<attr name="background_playlist" format="reference|color" />
<attr name="font_default" format="reference|color" />
<attr name="font_light" format="reference|color" />
<attr name="font_actionbar" format="reference|color" />
<attr name="font_actionbar_selected" format="reference|color" />
<attr name="video_player_overlay" format="reference|color" />
<attr name="status_bar_overlay" format="reference|color" />
<attr name="advanced_options_divider" format="reference|color" />
......
......@@ -30,6 +30,7 @@
<item name="playlist_item_footer">@color/grey2</item>
<item name="background_default">@color/grey50</item>
<item name="background_default_darker">@color/grey100</item>
<item name="background_actionbar">@color/darkorange</item>
<item name="background_menu_divider">@color/background_menu_divider</item>
<item name="background_menu">@color/background_menu</item>
<item name="background_player">@color/grey100</item>
......@@ -40,6 +41,8 @@
<item name="audio_player_header_time">@color/darkorange</item>
<item name="font_default">@color/font_default</item>
<item name="font_light">@color/font_light</item>
<item name="font_actionbar">@color/orange200</item>
<item name="font_actionbar_selected">@color/grey50</item>
<item name="list_menu">@color/font_light</item>
<item name="list_subtitle">@color/list_subtitle</item>
<item name="list_title_last">@color/list_title_last</item>
......@@ -100,6 +103,7 @@
<item name="playlist_item_footer">@color/grey1</item>
<item name="background_default">@color/grey850</item>
<item name="background_default_darker">@color/grey875</item>
<item name="background_actionbar">@color/grey875</item>
<item name="background_menu_divider">@color/grey1</item>
<item name="background_menu">@color/grey850</item>
<item name="background_player">@color/grey850</item>
......@@ -110,6 +114,8 @@
<item name="audio_player_header_time">@color/darkorange</item>
<item name="font_default">@color/grey50</item>
<item name="font_light">@color/font_light</item>
<item name="font_actionbar">@color/grey600</item>
<item name="font_actionbar_selected">@color/grey200</item>
<item name="list_menu">@color/grey50</item>
<item name="list_subtitle">@color/grey400</item>
<item name="list_title_last">@color/list_title_last</item>
......
......@@ -33,6 +33,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import org.videolan.vlc.R;
import org.videolan.vlc.util.Util;
/**
* To be used with ViewPager to provide a tab indicator component which give constant feedback as to
......@@ -71,7 +72,6 @@ public class SlidingTabLayout extends HorizontalScrollView {
private boolean mDistributeEvenly;
private ViewPager mViewPager;
private SparseArray<String> mContentDescriptions = new SparseArray<String>();
private ViewPager.OnPageChangeListener mViewPagerPageChangeListener;
private final SlidingTabStrip mTabStrip;
public SlidingTabLayout(Context context) {
this(context, null);
......@@ -85,7 +85,7 @@ public class SlidingTabLayout extends HorizontalScrollView {
setHorizontalScrollBarEnabled(false);
int hpadding = getResources().getDimensionPixelSize(R.dimen.tab_layout_horizontal_padding);
setPadding(hpadding, 0, hpadding, 0);
setBackgroundColor(getResources().getColor(org.videolan.vlc.R.color.darkorange));
setBackgroundColor(getResources().getColor(Util.getResourceFromAttribute(context, org.videolan.vlc.R.attr.background_actionbar)));
// Make sure that the Tab Strips fills this View
setFillViewport(true);
mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);
......@@ -187,6 +187,7 @@ public class SlidingTabLayout extends HorizontalScrollView {
lp.weight = 1;
}
tabTitleView.setText(adapter.getPageTitle(i).toString().toUpperCase());
tabTitleView.setTypeface(Typeface.DEFAULT_BOLD);
tabView.setOnClickListener(tabClickListener);
String desc = mContentDescriptions.get(i, null);
if (desc != null) {
......@@ -195,6 +196,7 @@ public class SlidingTabLayout extends HorizontalScrollView {
mTabStrip.addView(tabView);
if (i == mViewPager.getCurrentItem()) {
tabView.setSelected(true);
tabTitleView.setTextColor(getResources().getColor(Util.getResourceFromAttribute(getContext(), R.attr.font_actionbar_selected)));
}
}
}
......@@ -274,4 +276,28 @@ public class SlidingTabLayout extends HorizontalScrollView {
}
}
}
private ViewPager.OnPageChangeListener mViewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
for (int i = 0; i < mTabStrip.getChildCount(); i++) {
if (mTabStrip.getChildAt(i) instanceof TextView) {
int color = (i == position)
? getResources().getColor(Util.getResourceFromAttribute(getContext(), R.attr.font_actionbar_selected))
: getResources().getColor(Util.getResourceFromAttribute(getContext(), R.attr.font_actionbar));
((TextView) mTabStrip.getChildAt(i)).setTextColor(color);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
};
}
\ No newline at end of file
......@@ -24,6 +24,9 @@ import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import org.videolan.vlc.util.Util;
class SlidingTabStrip extends LinearLayout {
private static final int DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS = 0;
private static final byte DEFAULT_BOTTOM_BORDER_COLOR_ALPHA = 0x26;
......@@ -51,7 +54,7 @@ class SlidingTabStrip extends LinearLayout {
mDefaultBottomBorderColor = setColorAlpha(themeForegroundColor,
DEFAULT_BOTTOM_BORDER_COLOR_ALPHA);
mDefaultTabColorizer = new SimpleTabColorizer();
mDefaultTabColorizer.setIndicatorColors(Color.WHITE);
mDefaultTabColorizer.setIndicatorColors(getResources().getColor(Util.getResourceFromAttribute(context, org.videolan.vlc.R.attr.font_actionbar_selected)));
// mDefaultTabColorizer.setIndicatorColors(DEFAULT_SELECTED_INDICATOR_COLOR);
mBottomBorderThickness = (int) (DEFAULT_BOTTOM_BORDER_THICKNESS_DIPS * density);
mBottomBorderPaint = new Paint();
......
......@@ -188,7 +188,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
setContentView(R.layout.main);
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
toolbar.setTitleTextColor(Color.WHITE);
toolbar.setTitleTextColor(getResources().getColor(Util.getResourceFromAttribute(mContext, R.attr.font_actionbar_selected)));
setSupportActionBar(toolbar);
mSlidingPane = (SlidingPaneLayout) findViewById(R.id.pane);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment