diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt index cb1e1e0ae..e852a590d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/WidgetListConfigureActivity.kt @@ -145,7 +145,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)) + listItems.add(ListSection(day, code)) 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)) @@ -155,7 +155,7 @@ class WidgetListConfigureActivity : SimpleActivity() { dateTime = dateTime.plusDays(1) code = Formatter.getDayCodeFromTS(dateTime.seconds()) day = Formatter.getDayTitle(this, code) - listItems.add(ListSection(day)) + listItems.add(ListSection(day, code)) time = dateTime.withHourOfDay(8) listItems.add(ListEvent(3, time.seconds(), time.plusHours(1).seconds(), getString(R.string.sample_title_3), "", false, config.primaryColor)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt index 2aea1111b..3a902600b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/adapters/EventListWidgetAdapter.kt @@ -7,9 +7,11 @@ import android.widget.RemoteViews import android.widget.RemoteViewsService import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.R.id.event_item_holder +import com.simplemobiletools.calendar.R.id.event_section_title import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.dbHelper import com.simplemobiletools.calendar.extensions.seconds +import com.simplemobiletools.calendar.helpers.DAY_CODE import com.simplemobiletools.calendar.helpers.EVENT_ID import com.simplemobiletools.calendar.helpers.EVENT_OCCURRENCE_TS import com.simplemobiletools.calendar.helpers.Formatter @@ -86,6 +88,11 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi setTextColor(R.id.event_section_title, textColor) setTextSize(R.id.event_section_title, mediumFontSize) setText(R.id.event_section_title, item.title) + + Intent().apply { + putExtra(DAY_CODE, item.code) + setOnClickFillInIntent(event_section_title, this) + } } } @@ -116,7 +123,7 @@ class EventListWidgetAdapter(val context: Context) : RemoteViewsService.RemoteVi val code = Formatter.getDayCodeFromTS(it.startTS) if (code != prevCode) { val day = Formatter.getDayTitle(context, code) - listItems.add(ListSection(day)) + listItems.add(ListSection(day, code)) prevCode = code } listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt index ac2f95b3e..463a64d20 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/extensions/Context.kt @@ -364,7 +364,7 @@ fun Context.getEventListItems(events: List): ArrayList { val code = Formatter.getDayCodeFromTS(it.startTS) if (code != prevCode) { val day = Formatter.getDayTitle(this, code) - listItems.add(ListSection(day)) + listItems.add(ListSection(day, code)) prevCode = code } listItems.add(ListEvent(it.id, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location)) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt index 4945dd50d..6205fb432 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/MyWidgetListProvider.kt @@ -9,7 +9,6 @@ import android.content.Intent import android.net.Uri import android.widget.RemoteViews import com.simplemobiletools.calendar.R -import com.simplemobiletools.calendar.activities.DayActivity import com.simplemobiletools.calendar.activities.SplashActivity import com.simplemobiletools.calendar.extensions.config import com.simplemobiletools.calendar.extensions.getNowSeconds @@ -85,7 +84,7 @@ class MyWidgetListProvider : AppWidgetProvider() { } private fun launchDayActivity(context: Context) { - Intent(context, DayActivity::class.java).apply { + Intent(context, SplashActivity::class.java).apply { putExtra(DAY_CODE, Formatter.getDayCodeFromDateTime(DateTime())) addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(this) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListSection.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListSection.kt index 91865f84c..5dee1e13a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListSection.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/ListSection.kt @@ -1,5 +1,3 @@ package com.simplemobiletools.calendar.models -class ListSection(val title: String, val isToday: Boolean = false) : ListItem() { - override fun toString() = "ListSection {title=$title, isToday=$isToday}" -} +data class ListSection(val title: String, val code: String, val isToday: Boolean = false) : ListItem()