redesigning the Event List view

This commit is contained in:
tibbi 2021-11-21 15:10:20 +01:00
parent 0d9f5b6903
commit b1324e93bb
34 changed files with 362 additions and 512 deletions

View file

@ -14,7 +14,7 @@ import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.helpers.MyWidgetListProvider import com.simplemobiletools.calendar.pro.helpers.MyWidgetListProvider
import com.simplemobiletools.calendar.pro.models.ListEvent import com.simplemobiletools.calendar.pro.models.ListEvent
import com.simplemobiletools.calendar.pro.models.ListItem import com.simplemobiletools.calendar.pro.models.ListItem
import com.simplemobiletools.calendar.pro.models.ListSection import com.simplemobiletools.calendar.pro.models.ListSectionDay
import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ColorPickerDialog
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
@ -139,7 +139,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
var dateTime = DateTime.now().withTime(0, 0, 0, 0).plusDays(1) var dateTime = DateTime.now().withTime(0, 0, 0, 0).plusDays(1)
var code = Formatter.getDayCodeFromTS(dateTime.seconds()) var code = Formatter.getDayCodeFromTS(dateTime.seconds())
var day = Formatter.getDayTitle(this, code) var day = Formatter.getDayTitle(this, code)
listItems.add(ListSection(day, code, false, false)) listItems.add(ListSectionDay(day, code, false, false))
var time = dateTime.withHourOfDay(7) 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), false, config.primaryColor, "", false, false)) 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, "", false, false))
@ -149,7 +149,7 @@ class WidgetListConfigureActivity : SimpleActivity() {
dateTime = dateTime.plusDays(1) dateTime = dateTime.plusDays(1)
code = Formatter.getDayCodeFromTS(dateTime.seconds()) code = Formatter.getDayCodeFromTS(dateTime.seconds())
day = Formatter.getDayTitle(this, code) day = Formatter.getDayTitle(this, code)
listItems.add(ListSection(day, code, false, false)) listItems.add(ListSectionDay(day, code, false, false))
time = dateTime.withHourOfDay(8) time = dateTime.withHourOfDay(8)
listItems.add(ListEvent(3, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_3), "", false, config.primaryColor, "", false, false)) listItems.add(ListEvent(3, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_3), "", false, config.primaryColor, "", false, false))

View file

@ -17,15 +17,14 @@ import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.beInvisibleIf import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_item_day_view.view.* import kotlinx.android.synthetic.main.event_list_item.view.*
class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
: MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
private val allDayString = resources.getString(R.string.all_day) private val allDayString = resources.getString(R.string.all_day)
private val replaceDescriptionWithLocation = activity.config.replaceDescription private val replaceDescriptionWithLocation = activity.config.replaceDescription
@ -59,13 +58,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun onActionModeDestroyed() {} override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.event_list_item, parent)
val layoutId = when (viewType) {
ITEM_EVENT -> R.layout.event_item_day_view
else -> R.layout.event_item_day_view_simple
}
return createViewHolder(layoutId, parent)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val event = events[position] val event = events[position]
@ -109,38 +102,24 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
private fun setupView(view: View, event: Event) { private fun setupView(view: View, event: Event) {
view.apply { view.apply {
event_item_frame.isSelected = selectedKeys.contains(event.id?.toInt()) event_item_holder.isSelected = selectedKeys.contains(event.id?.toInt())
event_item_holder.background.applyColorFilter(textColor)
event_item_title.text = event.title event_item_title.text = event.title
event_item_description?.text = if (replaceDescriptionWithLocation) event.location else event.description event_item_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
event_item_start.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS) if (event.startTS != event.endTS && !event.getIsAllDay()) {
event_item_end?.beInvisibleIf(event.startTS == event.endTS) event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, event.endTS)}"
event_item_color_bar.background.applyColorFilter(event.color)
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)
if (startCode != endCode) {
if (event.getIsAllDay()) {
text = Formatter.getDateFromCode(context, endCode, true)
} else {
append(" (${Formatter.getDateFromCode(context, endCode, true)})")
}
} else if (event.getIsAllDay()) {
beInvisible()
}
}
} }
event_item_description?.text = if (replaceDescriptionWithLocation) event.location else event.description
event_item_description.beVisibleIf(event_item_description.text.isNotEmpty())
event_item_color_bar.background.applyColorFilter(event.color)
var newTextColor = textColor var newTextColor = textColor
if (dimPastEvents && event.isPastEvent && !isPrintVersion) { if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
newTextColor = newTextColor.adjustAlpha(LOWER_ALPHA) newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
} }
event_item_start.setTextColor(newTextColor) event_item_time.setTextColor(newTextColor)
event_item_end?.setTextColor(newTextColor)
event_item_title.setTextColor(newTextColor) event_item_title.setTextColor(newTextColor)
event_item_description?.setTextColor(newTextColor) event_item_description?.setTextColor(newTextColor)
} }

View file

@ -14,24 +14,26 @@ import com.simplemobiletools.calendar.pro.helpers.*
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.models.ListEvent import com.simplemobiletools.calendar.pro.models.ListEvent
import com.simplemobiletools.calendar.pro.models.ListItem import com.simplemobiletools.calendar.pro.models.ListItem
import com.simplemobiletools.calendar.pro.models.ListSection import com.simplemobiletools.calendar.pro.models.ListSectionDay
import com.simplemobiletools.calendar.pro.models.ListSectionMonth
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.beInvisibleIf
import com.simplemobiletools.commons.helpers.LOWER_ALPHA import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
import kotlinx.android.synthetic.main.event_list_item.view.* import kotlinx.android.synthetic.main.event_list_item.view.*
import kotlinx.android.synthetic.main.event_list_section.view.* import kotlinx.android.synthetic.main.event_list_section_day.view.*
import java.util.* import java.util.*
class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListItem>, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?, class EventListAdapter(
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { activity: SimpleActivity, var listItems: ArrayList<ListItem>, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?,
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
private val topDivider = resources.getDrawable(R.drawable.divider_width)
private val allDayString = resources.getString(R.string.all_day) private val allDayString = resources.getString(R.string.all_day)
private val replaceDescription = activity.config.replaceDescription private val replaceDescription = activity.config.replaceDescription
private val dimPastEvents = activity.config.dimPastEvents private val dimPastEvents = activity.config.dimPastEvents
@ -42,7 +44,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
init { init {
setupDragListener(true) setupDragListener(true)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSection && !it.isPastSection } val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) { if (firstNonPastSectionIndex != -1) {
activity.runOnUiThread { activity.runOnUiThread {
recyclerView.scrollToPosition(firstNonPastSectionIndex) recyclerView.scrollToPosition(firstNonPastSectionIndex)
@ -75,9 +77,9 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder {
val layoutId = when (viewType) { val layoutId = when (viewType) {
ITEM_EVENT -> R.layout.event_list_item ITEM_SECTION_DAY -> R.layout.event_list_section_day
ITEM_EVENT_SIMPLE -> R.layout.event_list_item_simple ITEM_SECTION_MONTH -> R.layout.event_list_section_month
else -> R.layout.event_list_section else -> R.layout.event_list_item
} }
return createViewHolder(layoutId, parent) return createViewHolder(layoutId, parent)
} }
@ -85,10 +87,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val listItem = listItems[position] val listItem = listItems[position]
holder.bindView(listItem, true, allowLongClick && listItem is ListEvent) { itemView, layoutPosition -> holder.bindView(listItem, true, allowLongClick && listItem is ListEvent) { itemView, layoutPosition ->
if (listItem is ListSection) { when (listItem) {
setupListSection(itemView, listItem, position) is ListSectionDay -> setupListSectionDay(itemView, listItem, position)
} else if (listItem is ListEvent) { is ListEvent -> setupListEvent(itemView, listItem)
setupListEvent(itemView, listItem) is ListSectionMonth -> setupListSectionMonth(itemView, listItem)
} }
} }
bindViewHolder(holder) bindViewHolder(holder)
@ -114,8 +116,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
} else { } else {
ITEM_EVENT ITEM_EVENT
} }
} else if (listItems[position] is ListSectionDay) {
ITEM_SECTION_DAY
} else { } else {
ITEM_HEADER ITEM_SECTION_MONTH
} }
fun toggle24HourFormat(use24HourFormat: Boolean) { fun toggle24HourFormat(use24HourFormat: Boolean) {
@ -145,68 +149,61 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
private fun setupListEvent(view: View, listEvent: ListEvent) { private fun setupListEvent(view: View, listEvent: ListEvent) {
view.apply { view.apply {
event_item_frame.isSelected = selectedKeys.contains(listEvent.hashCode()) event_item_holder.isSelected = selectedKeys.contains(listEvent.hashCode())
event_item_holder.background.applyColorFilter(textColor)
event_item_title.text = listEvent.title event_item_title.text = listEvent.title
event_item_description?.text = if (replaceDescription) listEvent.location else listEvent.description event_item_time.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS)
event_item_start.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS) if (listEvent.startTS != listEvent.endTS && !listEvent.isAllDay) {
event_item_end?.beInvisibleIf(listEvent.startTS == listEvent.endTS) event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, listEvent.endTS)}"
event_item_color_bar.background.applyColorFilter(listEvent.color)
if (listEvent.startTS != listEvent.endTS) {
event_item_end?.apply {
val startCode = Formatter.getDayCodeFromTS(listEvent.startTS)
val endCode = Formatter.getDayCodeFromTS(listEvent.endTS)
text = Formatter.getTimeFromTS(context, listEvent.endTS)
if (startCode != endCode) {
if (listEvent.isAllDay) {
text = Formatter.getDateFromCode(context, endCode, true)
} else {
append(" (${Formatter.getDateFromCode(context, endCode, true)})")
}
} else if (listEvent.isAllDay) {
beInvisible()
}
}
} }
var startTextColor = textColor event_item_description.text = if (replaceDescription) listEvent.location else listEvent.description
var endTextColor = textColor event_item_description.beVisibleIf(event_item_description.text.isNotEmpty())
event_item_color_bar.background.applyColorFilter(listEvent.color)
var newTextColor = textColor
if (listEvent.isAllDay || listEvent.startTS <= now && listEvent.endTS <= now) { if (listEvent.isAllDay || listEvent.startTS <= now && listEvent.endTS <= now) {
if (listEvent.isAllDay && Formatter.getDayCodeFromTS(listEvent.startTS) == Formatter.getDayCodeFromTS(now) && !isPrintVersion) { if (listEvent.isAllDay && Formatter.getDayCodeFromTS(listEvent.startTS) == Formatter.getDayCodeFromTS(now) && !isPrintVersion) {
startTextColor = adjustedPrimaryColor newTextColor = adjustedPrimaryColor
} }
if (dimPastEvents && listEvent.isPastEvent && !isPrintVersion) { if (dimPastEvents && listEvent.isPastEvent && !isPrintVersion) {
startTextColor = startTextColor.adjustAlpha(LOWER_ALPHA) newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
endTextColor = endTextColor.adjustAlpha(LOWER_ALPHA)
} }
} else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) { } else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) {
startTextColor = adjustedPrimaryColor newTextColor = adjustedPrimaryColor
} }
event_item_start.setTextColor(startTextColor) event_item_time.setTextColor(newTextColor)
event_item_end?.setTextColor(endTextColor) event_item_title.setTextColor(newTextColor)
event_item_title.setTextColor(startTextColor) event_item_description.setTextColor(newTextColor)
event_item_description?.setTextColor(startTextColor)
} }
} }
private fun setupListSection(view: View, listSection: ListSection, position: Int) { private fun setupListSectionDay(view: View, listSectionDay: ListSectionDay, position: Int) {
view.event_section_title.apply { view.event_section_title.apply {
text = listSection.title text = listSectionDay.title
setCompoundDrawablesWithIntrinsicBounds(null, if (position == 0) null else topDivider, null, null) var color = if (listSectionDay.isToday && !isPrintVersion) adjustedPrimaryColor else textColor
var color = if (listSection.isToday && !isPrintVersion) adjustedPrimaryColor else textColor if (dimPastEvents && listSectionDay.isPastSection && !isPrintVersion) {
if (dimPastEvents && listSection.isPastSection && !isPrintVersion) {
color = color.adjustAlpha(LOWER_ALPHA) color = color.adjustAlpha(LOWER_ALPHA)
} }
setTextColor(color)
val dayColor = if (listSectionDay.isToday) adjustedPrimaryColor else textColor
setTextColor(dayColor)
}
}
private fun setupListSectionMonth(view: View, listSectionMonth: ListSectionMonth) {
view.event_section_title.apply {
text = listSectionMonth.title
setTextColor(adjustedPrimaryColor)
} }
} }
private fun shareEvents() = activity.shareEvents(getSelectedEventIds()) private fun shareEvents() = activity.shareEvents(getSelectedEventIds())
private fun getSelectedEventIds() = listItems.filter { it is ListEvent && selectedKeys.contains(it.hashCode()) }.map { (it as ListEvent).id }.toMutableList() as ArrayList<Long> private fun getSelectedEventIds() =
listItems.filter { it is ListEvent && selectedKeys.contains(it.hashCode()) }.map { (it as ListEvent).id }.toMutableList() as ArrayList<Long>
private fun askConfirmDelete() { private fun askConfirmDelete() {
val eventIds = getSelectedEventIds() val eventIds = getSelectedEventIds()

View file

@ -17,12 +17,13 @@ import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.calendar.pro.models.ListEvent import com.simplemobiletools.calendar.pro.models.ListEvent
import com.simplemobiletools.calendar.pro.models.ListItem import com.simplemobiletools.calendar.pro.models.ListItem
import com.simplemobiletools.calendar.pro.models.ListSection import com.simplemobiletools.calendar.pro.models.ListSectionDay
import com.simplemobiletools.commons.extensions.adjustAlpha import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.setBackgroundColor import com.simplemobiletools.commons.extensions.setBackgroundColor
import com.simplemobiletools.commons.extensions.setText import com.simplemobiletools.commons.extensions.setText
import com.simplemobiletools.commons.extensions.setTextSize import com.simplemobiletools.commons.extensions.setTextSize
import com.simplemobiletools.commons.helpers.LOWER_ALPHA import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.* import java.util.*
@ -33,12 +34,12 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
private val allDayString = context.resources.getString(R.string.all_day) private val allDayString = context.resources.getString(R.string.all_day)
private var events = ArrayList<ListItem>() private var events = ArrayList<ListItem>()
private var textColor = context.config.widgetTextColor private var textColor = context.config.widgetTextColor
private var weakTextColor = textColor.adjustAlpha(LOWER_ALPHA) private var weakTextColor = textColor.adjustAlpha(MEDIUM_ALPHA)
private val replaceDescription = context.config.replaceDescription private val replaceDescription = context.config.replaceDescription
private val dimPastEvents = context.config.dimPastEvents private val dimPastEvents = context.config.dimPastEvents
private var mediumFontSize = context.getWidgetFontSize() private var mediumFontSize = context.getWidgetFontSize()
override fun getViewAt(position: Int): RemoteViews? { override fun getViewAt(position: Int): RemoteViews {
val type = getItemViewType(position) val type = getItemViewType(position)
val remoteView: RemoteViews val remoteView: RemoteViews
@ -49,7 +50,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
setupListEvent(remoteView, event) setupListEvent(remoteView, event)
} else { } else {
remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget) remoteView = RemoteViews(context.packageName, R.layout.event_list_section_widget)
val section = events.getOrNull(position) as? ListSection val section = events.getOrNull(position) as? ListSectionDay
if (section != null) { if (section != null) {
setupListSection(remoteView, section) setupListSection(remoteView, section)
} }
@ -63,12 +64,12 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
return if (detailField.isNotEmpty()) { return if (detailField.isNotEmpty()) {
R.layout.event_list_item_widget R.layout.event_list_item_widget
} else if (event.startTS == event.endTS) { } else if (event.startTS == event.endTS) {
R.layout.event_list_item_widget_simple R.layout.event_list_item_widget
} else if (event.isAllDay) { } else if (event.isAllDay) {
val startCode = Formatter.getDayCodeFromTS(event.startTS) val startCode = Formatter.getDayCodeFromTS(event.startTS)
val endCode = Formatter.getDayCodeFromTS(event.endTS) val endCode = Formatter.getDayCodeFromTS(event.endTS)
if (startCode == endCode) { if (startCode == endCode) {
R.layout.event_list_item_widget_simple R.layout.event_list_item_widget
} else { } else {
R.layout.event_list_item_widget R.layout.event_list_item_widget
} }
@ -82,7 +83,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
remoteView.apply { remoteView.apply {
setText(R.id.event_item_title, item.title) setText(R.id.event_item_title, item.title)
setText(R.id.event_item_description, if (replaceDescription) item.location else item.description) setText(R.id.event_item_description, if (replaceDescription) item.location else item.description)
setText(R.id.event_item_start, if (item.isAllDay) allDayString else Formatter.getTimeFromTS(context, item.startTS)) setText(R.id.event_item_time, if (item.isAllDay) allDayString else Formatter.getTimeFromTS(context, item.startTS))
setBackgroundColor(R.id.event_item_color_bar, item.color) setBackgroundColor(R.id.event_item_color_bar, item.color)
if (item.startTS == item.endTS) { if (item.startTS == item.endTS) {
@ -111,12 +112,12 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
setTextColor(R.id.event_item_title, curTextColor) setTextColor(R.id.event_item_title, curTextColor)
setTextColor(R.id.event_item_description, curTextColor) setTextColor(R.id.event_item_description, curTextColor)
setTextColor(R.id.event_item_start, curTextColor) setTextColor(R.id.event_item_time, curTextColor)
setTextColor(R.id.event_item_end, curTextColor) setTextColor(R.id.event_item_end, curTextColor)
setTextSize(R.id.event_item_title, mediumFontSize) setTextSize(R.id.event_item_title, mediumFontSize)
setTextSize(R.id.event_item_description, mediumFontSize) setTextSize(R.id.event_item_description, mediumFontSize)
setTextSize(R.id.event_item_start, mediumFontSize) setTextSize(R.id.event_item_time, mediumFontSize)
setTextSize(R.id.event_item_end, mediumFontSize) setTextSize(R.id.event_item_end, mediumFontSize)
Intent().apply { Intent().apply {
@ -127,7 +128,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
} }
} }
private fun setupListSection(remoteView: RemoteViews, item: ListSection) { private fun setupListSection(remoteView: RemoteViews, item: ListSectionDay) {
var curTextColor = textColor var curTextColor = textColor
if (dimPastEvents && item.isPastSection) { if (dimPastEvents && item.isPastSection) {
curTextColor = weakTextColor curTextColor = weakTextColor
@ -188,12 +189,23 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
if (code != prevCode) { if (code != prevCode) {
val day = Formatter.getDayTitle(context, code) val day = Formatter.getDayTitle(context, code)
val isToday = day == today val isToday = day == today
val listSection = ListSection(day, code, isToday, !isToday && it.startTS < now) val listSection = ListSectionDay(day, code, isToday, !isToday && it.startTS < now)
listItems.add(listSection) listItems.add(listSection)
prevCode = code prevCode = code
} }
val listEvent = ListEvent(it.id!!, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location, it.isPastEvent, it.repeatInterval > 0) val listEvent = ListEvent(
it.id!!,
it.startTS,
it.endTS,
it.title,
it.description,
it.getIsAllDay(),
it.color,
it.location,
it.isPastEvent,
it.repeatInterval > 0
)
listItems.add(listEvent) listItems.add(listEvent)
} }

View file

@ -475,7 +475,7 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou
} }
} }
fun Context.getEventListItems(events: List<Event>, addSections: Boolean = true): ArrayList<ListItem> { fun Context.getEventListItems(events: List<Event>, addSectionDays: Boolean = true, addSectionMonths: Boolean = true): ArrayList<ListItem> {
val listItems = ArrayList<ListItem>(events.size) val listItems = ArrayList<ListItem>(events.size)
val replaceDescription = config.replaceDescription val replaceDescription = config.replaceDescription
@ -495,18 +495,29 @@ fun Context.getEventListItems(events: List<Event>, addSections: Boolean = true):
}.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description }) }.thenBy { it.title }.thenBy { if (replaceDescription) it.location else it.description })
var prevCode = "" var prevCode = ""
var prevMonthLabel = ""
val now = getNowSeconds() val now = getNowSeconds()
val today = Formatter.getDayTitle(this, Formatter.getDayCodeFromTS(now)) val todayCode = Formatter.getDayCodeFromTS(now)
sorted.forEach { sorted.forEach {
val code = Formatter.getDayCodeFromTS(it.startTS) val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode && addSections) { if (addSectionMonths) {
val day = Formatter.getDayTitle(this, code) val monthLabel = Formatter.getLongMonthYear(this, code)
val isToday = day == today if (monthLabel != prevMonthLabel) {
val listSection = ListSection(day, code, isToday, !isToday && it.startTS < now) val listSectionMonth = ListSectionMonth(monthLabel)
listItems.add(listSection) listItems.add(listSectionMonth)
prevMonthLabel = monthLabel
}
}
if (code != prevCode && addSectionDays) {
val day = Formatter.getDateDayTitle(code)
val isToday = code == todayCode
val listSectionDay = ListSectionDay(day, code, isToday, !isToday && it.startTS < now)
listItems.add(listSectionDay)
prevCode = code prevCode = code
} }
val listEvent = val listEvent =
ListEvent(it.id!!, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location, it.isPastEvent, it.repeatInterval > 0) ListEvent(it.id!!, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location, it.isPastEvent, it.repeatInterval > 0)
listItems.add(listEvent) listItems.add(listEvent)

View file

@ -43,7 +43,7 @@ class DayFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_day, container, false) val view = inflater.inflate(R.layout.fragment_day, container, false)
mHolder = view.day_holder mHolder = view.day_holder
mDayCode = arguments!!.getString(DAY_CODE)!! mDayCode = requireArguments().getString(DAY_CODE)!!
setupButtons() setupButtons()
return view return view
} }
@ -54,7 +54,7 @@ class DayFragment : Fragment() {
} }
private fun setupButtons() { private fun setupButtons() {
mTextColor = context!!.config.textColor mTextColor = requireContext().config.textColor
mHolder.top_left_arrow.apply { mHolder.top_left_arrow.apply {
applyColorFilter(mTextColor) applyColorFilter(mTextColor)
@ -63,7 +63,7 @@ class DayFragment : Fragment() {
mListener?.goLeft() mListener?.goLeft()
} }
val pointerLeft = context!!.getDrawable(R.drawable.ic_chevron_left_vector) val pointerLeft = requireContext().getDrawable(R.drawable.ic_chevron_left_vector)
pointerLeft?.isAutoMirrored = true pointerLeft?.isAutoMirrored = true
setImageDrawable(pointerLeft) setImageDrawable(pointerLeft)
} }
@ -75,12 +75,12 @@ class DayFragment : Fragment() {
mListener?.goRight() mListener?.goRight()
} }
val pointerRight = context!!.getDrawable(R.drawable.ic_chevron_right_vector) val pointerRight = requireContext().getDrawable(R.drawable.ic_chevron_right_vector)
pointerRight?.isAutoMirrored = true pointerRight?.isAutoMirrored = true
setImageDrawable(pointerRight) setImageDrawable(pointerRight)
} }
val day = Formatter.getDayTitle(context!!, mDayCode) val day = Formatter.getDayTitle(requireContext(), mDayCode)
mHolder.top_value.apply { mHolder.top_value.apply {
text = day text = day
contentDescription = text contentDescription = text
@ -106,7 +106,7 @@ class DayFragment : Fragment() {
} }
lastHash = newHash lastHash = newHash
val replaceDescription = context!!.config.replaceDescription val replaceDescription = requireContext().config.replaceDescription
val sorted = ArrayList(events.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, { val sorted = ArrayList(events.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, {
if (replaceDescription) it.location else it.description if (replaceDescription) it.location else it.description
}))) })))
@ -147,12 +147,12 @@ class DayFragment : Fragment() {
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode() (day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
Handler().postDelayed({ Handler().postDelayed({
context!!.printBitmap(day_holder.getViewBitmap()) requireContext().printBitmap(day_holder.getViewBitmap())
Handler().postDelayed({ Handler().postDelayed({
top_left_arrow.beVisible() top_left_arrow.beVisible()
top_right_arrow.beVisible() top_right_arrow.beVisible()
top_value.setTextColor(context!!.config.textColor) top_value.setTextColor(requireContext().config.textColor)
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode() (day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
}, 1000) }, 1000)
}, 1000) }, 1000)

View file

@ -40,7 +40,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_days_holder, container, false) val view = inflater.inflate(R.layout.fragment_days_holder, container, false)
view.background = ColorDrawable(context!!.config.backgroundColor) view.background = ColorDrawable(requireContext().config.backgroundColor)
viewPager = view.fragment_days_viewpager viewPager = view.fragment_days_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt() viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment() setupFragment()
@ -49,7 +49,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() { private fun setupFragment() {
val codes = getDays(currentDayCode) val codes = getDays(currentDayCode)
val dailyAdapter = MyDayPagerAdapter(activity!!.supportFragmentManager, codes, this) val dailyAdapter = MyDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultDailyPage = codes.size / 2 defaultDailyPage = codes.size / 2
@ -104,19 +104,19 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
} }
override fun showGoToDateDialog() { override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme()) requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val dateTime = Formatter.getDateTimeFromCode(currentDayCode) val dateTime = Formatter.getDateTimeFromCode(currentDayCode)
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.create().apply { .create().apply {
activity?.setupDialogStuff(view, this) activity?.setupDialogStuff(view, this)
} }
} }
private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) { private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) {

View file

@ -17,7 +17,7 @@ import com.simplemobiletools.calendar.pro.helpers.Formatter
import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.calendar.pro.models.ListEvent import com.simplemobiletools.calendar.pro.models.ListEvent
import com.simplemobiletools.calendar.pro.models.ListItem import com.simplemobiletools.calendar.pro.models.ListItem
import com.simplemobiletools.calendar.pro.models.ListSection import com.simplemobiletools.calendar.pro.models.ListSectionDay
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.MONTH_SECONDS import com.simplemobiletools.commons.helpers.MONTH_SECONDS
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
@ -48,7 +48,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_event_list, container, false) mView = inflater.inflate(R.layout.fragment_event_list, container, false)
mView.background = ColorDrawable(context!!.config.backgroundColor) mView.background = ColorDrawable(requireContext().config.backgroundColor)
mView.calendar_events_list_holder?.id = (System.currentTimeMillis() % 100000).toInt() mView.calendar_events_list_holder?.id = (System.currentTimeMillis() % 100000).toInt()
mView.calendar_empty_list_placeholder_2.apply { mView.calendar_empty_list_placeholder_2.apply {
setTextColor(context.getAdjustedPrimaryColor()) setTextColor(context.getAdjustedPrimaryColor())
@ -58,7 +58,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
} }
} }
use24HourFormat = context!!.config.use24HourFormat use24HourFormat = requireContext().config.use24HourFormat
updateActionBarTitle() updateActionBarTitle()
return mView return mView
} }
@ -66,7 +66,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
checkEvents() checkEvents()
val use24Hour = context!!.config.use24HourFormat val use24Hour = requireContext().config.use24HourFormat
if (use24Hour != use24HourFormat) { if (use24Hour != use24HourFormat) {
use24HourFormat = use24Hour use24HourFormat = use24Hour
(mView.calendar_events_list.adapter as? EventListAdapter)?.toggle24HourFormat(use24HourFormat) (mView.calendar_events_list.adapter as? EventListAdapter)?.toggle24HourFormat(use24HourFormat)
@ -75,23 +75,24 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
use24HourFormat = context!!.config.use24HourFormat use24HourFormat = requireContext().config.use24HourFormat
} }
private fun checkEvents() { private fun checkEvents() {
if (!wereInitialEventsAdded) { if (!wereInitialEventsAdded) {
minFetchedTS = DateTime().minusMinutes(context!!.config.displayPastEvents).seconds() minFetchedTS = DateTime().minusMinutes(requireContext().config.displayPastEvents).seconds()
maxFetchedTS = DateTime().plusMonths(6).seconds() maxFetchedTS = DateTime().plusMonths(6).seconds()
} }
context!!.eventsHelper.getEvents(minFetchedTS, maxFetchedTS) { requireContext().eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
if (it.size >= MIN_EVENTS_TRESHOLD) { if (it.size >= MIN_EVENTS_TRESHOLD) {
receivedEvents(it, NOT_UPDATING) receivedEvents(it, NOT_UPDATING)
} else { } else {
if (!wereInitialEventsAdded) { if (!wereInitialEventsAdded) {
maxFetchedTS += FETCH_INTERVAL maxFetchedTS += FETCH_INTERVAL
} }
context!!.eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
requireContext().eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
mEvents = it mEvents = it
receivedEvents(mEvents, NOT_UPDATING, !wereInitialEventsAdded) receivedEvents(mEvents, NOT_UPDATING, !wereInitialEventsAdded)
} }
@ -106,7 +107,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
} }
mEvents = events mEvents = events
val listItems = context!!.getEventListItems(mEvents) val listItems = requireContext().getEventListItems(mEvents)
activity?.runOnUiThread { activity?.runOnUiThread {
if (activity == null) { if (activity == null) {
@ -154,7 +155,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
mView.calendar_events_list.scrollToPosition(item) mView.calendar_events_list.scrollToPosition(item)
} }
} else if (updateStatus == UPDATE_BOTTOM) { } else if (updateStatus == UPDATE_BOTTOM) {
mView.calendar_events_list.smoothScrollBy(0, context!!.resources.getDimension(R.dimen.endless_scroll_move_height).toInt()) mView.calendar_events_list.smoothScrollBy(0, requireContext().resources.getDimension(R.dimen.endless_scroll_move_height).toInt())
} }
} }
checkPlaceholderVisibility() checkPlaceholderVisibility()
@ -166,7 +167,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
mView.calendar_empty_list_placeholder_2.beVisibleIf(mEvents.isEmpty()) mView.calendar_empty_list_placeholder_2.beVisibleIf(mEvents.isEmpty())
mView.calendar_events_list.beGoneIf(mEvents.isEmpty()) mView.calendar_events_list.beGoneIf(mEvents.isEmpty())
if (activity != null) if (activity != null)
mView.calendar_empty_list_placeholder.setTextColor(activity!!.config.textColor) mView.calendar_empty_list_placeholder.setTextColor(requireActivity().config.textColor)
} }
private fun fetchPreviousPeriod() { private fun fetchPreviousPeriod() {
@ -175,7 +176,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val oldMinFetchedTS = minFetchedTS - 1 val oldMinFetchedTS = minFetchedTS - 1
minFetchedTS -= FETCH_INTERVAL minFetchedTS -= FETCH_INTERVAL
context!!.eventsHelper.getEvents(minFetchedTS, oldMinFetchedTS) { requireContext().eventsHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
mEvents.addAll(0, it) mEvents.addAll(0, it)
receivedEvents(mEvents, UPDATE_TOP) receivedEvents(mEvents, UPDATE_TOP)
} }
@ -184,7 +185,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
private fun fetchNextPeriod() { private fun fetchNextPeriod() {
val oldMaxFetchedTS = maxFetchedTS + 1 val oldMaxFetchedTS = maxFetchedTS + 1
maxFetchedTS += FETCH_INTERVAL maxFetchedTS += FETCH_INTERVAL
context!!.eventsHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) { requireContext().eventsHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
mEvents.addAll(it) mEvents.addAll(it)
receivedEvents(mEvents, UPDATE_BOTTOM) receivedEvents(mEvents, UPDATE_BOTTOM)
} }
@ -195,8 +196,8 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
} }
override fun goToToday() { override fun goToToday() {
val listItems = context!!.getEventListItems(mEvents) val listItems = requireContext().getEventListItems(mEvents)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSection && !it.isPastSection } val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) { if (firstNonPastSectionIndex != -1) {
(mView.calendar_events_list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(firstNonPastSectionIndex, 0) (mView.calendar_events_list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(firstNonPastSectionIndex, 0)
mView.calendar_events_list.onGlobalLayout { mView.calendar_events_list.onGlobalLayout {
@ -229,7 +230,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
(calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode() (calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode()
Handler().postDelayed({ Handler().postDelayed({
context!!.printBitmap(calendar_events_list.getViewBitmap()) requireContext().printBitmap(calendar_events_list.getViewBitmap())
Handler().postDelayed({ Handler().postDelayed({
(calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode() (calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode()

View file

@ -49,9 +49,9 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_month_day, container, false) val view = inflater.inflate(R.layout.fragment_month_day, container, false)
mRes = resources mRes = resources
mPackageName = activity!!.packageName mPackageName = requireActivity().packageName
mHolder = view.month_day_calendar_holder mHolder = view.month_day_calendar_holder
mDayCode = arguments!!.getString(DAY_CODE)!! mDayCode = requireArguments().getString(DAY_CODE)!!
val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode) val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode)
mHolder.month_day_selected_day_label.apply { mHolder.month_day_selected_day_label.apply {
@ -61,10 +61,10 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
} }
} }
mConfig = context!!.config mConfig = requireContext().config
storeStateVariables() storeStateVariables()
setupButtons() setupButtons()
mCalendar = MonthlyCalendarImpl(this, context!!) mCalendar = MonthlyCalendarImpl(this, requireContext())
return view return view
} }
@ -135,9 +135,9 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
} }
} }
val listItems = activity!!.getEventListItems(filtered, false) val listItems = requireActivity().getEventListItems(filtered, mSelectedDayCode.isEmpty(), false)
if (mSelectedDayCode.isNotEmpty()) { if (mSelectedDayCode.isNotEmpty()) {
mHolder.month_day_selected_day_label.text = Formatter.getDateFromCode(activity!!, mSelectedDayCode, false) mHolder.month_day_selected_day_label.text = Formatter.getDateFromCode(requireActivity(), mSelectedDayCode, false)
} }
activity?.runOnUiThread { activity?.runOnUiThread {
@ -178,7 +178,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
fun getNewEventDayCode() = if (mSelectedDayCode.isEmpty()) mDayCode else mSelectedDayCode fun getNewEventDayCode() = if (mSelectedDayCode.isEmpty()) mDayCode else mSelectedDayCode
private fun getMonthLabel(shownMonthDateTime: DateTime): String { private fun getMonthLabel(shownMonthDateTime: DateTime): String {
var month = Formatter.getMonthName(activity!!, shownMonthDateTime.monthOfYear) var month = Formatter.getMonthName(requireActivity(), shownMonthDateTime.monthOfYear)
val targetYear = shownMonthDateTime.toString(YEAR_PATTERN) val targetYear = shownMonthDateTime.toString(YEAR_PATTERN)
if (targetYear != DateTime().toString(YEAR_PATTERN)) { if (targetYear != DateTime().toString(YEAR_PATTERN)) {
month += " $targetYear" month += " $targetYear"

View file

@ -42,7 +42,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_months_days_holder, container, false) val view = inflater.inflate(R.layout.fragment_months_days_holder, container, false)
view.background = ColorDrawable(context!!.config.backgroundColor) view.background = ColorDrawable(requireContext().config.backgroundColor)
viewPager = view.fragment_months_days_viewpager viewPager = view.fragment_months_days_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt() viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment() setupFragment()
@ -51,7 +51,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() { private fun setupFragment() {
val codes = getMonths(currentDayCode) val codes = getMonths(currentDayCode)
val monthlyDailyAdapter = MyMonthDayPagerAdapter(activity!!.supportFragmentManager, codes, this) val monthlyDailyAdapter = MyMonthDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2 defaultMonthlyPage = codes.size / 2
viewPager!!.apply { viewPager!!.apply {
@ -106,7 +106,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
} }
override fun showGoToDateDialog() { override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme()) requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone() datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
@ -114,7 +114,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
val dateTime = DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString()) val dateTime = DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.create().apply { .create().apply {

View file

@ -45,14 +45,14 @@ class MonthFragment : Fragment(), MonthlyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_month, container, false) val view = inflater.inflate(R.layout.fragment_month, container, false)
mRes = resources mRes = resources
mPackageName = activity!!.packageName mPackageName = requireActivity().packageName
mHolder = view.month_calendar_holder mHolder = view.month_calendar_holder
mDayCode = arguments!!.getString(DAY_CODE)!! mDayCode = requireArguments().getString(DAY_CODE)!!
mConfig = context!!.config mConfig = requireContext().config
storeStateVariables() storeStateVariables()
setupButtons() setupButtons()
mCalendar = MonthlyCalendarImpl(this, context!!) mCalendar = MonthlyCalendarImpl(this, requireContext())
return view return view
} }
@ -116,7 +116,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
listener?.goLeft() listener?.goLeft()
} }
val pointerLeft = context!!.getDrawable(R.drawable.ic_chevron_left_vector) val pointerLeft = requireContext().getDrawable(R.drawable.ic_chevron_left_vector)
pointerLeft?.isAutoMirrored = true pointerLeft?.isAutoMirrored = true
setImageDrawable(pointerLeft) setImageDrawable(pointerLeft)
} }
@ -128,7 +128,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
listener?.goRight() listener?.goRight()
} }
val pointerRight = context!!.getDrawable(R.drawable.ic_chevron_right_vector) val pointerRight = requireContext().getDrawable(R.drawable.ic_chevron_right_vector)
pointerRight?.isAutoMirrored = true pointerRight?.isAutoMirrored = true
setImageDrawable(pointerRight) setImageDrawable(pointerRight)
} }
@ -154,7 +154,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color)) top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
month_view_wrapper.togglePrintMode() month_view_wrapper.togglePrintMode()
context!!.printBitmap(month_calendar_holder.getViewBitmap()) requireContext().printBitmap(month_calendar_holder.getViewBitmap())
top_left_arrow.beVisible() top_left_arrow.beVisible()
top_right_arrow.beVisible() top_right_arrow.beVisible()

View file

@ -42,7 +42,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_months_holder, container, false) val view = inflater.inflate(R.layout.fragment_months_holder, container, false)
view.background = ColorDrawable(context!!.config.backgroundColor) view.background = ColorDrawable(requireContext().config.backgroundColor)
viewPager = view.fragment_months_viewpager viewPager = view.fragment_months_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt() viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment() setupFragment()
@ -51,7 +51,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() { private fun setupFragment() {
val codes = getMonths(currentDayCode) val codes = getMonths(currentDayCode)
val monthlyAdapter = MyMonthPagerAdapter(activity!!.supportFragmentManager, codes, this) val monthlyAdapter = MyMonthPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2 defaultMonthlyPage = codes.size / 2
viewPager!!.apply { viewPager!!.apply {
@ -106,7 +106,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
} }
override fun showGoToDateDialog() { override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme()) requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone() datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
@ -114,7 +114,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
val dateTime = DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString()) val dateTime = DateTime(Formatter.getDateTimeFromCode(currentDayCode).toString())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.create().apply { .create().apply {

View file

@ -81,14 +81,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
res = context!!.resources res = requireContext().resources
config = context!!.config config = requireContext().config
rowHeight = context!!.getWeeklyViewItemHeight() rowHeight = requireContext().getWeeklyViewItemHeight()
defaultRowHeight = res.getDimension(R.dimen.weekly_view_row_height) defaultRowHeight = res.getDimension(R.dimen.weekly_view_row_height)
weekTimestamp = arguments!!.getLong(WEEK_START_TIMESTAMP) weekTimestamp = requireArguments().getLong(WEEK_START_TIMESTAMP)
dimPastEvents = config.dimPastEvents dimPastEvents = config.dimPastEvents
highlightWeekends = config.highlightWeekends highlightWeekends = config.highlightWeekends
primaryColor = context!!.getAdjustedPrimaryColor() primaryColor = requireContext().getAdjustedPrimaryColor()
allDayRows.add(HashSet()) allDayRows.add(HashSet())
} }
@ -96,7 +96,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
this.inflater = inflater this.inflater = inflater
val fullHeight = context!!.getWeeklyViewItemHeight().toInt() * 24 val fullHeight = requireContext().getWeeklyViewItemHeight().toInt() * 24
mView = inflater.inflate(R.layout.fragment_week, container, false).apply { mView = inflater.inflate(R.layout.fragment_week, container, false).apply {
scrollView = week_events_scrollview scrollView = week_events_scrollview
week_horizontal_grid_holder.layoutParams.height = fullHeight week_horizontal_grid_holder.layoutParams.height = fullHeight
@ -137,7 +137,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
context!!.eventsHelper.getEventTypes(activity!!, false) { requireContext().eventsHelper.getEventTypes(requireActivity(), false) {
it.map { it.map {
eventTypeColors.put(it.id!!, it.color) eventTypeColors.put(it.id!!, it.color)
} }
@ -180,7 +180,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
fun updateCalendar() { fun updateCalendar() {
if (context != null) { if (context != null) {
WeeklyCalendarImpl(this, context!!).updateWeeklyCalendar(weekTimestamp) WeeklyCalendarImpl(this, requireContext()).updateWeeklyCalendar(weekTimestamp)
} }
} }
@ -386,7 +386,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
lastHash = newHash lastHash = newHash
activity!!.runOnUiThread { requireActivity().runOnUiThread {
if (context != null && activity != null && isAdded) { if (context != null && activity != null && isAdded) {
val replaceDescription = config.replaceDescription val replaceDescription = config.replaceDescription
val sorted = events.sortedWith( val sorted = events.sortedWith(
@ -506,7 +506,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor) var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
var textColor = backgroundColor.getContrastColor() var textColor = backgroundColor.getContrastColor()
if (dimPastEvents && event.isPastEvent && !isPrintVersion) { if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
backgroundColor = backgroundColor.adjustAlpha(LOWER_ALPHA) backgroundColor = backgroundColor.adjustAlpha(MEDIUM_ALPHA)
textColor = textColor.adjustAlpha(HIGHER_ALPHA) textColor = textColor.adjustAlpha(HIGHER_ALPHA)
} }

View file

@ -48,9 +48,9 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
weekHolder = inflater.inflate(R.layout.fragment_week_holder, container, false) as ViewGroup weekHolder = inflater.inflate(R.layout.fragment_week_holder, container, false) as ViewGroup
weekHolder!!.background = ColorDrawable(context!!.config.backgroundColor) weekHolder!!.background = ColorDrawable(requireContext().config.backgroundColor)
val itemHeight = context!!.getWeeklyViewItemHeight().toInt() val itemHeight = requireContext().getWeeklyViewItemHeight().toInt()
weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight) weekHolder!!.week_view_hours_holder.setPadding(0, 0, 0, itemHeight)
viewPager = weekHolder!!.week_view_view_pager viewPager = weekHolder!!.week_view_view_pager
@ -92,7 +92,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupWeeklyViewPager() { private fun setupWeeklyViewPager() {
val weekTSs = getWeekTimestamps(currentWeekTS) val weekTSs = getWeekTimestamps(currentWeekTS)
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this) val weeklyAdapter = MyWeekPagerAdapter(requireActivity().supportFragmentManager, weekTSs, this)
defaultWeeklyPage = weekTSs.size / 2 defaultWeeklyPage = weekTSs.size / 2
@ -125,12 +125,12 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}) })
} }
private fun addHours(textColor: Int = context!!.config.textColor) { private fun addHours(textColor: Int = requireContext().config.textColor) {
val itemHeight = context!!.getWeeklyViewItemHeight().toInt() val itemHeight = requireContext().getWeeklyViewItemHeight().toInt()
weekHolder!!.week_view_hours_holder.removeAllViews() weekHolder!!.week_view_hours_holder.removeAllViews()
val hourDateTime = DateTime().withDate(2000, 1, 1).withTime(0, 0, 0, 0) val hourDateTime = DateTime().withDate(2000, 1, 1).withTime(0, 0, 0, 0)
for (i in 1..23) { for (i in 1..23) {
val formattedHours = Formatter.getHours(context!!, hourDateTime.withHourOfDay(i)) val formattedHours = Formatter.getHours(requireContext(), hourDateTime.withHourOfDay(i))
(layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply { (layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply {
text = formattedHours text = formattedHours
setTextColor(textColor) setTextColor(textColor)
@ -143,7 +143,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun getWeekTimestamps(targetSeconds: Long): List<Long> { private fun getWeekTimestamps(targetSeconds: Long): List<Long> {
val weekTSs = ArrayList<Long>(PREFILLED_WEEKS) val weekTSs = ArrayList<Long>(PREFILLED_WEEKS)
val dateTime = Formatter.getDateTimeFromTS(targetSeconds) val dateTime = Formatter.getDateTimeFromTS(targetSeconds)
val shownWeekDays = context!!.config.weeklyViewDays val shownWeekDays = requireContext().config.weeklyViewDays
var currentWeek = dateTime.minusDays(PREFILLED_WEEKS / 2 * shownWeekDays) var currentWeek = dateTime.minusDays(PREFILLED_WEEKS / 2 * shownWeekDays)
for (i in 0 until PREFILLED_WEEKS) { for (i in 0 until PREFILLED_WEEKS) {
weekTSs.add(currentWeek.seconds()) weekTSs.add(currentWeek.seconds())
@ -155,7 +155,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupWeeklyActionbarTitle(timestamp: Long) { private fun setupWeeklyActionbarTitle(timestamp: Long) {
val startDateTime = Formatter.getDateTimeFromTS(timestamp) val startDateTime = Formatter.getDateTimeFromTS(timestamp)
val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS) val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS)
val startMonthName = Formatter.getMonthName(context!!, startDateTime.monthOfYear) val startMonthName = Formatter.getMonthName(requireContext(), startDateTime.monthOfYear)
if (startDateTime.monthOfYear == endDateTime.monthOfYear) { if (startDateTime.monthOfYear == endDateTime.monthOfYear) {
var newTitle = startMonthName var newTitle = startMonthName
if (startDateTime.year != DateTime().year) { if (startDateTime.year != DateTime().year) {
@ -163,7 +163,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
} }
(activity as AppCompatActivity).updateActionBarTitle(newTitle) (activity as AppCompatActivity).updateActionBarTitle(newTitle)
} else { } else {
val endMonthName = Formatter.getMonthName(context!!, endDateTime.monthOfYear) val endMonthName = Formatter.getMonthName(requireContext(), endDateTime.monthOfYear)
(activity as AppCompatActivity).updateActionBarTitle("$startMonthName - $endMonthName") (activity as AppCompatActivity).updateActionBarTitle("$startMonthName - $endMonthName")
} }
(activity as AppCompatActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}") (activity as AppCompatActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}")
@ -175,14 +175,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
} }
override fun showGoToDateDialog() { override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme()) requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val dateTime = Formatter.getUTCDateTimeFromTS(currentWeekTS) val dateTime = Formatter.getUTCDateTimeFromTS(currentWeekTS)
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.create().apply { .create().apply {
@ -191,7 +191,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
} }
private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) { private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) {
val isSundayFirst = context!!.config.isSundayFirst val isSundayFirst = requireContext().config.isSundayFirst
val month = datePicker.month + 1 val month = datePicker.month + 1
val year = datePicker.year val year = datePicker.year
val day = datePicker.dayOfMonth val day = datePicker.dayOfMonth
@ -227,13 +227,13 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
} }
private fun updateWeeklyViewDays(days: Int) { private fun updateWeeklyViewDays(days: Int) {
context!!.config.weeklyViewDays = days requireContext().config.weeklyViewDays = days
updateDaysCount(days) updateDaysCount(days)
setupWeeklyViewPager() setupWeeklyViewPager()
} }
private fun updateDaysCount(cnt: Int) { private fun updateDaysCount(cnt: Int) {
weekHolder!!.week_view_days_count.text = context!!.resources.getQuantityString(R.plurals.days, cnt, cnt) weekHolder!!.week_view_days_count.text = requireContext().resources.getQuantityString(R.plurals.days, cnt, cnt)
} }
override fun refreshEvents() { override fun refreshEvents() {
@ -296,14 +296,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0) (viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
Handler().postDelayed({ Handler().postDelayed({
context!!.printBitmap(weekHolder!!.week_view_holder.getViewBitmap()) requireContext().printBitmap(weekHolder!!.week_view_holder.getViewBitmap())
Handler().postDelayed({ Handler().postDelayed({
week_view_days_count_divider.beVisible() week_view_days_count_divider.beVisible()
week_view_seekbar.beVisible() week_view_seekbar.beVisible()
week_view_days_count.beVisible() week_view_days_count.beVisible()
addHours() addHours()
background = ColorDrawable(context!!.config.backgroundColor) background = ColorDrawable(requireContext().config.backgroundColor)
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0) (viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
}, 1000) }, 1000)
}, 1000) }, 1000)

View file

@ -34,22 +34,22 @@ class YearFragment : Fragment(), YearlyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_year, container, false) mView = inflater.inflate(R.layout.fragment_year, container, false)
mYear = arguments!!.getInt(YEAR_LABEL) mYear = requireArguments().getInt(YEAR_LABEL)
context!!.updateTextColors(mView.calendar_holder) requireContext().updateTextColors(mView.calendar_holder)
setupMonths() setupMonths()
mCalendar = YearlyCalendarImpl(this, context!!, mYear) mCalendar = YearlyCalendarImpl(this, requireContext(), mYear)
return mView return mView
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
mSundayFirst = context!!.config.isSundayFirst mSundayFirst = requireContext().config.isSundayFirst
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
val sundayFirst = context!!.config.isSundayFirst val sundayFirst = requireContext().config.isSundayFirst
if (sundayFirst != mSundayFirst) { if (sundayFirst != mSundayFirst) {
mSundayFirst = sundayFirst mSundayFirst = sundayFirst
setupMonths() setupMonths()
@ -69,16 +69,16 @@ class YearFragment : Fragment(), YearlyCalendar {
val now = DateTime() val now = DateTime()
for (i in 1..12) { for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", context!!.packageName)) val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
var dayOfWeek = dateTime.withMonthOfYear(i).dayOfWeek().get() var dayOfWeek = dateTime.withMonthOfYear(i).dayOfWeek().get()
if (!mSundayFirst) { if (!mSundayFirst) {
dayOfWeek-- dayOfWeek--
} }
val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${i}_label", "id", context!!.packageName)) val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${i}_label", "id", requireContext().packageName))
val curTextColor = when { val curTextColor = when {
isPrintVersion -> resources.getColor(R.color.theme_light_text_color) isPrintVersion -> resources.getColor(R.color.theme_light_text_color)
else -> context!!.config.textColor else -> requireContext().config.textColor
} }
monthLabel.setTextColor(curTextColor) monthLabel.setTextColor(curTextColor)
@ -96,10 +96,10 @@ class YearFragment : Fragment(), YearlyCalendar {
private fun markCurrentMonth(now: DateTime) { private fun markCurrentMonth(now: DateTime) {
if (now.year == mYear) { if (now.year == mYear) {
val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName)) val monthLabel = mView.findViewById<TextView>(resources.getIdentifier("month_${now.monthOfYear}_label", "id", requireContext().packageName))
monthLabel.setTextColor(context!!.getAdjustedPrimaryColor()) monthLabel.setTextColor(requireContext().getAdjustedPrimaryColor())
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName)) val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_${now.monthOfYear}", "id", requireContext().packageName))
monthView.todaysId = now.dayOfMonth monthView.todaysId = now.dayOfMonth
} }
} }
@ -114,7 +114,7 @@ class YearFragment : Fragment(), YearlyCalendar {
lastHash = hashCode lastHash = hashCode
for (i in 1..12) { for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", context!!.packageName)) val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
monthView.setEvents(events.get(i)) monthView.setEvents(events.get(i))
} }
} }
@ -124,7 +124,7 @@ class YearFragment : Fragment(), YearlyCalendar {
setupMonths() setupMonths()
toggleSmallMonthPrintModes() toggleSmallMonthPrintModes()
context!!.printBitmap(mView.calendar_holder.getViewBitmap()) requireContext().printBitmap(mView.calendar_holder.getViewBitmap())
isPrintVersion = false isPrintVersion = false
setupMonths() setupMonths()
@ -133,7 +133,7 @@ class YearFragment : Fragment(), YearlyCalendar {
private fun toggleSmallMonthPrintModes() { private fun toggleSmallMonthPrintModes() {
for (i in 1..12) { for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", context!!.packageName)) val monthView = mView.findViewById<SmallMonthView>(resources.getIdentifier("month_$i", "id", requireContext().packageName))
monthView.togglePrintMode() monthView.togglePrintMode()
} }
} }

View file

@ -11,7 +11,6 @@ import androidx.appcompat.app.AlertDialog
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.activities.MainActivity import com.simplemobiletools.calendar.pro.activities.MainActivity
import com.simplemobiletools.calendar.pro.adapters.MyMonthPagerAdapter
import com.simplemobiletools.calendar.pro.adapters.MyYearPagerAdapter import com.simplemobiletools.calendar.pro.adapters.MyYearPagerAdapter
import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -40,7 +39,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_years_holder, container, false) val view = inflater.inflate(R.layout.fragment_years_holder, container, false)
view.background = ColorDrawable(context!!.config.backgroundColor) view.background = ColorDrawable(requireContext().config.backgroundColor)
viewPager = view.fragment_years_viewpager viewPager = view.fragment_years_viewpager
viewPager!!.id = (System.currentTimeMillis() % 100000).toInt() viewPager!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment() setupFragment()
@ -49,7 +48,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
private fun setupFragment() { private fun setupFragment() {
val years = getYears(currentYear) val years = getYears(currentYear)
val yearlyAdapter = MyYearPagerAdapter(activity!!.supportFragmentManager, years) val yearlyAdapter = MyYearPagerAdapter(requireActivity().supportFragmentManager, years)
defaultYearlyPage = years.size / 2 defaultYearlyPage = years.size / 2
viewPager?.apply { viewPager?.apply {
@ -91,7 +90,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
} }
override fun showGoToDateDialog() { override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme()) requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone() datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
@ -100,12 +99,12 @@ class YearFragmentsHolder : MyFragmentHolder() {
val dateTime = DateTime(Formatter.getDateTimeFromCode("${currentYear}0523").toString()) val dateTime = DateTime(Formatter.getDateTimeFromCode("${currentYear}0523").toString())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) }
.create().apply { .create().apply {
activity?.setupDialogStuff(view, this) activity?.setupDialogStuff(view, this)
} }
} }
private fun datePicked(datePicker: DatePicker) { private fun datePicked(datePicker: DatePicker) {

View file

@ -32,7 +32,8 @@ const val REMINDER_OFF = -1
const val ITEM_EVENT = 0 const val ITEM_EVENT = 0
const val ITEM_EVENT_SIMPLE = 1 const val ITEM_EVENT_SIMPLE = 1
const val ITEM_HEADER = 2 const val ITEM_SECTION_DAY = 2
const val ITEM_SECTION_MONTH = 3
const val DEFAULT_START_TIME_NEXT_FULL_HOUR = -1 const val DEFAULT_START_TIME_NEXT_FULL_HOUR = -1
const val DEFAULT_START_TIME_CURRENT_TIME = -2 const val DEFAULT_START_TIME_CURRENT_TIME = -2

View file

@ -17,6 +17,7 @@ object Formatter {
private const val DAY_PATTERN = "d" private const val DAY_PATTERN = "d"
private const val DAY_OF_WEEK_PATTERN = "EEE" private const val DAY_OF_WEEK_PATTERN = "EEE"
private const val LONGEST_PATTERN = "MMMM d YYYY (EEEE)" private const val LONGEST_PATTERN = "MMMM d YYYY (EEEE)"
private const val DATE_DAY_PATTERN = "d EEEE"
private const val PATTERN_TIME_12 = "hh:mm a" private const val PATTERN_TIME_12 = "hh:mm a"
private const val PATTERN_TIME_24 = "HH:mm" private const val PATTERN_TIME_24 = "HH:mm"
@ -29,11 +30,15 @@ object Formatter {
val year = dateTime.toString(YEAR_PATTERN) val year = dateTime.toString(YEAR_PATTERN)
val monthIndex = Integer.valueOf(dayCode.substring(4, 6)) val monthIndex = Integer.valueOf(dayCode.substring(4, 6))
var month = getMonthName(context, monthIndex) var month = getMonthName(context, monthIndex)
if (shortMonth) if (shortMonth) {
month = month.substring(0, Math.min(month.length, 3)) month = month.substring(0, Math.min(month.length, 3))
}
var date = "$month $day" var date = "$month $day"
if (year != DateTime().toString(YEAR_PATTERN)) if (year != DateTime().toString(YEAR_PATTERN)) {
date += " $year" date += " $year"
}
return date return date
} }
@ -47,6 +52,25 @@ object Formatter {
date date
} }
fun getDateDayTitle(dayCode: String): String {
val dateTime = getDateTimeFromCode(dayCode)
return dateTime.toString(DATE_DAY_PATTERN)
}
fun getLongMonthYear(context: Context, dayCode: String): String {
val dateTime = getDateTimeFromCode(dayCode)
val monthIndex = Integer.valueOf(dayCode.substring(4, 6))
val month = getMonthName(context, monthIndex)
val year = dateTime.toString(YEAR_PATTERN)
var date = month
if (year != DateTime().toString(YEAR_PATTERN)) {
date += " $year"
}
return date
}
fun getLongestDate(ts: Long) = getDateTimeFromTS(ts).toString(LONGEST_PATTERN) fun getLongestDate(ts: Long) = getDateTimeFromTS(ts).toString(LONGEST_PATTERN)
fun getDate(context: Context, dateTime: DateTime, addDayOfWeek: Boolean = true) = getDayTitle(context, getDayCodeFromDateTime(dateTime), addDayOfWeek) fun getDate(context: Context, dateTime: DateTime, addDayOfWeek: Boolean = true) = getDayTitle(context, getDayCodeFromDateTime(dateTime), addDayOfWeek)
@ -71,7 +95,8 @@ object Formatter {
fun getDateTimeFromCode(dayCode: String) = DateTimeFormat.forPattern(DAYCODE_PATTERN).withZone(DateTimeZone.UTC).parseDateTime(dayCode) fun getDateTimeFromCode(dayCode: String) = DateTimeFormat.forPattern(DAYCODE_PATTERN).withZone(DateTimeZone.UTC).parseDateTime(dayCode)
fun getLocalDateTimeFromCode(dayCode: String) = DateTimeFormat.forPattern(DAYCODE_PATTERN).withZone(DateTimeZone.getDefault()).parseLocalDate(dayCode).toDateTimeAtStartOfDay() fun getLocalDateTimeFromCode(dayCode: String) =
DateTimeFormat.forPattern(DAYCODE_PATTERN).withZone(DateTimeZone.getDefault()).parseLocalDate(dayCode).toDateTimeAtStartOfDay()
fun getTimeFromTS(context: Context, ts: Long) = getTime(context, getDateTimeFromTS(ts)) fun getTimeFromTS(context: Context, ts: Long) = getTime(context, getDateTimeFromTS(ts))

View file

@ -1,3 +0,0 @@
package com.simplemobiletools.calendar.pro.models
data class ListSection(val title: String, val code: String, val isToday: Boolean, val isPastSection: Boolean) : ListItem()

View file

@ -0,0 +1,3 @@
package com.simplemobiletools.calendar.pro.models
data class ListSectionDay(val title: String, val code: String, val isToday: Boolean, val isPastSection: Boolean) : ListItem()

View file

@ -0,0 +1,3 @@
package com.simplemobiletools.calendar.pro.models
data class ListSectionMonth(val title: String) : ListItem()

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/activated_item_foreground" />
<corners android:radius="@dimen/activity_margin" />
</shape>

View file

@ -2,12 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<size
android:width="@dimen/event_color_bar_width"
android:height="@dimen/event_color_bar_height" />
<solid android:color="@color/md_grey_white" /> <solid android:color="@color/md_grey_white" />
<corners android:radius="@dimen/small_margin" /> <corners
android:bottomLeftRadius="@dimen/activity_margin"
android:topLeftRadius="@dimen/activity_margin" />
</shape> </shape>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<selector>
<item
android:drawable="@drawable/activated_item_foreground_rounded"
android:state_selected="true" />
</selector>
</item>
<item>
<ripple android:color="@color/pressed_item_foreground">
<item android:id="@android:id/mask">
<color android:color="@android:color/white" />
</item>
</ripple>
</item>
</layer-list>

View file

@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_item_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector"
android:paddingStart="@dimen/activity_margin">
<RelativeLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/normal_margin">
<ImageView
android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width"
android:layout_height="match_parent"
android:layout_alignTop="@+id/event_item_title"
android:layout_alignBottom="@+id/event_item_description"
android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar"
android:paddingTop="@dimen/tiny_margin"
android:paddingBottom="@dimen/tiny_margin" />
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
android:textSize="@dimen/day_text_size"
tools:text="13:00" />
<TextView
android:id="@+id/event_item_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start"
android:layout_toEndOf="@+id/event_item_color_bar"
android:text="15:00"
android:textSize="@dimen/day_text_size" />
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:layout_toEndOf="@+id/event_item_start"
android:ellipsize="end"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/day_text_size"
tools:text="Event title" />
<TextView
android:id="@+id/event_item_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title"
android:layout_marginStart="@dimen/activity_margin"
android:layout_toEndOf="@+id/event_item_end"
android:ellipsize="end"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/day_text_size"
tools:text="Event description" />
</RelativeLayout>
</FrameLayout>

View file

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_item_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector"
android:paddingStart="@dimen/activity_margin">
<RelativeLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<ImageView
android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width"
android:layout_height="match_parent"
android:layout_alignTop="@+id/event_item_start"
android:layout_alignBottom="@+id/event_item_start"
android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar"
android:paddingTop="@dimen/tiny_margin"
android:paddingBottom="@dimen/tiny_margin" />
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
android:textSize="@dimen/day_text_size"
tools:text="13:00" />
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:layout_toEndOf="@+id/event_item_start"
android:ellipsize="end"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/day_text_size"
tools:text="Event title" />
</RelativeLayout>
</FrameLayout>

View file

@ -1,77 +1,85 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_item_frame" android:id="@+id/event_item_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:layout_marginStart="@dimen/activity_margin"
android:clickable="true" android:layout_marginEnd="@dimen/activity_margin"
android:focusable="true" android:layout_marginBottom="@dimen/medium_margin"
android:foreground="@drawable/selector" android:background="@drawable/section_holder_stroke"
android:paddingStart="@dimen/activity_margin"> android:foreground="@drawable/selector_rounded">
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin" android:background="@drawable/ripple_all_corners"
android:paddingEnd="@dimen/activity_margin" app:layout_constraintBottom_toBottomOf="parent"
android:paddingBottom="@dimen/medium_margin"> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView <ImageView
android:id="@+id/event_item_color_bar" android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width" android:layout_width="@dimen/event_color_bar_width"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_alignTop="@+id/event_item_start"
android:layout_alignBottom="@+id/event_item_end"
android:layout_marginEnd="@dimen/small_margin" android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar" android:background="@drawable/event_list_color_bar"
android:paddingTop="@dimen/tiny_margin" android:contentDescription="@null"
android:paddingBottom="@dimen/tiny_margin" /> app:layout_constraintBottom_toBottomOf="@+id/event_item_description"
app:layout_constraintStart_toStartOf="parent"
<TextView app:layout_constraintTop_toTopOf="@id/event_item_title" />
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
android:textSize="@dimen/day_text_size"
tools:text="13:00" />
<TextView
android:id="@+id/event_item_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start"
android:layout_toEndOf="@+id/event_item_color_bar"
android:includeFontPadding="false"
android:text="15:00"
android:textSize="@dimen/day_text_size" />
<TextView <TextView
android:id="@+id/event_item_title" android:id="@+id/event_item_title"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin" android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/event_item_start"
android:ellipsize="end" android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1" android:maxLines="1"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/activity_margin" android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/tiny_margin"
android:textSize="@dimen/day_text_size" android:textSize="@dimen/day_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/event_item_color_bar"
app:layout_constraintTop_toTopOf="parent"
tools:text="Event title" /> tools:text="Event title" />
<TextView <android.widget.TextView
android:id="@+id/event_item_description" android:id="@+id/event_item_time"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title" android:layout_below="@+id/event_item_title"
android:layout_marginStart="@dimen/activity_margin" android:layout_alignStart="@+id/event_item_title"
android:layout_toEndOf="@+id/event_item_end" android:alpha="0.8"
android:includeFontPadding="false"
android:paddingBottom="@dimen/small_margin"
android:textFontWeight="300"
android:textSize="@dimen/normal_text_size"
app:layout_constraintStart_toStartOf="@+id/event_item_title"
app:layout_constraintTop_toBottomOf="@+id/event_item_title"
tools:text="13:00" />
<android.widget.TextView
android:id="@+id/event_item_description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/event_item_title"
android:alpha="0.8"
android:ellipsize="end" android:ellipsize="end"
android:includeFontPadding="false" android:includeFontPadding="false"
android:maxLines="1" android:maxLines="1"
android:paddingEnd="@dimen/activity_margin" android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/day_text_size" android:paddingBottom="@dimen/small_margin"
android:textFontWeight="300"
android:textSize="@dimen/normal_text_size"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/event_item_time"
app:layout_constraintTop_toBottomOf="@+id/event_item_time"
tools:text="Event description" /> tools:text="Event description" />
</RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout> </androidx.constraintlayout.widget.ConstraintLayout><!--</FrameLayout>-->

View file

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_item_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector"
android:paddingStart="@dimen/activity_margin">
<RelativeLayout
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<ImageView
android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width"
android:layout_height="match_parent"
android:layout_alignTop="@+id/event_item_start"
android:layout_alignBottom="@+id/event_item_start"
android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar"
android:paddingTop="@dimen/tiny_margin"
android:paddingBottom="@dimen/tiny_margin" />
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
android:textSize="@dimen/day_text_size"
tools:text="13:00" />
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:layout_toEndOf="@+id/event_item_start"
android:ellipsize="end"
android:maxLines="1"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/day_text_size"
tools:text="Event title" />
</RelativeLayout>
</FrameLayout>

View file

@ -8,9 +8,9 @@
<ImageView <ImageView
android:id="@+id/event_item_color_bar" android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width" android:layout_width="4dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_alignTop="@+id/event_item_start" android:layout_alignTop="@+id/event_item_time"
android:layout_alignBottom="@+id/event_item_end" android:layout_alignBottom="@+id/event_item_end"
android:layout_marginEnd="@dimen/small_margin" android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar" android:background="@drawable/event_list_color_bar"
@ -18,7 +18,7 @@
android:paddingBottom="@dimen/tiny_margin" /> android:paddingBottom="@dimen/tiny_margin" />
<TextView <TextView
android:id="@+id/event_item_start" android:id="@+id/event_item_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar" android:layout_toEndOf="@+id/event_item_color_bar"
@ -29,7 +29,7 @@
android:id="@+id/event_item_end" android:id="@+id/event_item_end"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/event_item_start" android:layout_below="@+id/event_item_time"
android:layout_toEndOf="@+id/event_item_color_bar" android:layout_toEndOf="@+id/event_item_color_bar"
android:includeFontPadding="false" android:includeFontPadding="false"
android:text="15:00" android:text="15:00"
@ -40,7 +40,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/normal_margin" android:layout_marginStart="@dimen/normal_margin"
android:layout_toEndOf="@+id/event_item_start" android:layout_toEndOf="@+id/event_item_time"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:paddingEnd="@dimen/small_margin" android:paddingEnd="@dimen/small_margin"

View file

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/event_item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/event_item_color_bar"
android:layout_width="@dimen/event_color_bar_width"
android:layout_height="match_parent"
android:layout_alignTop="@+id/event_item_start"
android:layout_alignBottom="@+id/event_item_start"
android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar"
android:paddingTop="@dimen/tiny_margin"
android:paddingBottom="@dimen/tiny_margin" />
<TextView
android:id="@+id/event_item_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
android:textSize="@dimen/day_text_size"
tools:text="13:00" />
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/normal_margin"
android:layout_toEndOf="@+id/event_item_start"
android:ellipsize="end"
android:maxLines="1"
android:paddingEnd="@dimen/small_margin"
android:textSize="@dimen/day_text_size"
tools:text="Event title" />
</RelativeLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<com.simplemobiletools.commons.views.MyTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_section_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:clickable="false"
android:focusable="false"
android:paddingStart="@dimen/activity_margin"
android:paddingBottom="@dimen/small_margin"
android:textSize="@dimen/normal_text_size" />

View file

@ -4,11 +4,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:clickable="false" android:clickable="false"
android:drawableTop="@drawable/divider_width"
android:drawablePadding="@dimen/medium_margin"
android:focusable="false" android:focusable="false"
android:paddingStart="@dimen/activity_margin" android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/small_margin"
android:textAllCaps="true" android:textAllCaps="true"
android:textSize="@dimen/normal_text_size" android:textFontWeight="300"
android:textStyle="bold" /> android:textSize="22sp" />

View file

@ -38,9 +38,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:padding="@dimen/normal_margin" android:paddingTop="@dimen/normal_margin"
android:textSize="@dimen/actionbar_text_size" android:paddingBottom="@dimen/small_margin"
tools:text="8/5/2021" /> android:textSize="22sp"
tools:text="November 19" />
<com.simplemobiletools.commons.views.MyTextView <com.simplemobiletools.commons.views.MyTextView
android:id="@+id/month_day_no_events_placeholder" android:id="@+id/month_day_no_events_placeholder"

View file

@ -27,7 +27,7 @@
<dimen name="year_view_day_text_size">8sp</dimen> <dimen name="year_view_day_text_size">8sp</dimen>
<dimen name="event_color_bar_width">4dp</dimen> <dimen name="event_color_bar_width">16dp</dimen>
<dimen name="event_color_bar_height">100dp</dimen> <dimen name="event_color_bar_height">100dp</dimen>
<dimen name="avatar_size">40dp</dimen> <dimen name="avatar_size">40dp</dimen>