diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt index d5fe335e9..7c4f610e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/MainActivity.kt @@ -1135,7 +1135,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { val listItems = getEventListItems(events) val eventsAdapter = EventListAdapter(this, listItems, true, this, search_results_list) { if (it is ListEvent) { - Intent(applicationContext, EventActivity::class.java).apply { + Intent(applicationContext, getActivityToOpen(it.isTask)).apply { putExtra(EVENT_ID, it.id) startActivity(this) } 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 984d86525..39f20d9dd 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 @@ -232,6 +232,7 @@ class WidgetListConfigureActivity : SimpleActivity() { config.primaryColor, "", false, + false, false ) ) @@ -247,6 +248,7 @@ class WidgetListConfigureActivity : SimpleActivity() { config.primaryColor, "", false, + false, false ) ) @@ -268,6 +270,7 @@ class WidgetListConfigureActivity : SimpleActivity() { config.primaryColor, "", false, + false, false ) ) @@ -283,6 +286,7 @@ class WidgetListConfigureActivity : SimpleActivity() { config.primaryColor, "", false, + false, false ) ) @@ -298,6 +302,7 @@ class WidgetListConfigureActivity : SimpleActivity() { config.primaryColor, "", false, + false, false ) ) 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 b0a077c42..7aa8cec28 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 @@ -216,7 +216,8 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV it.color, it.location, it.isPastEvent, - it.repeatInterval > 0 + it.repeatInterval > 0, + it.isTask() ) 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 20860a8d7..6b736fe5f 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 @@ -544,7 +544,19 @@ fun Context.getEventListItems(events: List, addSectionDays: Boolean = tru } val listEvent = - ListEvent(it.id!!, it.startTS, it.endTS, it.title, it.description, it.getIsAllDay(), it.color, it.location, it.isPastEvent, it.repeatInterval > 0) + ListEvent( + it.id!!, + it.startTS, + it.endTS, + it.title, + it.description, + it.getIsAllDay(), + it.color, + it.location, + it.isPastEvent, + it.repeatInterval > 0, + it.isTask() + ) listItems.add(listEvent) } return listItems @@ -610,7 +622,7 @@ fun Context.printBitmap(bitmap: Bitmap) { } fun Context.editEvent(event: ListEvent) { - Intent(this, EventActivity::class.java).apply { + Intent(this, getActivityToOpen(event.isTask)).apply { putExtra(EVENT_ID, event.id) putExtra(EVENT_OCCURRENCE_TS, event.startTS) startActivity(this) 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 d5b0ab9f3..fa88222ab 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 @@ -16,9 +16,7 @@ import com.simplemobiletools.calendar.pro.extensions.config import com.simplemobiletools.calendar.pro.extensions.eventsHelper import com.simplemobiletools.calendar.pro.extensions.getViewBitmap import com.simplemobiletools.calendar.pro.extensions.printBitmap -import com.simplemobiletools.calendar.pro.helpers.DAY_CODE -import com.simplemobiletools.calendar.pro.helpers.EVENT_ID -import com.simplemobiletools.calendar.pro.helpers.EVENT_OCCURRENCE_TS +import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.interfaces.NavigationListener import com.simplemobiletools.calendar.pro.models.Event @@ -131,7 +129,7 @@ class DayFragment : Fragment() { } private fun editEvent(event: Event) { - Intent(context, event.getActivityToOpen()).apply { + Intent(context, getActivityToOpen(event.isTask())).apply { putExtra(EVENT_ID, event.id) putExtra(EVENT_OCCURRENCE_TS, event.startTS) startActivity(this) 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 45833f751..cc2c5e25f 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 @@ -549,7 +549,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { } setOnClickListener { - Intent(context, event.getActivityToOpen()).apply { + Intent(context, getActivityToOpen(event.isTask())).apply { putExtra(EVENT_ID, event.id!!) putExtra(EVENT_OCCURRENCE_TS, event.startTS) startActivity(this) @@ -719,7 +719,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { calculateExtraHeight() setOnClickListener { - Intent(context, event.getActivityToOpen()).apply { + Intent(context, getActivityToOpen(event.isTask())).apply { putExtra(EVENT_ID, event.id) putExtra(EVENT_OCCURRENCE_TS, event.startTS) startActivity(this) 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 8af029fac..b17201347 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 @@ -1,5 +1,8 @@ package com.simplemobiletools.calendar.pro.helpers +import com.simplemobiletools.calendar.pro.activities.EventActivity +import com.simplemobiletools.calendar.pro.activities.TaskActivity + const val STORED_LOCALLY_ONLY = 0 const val ROW_COUNT = 6 const val COLUMN_COUNT = 7 @@ -224,3 +227,9 @@ fun isWeekend(i: Int, isSundayFirst: Boolean): Boolean { i == 5 || i == 6 || i == 12 || i == 13 } } + +fun getActivityToOpen(isTask: Boolean) = if (isTask) { + TaskActivity::class.java +} else { + EventActivity::class.java +} diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt index 61cd3a243..50a2c58da 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/Event.kt @@ -5,8 +5,6 @@ import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.Index import androidx.room.PrimaryKey -import com.simplemobiletools.calendar.pro.activities.EventActivity -import com.simplemobiletools.calendar.pro.activities.TaskActivity import com.simplemobiletools.calendar.pro.extensions.seconds import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.commons.extensions.addBitIf @@ -207,10 +205,4 @@ data class Event( DateTimeZone.getDefault().id } } - - fun getActivityToOpen() = if (isTask()) { - TaskActivity::class.java - } else { - EventActivity::class.java - } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListEvent.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListEvent.kt index c04072bed..2a9e6b6ac 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListEvent.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/ListEvent.kt @@ -1,4 +1,4 @@ package com.simplemobiletools.calendar.pro.models data class ListEvent(var id: Long, var startTS: Long, var endTS: Long, var title: String, var description: String, var isAllDay: Boolean, var color: Int, - var location: String, var isPastEvent: Boolean, var isRepeatable: Boolean) : ListItem() + var location: String, var isPastEvent: Boolean, var isRepeatable: Boolean, var isTask: Boolean) : ListItem()