Styled light theme for tabs and app
This commit is contained in:
parent
98dd32f9b8
commit
d85b149d5a
5 changed files with 58 additions and 50 deletions
|
@ -10,30 +10,31 @@
|
|||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
<attr name="pstsIndicatorColor" format="color" />
|
||||
<attr name="pstsUnderlineColor" format="color" />
|
||||
<attr name="pstsDividerColor" format="color" />
|
||||
<attr name="pstsDividerWidth" format="dimension" />
|
||||
<attr name="pstsIndicatorHeight" format="dimension" />
|
||||
<attr name="pstsUnderlineHeight" format="dimension" />
|
||||
<attr name="pstsDividerPadding" format="dimension" />
|
||||
<attr name="pstsTabPaddingLeftRight" format="dimension" />
|
||||
<attr name="pstsScrollOffset" format="dimension" />
|
||||
<attr name="pstsTabBackground" format="reference" />
|
||||
<attr name="pstsShouldExpand" format="boolean" />
|
||||
<attr name="pstsTextAllCaps" format="boolean" />
|
||||
<attr name="pstsPaddingMiddle" format="boolean" />
|
||||
<attr name="pstsTextColor" format="color"/>
|
||||
<attr name="pstsIndicatorColor" format="color"/>
|
||||
<attr name="pstsUnderlineColor" format="color"/>
|
||||
<attr name="pstsDividerColor" format="color"/>
|
||||
<attr name="pstsDividerWidth" format="dimension"/>
|
||||
<attr name="pstsIndicatorHeight" format="dimension"/>
|
||||
<attr name="pstsUnderlineHeight" format="dimension"/>
|
||||
<attr name="pstsDividerPadding" format="dimension"/>
|
||||
<attr name="pstsTabPaddingLeftRight" format="dimension"/>
|
||||
<attr name="pstsScrollOffset" format="dimension"/>
|
||||
<attr name="pstsTabBackground" format="reference"/>
|
||||
<attr name="pstsShouldExpand" format="boolean"/>
|
||||
<attr name="pstsTextAllCaps" format="boolean"/>
|
||||
<attr name="pstsPaddingMiddle" format="boolean"/>
|
||||
<attr name="pstsTextStyle">
|
||||
<flag name="normal" value="0x0" />
|
||||
<flag name="bold" value="0x1" />
|
||||
<flag name="italic" value="0x2" />
|
||||
<flag name="normal" value="0x0"/>
|
||||
<flag name="bold" value="0x1"/>
|
||||
<flag name="italic" value="0x2"/>
|
||||
</attr>
|
||||
<attr name="pstsTextSelectedStyle">
|
||||
<flag name="normal" value="0x0" />
|
||||
<flag name="bold" value="0x1" />
|
||||
<flag name="italic" value="0x2" />
|
||||
<flag name="normal" value="0x0"/>
|
||||
<flag name="bold" value="0x1"/>
|
||||
<flag name="italic" value="0x2"/>
|
||||
</attr>
|
||||
<attr name="pstsTextAlpha" format="float" />
|
||||
<attr name="pstsTextSelectedAlpha" format="float" />
|
||||
<attr name="pstsTextAlpha" format="float"/>
|
||||
<attr name="pstsTextSelectedAlpha" format="float"/>
|
||||
</declare-styleable>
|
||||
</resources>
|
|
@ -18,7 +18,6 @@
|
|||
<color name="gpx_time_span_color">#0080FF</color>
|
||||
|
||||
|
||||
|
||||
<color name="background_tab_pressed">#1AFFFFFF</color>
|
||||
|
||||
<color name="color_transparent">#00000000</color>
|
||||
|
|
|
@ -71,6 +71,8 @@
|
|||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="bottomToolBarColor">@color/tool_bar_light_color</item>
|
||||
<item name="pstsTabBackground">@color/actionbar_light_color</item>
|
||||
<item name="pstsIndicatorColor">@color/color_white</item>
|
||||
<item name="pstsTextColor">@color/color_white</item>
|
||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
|
||||
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarLight</item>
|
||||
</style>
|
||||
|
@ -82,6 +84,7 @@
|
|||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="bottomToolBarColor">@color/tool_bar_dark_color</item>
|
||||
<item name="pstsTabBackground">@color/actionbar_dark_color</item>
|
||||
<item name="pstsIndicatorColor">@color/actionbar_light_color</item>
|
||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
</style>
|
||||
|
@ -89,14 +92,13 @@
|
|||
<style name="OsmandLightDarkActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<item name="reset_image">@drawable/ic_action_delete_light</item> <!-- @drawable/a_1_navigation_cancel_light -->
|
||||
<item name="expandable_category_color">@color/group_background</item>
|
||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
<item name="bottomToolBarColor">@color/tool_bar_dark_color</item>
|
||||
<item name="pstsTabBackground">@color/actionbar_dark_color</item>
|
||||
<item name="pstsIndicatorColor">@color/actionbar_light_color</item>
|
||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<style name="Widget.Styled.ActionBarDark" parent="Widget.AppCompat.Light.ActionBar.Solid.Inverse">
|
||||
<item name="background">@color/actionbar_dark_color</item>
|
||||
<item name="android:background">@color/actionbar_dark_color</item>
|
||||
|
@ -105,6 +107,12 @@
|
|||
<style name="Widget.Styled.ActionBarLight" parent="Widget.AppCompat.Light.ActionBar.Solid">
|
||||
<item name="background">@color/actionbar_light_color</item>
|
||||
<item name="android:background">@color/actionbar_light_color</item>
|
||||
<item name="android:titleTextStyle">@style/Widget.Styled.LightActionBarHeader</item>
|
||||
<item name="titleTextStyle">@style/Widget.Styled.LightActionBarHeader</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Styled.LightActionBarHeader" parent="@android:style/TextAppearance">
|
||||
<item name="android:textColor">@color/color_white</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Spinner" parent="android:Widget">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
|
@ -45,8 +46,10 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity {
|
|||
});
|
||||
if (((OsmandApplication)getApplication()).getSettings().isLightActionBar()){
|
||||
toolbar.setBackgroundColor(getResources().getColor(R.color.actionbar_light_color));
|
||||
toolbar.setTitleTextColor(getResources().getColor(R.color.color_white));
|
||||
} else {
|
||||
toolbar.setBackgroundColor(getResources().getColor(R.color.actionbar_dark_color));
|
||||
|
||||
}
|
||||
getSpinner().setVisibility(View.GONE);
|
||||
setProgressVisibility(false);
|
||||
|
|
|
@ -109,8 +109,8 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
private int tabPadding = 12;
|
||||
private int tabTextSize = 14;
|
||||
private ColorStateList tabTextColor = null;
|
||||
private float tabTextAlpha = HALF_TRANSP;
|
||||
private int tabTextColor = 0;
|
||||
private float tabTextAlpha = OPAQUE;
|
||||
private float tabTextSelectedAlpha = OPAQUE;
|
||||
|
||||
private int padding = 0;
|
||||
|
@ -161,11 +161,11 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
|
||||
ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
|
||||
int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
|
||||
if (colorStateList != null) {
|
||||
tabTextColor = colorStateList;
|
||||
} else {
|
||||
tabTextColor = getColorStateList(textPrimaryColor);
|
||||
}
|
||||
// if (colorStateList != null) {
|
||||
// tabTextColor = colorStateList;
|
||||
// } else {
|
||||
// tabTextColor = getColorStateList(textPrimaryColor);
|
||||
// }
|
||||
|
||||
underlineColor = textPrimaryColor;
|
||||
dividerColor = textPrimaryColor;
|
||||
|
@ -179,6 +179,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
|
||||
// get custom attrs
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
|
||||
tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextColor, underlineColor);
|
||||
indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
|
||||
underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
|
||||
dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
|
||||
|
@ -194,7 +195,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
|
||||
tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
|
||||
tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
|
||||
tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
|
||||
tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, OPAQUE);
|
||||
tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
|
||||
a.recycle();
|
||||
|
||||
|
@ -301,6 +302,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
}
|
||||
|
||||
private void updateTabStyles() {
|
||||
tabsContainer.setBackgroundResource(tabBackgroundResId);
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
View v = tabsContainer.getChildAt(i);
|
||||
v.setBackgroundResource(tabBackgroundResId);
|
||||
|
@ -310,9 +312,8 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
if (tab_title != null) {
|
||||
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||
if (tabTextColor != null) {
|
||||
tab_title.setTextColor(tabTextColor);
|
||||
}
|
||||
|
||||
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
|
||||
// pre-ICS-build
|
||||
if (textAllCaps) {
|
||||
|
@ -657,7 +658,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
return textAllCaps;
|
||||
}
|
||||
|
||||
public ColorStateList getTextColor() {
|
||||
public int getTextColor() {
|
||||
return tabTextColor;
|
||||
}
|
||||
|
||||
|
@ -741,24 +742,20 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
}
|
||||
|
||||
public void setTextColor(int textColor) {
|
||||
setTextColor(getColorStateList(textColor));
|
||||
tabTextColor = textColor;
|
||||
}
|
||||
|
||||
private ColorStateList getColorStateList(int textColor) {
|
||||
return new ColorStateList(new int[][]{new int[]{}}, new int[]{textColor});
|
||||
}
|
||||
|
||||
public void setTextColor(ColorStateList colorStateList) {
|
||||
this.tabTextColor = colorStateList;
|
||||
updateTabStyles();
|
||||
}
|
||||
|
||||
public void setTextColorResource(int resId) {
|
||||
setTextColor(getResources().getColor(resId));
|
||||
}
|
||||
|
||||
public void setTextColorStateListResource(int resId) {
|
||||
setTextColor(getResources().getColorStateList(resId));
|
||||
setTextColor(getResources().getColor(resId));
|
||||
}
|
||||
|
||||
public void setTypeface(Typeface typeface, int style) {
|
||||
|
|
Loading…
Reference in a new issue