From c1a2051f8c5c36eef744d4c23722d2c9a0ffd4fc Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 22 Jan 2017 16:48:25 +0100 Subject: [PATCH] properly update the weekly screen if some color changes --- .../calendar/activities/MainActivity.kt | 20 +++++++++++++------ .../calendar/fragments/WeekFragment.kt | 7 +++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index bafdb8b46..a4cdfb420 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -41,6 +41,8 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { private var mSnackbar: Snackbar? = null private var mEventListFragment: EventListFragment? = null private var mStoredTextColor = 0 + private var mStoredBackgroundColor = 0 + private var mStoredPrimaryColor = 0 private var mStoredIsSundayFirst = false companion object { @@ -52,16 +54,18 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { setContentView(R.layout.activity_main) calendar_fab.setOnClickListener { addNewEvent() } updateViewPager() - mStoredTextColor = config.textColor - mStoredIsSundayFirst = config.isSundayFirst checkWhatsNewDialog() } override fun onResume() { super.onResume() - if (mStoredTextColor != config.textColor) + if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor) updateViewPager() + mStoredTextColor = config.textColor + mStoredPrimaryColor = config.primaryColor + mStoredBackgroundColor = config.backgroundColor + if (mStoredIsSundayFirst != config.isSundayFirst && config.storedView == WEEKLY_VIEW) fillWeeklyViewPager() @@ -74,6 +78,8 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { checkDeleteEvents() mStoredTextColor = config.textColor mStoredIsSundayFirst = config.isSundayFirst + mStoredBackgroundColor = config.backgroundColor + mStoredPrimaryColor = config.primaryColor } override fun onDestroy() { @@ -195,10 +201,12 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener { week_view_hours_holder.removeAllViews() for (i in 1..23) { - val view = layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView val value = i.toString() - view.text = if (value.length == 2) value else "0$value" - week_view_hours_holder.addView(view) + (layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply { + text = if (value.length == 2) value else "0$value" + setTextColor(mStoredTextColor) + week_view_hours_holder.addView(this) + } } week_view_view_pager.apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt index dd3ad6d36..936d6b418 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -94,10 +94,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { private fun setupDayLabels() { var curDay = Formatter.getDateTimeFromTS(mWeekTimestamp) + val textColor = context.config.textColor for (i in 0..6) { - val view = mView.findViewById(mRes.getIdentifier("week_day_label_$i", "id", context.packageName)) as TextView val dayLetter = getDayLetter(curDay.dayOfWeek) - view.text = "$dayLetter\n${curDay.dayOfMonth}" + (mView.findViewById(mRes.getIdentifier("week_day_label_$i", "id", context.packageName)) as TextView).apply { + text = "$dayLetter\n${curDay.dayOfMonth}" + setTextColor(textColor) + } curDay = curDay.plusDays(1) } }