From 5babf8acd292dc99ebf64969a02d3ae45eaac4d9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 11 Feb 2017 23:01:36 +0100 Subject: [PATCH] use the actual event type colors at weekly view --- .../simplemobiletools/calendar/activities/MainActivity.kt | 6 ++++++ .../simplemobiletools/calendar/fragments/WeekFragment.kt | 4 ++-- 2 files changed, 8 insertions(+), 2 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 843373403..2818cee02 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -6,6 +6,7 @@ import android.content.pm.PackageManager import android.os.Bundle import android.support.v4.app.ActivityCompat import android.support.v4.view.ViewPager +import android.util.SparseIntArray import android.view.Menu import android.view.MenuItem import android.widget.TextView @@ -51,6 +52,7 @@ class MainActivity : SimpleActivity(), NavigationListener { companion object { var mWeekScrollY = 0 + var eventTypeColors = SparseIntArray(3) } override fun onCreate(savedInstanceState: Bundle?) { @@ -66,6 +68,10 @@ class MainActivity : SimpleActivity(), NavigationListener { if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor) updateViewPager() + DBHelper.newInstance(applicationContext).getEventTypes { + eventTypeColors.clear() + it.map { eventTypeColors.put(it.id, it.color) } + } mStoredTextColor = config.textColor mStoredPrimaryColor = config.primaryColor mStoredBackgroundColor = config.backgroundColor 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 be4ca3892..ba433e0a5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -234,7 +234,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val duration = endDateTime.minuteOfDay - startMinutes (inflater.inflate(R.layout.week_event_marker, null, false) as TextView).apply { - background = ColorDrawable(primaryColor) + background = ColorDrawable(MainActivity.eventTypeColors.get(event.eventType, primaryColor)) text = event.title activity.runOnUiThread { layout.addView(this) @@ -295,7 +295,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { private fun addAllDayEvent(event: Event) { (inflater.inflate(R.layout.week_all_day_event_marker, null, false) as TextView).apply { - background = ColorDrawable(primaryColor) + background = ColorDrawable(MainActivity.eventTypeColors.get(event.eventType, primaryColor)) text = event.title val startDateTime = Formatter.getDateTimeFromTS(event.startTS)