diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt index 57c25a4e1..355420664 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/DayEventsAdapter.kt @@ -12,6 +12,7 @@ import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.helpers.Formatter import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.commons.dialogs.ConfirmationDialog +import com.simplemobiletools.commons.extensions.beInvisible import com.simplemobiletools.commons.extensions.beInvisibleIf import kotlinx.android.synthetic.main.event_item_day_view.view.* import java.util.* @@ -25,6 +26,7 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List, va var actMode: ActionMode? = null val markedItems = HashSet() var textColor = 0 + var allDayString = "" fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) { itemView.event_item_frame.isSelected = select @@ -40,6 +42,7 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List, va init { textColor = activity.config.textColor + allDayString = activity.resources.getString(R.string.all_day) } val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) { @@ -97,24 +100,34 @@ class DayEventsAdapter(val activity: SimpleActivity, val mItems: List, va itemView.apply { event_item_title.text = event.title - event_item_title.setTextColor(textColor) - event_item_description.text = event.description - event_item_description.setTextColor(textColor) - - event_item_start.text = Formatter.getTimeFromTS(context, event.startTS) - event_item_start.setTextColor(textColor) - - toggleItemSelection(this, markedItems.contains(pos), pos) + event_item_start.text = if (event.isAllDay) allDayString else Formatter.getTimeFromTS(context, event.startTS) event_item_end.beInvisibleIf(event.startTS == event.endTS) + toggleItemSelection(this, markedItems.contains(pos), pos) if (event.startTS != event.endTS) { + val startCode = Formatter.getDayCodeFromTS(event.startTS) + val endCode = Formatter.getDayCodeFromTS(event.endTS) + event_item_end.apply { text = Formatter.getTimeFromTS(context, event.endTS) - setTextColor(textColor) + if (startCode != endCode) { + if (event.isAllDay) { + text = Formatter.getDateFromCode(context, endCode, true) + } else { + append(" (${Formatter.getDateFromCode(context, endCode, true)})") + } + } else if (event.isAllDay) { + beInvisible() + } } } + event_item_start.setTextColor(textColor) + event_item_end.setTextColor(textColor) + event_item_title.setTextColor(textColor) + event_item_description.setTextColor(textColor) + setOnClickListener { viewClicked(multiSelector, event, pos) } setOnLongClickListener { if (!multiSelector.isSelectable) { 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 a50c109e1..95703bea1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListAdapter.kt @@ -132,19 +132,20 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List, toggleItemSelection(this, markedItems.contains(pos), pos) if (item.startTS != item.endTS) { - event_item_end.text = Formatter.getTimeFromTS(context, item.endTS) - val startCode = Formatter.getDayCodeFromTS(item.startTS) val endCode = Formatter.getDayCodeFromTS(item.endTS) - if (startCode != endCode) { - if (item.isAllDay) { - event_item_end.text = Formatter.getDateFromCode(context, endCode, true) - } else { - event_item_end.append(" (${Formatter.getDateFromCode(context, endCode, true)})") + event_item_end.apply { + text = Formatter.getTimeFromTS(context, item.endTS) + if (startCode != endCode) { + if (item.isAllDay) { + text = Formatter.getDateFromCode(context, endCode, true) + } else { + append(" (${Formatter.getDateFromCode(context, endCode, true)})") + } + } else if (item.isAllDay) { + beInvisible() } - } else if (item.isAllDay) { - event_item_end.beInvisible() } } 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 c20e66a90..063ef0fac 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt @@ -120,7 +120,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.isAllDay())) + listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay)) } 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 4b81ebc47..33b9d9606 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/EventListFragment.kt @@ -70,7 +70,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, DBHelper.Event listItems.add(ListSection(day)) prevCode = code } - listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay())) + listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.isAllDay)) } mAllEvents = events 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 70673369e..39a2dd3ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/fragments/WeekFragment.kt @@ -215,7 +215,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { var hadAllDayEvent = false val sorted = events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { it.description })) for (event in sorted) { - if (event.isAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) { + if (event.isAllDay || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) { hadAllDayEvent = true addAllDayEvent(event) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt index e347ca319..7e8b11300 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -28,5 +28,5 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var endTS = newEndTS } - fun isAllDay() = flags and FLAG_ALL_DAY != 0 + val isAllDay = flags and FLAG_ALL_DAY != 0 } 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 2e5869814..20d84b455 100644 --- a/app/src/main/res/layout/event_item_day_view.xml +++ b/app/src/main/res/layout/event_item_day_view.xml @@ -33,7 +33,7 @@ android:id="@+id/event_item_title" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/big_margin" + android:layout_marginLeft="@dimen/activity_margin" android:layout_toRightOf="@+id/event_item_start" android:ellipsize="end" android:maxLines="1" @@ -46,8 +46,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/event_item_title" - android:layout_marginLeft="@dimen/big_margin" - android:layout_toRightOf="@+id/event_item_start" + android:layout_marginLeft="@dimen/activity_margin" + android:layout_toRightOf="@+id/event_item_end" android:alpha=".4" android:ellipsize="end" android:maxLines="1"