Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for attrs in textColor #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.sundeepk.compactcalendarview;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
Expand Down Expand Up @@ -142,8 +143,21 @@ private void loadAttributes(AttributeSet attrs, Context context) {
if (attrs != null && context != null) {
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CompactCalendarView, 0, 0);
try {

int id = typedArray.getResourceId(R.styleable.CompactCalendarView_compactCalendarTextColor, -1);
if (id != -1) {
TypedArray app = context.getTheme().obtainStyledAttributes(id, new int[]{ android.R.attr.textColor, android.R.attr.typeface, android.R.attr.textStyle});
if (app != null){
calenderTextColor = app.getColor(0, 0);
app.recycle();
}
} else {
calenderTextColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarTextColor, calenderTextColor);
}

//ColorStateList textColorStateList = typedArray.getColorStateList(R.styleable.CompactCalendarView_compactCalendarTextColor);
currentDayBackgroundColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarCurrentDayBackgroundColor, currentDayBackgroundColor);
calenderTextColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarTextColor, calenderTextColor);

currentDayTextColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarCurrentDayTextColor, calenderTextColor);
otherMonthDaysTextColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarOtherMonthDaysTextColor, otherMonthDaysTextColor);
currentSelectedDayBackgroundColor = typedArray.getColor(R.styleable.CompactCalendarView_compactCalendarCurrentSelectedDayBackgroundColor, currentSelectedDayBackgroundColor);
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<attr name="compactCalendarCurrentDayTextColor" format="color"/>
<attr name="compactCalendarCurrentSelectedDayBackgroundColor" format="color"/>
<attr name="compactCalendarCurrentSelectedDayTextColor" format="color"/>
<attr name="compactCalendarTextColor" format="color"/>
<attr name="compactCalendarTextColor" format="reference|color"/>
<attr name="compactCalendarMultiEventIndicatorColor" format="color"/>
<attr name="compactCalendarTargetHeight" format="dimension"/>
<attr name="compactCalendarEventIndicatorStyle"/>
Expand Down