launch the given day at pressing a day at list widget

This commit is contained in:
tibbi 2018-01-22 17:15:26 +01:00
parent ccc738203b
commit 2fc5213391
5 changed files with 13 additions and 9 deletions

View File

@ -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))

View File

@ -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))

View File

@ -364,7 +364,7 @@ fun Context.getEventListItems(events: List<Event>): ArrayList<ListItem> {
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))

View File

@ -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)

View File

@ -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()