From b1324e93bbbad41ab20ba464f2dd374160bab53e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 21 Nov 2021 15:10:20 +0100 Subject: [PATCH] redesigning the Event List view --- .../activities/WidgetListConfigureActivity.kt | 6 +- .../calendar/pro/adapters/DayEventsAdapter.kt | 55 +++------ .../calendar/pro/adapters/EventListAdapter.kt | 107 +++++++++--------- .../pro/adapters/EventListWidgetAdapter.kt | 36 ++++-- .../calendar/pro/extensions/Context.kt | 25 ++-- .../calendar/pro/fragments/DayFragment.kt | 16 +-- .../pro/fragments/DayFragmentsHolder.kt | 18 +-- .../pro/fragments/EventListFragment.kt | 33 +++--- .../pro/fragments/MonthDayFragment.kt | 14 +-- .../pro/fragments/MonthDayFragmentsHolder.kt | 8 +- .../calendar/pro/fragments/MonthFragment.kt | 14 +-- .../pro/fragments/MonthFragmentsHolder.kt | 8 +- .../calendar/pro/fragments/WeekFragment.kt | 20 ++-- .../pro/fragments/WeekFragmentsHolder.kt | 32 +++--- .../calendar/pro/fragments/YearFragment.kt | 28 ++--- .../pro/fragments/YearFragmentsHolder.kt | 19 ++-- .../calendar/pro/helpers/Constants.kt | 3 +- .../calendar/pro/helpers/Formatter.kt | 31 ++++- .../calendar/pro/models/ListSection.kt | 3 - .../calendar/pro/models/ListSectionDay.kt | 3 + .../calendar/pro/models/ListSectionMonth.kt | 3 + .../activated_item_foreground_rounded.xml | 8 ++ .../res/drawable/event_list_color_bar.xml | 8 +- .../main/res/drawable/selector_rounded.xml | 17 +++ .../main/res/layout/event_item_day_view.xml | 74 ------------ .../res/layout/event_item_day_view_simple.xml | 53 --------- app/src/main/res/layout/event_list_item.xml | 100 ++++++++-------- .../res/layout/event_list_item_simple.xml | 53 --------- .../res/layout/event_list_item_widget.xml | 10 +- .../layout/event_list_item_widget_simple.xml | 40 ------- .../res/layout/event_list_section_day.xml | 11 ++ ...ction.xml => event_list_section_month.xml} | 9 +- .../main/res/layout/fragment_month_day.xml | 7 +- app/src/main/res/values/dimens.xml | 2 +- 34 files changed, 362 insertions(+), 512 deletions(-) delete mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSection.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionDay.kt create mode 100644 app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionMonth.kt create mode 100644 app/src/main/res/drawable/activated_item_foreground_rounded.xml create mode 100644 app/src/main/res/drawable/selector_rounded.xml delete mode 100644 app/src/main/res/layout/event_item_day_view.xml delete mode 100644 app/src/main/res/layout/event_item_day_view_simple.xml delete mode 100644 app/src/main/res/layout/event_list_item_simple.xml delete mode 100644 app/src/main/res/layout/event_list_item_widget_simple.xml create mode 100644 app/src/main/res/layout/event_list_section_day.xml rename app/src/main/res/layout/{event_list_section.xml => event_list_section_month.xml} (64%) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt index 29f2c8f50..ad7b681f9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/WidgetListConfigureActivity.kt @@ -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)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt index 225f3c7c5..17c24c6d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/DayEventsAdapter.kt @@ -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, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) - : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { +class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, 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, 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, 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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt index 89cbaea5c..081df4967 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListAdapter.kt @@ -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, val allowLongClick: Boolean, val listener: RefreshRecyclerViewListener?, - recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, null, itemClick) { +class EventListAdapter( + activity: SimpleActivity, var listItems: ArrayList, 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 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 - 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= 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 + private fun getSelectedEventIds() = + listItems.filter { it is ListEvent && selectedKeys.contains(it.hashCode()) }.map { (it as ListEvent).id }.toMutableList() as ArrayList private fun askConfirmDelete() { val eventIds = getSelectedEventIds() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt index 25eeb7313..389bef780 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/adapters/EventListWidgetAdapter.kt @@ -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() 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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt index 0ddbaba29..323916f7b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt @@ -475,7 +475,7 @@ fun Context.addDayEvents(day: DayMonthly, linearLayout: LinearLayout, res: Resou } } -fun Context.getEventListItems(events: List, addSections: Boolean = true): ArrayList { +fun Context.getEventListItems(events: List, addSectionDays: Boolean = true, addSectionMonths: Boolean = true): ArrayList { val listItems = ArrayList(events.size) val replaceDescription = config.replaceDescription @@ -495,18 +495,29 @@ fun Context.getEventListItems(events: List, 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) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragment.kt index f79252bbf..2945e2bb8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragment.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt index 03f9343b7..584679333 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/DayFragmentsHolder.kt @@ -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(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) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt index 7877284ac..f2aadce04 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/EventListFragment.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragment.kt index fc3ec246f..e84a456bf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragment.kt @@ -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" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt index 567e0ad00..5d3672b25 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthDayFragmentsHolder.kt @@ -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(R.id.date_picker) datePicker.findViewById(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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragment.kt index 11aebe920..fa7bd887e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragment.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt index 474b985ea..4a8eb35a5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/MonthFragmentsHolder.kt @@ -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(R.id.date_picker) datePicker.findViewById(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 { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt index ac6b14f94..ab5f47bfa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragment.kt @@ -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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index d175add18..e59f12df1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -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 { val weekTSs = ArrayList(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(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) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt index a8fc89edc..411ed1ac6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragment.kt @@ -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(resources.getIdentifier("month_$i", "id", context!!.packageName)) + val monthView = mView.findViewById(resources.getIdentifier("month_$i", "id", requireContext().packageName)) var dayOfWeek = dateTime.withMonthOfYear(i).dayOfWeek().get() if (!mSundayFirst) { dayOfWeek-- } - val monthLabel = mView.findViewById(resources.getIdentifier("month_${i}_label", "id", context!!.packageName)) + val monthLabel = mView.findViewById(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(resources.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName)) - monthLabel.setTextColor(context!!.getAdjustedPrimaryColor()) + val monthLabel = mView.findViewById(resources.getIdentifier("month_${now.monthOfYear}_label", "id", requireContext().packageName)) + monthLabel.setTextColor(requireContext().getAdjustedPrimaryColor()) - val monthView = mView.findViewById(resources.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName)) + val monthView = mView.findViewById(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(resources.getIdentifier("month_$i", "id", context!!.packageName)) + val monthView = mView.findViewById(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(resources.getIdentifier("month_$i", "id", context!!.packageName)) + val monthView = mView.findViewById(resources.getIdentifier("month_$i", "id", requireContext().packageName)) monthView.togglePrintMode() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt index e0e5175c3..f49d9df7f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/YearFragmentsHolder.kt @@ -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(R.id.date_picker) datePicker.findViewById(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) { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt index f578c213e..450d0abc4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Constants.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt index 23cdef3de..1522ffe32 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Formatter.kt @@ -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)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSection.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSection.kt deleted file mode 100644 index 13803956a..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSection.kt +++ /dev/null @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionDay.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionDay.kt new file mode 100644 index 000000000..18b07fa19 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionDay.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionMonth.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionMonth.kt new file mode 100644 index 000000000..96b0260f5 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListSectionMonth.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.calendar.pro.models + +data class ListSectionMonth(val title: String) : ListItem() diff --git a/app/src/main/res/drawable/activated_item_foreground_rounded.xml b/app/src/main/res/drawable/activated_item_foreground_rounded.xml new file mode 100644 index 000000000..153f2adf0 --- /dev/null +++ b/app/src/main/res/drawable/activated_item_foreground_rounded.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/app/src/main/res/drawable/event_list_color_bar.xml b/app/src/main/res/drawable/event_list_color_bar.xml index 7db18a312..24427f81e 100644 --- a/app/src/main/res/drawable/event_list_color_bar.xml +++ b/app/src/main/res/drawable/event_list_color_bar.xml @@ -2,12 +2,10 @@ - - - + diff --git a/app/src/main/res/drawable/selector_rounded.xml b/app/src/main/res/drawable/selector_rounded.xml new file mode 100644 index 000000000..cb1452325 --- /dev/null +++ b/app/src/main/res/drawable/selector_rounded.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/event_item_day_view.xml b/app/src/main/res/layout/event_item_day_view.xml deleted file mode 100644 index b3338b928..000000000 --- a/app/src/main/res/layout/event_item_day_view.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/event_item_day_view_simple.xml b/app/src/main/res/layout/event_item_day_view_simple.xml deleted file mode 100644 index cc9d2147b..000000000 --- a/app/src/main/res/layout/event_item_day_view_simple.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/event_list_item.xml b/app/src/main/res/layout/event_list_item.xml index d1c201a09..d2b07f2ff 100644 --- a/app/src/main/res/layout/event_list_item.xml +++ b/app/src/main/res/layout/event_list_item.xml @@ -1,77 +1,85 @@ - + 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"> - + 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"> - - - - + android:contentDescription="@null" + app:layout_constraintBottom_toBottomOf="@+id/event_item_description" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@id/event_item_title" /> - + + - - + + diff --git a/app/src/main/res/layout/event_list_item_simple.xml b/app/src/main/res/layout/event_list_item_simple.xml deleted file mode 100644 index cc9d2147b..000000000 --- a/app/src/main/res/layout/event_list_item_simple.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/event_list_item_widget.xml b/app/src/main/res/layout/event_list_item_widget.xml index 15b44d0d2..eb1ddce4d 100644 --- a/app/src/main/res/layout/event_list_item_widget.xml +++ b/app/src/main/res/layout/event_list_item_widget.xml @@ -8,9 +8,9 @@ - - - - - - - - - diff --git a/app/src/main/res/layout/event_list_section_day.xml b/app/src/main/res/layout/event_list_section_day.xml new file mode 100644 index 000000000..b0656e1a1 --- /dev/null +++ b/app/src/main/res/layout/event_list_section_day.xml @@ -0,0 +1,11 @@ + + diff --git a/app/src/main/res/layout/event_list_section.xml b/app/src/main/res/layout/event_list_section_month.xml similarity index 64% rename from app/src/main/res/layout/event_list_section.xml rename to app/src/main/res/layout/event_list_section_month.xml index 214210517..772b6ec70 100644 --- a/app/src/main/res/layout/event_list_section.xml +++ b/app/src/main/res/layout/event_list_section_month.xml @@ -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" /> diff --git a/app/src/main/res/layout/fragment_month_day.xml b/app/src/main/res/layout/fragment_month_day.xml index 9a4c3a4a6..10630be12 100644 --- a/app/src/main/res/layout/fragment_month_day.xml +++ b/app/src/main/res/layout/fragment_month_day.xml @@ -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" /> 8sp - 4dp + 16dp 100dp 40dp