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.models.ListEvent
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.extensions.adjustAlpha
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 code = Formatter.getDayCodeFromTS(dateTime.seconds())
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)
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)
code = Formatter.getDayCodeFromTS(dateTime.seconds())
day = Formatter.getDayTitle(this, code)
listItems.add(ListSection(day, code, false, false))
listItems.add(ListSectionDay(day, code, false, false))
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))

View file

@ -17,15 +17,14 @@ import com.simplemobiletools.calendar.pro.models.Event
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
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)
: MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
private val allDayString = resources.getString(R.string.all_day)
private val replaceDescriptionWithLocation = activity.config.replaceDescription
@ -59,13 +58,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun onActionModeDestroyed() {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
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 onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.event_list_item, parent)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val event = events[position]
@ -109,38 +102,24 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
private fun setupView(view: View, event: Event) {
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_description?.text = if (replaceDescriptionWithLocation) event.location else event.description
event_item_start.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
event_item_end?.beInvisibleIf(event.startTS == 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_time.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
if (event.startTS != event.endTS && !event.getIsAllDay()) {
event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, event.endTS)}"
}
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
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
newTextColor = newTextColor.adjustAlpha(LOWER_ALPHA)
newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
}
event_item_start.setTextColor(newTextColor)
event_item_end?.setTextColor(newTextColor)
event_item_time.setTextColor(newTextColor)
event_item_title.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.models.ListEvent
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.extensions.adjustAlpha
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.beInvisible
import com.simplemobiletools.commons.extensions.beInvisibleIf
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
import com.simplemobiletools.commons.views.MyRecyclerView
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.*
class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListItem>, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?,
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) {
class EventListAdapter(
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 replaceDescription = activity.config.replaceDescription
private val dimPastEvents = activity.config.dimPastEvents
@ -42,7 +44,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
init {
setupDragListener(true)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSection && !it.isPastSection }
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) {
activity.runOnUiThread {
recyclerView.scrollToPosition(firstNonPastSectionIndex)
@ -75,9 +77,9 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder {
val layoutId = when (viewType) {
ITEM_EVENT -> R.layout.event_list_item
ITEM_EVENT_SIMPLE -> R.layout.event_list_item_simple
else -> R.layout.event_list_section
ITEM_SECTION_DAY -> R.layout.event_list_section_day
ITEM_SECTION_MONTH -> R.layout.event_list_section_month
else -> R.layout.event_list_item
}
return createViewHolder(layoutId, parent)
}
@ -85,10 +87,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val listItem = listItems[position]
holder.bindView(listItem, true, allowLongClick && listItem is ListEvent) { itemView, layoutPosition ->
if (listItem is ListSection) {
setupListSection(itemView, listItem, position)
} else if (listItem is ListEvent) {
setupListEvent(itemView, listItem)
when (listItem) {
is ListSectionDay -> setupListSectionDay(itemView, listItem, position)
is ListEvent -> setupListEvent(itemView, listItem)
is ListSectionMonth -> setupListSectionMonth(itemView, listItem)
}
}
bindViewHolder(holder)
@ -114,8 +116,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
} else {
ITEM_EVENT
}
} else if (listItems[position] is ListSectionDay) {
ITEM_SECTION_DAY
} else {
ITEM_HEADER
ITEM_SECTION_MONTH
}
fun toggle24HourFormat(use24HourFormat: Boolean) {
@ -145,68 +149,61 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
private fun setupListEvent(view: View, listEvent: ListEvent) {
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_description?.text = if (replaceDescription) listEvent.location else listEvent.description
event_item_start.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS)
event_item_end?.beInvisibleIf(listEvent.startTS == 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()
}
}
event_item_time.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS)
if (listEvent.startTS != listEvent.endTS && !listEvent.isAllDay) {
event_item_time.text = "${event_item_time.text} - ${Formatter.getTimeFromTS(context, listEvent.endTS)}"
}
var startTextColor = textColor
var endTextColor = textColor
event_item_description.text = if (replaceDescription) listEvent.location else listEvent.description
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 && Formatter.getDayCodeFromTS(listEvent.startTS) == Formatter.getDayCodeFromTS(now) && !isPrintVersion) {
startTextColor = adjustedPrimaryColor
newTextColor = adjustedPrimaryColor
}
if (dimPastEvents && listEvent.isPastEvent && !isPrintVersion) {
startTextColor = startTextColor.adjustAlpha(LOWER_ALPHA)
endTextColor = endTextColor.adjustAlpha(LOWER_ALPHA)
newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA)
}
} else if (listEvent.startTS <= now && listEvent.endTS >= now && !isPrintVersion) {
startTextColor = adjustedPrimaryColor
newTextColor = adjustedPrimaryColor
}
event_item_start.setTextColor(startTextColor)
event_item_end?.setTextColor(endTextColor)
event_item_title.setTextColor(startTextColor)
event_item_description?.setTextColor(startTextColor)
event_item_time.setTextColor(newTextColor)
event_item_title.setTextColor(newTextColor)
event_item_description.setTextColor(newTextColor)
}
}
private fun setupListSection(view: View, listSection: ListSection, position: Int) {
private fun setupListSectionDay(view: View, listSectionDay: ListSectionDay, position: Int) {
view.event_section_title.apply {
text = listSection.title
setCompoundDrawablesWithIntrinsicBounds(null, if (position == 0) null else topDivider, null, null)
var color = if (listSection.isToday && !isPrintVersion) adjustedPrimaryColor else textColor
if (dimPastEvents && listSection.isPastSection && !isPrintVersion) {
text = listSectionDay.title
var color = if (listSectionDay.isToday && !isPrintVersion) adjustedPrimaryColor else textColor
if (dimPastEvents && listSectionDay.isPastSection && !isPrintVersion) {
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 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() {
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.ListEvent
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.setBackgroundColor
import com.simplemobiletools.commons.extensions.setText
import com.simplemobiletools.commons.extensions.setTextSize
import com.simplemobiletools.commons.helpers.LOWER_ALPHA
import com.simplemobiletools.commons.helpers.MEDIUM_ALPHA
import org.joda.time.DateTime
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 var events = ArrayList<ListItem>()
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 dimPastEvents = context.config.dimPastEvents
private var mediumFontSize = context.getWidgetFontSize()
override fun getViewAt(position: Int): RemoteViews? {
override fun getViewAt(position: Int): RemoteViews {
val type = getItemViewType(position)
val remoteView: RemoteViews
@ -49,7 +50,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
setupListEvent(remoteView, event)
} else {
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) {
setupListSection(remoteView, section)
}
@ -63,12 +64,12 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
return if (detailField.isNotEmpty()) {
R.layout.event_list_item_widget
} else if (event.startTS == event.endTS) {
R.layout.event_list_item_widget_simple
R.layout.event_list_item_widget
} else if (event.isAllDay) {
val startCode = Formatter.getDayCodeFromTS(event.startTS)
val endCode = Formatter.getDayCodeFromTS(event.endTS)
if (startCode == endCode) {
R.layout.event_list_item_widget_simple
R.layout.event_list_item_widget
} else {
R.layout.event_list_item_widget
}
@ -82,7 +83,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
remoteView.apply {
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_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)
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_description, curTextColor)
setTextColor(R.id.event_item_start, curTextColor)
setTextColor(R.id.event_item_time, curTextColor)
setTextColor(R.id.event_item_end, curTextColor)
setTextSize(R.id.event_item_title, 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)
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
if (dimPastEvents && item.isPastSection) {
curTextColor = weakTextColor
@ -188,12 +189,23 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi
if (code != prevCode) {
val day = Formatter.getDayTitle(context, code)
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)
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)
}

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 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 })
var prevCode = ""
var prevMonthLabel = ""
val now = getNowSeconds()
val today = Formatter.getDayTitle(this, Formatter.getDayCodeFromTS(now))
val todayCode = Formatter.getDayCodeFromTS(now)
sorted.forEach {
val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode && addSections) {
val day = Formatter.getDayTitle(this, code)
val isToday = day == today
val listSection = ListSection(day, code, isToday, !isToday && it.startTS < now)
listItems.add(listSection)
if (addSectionMonths) {
val monthLabel = Formatter.getLongMonthYear(this, code)
if (monthLabel != prevMonthLabel) {
val listSectionMonth = ListSectionMonth(monthLabel)
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
}
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)

View file

@ -43,7 +43,7 @@ class DayFragment : Fragment() {
val view = inflater.inflate(R.layout.fragment_day, container, false)
mHolder = view.day_holder
mDayCode = arguments!!.getString(DAY_CODE)!!
mDayCode = requireArguments().getString(DAY_CODE)!!
setupButtons()
return view
}
@ -54,7 +54,7 @@ class DayFragment : Fragment() {
}
private fun setupButtons() {
mTextColor = context!!.config.textColor
mTextColor = requireContext().config.textColor
mHolder.top_left_arrow.apply {
applyColorFilter(mTextColor)
@ -63,7 +63,7 @@ class DayFragment : Fragment() {
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
setImageDrawable(pointerLeft)
}
@ -75,12 +75,12 @@ class DayFragment : Fragment() {
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
setImageDrawable(pointerRight)
}
val day = Formatter.getDayTitle(context!!, mDayCode)
val day = Formatter.getDayTitle(requireContext(), mDayCode)
mHolder.top_value.apply {
text = day
contentDescription = text
@ -106,7 +106,7 @@ class DayFragment : Fragment() {
}
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 }, {
if (replaceDescription) it.location else it.description
})))
@ -147,12 +147,12 @@ class DayFragment : Fragment() {
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
Handler().postDelayed({
context!!.printBitmap(day_holder.getViewBitmap())
requireContext().printBitmap(day_holder.getViewBitmap())
Handler().postDelayed({
top_left_arrow.beVisible()
top_right_arrow.beVisible()
top_value.setTextColor(context!!.config.textColor)
top_value.setTextColor(requireContext().config.textColor)
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
}, 1000)
}, 1000)

View file

@ -40,7 +40,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
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!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
@ -49,7 +49,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() {
val codes = getDays(currentDayCode)
val dailyAdapter = MyDayPagerAdapter(activity!!.supportFragmentManager, codes, this)
val dailyAdapter = MyDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultDailyPage = codes.size / 2
@ -104,19 +104,19 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme())
requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val dateTime = Formatter.getDateTimeFromCode(currentDayCode)
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
AlertDialog.Builder(context!!)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.create().apply {
activity?.setupDialogStuff(view, this)
}
AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.create().apply {
activity?.setupDialogStuff(view, this)
}
}
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.ListEvent
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.helpers.MONTH_SECONDS
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
@ -48,7 +48,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
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_empty_list_placeholder_2.apply {
setTextColor(context.getAdjustedPrimaryColor())
@ -58,7 +58,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
}
use24HourFormat = context!!.config.use24HourFormat
use24HourFormat = requireContext().config.use24HourFormat
updateActionBarTitle()
return mView
}
@ -66,7 +66,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onResume() {
super.onResume()
checkEvents()
val use24Hour = context!!.config.use24HourFormat
val use24Hour = requireContext().config.use24HourFormat
if (use24Hour != use24HourFormat) {
use24HourFormat = use24Hour
(mView.calendar_events_list.adapter as? EventListAdapter)?.toggle24HourFormat(use24HourFormat)
@ -75,23 +75,24 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
override fun onPause() {
super.onPause()
use24HourFormat = context!!.config.use24HourFormat
use24HourFormat = requireContext().config.use24HourFormat
}
private fun checkEvents() {
if (!wereInitialEventsAdded) {
minFetchedTS = DateTime().minusMinutes(context!!.config.displayPastEvents).seconds()
minFetchedTS = DateTime().minusMinutes(requireContext().config.displayPastEvents).seconds()
maxFetchedTS = DateTime().plusMonths(6).seconds()
}
context!!.eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
requireContext().eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
if (it.size >= MIN_EVENTS_TRESHOLD) {
receivedEvents(it, NOT_UPDATING)
} else {
if (!wereInitialEventsAdded) {
maxFetchedTS += FETCH_INTERVAL
}
context!!.eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
requireContext().eventsHelper.getEvents(minFetchedTS, maxFetchedTS) {
mEvents = it
receivedEvents(mEvents, NOT_UPDATING, !wereInitialEventsAdded)
}
@ -106,7 +107,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
mEvents = events
val listItems = context!!.getEventListItems(mEvents)
val listItems = requireContext().getEventListItems(mEvents)
activity?.runOnUiThread {
if (activity == null) {
@ -154,7 +155,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
mView.calendar_events_list.scrollToPosition(item)
}
} 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()
@ -166,7 +167,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
mView.calendar_empty_list_placeholder_2.beVisibleIf(mEvents.isEmpty())
mView.calendar_events_list.beGoneIf(mEvents.isEmpty())
if (activity != null)
mView.calendar_empty_list_placeholder.setTextColor(activity!!.config.textColor)
mView.calendar_empty_list_placeholder.setTextColor(requireActivity().config.textColor)
}
private fun fetchPreviousPeriod() {
@ -175,7 +176,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val oldMinFetchedTS = minFetchedTS - 1
minFetchedTS -= FETCH_INTERVAL
context!!.eventsHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
requireContext().eventsHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
mEvents.addAll(0, it)
receivedEvents(mEvents, UPDATE_TOP)
}
@ -184,7 +185,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
private fun fetchNextPeriod() {
val oldMaxFetchedTS = maxFetchedTS + 1
maxFetchedTS += FETCH_INTERVAL
context!!.eventsHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
requireContext().eventsHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
mEvents.addAll(it)
receivedEvents(mEvents, UPDATE_BOTTOM)
}
@ -195,8 +196,8 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
}
override fun goToToday() {
val listItems = context!!.getEventListItems(mEvents)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSection && !it.isPastSection }
val listItems = requireContext().getEventListItems(mEvents)
val firstNonPastSectionIndex = listItems.indexOfFirst { it is ListSectionDay && !it.isPastSection }
if (firstNonPastSectionIndex != -1) {
(mView.calendar_events_list.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(firstNonPastSectionIndex, 0)
mView.calendar_events_list.onGlobalLayout {
@ -229,7 +230,7 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
(calendar_events_list.adapter as? EventListAdapter)?.togglePrintMode()
Handler().postDelayed({
context!!.printBitmap(calendar_events_list.getViewBitmap())
requireContext().printBitmap(calendar_events_list.getViewBitmap())
Handler().postDelayed({
(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? {
val view = inflater.inflate(R.layout.fragment_month_day, container, false)
mRes = resources
mPackageName = activity!!.packageName
mPackageName = requireActivity().packageName
mHolder = view.month_day_calendar_holder
mDayCode = arguments!!.getString(DAY_CODE)!!
mDayCode = requireArguments().getString(DAY_CODE)!!
val shownMonthDateTime = Formatter.getDateTimeFromCode(mDayCode)
mHolder.month_day_selected_day_label.apply {
@ -61,10 +61,10 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
}
}
mConfig = context!!.config
mConfig = requireContext().config
storeStateVariables()
setupButtons()
mCalendar = MonthlyCalendarImpl(this, context!!)
mCalendar = MonthlyCalendarImpl(this, requireContext())
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()) {
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 {
@ -178,7 +178,7 @@ class MonthDayFragment : Fragment(), MonthlyCalendar, RefreshRecyclerViewListene
fun getNewEventDayCode() = if (mSelectedDayCode.isEmpty()) mDayCode else mSelectedDayCode
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)
if (targetYear != DateTime().toString(YEAR_PATTERN)) {
month += " $targetYear"

View file

@ -42,7 +42,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
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!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
@ -51,7 +51,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() {
val codes = getMonths(currentDayCode)
val monthlyDailyAdapter = MyMonthDayPagerAdapter(activity!!.supportFragmentManager, codes, this)
val monthlyDailyAdapter = MyMonthDayPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2
viewPager!!.apply {
@ -106,7 +106,7 @@ class MonthDayFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme())
requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
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())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!)
AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.create().apply {

View file

@ -45,14 +45,14 @@ class MonthFragment : Fragment(), MonthlyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_month, container, false)
mRes = resources
mPackageName = activity!!.packageName
mPackageName = requireActivity().packageName
mHolder = view.month_calendar_holder
mDayCode = arguments!!.getString(DAY_CODE)!!
mConfig = context!!.config
mDayCode = requireArguments().getString(DAY_CODE)!!
mConfig = requireContext().config
storeStateVariables()
setupButtons()
mCalendar = MonthlyCalendarImpl(this, context!!)
mCalendar = MonthlyCalendarImpl(this, requireContext())
return view
}
@ -116,7 +116,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
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
setImageDrawable(pointerLeft)
}
@ -128,7 +128,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
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
setImageDrawable(pointerRight)
}
@ -154,7 +154,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
month_view_wrapper.togglePrintMode()
context!!.printBitmap(month_calendar_holder.getViewBitmap())
requireContext().printBitmap(month_calendar_holder.getViewBitmap())
top_left_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? {
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!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
@ -51,7 +51,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
private fun setupFragment() {
val codes = getMonths(currentDayCode)
val monthlyAdapter = MyMonthPagerAdapter(activity!!.supportFragmentManager, codes, this)
val monthlyAdapter = MyMonthPagerAdapter(requireActivity().supportFragmentManager, codes, this)
defaultMonthlyPage = codes.size / 2
viewPager!!.apply {
@ -106,7 +106,7 @@ class MonthFragmentsHolder : MyFragmentHolder(), NavigationListener {
}
override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme())
requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
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())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!)
AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(dateTime, datePicker) }
.create().apply {

View file

@ -81,14 +81,14 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
res = context!!.resources
config = context!!.config
rowHeight = context!!.getWeeklyViewItemHeight()
res = requireContext().resources
config = requireContext().config
rowHeight = requireContext().getWeeklyViewItemHeight()
defaultRowHeight = res.getDimension(R.dimen.weekly_view_row_height)
weekTimestamp = arguments!!.getLong(WEEK_START_TIMESTAMP)
weekTimestamp = requireArguments().getLong(WEEK_START_TIMESTAMP)
dimPastEvents = config.dimPastEvents
highlightWeekends = config.highlightWeekends
primaryColor = context!!.getAdjustedPrimaryColor()
primaryColor = requireContext().getAdjustedPrimaryColor()
allDayRows.add(HashSet())
}
@ -96,7 +96,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
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 {
scrollView = week_events_scrollview
week_horizontal_grid_holder.layoutParams.height = fullHeight
@ -137,7 +137,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onResume() {
super.onResume()
context!!.eventsHelper.getEventTypes(activity!!, false) {
requireContext().eventsHelper.getEventTypes(requireActivity(), false) {
it.map {
eventTypeColors.put(it.id!!, it.color)
}
@ -180,7 +180,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
fun updateCalendar() {
if (context != null) {
WeeklyCalendarImpl(this, context!!).updateWeeklyCalendar(weekTimestamp)
WeeklyCalendarImpl(this, requireContext()).updateWeeklyCalendar(weekTimestamp)
}
}
@ -386,7 +386,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
lastHash = newHash
activity!!.runOnUiThread {
requireActivity().runOnUiThread {
if (context != null && activity != null && isAdded) {
val replaceDescription = config.replaceDescription
val sorted = events.sortedWith(
@ -506,7 +506,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
var backgroundColor = eventTypeColors.get(event.eventType, primaryColor)
var textColor = backgroundColor.getContrastColor()
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
backgroundColor = backgroundColor.adjustAlpha(LOWER_ALPHA)
backgroundColor = backgroundColor.adjustAlpha(MEDIUM_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? {
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)
viewPager = weekHolder!!.week_view_view_pager
@ -92,7 +92,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupWeeklyViewPager() {
val weekTSs = getWeekTimestamps(currentWeekTS)
val weeklyAdapter = MyWeekPagerAdapter(activity!!.supportFragmentManager, weekTSs, this)
val weeklyAdapter = MyWeekPagerAdapter(requireActivity().supportFragmentManager, weekTSs, this)
defaultWeeklyPage = weekTSs.size / 2
@ -125,12 +125,12 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
})
}
private fun addHours(textColor: Int = context!!.config.textColor) {
val itemHeight = context!!.getWeeklyViewItemHeight().toInt()
private fun addHours(textColor: Int = requireContext().config.textColor) {
val itemHeight = requireContext().getWeeklyViewItemHeight().toInt()
weekHolder!!.week_view_hours_holder.removeAllViews()
val hourDateTime = DateTime().withDate(2000, 1, 1).withTime(0, 0, 0, 0)
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 {
text = formattedHours
setTextColor(textColor)
@ -143,7 +143,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun getWeekTimestamps(targetSeconds: Long): List<Long> {
val weekTSs = ArrayList<Long>(PREFILLED_WEEKS)
val dateTime = Formatter.getDateTimeFromTS(targetSeconds)
val shownWeekDays = context!!.config.weeklyViewDays
val shownWeekDays = requireContext().config.weeklyViewDays
var currentWeek = dateTime.minusDays(PREFILLED_WEEKS / 2 * shownWeekDays)
for (i in 0 until PREFILLED_WEEKS) {
weekTSs.add(currentWeek.seconds())
@ -155,7 +155,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
private fun setupWeeklyActionbarTitle(timestamp: Long) {
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
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) {
var newTitle = startMonthName
if (startDateTime.year != DateTime().year) {
@ -163,7 +163,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
(activity as AppCompatActivity).updateActionBarTitle(newTitle)
} else {
val endMonthName = Formatter.getMonthName(context!!, endDateTime.monthOfYear)
val endMonthName = Formatter.getMonthName(requireContext(), endDateTime.monthOfYear)
(activity as AppCompatActivity).updateActionBarTitle("$startMonthName - $endMonthName")
}
(activity as AppCompatActivity).updateActionBarSubtitle("${getString(R.string.week)} ${startDateTime.plusDays(3).weekOfWeekyear}")
@ -175,14 +175,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme())
requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val dateTime = Formatter.getUTCDateTimeFromTS(currentWeekTS)
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
AlertDialog.Builder(context!!)
AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> dateSelected(dateTime, datePicker) }
.create().apply {
@ -191,7 +191,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) {
val isSundayFirst = context!!.config.isSundayFirst
val isSundayFirst = requireContext().config.isSundayFirst
val month = datePicker.month + 1
val year = datePicker.year
val day = datePicker.dayOfMonth
@ -227,13 +227,13 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
}
private fun updateWeeklyViewDays(days: Int) {
context!!.config.weeklyViewDays = days
requireContext().config.weeklyViewDays = days
updateDaysCount(days)
setupWeeklyViewPager()
}
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() {
@ -296,14 +296,14 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener {
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
Handler().postDelayed({
context!!.printBitmap(weekHolder!!.week_view_holder.getViewBitmap())
requireContext().printBitmap(weekHolder!!.week_view_holder.getViewBitmap())
Handler().postDelayed({
week_view_days_count_divider.beVisible()
week_view_seekbar.beVisible()
week_view_days_count.beVisible()
addHours()
background = ColorDrawable(context!!.config.backgroundColor)
background = ColorDrawable(requireContext().config.backgroundColor)
(viewPager?.adapter as? MyWeekPagerAdapter)?.togglePrintMode(viewPager?.currentItem ?: 0)
}, 1000)
}, 1000)

View file

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

View file

@ -11,7 +11,6 @@ import androidx.appcompat.app.AlertDialog
import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.pro.R
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.extensions.config
import com.simplemobiletools.calendar.pro.helpers.Formatter
@ -40,7 +39,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
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!!.id = (System.currentTimeMillis() % 100000).toInt()
setupFragment()
@ -49,7 +48,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
private fun setupFragment() {
val years = getYears(currentYear)
val yearlyAdapter = MyYearPagerAdapter(activity!!.supportFragmentManager, years)
val yearlyAdapter = MyYearPagerAdapter(requireActivity().supportFragmentManager, years)
defaultYearlyPage = years.size / 2
viewPager?.apply {
@ -91,7 +90,7 @@ class YearFragmentsHolder : MyFragmentHolder() {
}
override fun showGoToDateDialog() {
activity!!.setTheme(context!!.getDialogTheme())
requireActivity().setTheme(requireContext().getDialogTheme())
val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
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())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context!!)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) }
.create().apply {
activity?.setupDialogStuff(view, this)
}
AlertDialog.Builder(requireContext())
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> datePicked(datePicker) }
.create().apply {
activity?.setupDialogStuff(view, this)
}
}
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_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_CURRENT_TIME = -2

View file

@ -17,6 +17,7 @@ object Formatter {
private const val DAY_PATTERN = "d"
private const val DAY_OF_WEEK_PATTERN = "EEE"
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_24 = "HH:mm"
@ -29,11 +30,15 @@ object Formatter {
val year = dateTime.toString(YEAR_PATTERN)
val monthIndex = Integer.valueOf(dayCode.substring(4, 6))
var month = getMonthName(context, monthIndex)
if (shortMonth)
if (shortMonth) {
month = month.substring(0, Math.min(month.length, 3))
}
var date = "$month $day"
if (year != DateTime().toString(YEAR_PATTERN))
if (year != DateTime().toString(YEAR_PATTERN)) {
date += " $year"
}
return date
}
@ -47,6 +52,25 @@ object Formatter {
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 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 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))

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"
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" />
<corners android:radius="@dimen/small_margin" />
<corners
android:bottomLeftRadius="@dimen/activity_margin"
android:topLeftRadius="@dimen/activity_margin" />
</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"?>
<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"
android:id="@+id/event_item_frame"
android:id="@+id/event_item_holder"
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">
android:layout_marginStart="@dimen/activity_margin"
android:layout_marginEnd="@dimen/activity_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:background="@drawable/section_holder_stroke"
android:foreground="@drawable/selector_rounded">
<RelativeLayout
android:id="@+id/event_item_holder"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/medium_margin">
android:background="@drawable/ripple_all_corners"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<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_end"
android:layout_height="0dp"
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:includeFontPadding="false"
android:text="15:00"
android:textSize="@dimen/day_text_size" />
android:contentDescription="@null"
app:layout_constraintBottom_toBottomOf="@+id/event_item_description"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/event_item_title" />
<TextView
android:id="@+id/event_item_title"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:layout_toEndOf="@+id/event_item_start"
android:layout_marginStart="@dimen/medium_margin"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:paddingTop="@dimen/small_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/tiny_margin"
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" />
<TextView
android:id="@+id/event_item_description"
android:layout_width="wrap_content"
<android.widget.TextView
android:id="@+id/event_item_time"
android:layout_width="0dp"
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:layout_alignStart="@+id/event_item_title"
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:includeFontPadding="false"
android:maxLines="1"
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" />
</RelativeLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</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
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_alignTop="@+id/event_item_start"
android:layout_alignTop="@+id/event_item_time"
android:layout_alignBottom="@+id/event_item_end"
android:layout_marginEnd="@dimen/small_margin"
android:background="@drawable/event_list_color_bar"
@ -18,7 +18,7 @@
android:paddingBottom="@dimen/tiny_margin" />
<TextView
android:id="@+id/event_item_start"
android:id="@+id/event_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/event_item_color_bar"
@ -29,7 +29,7 @@
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_below="@+id/event_item_time"
android:layout_toEndOf="@+id/event_item_color_bar"
android:includeFontPadding="false"
android:text="15:00"
@ -40,7 +40,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/normal_margin"
android:layout_toEndOf="@+id/event_item_start"
android:layout_toEndOf="@+id/event_item_time"
android:ellipsize="end"
android:maxLines="1"
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_height="wrap_content"
android:clickable="false"
android:drawableTop="@drawable/divider_width"
android:drawablePadding="@dimen/medium_margin"
android:focusable="false"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/small_margin"
android:textAllCaps="true"
android:textSize="@dimen/normal_text_size"
android:textStyle="bold" />
android:textFontWeight="300"
android:textSize="22sp" />

View file

@ -38,9 +38,10 @@
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/normal_margin"
android:textSize="@dimen/actionbar_text_size"
tools:text="8/5/2021" />
android:paddingTop="@dimen/normal_margin"
android:paddingBottom="@dimen/small_margin"
android:textSize="22sp"
tools:text="November 19" />
<com.simplemobiletools.commons.views.MyTextView
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="event_color_bar_width">4dp</dimen>
<dimen name="event_color_bar_width">16dp</dimen>
<dimen name="event_color_bar_height">100dp</dimen>
<dimen name="avatar_size">40dp</dimen>