From 5e9570ac7deea451cc225a59dce3b4760fa6171f Mon Sep 17 00:00:00 2001 From: Valerio Santinelli Date: Wed, 27 Sep 2017 09:00:06 +0200 Subject: [PATCH] Support for attrs in textColor --- .../CompactCalendarController.java | 16 +++++++++++++++- library/src/main/res/values/attrs.xml | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java b/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java index 9a22199c..2ea799cd 100755 --- a/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java +++ b/library/src/main/java/com/github/sundeepk/compactcalendarview/CompactCalendarController.java @@ -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; @@ -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); diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index be80746e..6256d6fe 100644 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -20,7 +20,7 @@ - +