diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt index 72200d43e..9e44f5852 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt @@ -140,9 +140,9 @@ class WidgetListConfigureActivity : AppCompatActivity() { listItems.add(ListSection(day)) var time = dateTime.withHourOfDay(7) - listItems.add(ListEvent(1, time.seconds(), time.plusMinutes(30).seconds(), getString(R.string.sample_title_1), getString(R.string.sample_description_1))) + listItems.add(ListEvent(1, time.seconds(), time.plusMinutes(30).seconds(), getString(R.string.sample_title_1), getString(R.string.sample_description_1), false, config.primaryColor)) time = dateTime.withHourOfDay(8) - listItems.add(ListEvent(2, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_2), getString(R.string.sample_description_2))) + listItems.add(ListEvent(2, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_2), getString(R.string.sample_description_2), false, config.primaryColor)) dateTime = dateTime.plusDays(1) code = Formatter.getDayCodeFromTS(dateTime.seconds()) @@ -150,11 +150,11 @@ class WidgetListConfigureActivity : AppCompatActivity() { listItems.add(ListSection(day)) time = dateTime.withHourOfDay(8) - listItems.add(ListEvent(3, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_3), "")) + listItems.add(ListEvent(3, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_3), "", false, config.primaryColor)) time = dateTime.withHourOfDay(13) - listItems.add(ListEvent(4, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_4), getString(R.string.sample_description_4))) + listItems.add(ListEvent(4, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_4), getString(R.string.sample_description_4), false, config.primaryColor)) time = dateTime.withHourOfDay(18) - listItems.add(ListEvent(5, time.seconds(), time.plusMinutes(10).seconds(), getString(R.string.sample_title_5), "")) + listItems.add(ListEvent(5, time.seconds(), time.plusMinutes(10).seconds(), getString(R.string.sample_title_5), "", false, config.primaryColor)) return listItems } 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 dc31cca15..e9ceade4a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.calendar.adapters +import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.support.v7.view.ActionMode import android.support.v7.widget.RecyclerView @@ -150,6 +151,8 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List, event_item_description.text = item.description event_item_start.text = if (item.isAllDay) allDayString else Formatter.getTimeFromTS(context, item.startTS) event_item_end.beInvisibleIf(item.startTS == item.endTS) + event_item_color.setColorFilter(item.color, PorterDuff.Mode.SRC_IN) + toggleItemSelection(this, markedItems.contains(pos), pos) if (item.startTS != item.endTS) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt index 1207582ab..572302dd8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt @@ -119,7 +119,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV listItems.add(ListSection(day)) prevCode = code } - listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay())) + listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color)) } this@EventListWidgetAdapter.events = listItems diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt index 23dfa1e0a..34bf849b5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt @@ -80,7 +80,7 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents listItems.add(ListSection(day)) prevCode = code } - listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay())) + listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color)) } val eventsAdapter = EventListAdapter(activity as SimpleActivity, listItems, this) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListEvent.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListEvent.kt index 8157e4558..83c8dd5a3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListEvent.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListEvent.kt @@ -1,6 +1,4 @@ package com.simplemobiletools.calendar.models class ListEvent(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var title: String = "", var description: String = "", - var isAllDay: Boolean = false) : ListItem() { - override fun toString() = "Event {id=$id, startTS=$startTS, endTS=$endTS, title=$title, description=$description, isAllDay=$isAllDay}" -} + var isAllDay: Boolean, var color: Int) : ListItem() diff --git a/app/src/main/res/layout/event_item_day_view.xml b/app/src/main/res/layout/event_item_day_view.xml index cedd31e35..ea19f0fa2 100644 --- a/app/src/main/res/layout/event_item_day_view.xml +++ b/app/src/main/res/layout/event_item_day_view.xml @@ -49,6 +49,7 @@ android:layout_height="wrap_content" android:layout_below="@+id/event_item_title" android:layout_marginLeft="@dimen/activity_margin" + android:layout_toLeftOf="@+id/event_item_color" android:layout_toRightOf="@+id/event_item_end" android:alpha=".4" android:ellipsize="end" diff --git a/app/src/main/res/layout/event_list_item.xml b/app/src/main/res/layout/event_list_item.xml index 673ff45c1..a4009802f 100644 --- a/app/src/main/res/layout/event_list_item.xml +++ b/app/src/main/res/layout/event_list_item.xml @@ -38,9 +38,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/activity_margin" + android:layout_toLeftOf="@+id/event_item_color" android:layout_toRightOf="@+id/event_item_start" android:ellipsize="end" android:maxLines="1" + android:paddingRight="@dimen/activity_margin" android:textSize="@dimen/day_text_size" tools:text="Event title"/> @@ -50,12 +52,25 @@ android:layout_height="wrap_content" android:layout_below="@+id/event_item_title" android:layout_marginLeft="@dimen/activity_margin" + android:layout_toLeftOf="@+id/event_item_color" android:layout_toRightOf="@+id/event_item_end" android:alpha=".4" android:ellipsize="end" android:maxLines="1" + android:paddingRight="@dimen/activity_margin" android:textSize="@dimen/day_text_size" tools:text="Event description"/> + +