下面列出了android.util.TypedValue#TYPE_LAST_COLOR_INT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void setOnClick(@IdRes int viewID, Class aActivity) {
View view = getActivity().findViewById(viewID);
if (getActivity().getClass() == aActivity) {
// Get the attribute highlight color
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.navigationDrawerHighlighted, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
int color = a.data;
view.setBackgroundColor(color);
}
setCloseDrawerOnClick(view, mDrawerLayout, containerView);
} else {
setStandardOnClick(view, getActivity(), aActivity, mDrawerLayout, containerView);
}
}
public static ColorStateList resolveActionTextColorStateList(Context context, @AttrRes int colorAttr, ColorStateList fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{colorAttr});
try {
final TypedValue value = a.peekValue(0);
if (value == null) {
return fallback;
}
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
final ColorStateList stateList = a.getColorStateList(0);
if (stateList != null) {
return stateList;
} else {
return fallback;
}
}
} finally {
a.recycle();
}
}
private View setOnClick(@IdRes int viewID, Class aActivity) {
View view = getActivity().findViewById(viewID);
if(getActivity().getClass() == aActivity) {
// Get the attribute highlight color
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(R.attr.navigationDrawerHighlighted, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
int color = a.data;
view.setBackgroundColor(color);
}
setCloseDrawerOnClick(view, mDrawerLayout, containerView);
} else {
setStandardOnClick(view, getActivity(), aActivity, mDrawerLayout, containerView);
}
return view;
}
public static ColorStateList getActionTextColorStateList(Context context, @ColorRes int colorId) {
final TypedValue value = new TypedValue();
context.getResources().getValue(colorId, value, true);
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
//noinspection deprecation
return context.getResources().getColorStateList(colorId);
} else {
return context.getColorStateList(colorId);
}
}
}
private static String getAttributeValue(XmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
@NonNull
ColorStateList loadColorStateList(Resources wrapper, TypedValue value, int id,
Resources.Theme theme)
throws NotFoundException {
if (TRACE_FOR_PRELOAD) {
// Log only framework resources
if ((id >>> 24) == 0x1) {
final String name = getResourceName(id);
if (name != null) android.util.Log.d("PreloadColorStateList", name);
}
}
final long key = (((long) value.assetCookie) << 32) | value.data;
// Handle inline color definitions.
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getColorStateListFromInt(value, key);
}
ComplexColor complexColor = loadComplexColorFromName(wrapper, theme, value, id);
if (complexColor != null && complexColor instanceof ColorStateList) {
return (ColorStateList) complexColor;
}
throw new NotFoundException(
"Can't find ColorStateList from drawable resource ID #0x"
+ Integer.toHexString(id));
}
public static ColorStateList getActionTextColorStateList(Context context, @ColorRes int colorId) {
final TypedValue value = new TypedValue();
context.getResources().getValue(colorId, value, true);
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
return context.getResources().getColorStateList(colorId);
}
}
private static String getAttributeValue(AXmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data == 0 ? "false" : "true";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) +
DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) +
FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
private void init() {
try {
border = new Paint();
border.setStyle(Paint.Style.STROKE);
if (this.isSelected()) {
border.setColor(Color.BLUE);
} else {
border.setColor(Color.GRAY);
}
back = new Paint();
back.setStyle(Paint.Style.FILL);
int color = android.R.color.background_light;
TypedValue a = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT)
color = a.data; // windowBackground is a color
back.setColor(color);
primary = new Paint();
primary.setStyle(Paint.Style.FILL);
primary.setColor(ContextCompat.getColor(getContext(), theme.getPrimaryColor()));
dark = new Paint();
dark.setStyle(Paint.Style.FILL);
dark.setColor(ContextCompat.getColor(getContext(), theme.getPrimaryDarkColor()));
accent = new Paint();
accent.setStyle(Paint.Style.FILL);
accent.setColor(ContextCompat.getColor(getContext(), theme.getAccentColor()));
accent.setAntiAlias(true);
accent.setDither(true);
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static Integer readDefaultValue(TypedArray a, int index) {
if (a.peekValue(index) != null) {
int type = a.peekValue(index).type;
if (type == TypedValue.TYPE_STRING) {
return Color.parseColor(standardiseColorDigits(a.getString(index)));
}
else if (TypedValue.TYPE_FIRST_COLOR_INT <= type && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return a.getColor(index, Color.GRAY);
}
else if (TypedValue.TYPE_FIRST_INT <= type && type <= TypedValue.TYPE_LAST_INT) {
return a.getInt(index, Color.GRAY);
}
}
return null;
}
/**
* Looks are current theme and retrieves the color attribute
* for the given set theme.
*
* @param context to retrieve the set theme and resolved attribute and then color res Id with {@link ContextCompat}
* @return color resource identifier for primary theme color
*/
public static int retrieveThemeColor(Context context, int resId) {
TypedValue outValue = resolveAttributeFromId(context, resId);
if (outValue.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& outValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return outValue.data;
} else {
return ContextCompat.getColor(context, outValue.resourceId);
}
}
public static int getAttrColor(Context context, int attrId) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attrId, typedValue, true);
if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return typedValue.data;
} else {
return context.getResources().getColor(typedValue.resourceId);
}
}
static boolean isColorAttribute(TypedArray a, int idx) {
synchronized (sTmpTypedValue) {
a.getValue(idx, sTmpTypedValue);
return sTmpTypedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& sTmpTypedValue.type <= TypedValue.TYPE_LAST_COLOR_INT;
}
}
public ResScalarValue factory(int type, int value, String rawValue) throws IOException {
switch (type) {
case TypedValue.TYPE_NULL:
return new ResReferenceValue(mPackage, 0, null);
case TypedValue.TYPE_REFERENCE:
return newReference(value, rawValue);
case TypedValue.TYPE_ATTRIBUTE:
return newReference(value, rawValue, true);
case TypedValue.TYPE_STRING:
return new ResStringValue(rawValue, value);
case TypedValue.TYPE_FLOAT:
return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue);
case TypedValue.TYPE_DIMENSION:
return new ResDimenValue(value, rawValue);
case TypedValue.TYPE_FRACTION:
return new ResFractionValue(value, rawValue);
case TypedValue.TYPE_INT_BOOLEAN:
return new ResBoolValue(value != 0, value, rawValue);
case 0x07:
return newReference(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return new ResColorValue(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return new ResIntValue(value, rawValue, type);
}
throw new IOException("Invalid value type: " + type);
}
private void setThemeBackground(View view) {
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
view.setBackgroundColor(a.data);
} else {
try {
Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId, getActivity().getTheme());
ViewCompat.setBackground(view, d);
} catch (Resources.NotFoundException ignore) {
}
}
}
private static String getAttributeValue(XmlResourceParser parser, int index) {
int type = parser.getAttributeValueType(index);
int data = parser.getAttributeValueData(index);
if (type == TypedValue.TYPE_STRING) {
return parser.getAttributeValue(index);
}
if (type == TypedValue.TYPE_ATTRIBUTE) {
return String.format("?%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_REFERENCE) {
return String.format("@%s%08X", getPackage(data), data);
}
if (type == TypedValue.TYPE_FLOAT) {
return String.valueOf(Float.intBitsToFloat(data));
}
if (type == TypedValue.TYPE_INT_HEX) {
return String.format("0x%08X", data);
}
if (type == TypedValue.TYPE_INT_BOOLEAN) {
return data != 0 ? "true" : "false";
}
if (type == TypedValue.TYPE_DIMENSION) {
return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type == TypedValue.TYPE_FRACTION) {
return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK];
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return String.format("#%08X", data);
}
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return String.valueOf(data);
}
if (type == 0x07) {
return String.format("@%s%08X", getPackage(data), data);
}
return String.format("<0x%X, type 0x%02X>", data, type);
}
private void getAttributes(Context context, @Nullable AttributeSet attrs)
{
// According to docs for obtainStyledAttributes, attrs can be null and I assume that each value will be set
// to the default
final TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SegmentedButtonGroup, 0, 0);
// Load background if available, this can be a drawable or a color
// Note: Not well documented but getDrawable will return a ColorDrawable if a color is specified
if (ta.hasValue(R.styleable.SegmentedButtonGroup_android_background))
backgroundDrawable = ta.getDrawable(R.styleable.SegmentedButtonGroup_android_background);
// Load background on selection if available, can be drawable or color
if (ta.hasValue(R.styleable.SegmentedButtonGroup_selectedBackground))
selectedBackgroundDrawable = ta.getDrawable(R.styleable.SegmentedButtonGroup_selectedBackground);
// Note: Must read radius before setBorder call in order to round the border corners!
radius = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_radius, 0);
selectedButtonRadius = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_selectedButtonRadius, 0);
// Setup border for button group
// Width is the thickness of the border, color is the color of the border
// Dash width and gap, if the dash width is not zero will make the border dashed with a ratio between dash
// width and gap
borderWidth = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_borderWidth, 0);
borderColor = ta.getColor(R.styleable.SegmentedButtonGroup_borderColor, Color.BLACK);
borderDashWidth = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_borderDashWidth, 0);
borderDashGap = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_borderDashGap, 0);
// Set the border to the read values, this will set the border values to itself but will create a
// GradientDrawable containing the border
setBorder(borderWidth, borderColor, borderDashWidth, borderDashGap);
// Get border information for the selected button
// Same defaults as the border above, however this border information will be passed to each button so that
// the correct border can be rendered around the selected button
selectedBorderWidth = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_selectedBorderWidth, 0);
selectedBorderColor = ta.getColor(R.styleable.SegmentedButtonGroup_selectedBorderColor, Color.BLACK);
selectedBorderDashWidth = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_selectedBorderDashWidth, 0);
selectedBorderDashGap = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_selectedBorderDashGap, 0);
position = ta.getInt(R.styleable.SegmentedButtonGroup_position, 0);
draggable = ta.getBoolean(R.styleable.SegmentedButtonGroup_draggable, false);
// Update clickable property
// Not updating this property sets the clickable value to false by default but this sets the default to true
// while keeping the clickable value if specified in the layouot XML
setClickable(ta.getBoolean(R.styleable.SegmentedButtonGroup_android_clickable, true));
ripple = ta.getBoolean(R.styleable.SegmentedButtonGroup_ripple, true);
hasRippleColor = ta.hasValue(R.styleable.SegmentedButtonGroup_rippleColor);
rippleColor = ta.getColor(R.styleable.SegmentedButtonGroup_rippleColor, Color.GRAY);
final int dividerWidth = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_dividerWidth, 1);
final int dividerRadius = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_dividerRadius, 0);
final int dividerPadding = ta.getDimensionPixelSize(R.styleable.SegmentedButtonGroup_dividerPadding, 0);
// Load divider value if available, the divider can be either a drawable resource or a color
// Load the TypedValue first and check the type to determine if color or drawable
final TypedValue value = new TypedValue();
if (ta.getValue(R.styleable.SegmentedButtonGroup_divider, value))
{
if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
{
// Note: Odd case where Android Studio layout preview editor will fail to display a
// SegmentedButtonGroup with a divider drawable because value.resourceId returns 0 and thus
// ContextCompat.getDrawable will return NullPointerException
// Loading drawable TypedArray.getDrawable or doing TypedArray.getResourceId fixes the problem
if (isInEditMode())
{
setDivider(ta.getDrawable(R.styleable.SegmentedButtonGroup_divider), dividerWidth, dividerRadius,
dividerPadding);
}
else
{
setDivider(ContextCompat.getDrawable(context, value.resourceId), dividerWidth, dividerRadius,
dividerPadding);
}
}
else if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT)
{
// Divider is a color, value.data is the color value
setDivider(value.data, dividerWidth, dividerRadius, dividerPadding);
}
else
{
// Invalid type for the divider, throw an exception
throw new IllegalArgumentException("Invalid type for SegmentedButtonGroup divider in layout XML "
+ "resource. Must be a color or drawable");
}
}
int selectionAnimationInterpolator = ta.getInt(R.styleable.SegmentedButtonGroup_selectionAnimationInterpolator,
ANIM_INTERPOLATOR_FAST_OUT_SLOW_IN);
setSelectionAnimationInterpolator(selectionAnimationInterpolator);
selectionAnimationDuration = ta.getInt(R.styleable.SegmentedButtonGroup_selectionAnimationDuration, 500);
// Recycle the typed array, required once done using it
ta.recycle();
}
private static boolean isColor(int type) {
return type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT;
}
/**
* @param context used to get the configuration for the drawable from
*/
DrawerArrowDrawable(Context context) {
/*final TypedArray typedArray = context.getTheme()
.obtainStyledAttributes(null, R.styleable.DrawerArrowToggle,
R.attr.drawerArrowStyle,
R.style.Base_Widget_AppCompat_DrawerArrowToggle);
mPaint.setAntiAlias(true);
mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0);
mTopBottomArrowSize = typedArray
.getDimension(R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0);
mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
mMiddleArrowSize = typedArray
.getDimension(R.styleable.DrawerArrowToggle_middleBarArrowSize, 0);
typedArray.recycle();*/
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
int color;
if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
color = typedValue.data;
} else {
try {
color = CompatibilityUtils.getColor(context.getResources(), typedValue.resourceId);
} catch (Exception e) {
color = 0;
}
}
mPaint.setAntiAlias(true);
mPaint.setColor(color);
mSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24.0f, context.getResources().getDisplayMetrics());
mBarSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 18.0f, context.getResources().getDisplayMetrics());
mTopBottomArrowSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 11.31f, context.getResources().getDisplayMetrics());
mBarThickness = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2.0f, context.getResources().getDisplayMetrics());
mBarGap = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3.0f, context.getResources().getDisplayMetrics());
mSpin = true;
mMiddleArrowSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16.0f, context.getResources().getDisplayMetrics());
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.SQUARE);
mPaint.setStrokeWidth(mBarThickness);
}
/**
* Sets up the colors of toolbar, status bar and nav drawer
*/
protected void setupToolbar(Toolbar toolbar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Bitmap ic = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_easy_xkcd_recents);
int color = themePrefs.getPrimaryColor(false);
ActivityManager.TaskDescription description = new ActivityManager.TaskDescription("Easy xkcd", ic, color);
setTaskDescription(description);
if (!(this instanceof MainActivity)) {
getWindow().setStatusBarColor(themePrefs.getPrimaryDarkColor());
}
int navBarColor;
int uiOptions = getWindow().getDecorView().getSystemUiVisibility();
int flagForLightNavBar = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0;
TypedValue backgroundColor = new TypedValue();
getTheme().resolveAttribute(android.R.attr.windowBackground, backgroundColor, true);
if (themePrefs.nightThemeEnabled()) {
uiOptions = uiOptions & Integer.reverse(flagForLightNavBar);
if (themePrefs.amoledThemeEnabled()) {
navBarColor = Color.BLACK;
} else if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT) {
navBarColor = backgroundColor.data;
} else {
navBarColor = Color.BLACK;
}
} else {
uiOptions = uiOptions | flagForLightNavBar;
if (backgroundColor.type >= TypedValue.TYPE_FIRST_COLOR_INT && backgroundColor.type <= TypedValue.TYPE_LAST_COLOR_INT &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
navBarColor = backgroundColor.data;
} else {
navBarColor = Color.BLACK;
}
}
getWindow().setNavigationBarColor(navBarColor);
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setBackgroundColor(themePrefs.getPrimaryColor(false));
if (themePrefs.amoledThemeEnabled()) {
toolbar.setPopupTheme(R.style.ThemeOverlay_AmoledBackground);
}
}