add All-day to daily view
This commit is contained in:
parent
5e180f7fc1
commit
feed23017c
7 changed files with 39 additions and 25 deletions
|
@ -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<Event>, va
|
|||
var actMode: ActionMode? = null
|
||||
val markedItems = HashSet<Int>()
|
||||
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<Event>, 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<Event>, 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) {
|
||||
|
|
|
@ -132,19 +132,20 @@ class EventListAdapter(val activity: SimpleActivity, val mItems: List<ListItem>,
|
|||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue