add a colored dot to the events list view too

This commit is contained in:
tibbi 2017-08-24 12:05:00 +02:00
parent 166d624eeb
commit 00e7d46be2
7 changed files with 27 additions and 10 deletions

View File

@ -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
}

View File

@ -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<ListItem>,
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) {

View File

@ -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

View File

@ -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) {

View File

@ -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()

View File

@ -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"

View File

@ -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"/>
<ImageView
android:id="@+id/event_item_color"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/event_item_title"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/event_item_title"
android:paddingRight="@dimen/medium_margin"
android:src="@drawable/monthly_event_dot"/>
</RelativeLayout>
</FrameLayout>