From 89d9c2c3ef6e36bf1cbba76ddcfdf280970eba9d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 2 Jan 2017 23:27:43 +0100 Subject: [PATCH] update the colors on a few more places --- .../calendar/adapters/EventListAdapter.kt | 5 ++- .../calendar/fragments/MonthFragment.kt | 37 ++++++++++--------- .../calendar/fragments/YearFragment.kt | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt index a26b5f721..f9b2871ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt @@ -49,9 +49,10 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List, } init { - textColor = Config.newInstance(activity).textColor + val config = Config.newInstance(activity) + textColor = config.textColor topDivider = activity.resources.getDrawable(R.drawable.divider) - primaryColor = activity.resources.getColor(R.color.color_primary) + primaryColor = config.primaryColor val mTodayCode = Formatter.getDayCodeFromTS(mNow) todayDate = Formatter.getDate(activity, mTodayCode) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt index fb75c1509..e8101adce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/MonthFragment.kt @@ -93,10 +93,11 @@ class MonthFragment : Fragment(), MonthlyCalendar { private fun setupButtons() { val baseColor = mConfig.textColor + val primaryColor = mConfig.primaryColor mTextColor = baseColor.adjustAlpha(HIGH_ALPHA) - mTextColorWithEvent = mRes.getColor(R.color.color_primary).adjustAlpha(HIGH_ALPHA) + mTextColorWithEvent = primaryColor.adjustAlpha(HIGH_ALPHA) mWeakTextColor = baseColor.adjustAlpha(LOW_ALPHA) - mWeakTextColorWithEvent = mRes.getColor(R.color.color_primary).adjustAlpha(LOW_ALPHA) + mWeakTextColorWithEvent = primaryColor.adjustAlpha(LOW_ALPHA) mHolder.apply { top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP) @@ -152,15 +153,15 @@ class MonthFragment : Fragment(), MonthlyCalendar { val letters = letterIDs for (i in 0..6) { - val dayTV = mHolder.findViewById(mRes.getIdentifier("label_" + i, "id", mPackageName)) as TextView - dayTV.textSize = mDayTextSize - dayTV.setTextColor(mTextColor) - var index = i if (!mSundayFirst) index = (index + 1) % letters.size - dayTV.text = getString(letters[index]) + (mHolder.findViewById(mRes.getIdentifier("label_$i", "id", mPackageName)) as TextView).apply { + textSize = mDayTextSize + setTextColor(mTextColor) + text = getString(letters[index]) + } } } @@ -175,16 +176,15 @@ class MonthFragment : Fragment(), MonthlyCalendar { week_num.beVisibleIf(displayWeekNumbers) for (i in 0..5) { - val weekIdTV = mHolder.findViewById(mRes.getIdentifier("week_num_" + i, "id", mPackageName)) as TextView - weekIdTV.text = "${days[i * 7].weekOfYear}:" - weekIdTV.setTextColor(mWeakTextColor) - weekIdTV.beVisibleIf(displayWeekNumbers) + (mHolder.findViewById(mRes.getIdentifier("week_num_$i", "id", mPackageName)) as TextView).apply { + text = "${days[i * 7].weekOfYear}:" + setTextColor(mWeakTextColor) + beVisibleIf(displayWeekNumbers) + } } for (i in 0..len - 1) { val day = days[i] - val dayTV = mHolder.findViewById(mRes.getIdentifier("day_" + i, "id", mPackageName)) as TextView - var curTextColor = if (day.hasEvent) mWeakTextColorWithEvent else mWeakTextColor var curTextSize = mDayTextSize @@ -196,11 +196,12 @@ class MonthFragment : Fragment(), MonthlyCalendar { curTextSize = mTodayTextSize } - dayTV.text = day.value.toString() - dayTV.setTextColor(curTextColor) - dayTV.textSize = curTextSize - - dayTV.setOnClickListener { openDay(day.code) } + (mHolder.findViewById(mRes.getIdentifier("day_$i", "id", mPackageName)) as TextView).apply { + text = day.value.toString() + setTextColor(curTextColor) + textSize = curTextSize + setOnClickListener { openDay(day.code) } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt index 36bb8eaec..ff5cf831c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/YearFragment.kt @@ -77,7 +77,7 @@ class YearFragment : Fragment(), YearlyCalendar { val now = DateTime() if (now.year == mYear) { val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) as TextView - monthLabel.setTextColor(res.getColor(R.color.color_primary).adjustAlpha(HIGH_ALPHA)) + monthLabel.setTextColor(Config.newInstance(context).primaryColor.adjustAlpha(HIGH_ALPHA)) val monthView = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}", "id", activity.packageName)) as SmallMonthView monthView.setTodaysId(now.dayOfMonth)