From ccb3b503f3dda6f7d43d7107d84ed5603af916a4 Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 3 Apr 2024 12:12:02 +0200 Subject: [PATCH 01/13] Initial, basic support for event STATUS attribute --- .../calendar/activities/EventActivity.kt | 48 +++++++++++++++++++ .../calendar/databases/EventsDatabase.kt | 11 ++++- .../fossify/calendar/helpers/CalDAVHelper.kt | 3 +- .../fossify/calendar/helpers/IcsExporter.kt | 2 +- .../org/fossify/calendar/models/Event.kt | 4 +- app/src/main/res/layout/activity_event.xml | 36 +++++++++++++- app/src/main/res/values-de/strings.xml | 5 +- app/src/main/res/values/strings.xml | 3 ++ 8 files changed, 106 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt index 61c9e5c18..efba401b1 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt @@ -9,6 +9,7 @@ import android.graphics.drawable.Drawable import android.graphics.drawable.LayerDrawable import android.net.Uri import android.os.Bundle +import android.provider.CalendarContract import android.provider.CalendarContract.Attendees import android.provider.CalendarContract.Colors import android.provider.ContactsContract.CommonDataKinds @@ -72,6 +73,7 @@ class EventActivity : SimpleActivity() { private var mAvailableContacts = ArrayList() private var mSelectedContacts = ArrayList() private var mAvailability = Attendees.AVAILABILITY_BUSY + private var mStatus = CalendarContract.Events.STATUS_CONFIRMED private var mStoredEventTypes = ArrayList() private var mOriginalTimeZone = DateTimeZone.getDefault().id private var mOriginalStartTS = 0L @@ -174,6 +176,7 @@ class EventActivity : SimpleActivity() { putString(ATTENDEES, Gson().toJson(getAllAttendees(false))) putInt(AVAILABILITY, mAvailability) + putInt(STATUS, mStatus) putInt(EVENT_COLOR, mEventColor) putLong(EVENT_TYPE_ID, mEventTypeId) @@ -207,6 +210,7 @@ class EventActivity : SimpleActivity() { mReminder3Type = getInt(REMINDER_3_TYPE) mAvailability = getInt(AVAILABILITY) + mStatus = getInt(STATUS) mEventColor = getInt(EVENT_COLOR) mRepeatInterval = getInt(REPEAT_INTERVAL) @@ -337,6 +341,14 @@ class EventActivity : SimpleActivity() { } } + eventStatus.setOnClickListener { + showStatusPicker(mStatus) { + mStatus = it + updateStatusText() + updateStatusImage() + } + } + eventTypeHolder.setOnClickListener { showEventTypeDialog() } eventAllDay.apply { isChecked = mEvent.getIsAllDay() @@ -458,6 +470,8 @@ class EventActivity : SimpleActivity() { updateCalDAVVisibility() updateAvailabilityText() updateAvailabilityImage() + updateStatusText() + updateStatusImage() } private fun setupEditEvent() { @@ -500,6 +514,7 @@ class EventActivity : SimpleActivity() { mEventTypeId = mEvent.eventType mEventCalendarId = mEvent.getCalDAVCalendarId() mAvailability = mEvent.availability + mStatus = mEvent.status mEventColor = mEvent.color mAttendees = mEvent.attendees.toMutableList() as ArrayList @@ -576,6 +591,7 @@ class EventActivity : SimpleActivity() { reminder2Type = mReminder2Type reminder3Minutes = mReminder3Minutes reminder3Type = mReminder3Type + status = mStatus eventType = mEventTypeId } } @@ -956,6 +972,17 @@ class EventActivity : SimpleActivity() { } } + private fun showStatusPicker(currentValue: Int, callback: (Int) -> Unit) { + val items = arrayListOf( + RadioItem(CalendarContract.Events.STATUS_TENTATIVE, getString(R.string.status_tentative)), + RadioItem(CalendarContract.Events.STATUS_CONFIRMED, getString(R.string.status_confirmed)), + RadioItem(CalendarContract.Events.STATUS_CANCELED, getString(R.string.status_canceled)), + ) + RadioGroupDialog(this, items, currentValue) { + callback(it as Int) + } + } + private fun updateReminderTypeImages() { updateReminderTypeImage(binding.eventReminder1Type, Reminder(mReminder1Minutes, mReminder1Type)) updateReminderTypeImage(binding.eventReminder2Type, Reminder(mReminder2Minutes, mReminder2Type)) @@ -994,6 +1021,24 @@ class EventActivity : SimpleActivity() { binding.eventAvailability.text = if (mAvailability == Attendees.AVAILABILITY_FREE) getString(R.string.status_free) else getString(R.string.status_busy) } + private fun updateStatusText() { + when (mStatus) { + CalendarContract.Events.STATUS_CONFIRMED -> binding.eventStatus.text = getString(R.string.status_confirmed) + CalendarContract.Events.STATUS_TENTATIVE -> binding.eventStatus.text = getString(R.string.status_tentative) + CalendarContract.Events.STATUS_CANCELED -> binding.eventStatus.text = getString(R.string.status_canceled) + } + } + + private fun updateStatusImage() { + val drawable = when (mStatus) { + CalendarContract.Events.STATUS_CONFIRMED -> R.drawable.ic_check_green + CalendarContract.Events.STATUS_CANCELED -> R.drawable.ic_cross_red + else -> R.drawable.ic_question_yellow + } + val icon = resources.getDrawable(drawable) + binding.eventStatusImage.setImageDrawable(icon) + } + private fun updateRepetitionText() { binding.eventRepetition.text = getRepetitionText(mRepeatInterval) } @@ -1036,6 +1081,8 @@ class EventActivity : SimpleActivity() { updateCalDAVVisibility() updateAvailabilityText() updateAvailabilityImage() + updateStatusText() + updateStatusImage() } } } else { @@ -1310,6 +1357,7 @@ class EventActivity : SimpleActivity() { source = newSource location = binding.eventLocation.value availability = mAvailability + status = mStatus color = mEventColor } diff --git a/app/src/main/kotlin/org/fossify/calendar/databases/EventsDatabase.kt b/app/src/main/kotlin/org/fossify/calendar/databases/EventsDatabase.kt index 716958631..64e3df3b7 100644 --- a/app/src/main/kotlin/org/fossify/calendar/databases/EventsDatabase.kt +++ b/app/src/main/kotlin/org/fossify/calendar/databases/EventsDatabase.kt @@ -22,7 +22,7 @@ import org.fossify.calendar.models.Widget import org.fossify.commons.extensions.getProperPrimaryColor import java.util.concurrent.Executors -@Database(entities = [Event::class, EventType::class, Widget::class, Task::class], version = 8) +@Database(entities = [Event::class, EventType::class, Widget::class, Task::class], version = 9) @TypeConverters(Converters::class) abstract class EventsDatabase : RoomDatabase() { @@ -55,6 +55,7 @@ abstract class EventsDatabase : RoomDatabase() { .addMigrations(MIGRATION_5_6) .addMigrations(MIGRATION_6_7) .addMigrations(MIGRATION_7_8) + .addMigrations(MIGRATION_8_9) .build() db!!.openHelper.setWriteAheadLoggingEnabled(true) } @@ -136,5 +137,13 @@ abstract class EventsDatabase : RoomDatabase() { } } } + + private val MIGRATION_8_9 = object : Migration(8, 9) { + override fun migrate(database: SupportSQLiteDatabase) { + database.apply { + execSQL("ALTER TABLE events ADD COLUMN status INTEGER NOT NULL DEFAULT 1") + } + } + } } } diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt index 6ff7124be..7a9a6eb48 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt @@ -5,6 +5,7 @@ import android.content.ContentUris import android.content.ContentValues import android.content.Context import android.graphics.Color +import android.provider.CalendarContract import android.provider.CalendarContract.* import android.widget.Toast import org.fossify.calendar.R @@ -421,7 +422,7 @@ class CalDAVHelper(val context: Context) { put(Events.TITLE, event.title) put(Events.DESCRIPTION, event.description) put(Events.EVENT_LOCATION, event.location) - put(Events.STATUS, Events.STATUS_CONFIRMED) + put(Events.STATUS, event.status) put(Events.AVAILABILITY, event.availability) if (event.color == 0) { diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt index 6ae801f33..81ef09996 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt @@ -149,7 +149,7 @@ class IcsExporter(private val context: Context) { writeLn("$MISSING_YEAR${if (event.hasMissingYear()) 1 else 0}") writeLn("$DTSTAMP$exportTime") - writeLn("$STATUS$CONFIRMED") + writeLn("$STATUS$CONFIRMED") // TODO real status Parser().getRepeatCode(event).let { if (it.isNotEmpty()) writeLn("$RRULE$it") } fillDescription(event.description.replace("\n", "\\n"), writer) diff --git a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt index 5c5ae1068..440043b62 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt @@ -1,5 +1,6 @@ package org.fossify.calendar.models +import android.provider.CalendarContract import android.provider.CalendarContract.Attendees import androidx.collection.LongSparseArray import androidx.room.ColumnInfo @@ -41,7 +42,8 @@ data class Event( @ColumnInfo(name = "source") var source: String = SOURCE_SIMPLE_CALENDAR, @ColumnInfo(name = "availability") var availability: Int = 0, @ColumnInfo(name = "color") var color: Int = 0, - @ColumnInfo(name = "type") var type: Int = TYPE_EVENT + @ColumnInfo(name = "type") var type: Int = TYPE_EVENT, + @ColumnInfo(name = "status") var status: Int = CalendarContract.Events.STATUS_CONFIRMED, ) : Serializable { companion object { diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index ced6aca8b..a00f402fc 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -506,6 +506,40 @@ android:background="@color/divider_grey" android:importantForAccessibility="no" /> + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index db1c6fae9..2bfbb7a44 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -208,6 +208,9 @@ Verfügbar Beschäftigt Der Abruf des Termins %s ist fehlgeschlagen + Vorläufig + Bestätigt + Abgelehnt Montag Dienstag Mittwoch @@ -257,4 +260,4 @@ Wie kann ich einen bestehenden Termintyp ändern oder löschen\? Du kannst beides in der App unter „Einstellungen – Termintypen verwalten“ einstellen. Klicke einfach auf den gewünschte Termin, um Beschriftung und Farbe zu ändern, oder wähle den gewünschten Termin durch langes Drücken aus und verwende den Mülleimer im oberen Menü. CalDAV - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 65d58867f..93aa40544 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -244,6 +244,9 @@ Free Busy Fetching event %s failed + Tentative + Confirmed + Canceled From 5b5d8d7124c3283bace185512f92484c362d9f9c Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 3 Apr 2024 15:11:36 +0200 Subject: [PATCH 02/13] Implement ICS import and export for status attribute --- .../org/fossify/calendar/helpers/IcsExporter.kt | 3 ++- .../org/fossify/calendar/helpers/IcsImporter.kt | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt index 81ef09996..f13572383 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt @@ -28,6 +28,7 @@ class IcsExporter(private val context: Context) { private var calendars = ArrayList() private val reminderLabel = context.getString(R.string.reminder) private val exportTime = Formatter.getExportedTime(System.currentTimeMillis()) + private val status = 1 fun exportEvents( outputStream: OutputStream?, @@ -149,7 +150,7 @@ class IcsExporter(private val context: Context) { writeLn("$MISSING_YEAR${if (event.hasMissingYear()) 1 else 0}") writeLn("$DTSTAMP$exportTime") - writeLn("$STATUS$CONFIRMED") // TODO real status + writeLn("$STATUS:${event.status}") Parser().getRepeatCode(event).let { if (it.isNotEmpty()) writeLn("$RRULE$it") } fillDescription(event.description.replace("\n", "\\n"), writer) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt index 71739df93..285dab928 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt @@ -1,6 +1,8 @@ package org.fossify.calendar.helpers +import android.provider.CalendarContract import android.provider.CalendarContract.Events +import org.fossify.calendar.R import org.fossify.calendar.activities.SimpleActivity import org.fossify.calendar.extensions.eventsDB import org.fossify.calendar.extensions.eventsHelper @@ -44,6 +46,7 @@ class IcsImporter(val activity: SimpleActivity) { private var curLastModified = 0L private var curCategoryColor = -2 private var curAvailability = Events.AVAILABILITY_BUSY + private var curStatus = Events.STATUS_CONFIRMED private var isNotificationDescription = false private var isProperReminderAction = false private var isSequence = false @@ -209,6 +212,14 @@ class IcsImporter(val activity: SimpleActivity) { isSequence = true } else if (line.startsWith(TRANSP)) { line.substring(TRANSP.length).let { curAvailability = if (it == TRANSPARENT) Events.AVAILABILITY_FREE else Events.AVAILABILITY_BUSY } + } else if (line.startsWith(STATUS)) { + line.substring(STATUS.length).let { + curStatus = when (it) { + Events.STATUS_CONFIRMED.toString() -> Events.STATUS_CONFIRMED + Events.STATUS_CANCELED.toString() -> Events.STATUS_CANCELED + else -> Events.STATUS_TENTATIVE + } + } } else if (line.trim() == BEGIN_ALARM) { isNotificationDescription = true } else if (line.trim() == END_ALARM) { @@ -274,7 +285,8 @@ class IcsImporter(val activity: SimpleActivity) { curLastModified, source, curAvailability, - type = curType + type = curType, + status = curStatus ) if (isAllDay && curEnd > curStart && !event.isTask()) { From 8eaa7ed8bb07b38b714c69018d53adfe7a9ca4fe Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 4 Apr 2024 09:24:55 +0200 Subject: [PATCH 03/13] Fix ICS import and export --- .../org/fossify/calendar/helpers/IcsExporter.kt | 2 +- .../org/fossify/calendar/helpers/IcsImporter.kt | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt index f13572383..8ca91022b 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt @@ -150,7 +150,7 @@ class IcsExporter(private val context: Context) { writeLn("$MISSING_YEAR${if (event.hasMissingYear()) 1 else 0}") writeLn("$DTSTAMP$exportTime") - writeLn("$STATUS:${event.status}") + writeLn("$STATUS${event.status}") Parser().getRepeatCode(event).let { if (it.isNotEmpty()) writeLn("$RRULE$it") } fillDescription(event.description.replace("\n", "\\n"), writer) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt index 285dab928..3eef1c747 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt @@ -177,6 +177,12 @@ class IcsImporter(val activity: SimpleActivity) { } else if (line.startsWith(STATUS)) { if (isParsingTask && line.substring(STATUS.length) == COMPLETED) { curFlags = curFlags or FLAG_TASK_COMPLETED + } else { + curStatus = when (line.substring(STATUS.length)) { + Events.STATUS_CONFIRMED.toString() -> Events.STATUS_CONFIRMED + Events.STATUS_CANCELED.toString() -> Events.STATUS_CANCELED + else -> Events.STATUS_TENTATIVE + } } } else if (line.startsWith(COMPLETED)) { if (isParsingTask && line.substring(COMPLETED.length).trim().isNotEmpty()) { @@ -212,14 +218,6 @@ class IcsImporter(val activity: SimpleActivity) { isSequence = true } else if (line.startsWith(TRANSP)) { line.substring(TRANSP.length).let { curAvailability = if (it == TRANSPARENT) Events.AVAILABILITY_FREE else Events.AVAILABILITY_BUSY } - } else if (line.startsWith(STATUS)) { - line.substring(STATUS.length).let { - curStatus = when (it) { - Events.STATUS_CONFIRMED.toString() -> Events.STATUS_CONFIRMED - Events.STATUS_CANCELED.toString() -> Events.STATUS_CANCELED - else -> Events.STATUS_TENTATIVE - } - } } else if (line.trim() == BEGIN_ALARM) { isNotificationDescription = true } else if (line.trim() == END_ALARM) { From 2660d149d8792ada51b6dc23ce9ab267267ce0f3 Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 4 Apr 2024 10:01:43 +0200 Subject: [PATCH 04/13] Fix icons --- .../org/fossify/calendar/activities/EventActivity.kt | 8 ++++---- .../main/res/drawable/ic_event_tentative_vector.xml | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/ic_event_tentative_vector.xml diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt index efba401b1..1427a456e 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt @@ -1031,11 +1031,11 @@ class EventActivity : SimpleActivity() { private fun updateStatusImage() { val drawable = when (mStatus) { - CalendarContract.Events.STATUS_CONFIRMED -> R.drawable.ic_check_green - CalendarContract.Events.STATUS_CANCELED -> R.drawable.ic_cross_red - else -> R.drawable.ic_question_yellow + CalendarContract.Events.STATUS_CONFIRMED -> R.drawable.ic_event_available_vector + CalendarContract.Events.STATUS_CANCELED -> R.drawable.ic_event_busy_vector + else -> R.drawable.ic_event_tentative_vector } - val icon = resources.getDrawable(drawable) + val icon = resources.getColoredDrawableWithColor(drawable, getProperTextColor()) binding.eventStatusImage.setImageDrawable(icon) } diff --git a/app/src/main/res/drawable/ic_event_tentative_vector.xml b/app/src/main/res/drawable/ic_event_tentative_vector.xml new file mode 100644 index 000000000..6af793d28 --- /dev/null +++ b/app/src/main/res/drawable/ic_event_tentative_vector.xml @@ -0,0 +1,12 @@ + + + + From 6fd557a04d8260e2a14e83d137fa9f377fbc4276 Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 4 Apr 2024 12:22:26 +0200 Subject: [PATCH 05/13] Show title of canceled events as strike-throughed in events list, week view and month view --- .../org/fossify/calendar/adapters/EventListWidgetAdapter.kt | 4 +++- .../main/kotlin/org/fossify/calendar/extensions/Context.kt | 3 ++- .../main/kotlin/org/fossify/calendar/extensions/Event.kt | 2 +- .../kotlin/org/fossify/calendar/extensions/ListEvent.kt | 2 +- .../org/fossify/calendar/extensions/MonthViewEvent.kt | 2 +- app/src/main/kotlin/org/fossify/calendar/models/Event.kt | 4 ++++ .../main/kotlin/org/fossify/calendar/models/ListEvent.kt | 6 ++++-- .../kotlin/org/fossify/calendar/models/MonthViewEvent.kt | 1 + app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt | 3 ++- 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt index b0a5334c3..6778bd7a3 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt @@ -3,6 +3,7 @@ package org.fossify.calendar.adapters import android.content.Context import android.content.Intent import android.graphics.Paint +import android.provider.CalendarContract import android.widget.RemoteViews import android.widget.RemoteViewsService import org.fossify.calendar.R @@ -235,7 +236,8 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV isRepeatable = event.repeatInterval > 0, isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), - isAttendeeInviteDeclined = event.isAttendeeInviteDeclined() + isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), + isEventCanceled = event.isEventCanceled() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt index a136e299a..59562208d 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt @@ -675,7 +675,8 @@ fun Context.getEventListItems(events: List, addSectionDays: Boolean = tru it.repeatInterval > 0, it.isTask(), it.isTaskCompleted(), - it.isAttendeeInviteDeclined() + it.isAttendeeInviteDeclined(), + it.isEventCanceled() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/Event.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/Event.kt index 9976094d4..0b2078894 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/Event.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/Event.kt @@ -41,4 +41,4 @@ fun Event.maybeAdjustRepeatLimitCount(original: Event, occurrenceTS: Long) { } } -fun Event.shouldStrikeThrough() = isTaskCompleted() || isAttendeeInviteDeclined() +fun Event.shouldStrikeThrough() = isTaskCompleted() || isAttendeeInviteDeclined() || isEventCanceled() diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/ListEvent.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/ListEvent.kt index 908ca6617..991d1cb51 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/ListEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/ListEvent.kt @@ -2,4 +2,4 @@ package org.fossify.calendar.extensions import org.fossify.calendar.models.ListEvent -fun ListEvent.shouldStrikeThrough() = isTaskCompleted || isAttendeeInviteDeclined +fun ListEvent.shouldStrikeThrough() = isTaskCompleted || isAttendeeInviteDeclined || isEventCanceled diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/MonthViewEvent.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/MonthViewEvent.kt index e52534361..d069dc4e1 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/MonthViewEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/MonthViewEvent.kt @@ -2,4 +2,4 @@ package org.fossify.calendar.extensions import org.fossify.calendar.models.MonthViewEvent -fun MonthViewEvent.shouldStrikeThrough() = isTaskCompleted || isAttendeeInviteDeclined +fun MonthViewEvent.shouldStrikeThrough() = isTaskCompleted || isAttendeeInviteDeclined || isEventCanceled diff --git a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt index 440043b62..653324ed0 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt @@ -216,4 +216,8 @@ data class Event( fun isAttendeeInviteDeclined() = attendees.any { it.isMe && it.status == Attendees.ATTENDEE_STATUS_DECLINED } + + fun isEventCanceled(): Boolean { + return status == CalendarContract.Events.STATUS_CANCELED + } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt index 8333451b9..806598153 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt @@ -13,7 +13,8 @@ data class ListEvent( var isRepeatable: Boolean, var isTask: Boolean, var isTaskCompleted: Boolean, - var isAttendeeInviteDeclined: Boolean + var isAttendeeInviteDeclined: Boolean, + var isEventCanceled: Boolean ) : ListItem() { companion object { @@ -30,7 +31,8 @@ data class ListEvent( isRepeatable = false, isTask = false, isTaskCompleted = false, - isAttendeeInviteDeclined = false + isAttendeeInviteDeclined = false, + isEventCanceled = false ) } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt index 780bd51e0..b0b85a0ad 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt @@ -14,4 +14,5 @@ data class MonthViewEvent( val isTask: Boolean, val isTaskCompleted: Boolean, val isAttendeeInviteDeclined: Boolean, + val isEventCanceled: Boolean ) diff --git a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt index caee570c8..c7aa616fa 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt @@ -156,7 +156,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con isPastEvent = event.isPastEvent, isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), - isAttendeeInviteDeclined = event.isAttendeeInviteDeclined() + isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), + isEventCanceled = event.isEventCanceled() ) allEvents.add(monthViewEvent) } From adb4a8b921682fdcf80347dc77c4241b3ebb0bc1 Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 5 Apr 2024 08:21:01 +0200 Subject: [PATCH 06/13] Export and import the string value instead of numeric value (according to RFC) --- .../kotlin/org/fossify/calendar/helpers/Constants.kt | 4 ++++ .../kotlin/org/fossify/calendar/helpers/Formatter.kt | 10 ++++++++++ .../kotlin/org/fossify/calendar/helpers/IcsExporter.kt | 2 +- .../kotlin/org/fossify/calendar/helpers/IcsImporter.kt | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt index b6d9b24f8..ca3e11ceb 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt @@ -268,6 +268,10 @@ const val EVENT_CALENDAR_ID = "EVENT_CALENDAR_ID" const val IS_NEW_EVENT = "IS_NEW_EVENT" const val EVENT_COLOR = "EVENT_COLOR" +// From Status attribute (RFC 5545 3.8.1.11) +const val CANCELLED = "CANCELLED" +const val TENTATIVE = "TENTATIVE" + // actions const val ACTION_MARK_COMPLETED = "ACTION_MARK_COMPLETED" diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt index 0ab342b5f..0e975bdc4 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt @@ -1,6 +1,8 @@ package org.fossify.calendar.helpers import android.content.Context +import android.provider.CalendarContract +import org.fossify.calendar.R import org.fossify.calendar.extensions.config import org.fossify.calendar.extensions.seconds import org.joda.time.DateTime @@ -138,4 +140,12 @@ object Formatter { fun getShiftedLocalTS(ts: Long) = getShiftedTS(dateTime = getUTCDateTimeFromTS(ts), toZone = DateTimeZone.getDefault()) fun getShiftedUtcTS(ts: Long) = getShiftedTS(dateTime = getDateTimeFromTS(ts), toZone = DateTimeZone.UTC) + + fun getStatusStringFromStatusCode(statusCode: Int): String { + return when (statusCode) { + CalendarContract.Events.STATUS_CONFIRMED -> CONFIRMED + CalendarContract.Events.STATUS_CANCELED -> CANCELLED + else -> TENTATIVE + } + } } diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt index 8ca91022b..97c7882e9 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt @@ -150,7 +150,7 @@ class IcsExporter(private val context: Context) { writeLn("$MISSING_YEAR${if (event.hasMissingYear()) 1 else 0}") writeLn("$DTSTAMP$exportTime") - writeLn("$STATUS${event.status}") + writeLn("$STATUS${Formatter.getStatusStringFromStatusCode(event.status)}") Parser().getRepeatCode(event).let { if (it.isNotEmpty()) writeLn("$RRULE$it") } fillDescription(event.description.replace("\n", "\\n"), writer) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt index 3eef1c747..a4a8d8c11 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt @@ -179,8 +179,8 @@ class IcsImporter(val activity: SimpleActivity) { curFlags = curFlags or FLAG_TASK_COMPLETED } else { curStatus = when (line.substring(STATUS.length)) { - Events.STATUS_CONFIRMED.toString() -> Events.STATUS_CONFIRMED - Events.STATUS_CANCELED.toString() -> Events.STATUS_CANCELED + CONFIRMED -> Events.STATUS_CONFIRMED + CANCELLED -> Events.STATUS_CANCELED else -> Events.STATUS_TENTATIVE } } From bb18589d21ec9a69bb866db10b4802c0d7c5545c Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 5 Apr 2024 08:40:16 +0200 Subject: [PATCH 07/13] Fix CalDav sync --- .../main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt index 7a9a6eb48..acf46ae02 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/CalDAVHelper.kt @@ -243,7 +243,7 @@ class CalDAVHelper(val context: Context) { reminder1?.type ?: REMINDER_NOTIFICATION, reminder2?.type ?: REMINDER_NOTIFICATION, reminder3?.type ?: REMINDER_NOTIFICATION, repeatRule.repeatInterval, repeatRule.repeatRule, repeatRule.repeatLimit, ArrayList(), attendees, importId, eventTimeZone, allDay, eventTypeId, - source = source, availability = availability, color = displayColor + source = source, availability = availability, color = displayColor, status = status ) if (event.getIsAllDay()) { From c4f583d9674d43fccc8ca6648754aedc43a4628f Mon Sep 17 00:00:00 2001 From: marco Date: Fri, 19 Apr 2024 09:30:36 +0200 Subject: [PATCH 08/13] Show tentative events as dimmed (same as past events can be shown) in event list, day, week and month view --- .../org/fossify/calendar/adapters/DayEventsAdapter.kt | 2 +- .../org/fossify/calendar/adapters/EventListAdapter.kt | 2 +- .../org/fossify/calendar/adapters/EventListWidgetAdapter.kt | 3 ++- .../main/kotlin/org/fossify/calendar/extensions/Context.kt | 3 ++- .../kotlin/org/fossify/calendar/fragments/WeekFragment.kt | 4 ++-- app/src/main/kotlin/org/fossify/calendar/models/Event.kt | 4 ++++ .../main/kotlin/org/fossify/calendar/models/ListEvent.kt | 6 ++++-- .../kotlin/org/fossify/calendar/models/MonthViewEvent.kt | 3 ++- app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt | 4 +++- 9 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt index 368364c7e..8cc4506d5 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt @@ -117,7 +117,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - dimPastEvents && event.isPastEvent && !isPrintVersion + ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion } if (adjustAlpha) { diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt index 6c3cf3a86..8c1689309 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt @@ -163,7 +163,7 @@ class EventListAdapter( val adjustAlpha = if (listEvent.isTask) { dimCompletedTasks && listEvent.isTaskCompleted } else { - dimPastEvents && listEvent.isPastEvent && !isPrintVersion + ((dimPastEvents && listEvent.isPastEvent) || listEvent.isEventTentative) && !isPrintVersion } if (adjustAlpha) { newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA) diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt index 6778bd7a3..e262fd323 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt @@ -237,7 +237,8 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), - isEventCanceled = event.isEventCanceled() + isEventCanceled = event.isEventCanceled(), + isEventTentative = event.isEventTentative() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt index 59562208d..e7a2c31fa 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt @@ -676,7 +676,8 @@ fun Context.getEventListItems(events: List, addSectionDays: Boolean = tru it.isTask(), it.isTaskCompleted(), it.isAttendeeInviteDeclined(), - it.isEventCanceled() + it.isEventCanceled(), + it.isEventTentative() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt index 53bcb4424..97f92c040 100644 --- a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt @@ -614,7 +614,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - dimPastEvents && event.isPastEvent && !isPrintVersion + ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion } if (adjustAlpha) { @@ -769,7 +769,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - dimPastEvents && event.isPastEvent && !isPrintVersion + ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion } if (adjustAlpha) { diff --git a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt index 653324ed0..d7c5c7186 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt @@ -220,4 +220,8 @@ data class Event( fun isEventCanceled(): Boolean { return status == CalendarContract.Events.STATUS_CANCELED } + + fun isEventTentative(): Boolean { + return status == CalendarContract.Events.STATUS_TENTATIVE + } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt index 806598153..c068871e4 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt @@ -14,7 +14,8 @@ data class ListEvent( var isTask: Boolean, var isTaskCompleted: Boolean, var isAttendeeInviteDeclined: Boolean, - var isEventCanceled: Boolean + var isEventCanceled: Boolean, + var isEventTentative: Boolean ) : ListItem() { companion object { @@ -32,7 +33,8 @@ data class ListEvent( isTask = false, isTaskCompleted = false, isAttendeeInviteDeclined = false, - isEventCanceled = false + isEventCanceled = false, + isEventTentative = false ) } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt index b0b85a0ad..c55316033 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt @@ -14,5 +14,6 @@ data class MonthViewEvent( val isTask: Boolean, val isTaskCompleted: Boolean, val isAttendeeInviteDeclined: Boolean, - val isEventCanceled: Boolean + val isEventCanceled: Boolean, + val isEventTentative: Boolean ) diff --git a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt index c7aa616fa..d4720bbbc 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt @@ -157,7 +157,8 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), - isEventCanceled = event.isEventCanceled() + isEventCanceled = event.isEventCanceled(), + isEventTentative = event.isEventTentative() ) allEvents.add(monthViewEvent) } @@ -402,6 +403,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con val adjustAlpha = when { event.isTask -> dimCompletedTasks && event.isTaskCompleted !startDay.isThisMonth && !endDay.isThisMonth -> true + event.isEventTentative -> true else -> dimPastEvents && event.isPastEvent && !isPrintVersion } From ec9ebf8f49fdd82311d4c2c02fb4701fa3529e03 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 14 Nov 2024 22:26:31 +0530 Subject: [PATCH 09/13] Revert "Show tentative events as dimmed (same as past events can be shown) in event list, day, week and month view" This reverts commit c4f583d9674d43fccc8ca6648754aedc43a4628f. --- .../org/fossify/calendar/adapters/DayEventsAdapter.kt | 2 +- .../org/fossify/calendar/adapters/EventListAdapter.kt | 2 +- .../org/fossify/calendar/adapters/EventListWidgetAdapter.kt | 3 +-- .../main/kotlin/org/fossify/calendar/extensions/Context.kt | 3 +-- .../kotlin/org/fossify/calendar/fragments/WeekFragment.kt | 4 ++-- app/src/main/kotlin/org/fossify/calendar/models/Event.kt | 4 ---- .../main/kotlin/org/fossify/calendar/models/ListEvent.kt | 6 ++---- .../kotlin/org/fossify/calendar/models/MonthViewEvent.kt | 3 +-- app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt | 4 +--- 9 files changed, 10 insertions(+), 21 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt index 8cc4506d5..368364c7e 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/DayEventsAdapter.kt @@ -117,7 +117,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList, r val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion + dimPastEvents && event.isPastEvent && !isPrintVersion } if (adjustAlpha) { diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt index 8c1689309..6c3cf3a86 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListAdapter.kt @@ -163,7 +163,7 @@ class EventListAdapter( val adjustAlpha = if (listEvent.isTask) { dimCompletedTasks && listEvent.isTaskCompleted } else { - ((dimPastEvents && listEvent.isPastEvent) || listEvent.isEventTentative) && !isPrintVersion + dimPastEvents && listEvent.isPastEvent && !isPrintVersion } if (adjustAlpha) { newTextColor = newTextColor.adjustAlpha(MEDIUM_ALPHA) diff --git a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt index 5d3e11510..2644c4b9c 100644 --- a/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/adapters/EventListWidgetAdapter.kt @@ -238,8 +238,7 @@ class EventListWidgetAdapter(val context: Context, val intent: Intent) : RemoteV isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), - isEventCanceled = event.isEventCanceled(), - isEventTentative = event.isEventTentative() + isEventCanceled = event.isEventCanceled() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt index e7a2c31fa..59562208d 100644 --- a/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/calendar/extensions/Context.kt @@ -676,8 +676,7 @@ fun Context.getEventListItems(events: List, addSectionDays: Boolean = tru it.isTask(), it.isTaskCompleted(), it.isAttendeeInviteDeclined(), - it.isEventCanceled(), - it.isEventTentative() + it.isEventCanceled() ) listItems.add(listEvent) } diff --git a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt index 0d61926a5..9f1a6be0c 100644 --- a/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt +++ b/app/src/main/kotlin/org/fossify/calendar/fragments/WeekFragment.kt @@ -617,7 +617,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion + dimPastEvents && event.isPastEvent && !isPrintVersion } if (adjustAlpha) { @@ -771,7 +771,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { val adjustAlpha = if (event.isTask()) { dimCompletedTasks && event.isTaskCompleted() } else { - ((dimPastEvents && event.isPastEvent) || event.isEventTentative()) && !isPrintVersion + dimPastEvents && event.isPastEvent && !isPrintVersion } if (adjustAlpha) { diff --git a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt index d7c5c7186..653324ed0 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/Event.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/Event.kt @@ -220,8 +220,4 @@ data class Event( fun isEventCanceled(): Boolean { return status == CalendarContract.Events.STATUS_CANCELED } - - fun isEventTentative(): Boolean { - return status == CalendarContract.Events.STATUS_TENTATIVE - } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt index c068871e4..806598153 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/ListEvent.kt @@ -14,8 +14,7 @@ data class ListEvent( var isTask: Boolean, var isTaskCompleted: Boolean, var isAttendeeInviteDeclined: Boolean, - var isEventCanceled: Boolean, - var isEventTentative: Boolean + var isEventCanceled: Boolean ) : ListItem() { companion object { @@ -33,8 +32,7 @@ data class ListEvent( isTask = false, isTaskCompleted = false, isAttendeeInviteDeclined = false, - isEventCanceled = false, - isEventTentative = false + isEventCanceled = false ) } } diff --git a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt index c55316033..b0b85a0ad 100644 --- a/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt +++ b/app/src/main/kotlin/org/fossify/calendar/models/MonthViewEvent.kt @@ -14,6 +14,5 @@ data class MonthViewEvent( val isTask: Boolean, val isTaskCompleted: Boolean, val isAttendeeInviteDeclined: Boolean, - val isEventCanceled: Boolean, - val isEventTentative: Boolean + val isEventCanceled: Boolean ) diff --git a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt index d4720bbbc..c7aa616fa 100644 --- a/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt +++ b/app/src/main/kotlin/org/fossify/calendar/views/MonthView.kt @@ -157,8 +157,7 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con isTask = event.isTask(), isTaskCompleted = event.isTaskCompleted(), isAttendeeInviteDeclined = event.isAttendeeInviteDeclined(), - isEventCanceled = event.isEventCanceled(), - isEventTentative = event.isEventTentative() + isEventCanceled = event.isEventCanceled() ) allEvents.add(monthViewEvent) } @@ -403,7 +402,6 @@ class MonthView(context: Context, attrs: AttributeSet, defStyle: Int) : View(con val adjustAlpha = when { event.isTask -> dimCompletedTasks && event.isTaskCompleted !startDay.isThisMonth && !endDay.isThisMonth -> true - event.isEventTentative -> true else -> dimPastEvents && event.isPastEvent && !isPrintVersion } From 6290aa9bab28501e56a3b51d8e02dfc568694123 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 14 Nov 2024 22:30:22 +0530 Subject: [PATCH 10/13] Shorten code --- .../calendar/activities/EventActivity.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt index 1427a456e..95e66684a 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt @@ -9,9 +9,9 @@ import android.graphics.drawable.Drawable import android.graphics.drawable.LayerDrawable import android.net.Uri import android.os.Bundle -import android.provider.CalendarContract import android.provider.CalendarContract.Attendees import android.provider.CalendarContract.Colors +import android.provider.CalendarContract.Events import android.provider.ContactsContract.CommonDataKinds import android.provider.ContactsContract.CommonDataKinds.StructuredName import android.provider.ContactsContract.Data @@ -73,7 +73,7 @@ class EventActivity : SimpleActivity() { private var mAvailableContacts = ArrayList() private var mSelectedContacts = ArrayList() private var mAvailability = Attendees.AVAILABILITY_BUSY - private var mStatus = CalendarContract.Events.STATUS_CONFIRMED + private var mStatus = Events.STATUS_CONFIRMED private var mStoredEventTypes = ArrayList() private var mOriginalTimeZone = DateTimeZone.getDefault().id private var mOriginalStartTS = 0L @@ -974,9 +974,9 @@ class EventActivity : SimpleActivity() { private fun showStatusPicker(currentValue: Int, callback: (Int) -> Unit) { val items = arrayListOf( - RadioItem(CalendarContract.Events.STATUS_TENTATIVE, getString(R.string.status_tentative)), - RadioItem(CalendarContract.Events.STATUS_CONFIRMED, getString(R.string.status_confirmed)), - RadioItem(CalendarContract.Events.STATUS_CANCELED, getString(R.string.status_canceled)), + RadioItem(Events.STATUS_TENTATIVE, getString(R.string.status_tentative)), + RadioItem(Events.STATUS_CONFIRMED, getString(R.string.status_confirmed)), + RadioItem(Events.STATUS_CANCELED, getString(R.string.status_canceled)), ) RadioGroupDialog(this, items, currentValue) { callback(it as Int) @@ -1023,16 +1023,16 @@ class EventActivity : SimpleActivity() { private fun updateStatusText() { when (mStatus) { - CalendarContract.Events.STATUS_CONFIRMED -> binding.eventStatus.text = getString(R.string.status_confirmed) - CalendarContract.Events.STATUS_TENTATIVE -> binding.eventStatus.text = getString(R.string.status_tentative) - CalendarContract.Events.STATUS_CANCELED -> binding.eventStatus.text = getString(R.string.status_canceled) + Events.STATUS_CONFIRMED -> binding.eventStatus.text = getString(R.string.status_confirmed) + Events.STATUS_TENTATIVE -> binding.eventStatus.text = getString(R.string.status_tentative) + Events.STATUS_CANCELED -> binding.eventStatus.text = getString(R.string.status_canceled) } } private fun updateStatusImage() { val drawable = when (mStatus) { - CalendarContract.Events.STATUS_CONFIRMED -> R.drawable.ic_event_available_vector - CalendarContract.Events.STATUS_CANCELED -> R.drawable.ic_event_busy_vector + Events.STATUS_CONFIRMED -> R.drawable.ic_event_available_vector + Events.STATUS_CANCELED -> R.drawable.ic_event_busy_vector else -> R.drawable.ic_event_tentative_vector } val icon = resources.getColoredDrawableWithColor(drawable, getProperTextColor()) From 4d013576dfa81d8c428866a4f3d22e002d03cc0d Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 14 Nov 2024 22:39:22 +0530 Subject: [PATCH 11/13] Move getStatusStringFromStatusCode to constants For consistencies sake. --- .../org/fossify/calendar/helpers/Constants.kt | 28 +++++++++++++++---- .../org/fossify/calendar/helpers/Formatter.kt | 10 ------- .../fossify/calendar/helpers/IcsExporter.kt | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt index 9a76477e1..7a6dd10c4 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Constants.kt @@ -1,5 +1,7 @@ package org.fossify.calendar.helpers +import android.provider.CalendarContract +import android.provider.CalendarContract.Events import org.fossify.calendar.activities.EventActivity import org.fossify.calendar.activities.TaskActivity import org.fossify.commons.helpers.MONTH_SECONDS @@ -14,7 +16,8 @@ const val COLUMN_COUNT = 7 const val SCHEDULE_CALDAV_REQUEST_CODE = 10000 const val AUTOMATIC_BACKUP_REQUEST_CODE = 10001 const val FETCH_INTERVAL = 3 * MONTH_SECONDS -const val MAX_SEARCH_YEAR = 2051218800L // 2035, limit search results for events repeating indefinitely +const val MAX_SEARCH_YEAR = + 2051218800L // 2035, limit search results for events repeating indefinitely // endless scrolling updating const val MIN_EVENTS_TRESHOLD = 30 @@ -71,7 +74,8 @@ const val TYPE_TASK = 1 const val TWELVE_HOURS = 43200 const val DAY = 86400 const val WEEK = 604800 -const val MONTH = 2592001 // exact value not taken into account, Joda is used for adding months and years +const val MONTH = + 2592001 // exact value not taken into account, Joda is used for adding months and years const val YEAR = 31536000 const val EVENT_PERIOD_TODAY = -1 @@ -148,10 +152,13 @@ const val AUTO_BACKUP_PAST_ENTRIES = "auto_backup_past_entries" const val LAST_AUTO_BACKUP_TIME = "last_auto_backup_time" // repeat_rule for monthly and yearly repetition -const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) -const val REPEAT_ORDER_WEEKDAY_USE_LAST = 2 // i.e. every last sunday. 4th if a month has 4 sundays, 5th if 5 (or last sunday in june, if yearly) +const val REPEAT_SAME_DAY = + 1 // i.e. 25th every month, or 3rd june (if yearly repetition) +const val REPEAT_ORDER_WEEKDAY_USE_LAST = + 2 // i.e. every last sunday. 4th if a month has 4 sundays, 5th if 5 (or last sunday in june, if yearly) const val REPEAT_LAST_DAY = 3 // i.e. every last day of the month -const val REPEAT_ORDER_WEEKDAY = 4 // i.e. every 4th sunday, even if a month has 4 sundays only (will stay 4th even at months with 5) +const val REPEAT_ORDER_WEEKDAY = + 4 // i.e. every 4th sunday, even if a month has 4 sundays only (will stay 4th even at months with 5) // special event and task flags const val FLAG_ALL_DAY = 1 @@ -178,7 +185,8 @@ const val DURATION = "DURATION:" const val SUMMARY = "SUMMARY" const val DESCRIPTION = "DESCRIPTION" const val DESCRIPTION_EXPORT = "DESCRIPTION:" -val DESCRIPTION_REGEX = Regex("""DESCRIPTION(?:(?:;[^:;]*="[^"]*")*;?(?:;LANGUAGE=[^:;]*)?(?:;[^:;]*="[^"]*")*)*:(.*(?:\r?\n\s+.*)*)""") +val DESCRIPTION_REGEX = + Regex("""DESCRIPTION(?:(?:;[^:;]*="[^"]*")*;?(?:;LANGUAGE=[^:;]*)?(?:;[^:;]*="[^"]*")*)*:(.*(?:\r?\n\s+.*)*)""") const val UID = "UID:" const val ACTION = "ACTION:" const val TRANSP = "TRANSP:" @@ -334,3 +342,11 @@ fun getJavaDayOfWeekFromJoda(dayOfWeek: Int): Int { else -> throw IllegalArgumentException("Invalid day: $dayOfWeek") } } + +fun getStatusStringFromEventStatus(statusCode: Int): String { + return when (statusCode) { + Events.STATUS_CONFIRMED -> CONFIRMED + Events.STATUS_CANCELED -> CANCELLED + else -> TENTATIVE + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt index 0e975bdc4..0ab342b5f 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/Formatter.kt @@ -1,8 +1,6 @@ package org.fossify.calendar.helpers import android.content.Context -import android.provider.CalendarContract -import org.fossify.calendar.R import org.fossify.calendar.extensions.config import org.fossify.calendar.extensions.seconds import org.joda.time.DateTime @@ -140,12 +138,4 @@ object Formatter { fun getShiftedLocalTS(ts: Long) = getShiftedTS(dateTime = getUTCDateTimeFromTS(ts), toZone = DateTimeZone.getDefault()) fun getShiftedUtcTS(ts: Long) = getShiftedTS(dateTime = getDateTimeFromTS(ts), toZone = DateTimeZone.UTC) - - fun getStatusStringFromStatusCode(statusCode: Int): String { - return when (statusCode) { - CalendarContract.Events.STATUS_CONFIRMED -> CONFIRMED - CalendarContract.Events.STATUS_CANCELED -> CANCELLED - else -> TENTATIVE - } - } } diff --git a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt index 97c7882e9..5c60276a1 100644 --- a/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/org/fossify/calendar/helpers/IcsExporter.kt @@ -150,7 +150,7 @@ class IcsExporter(private val context: Context) { writeLn("$MISSING_YEAR${if (event.hasMissingYear()) 1 else 0}") writeLn("$DTSTAMP$exportTime") - writeLn("$STATUS${Formatter.getStatusStringFromStatusCode(event.status)}") + writeLn("$STATUS${getStatusStringFromEventStatus(event.status)}") Parser().getRepeatCode(event).let { if (it.isNotEmpty()) writeLn("$RRULE$it") } fillDescription(event.description.replace("\n", "\\n"), writer) From 87926c9d642323f81bb0352884c8f7c4cd2d5743 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Thu, 14 Nov 2024 22:58:52 +0530 Subject: [PATCH 12/13] Update event status icons --- .../org/fossify/calendar/activities/EventActivity.kt | 6 +++--- .../res/drawable/ic_cancel_circle_outline_vector.xml | 3 +++ .../res/drawable/ic_check_circle_outline_vector.xml | 3 +++ .../main/res/drawable/ic_event_tentative_vector.xml | 12 ------------ .../drawable/ic_question_circle_outline_vector.xml | 3 +++ app/src/main/res/layout/activity_event.xml | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 app/src/main/res/drawable/ic_cancel_circle_outline_vector.xml create mode 100644 app/src/main/res/drawable/ic_check_circle_outline_vector.xml delete mode 100644 app/src/main/res/drawable/ic_event_tentative_vector.xml create mode 100644 app/src/main/res/drawable/ic_question_circle_outline_vector.xml diff --git a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt index 95e66684a..afefd0205 100644 --- a/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt @@ -1031,9 +1031,9 @@ class EventActivity : SimpleActivity() { private fun updateStatusImage() { val drawable = when (mStatus) { - Events.STATUS_CONFIRMED -> R.drawable.ic_event_available_vector - Events.STATUS_CANCELED -> R.drawable.ic_event_busy_vector - else -> R.drawable.ic_event_tentative_vector + Events.STATUS_CONFIRMED -> R.drawable.ic_check_circle_outline_vector + Events.STATUS_CANCELED -> R.drawable.ic_cancel_circle_outline_vector + else -> R.drawable.ic_question_circle_outline_vector } val icon = resources.getColoredDrawableWithColor(drawable, getProperTextColor()) binding.eventStatusImage.setImageDrawable(icon) diff --git a/app/src/main/res/drawable/ic_cancel_circle_outline_vector.xml b/app/src/main/res/drawable/ic_cancel_circle_outline_vector.xml new file mode 100644 index 000000000..f3e7cc08d --- /dev/null +++ b/app/src/main/res/drawable/ic_cancel_circle_outline_vector.xml @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/res/drawable/ic_check_circle_outline_vector.xml b/app/src/main/res/drawable/ic_check_circle_outline_vector.xml new file mode 100644 index 000000000..54fb393f9 --- /dev/null +++ b/app/src/main/res/drawable/ic_check_circle_outline_vector.xml @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/res/drawable/ic_event_tentative_vector.xml b/app/src/main/res/drawable/ic_event_tentative_vector.xml deleted file mode 100644 index 6af793d28..000000000 --- a/app/src/main/res/drawable/ic_event_tentative_vector.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_question_circle_outline_vector.xml b/app/src/main/res/drawable/ic_question_circle_outline_vector.xml new file mode 100644 index 000000000..833c1a59a --- /dev/null +++ b/app/src/main/res/drawable/ic_question_circle_outline_vector.xml @@ -0,0 +1,3 @@ + + + diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index a00f402fc..634b7629a 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -514,7 +514,7 @@ android:layout_alignBottom="@+id/event_status" android:layout_marginStart="@dimen/normal_margin" android:padding="@dimen/medium_margin" - android:src="@drawable/ic_event_busy_vector" /> + android:src="@drawable/ic_check_circle_outline_vector" /> Date: Thu, 14 Nov 2024 23:05:37 +0530 Subject: [PATCH 13/13] Move the event status setting up --- app/src/main/res/layout/activity_event.xml | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index 634b7629a..4eb944cf5 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -473,69 +473,69 @@ android:importantForAccessibility="no" /> + android:src="@drawable/ic_check_circle_outline_vector" /> + android:src="@drawable/ic_event_busy_vector" /> @@ -557,7 +557,7 @@ android:id="@+id/event_caldav_calendar_holder" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@+id/event_status_divider" + android:layout_below="@+id/event_availability_divider" android:layout_toEndOf="@+id/event_caldav_calendar_image" android:background="?attr/selectableItemBackground" android:visibility="gone">