From abbe87d509b64caf81c1a1b292cda93498ae5aec Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 24 Feb 2022 16:09:06 +0100 Subject: [PATCH] launch TaskActivity if editing a task --- app/build.gradle | 2 +- .../calendar/pro/activities/TaskActivity.kt | 2 +- .../calendar/pro/fragments/DayFragment.kt | 3 +-- .../calendar/pro/fragments/WeekFragment.kt | 4 ++-- .../simplemobiletools/calendar/pro/helpers/Constants.kt | 1 - .../com/simplemobiletools/calendar/pro/models/Event.kt | 8 ++++++++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 210ab1f63..fc5ec1fab 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,7 +69,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:43cdaa1296' + implementation 'com.github.SimpleMobileTools:Simple-Commons:ec74a7c44f' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt index 0dff42737..122f3fd47 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt @@ -37,7 +37,7 @@ class TaskActivity : SimpleActivity() { val intent = intent ?: return mDialogTheme = getDialogTheme() updateColors() - val taskId = intent.getLongExtra(TASK_ID, 0L) + val taskId = intent.getLongExtra(EVENT_ID, 0L) gotTask(savedInstanceState, null) } 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 2945e2bb8..d5b0ab9f3 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 @@ -9,7 +9,6 @@ import android.view.ViewGroup import android.widget.RelativeLayout import androidx.fragment.app.Fragment import com.simplemobiletools.calendar.pro.R -import com.simplemobiletools.calendar.pro.activities.EventActivity import com.simplemobiletools.calendar.pro.activities.MainActivity import com.simplemobiletools.calendar.pro.activities.SimpleActivity import com.simplemobiletools.calendar.pro.adapters.DayEventsAdapter @@ -132,7 +131,7 @@ class DayFragment : Fragment() { } private fun editEvent(event: Event) { - Intent(context, EventActivity::class.java).apply { + Intent(context, event.getActivityToOpen()).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 0c685ea0f..45833f751 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, EventActivity::class.java).apply { + Intent(context, event.getActivityToOpen()).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, EventActivity::class.java).apply { + Intent(context, event.getActivityToOpen()).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 03ef4f799..8af029fac 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 @@ -8,7 +8,6 @@ const val SCHEDULE_CALDAV_REQUEST_CODE = 10000 const val DAY_CODE = "day_code" const val YEAR_LABEL = "year" const val EVENT_ID = "event_id" -const val TASK_ID = "task_id" const val IS_DUPLICATE_INTENT = "is_duplicate_intent" const val EVENT_OCCURRENCE_TS = "event_occurrence_ts" const val NEW_EVENT_START_TS = "new_event_start_ts" 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 50a2c58da..61cd3a243 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,6 +5,8 @@ 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 @@ -205,4 +207,10 @@ data class Event( DateTimeZone.getDefault().id } } + + fun getActivityToOpen() = if (isTask()) { + TaskActivity::class.java + } else { + EventActivity::class.java + } }