From 549665e3021e613f3f12e7640dcc8be8d5c6f1a1 Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Tue, 4 Jul 2023 20:09:16 +0200 Subject: [PATCH 01/12] Fixed displaying long events in weekly view (#2135) --- .../calendar/pro/fragments/WeekFragment.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 3f4c344b0..5433d94ef 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 @@ -552,7 +552,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { do { val dayOfWeek = dayColumns.indexOfFirst { it.tag == currentDayCode } if (dayOfWeek == -1 || dayOfWeek >= config.weeklyViewDays) { - continue@dayevents + if (startDayCode != endDayCode) { + currentDateTime = currentDateTime.plusDays(1) + currentDayCode = Formatter.getDayCodeFromDateTime(currentDateTime) + continue + } else { + continue@dayevents + } } val dayColumn = dayColumns[dayOfWeek] From f43f3002e731cdcd01a5caf238ffa1a85a065567 Mon Sep 17 00:00:00 2001 From: Edgars Bimbirulis Date: Mon, 10 Jul 2023 02:03:20 +0300 Subject: [PATCH 02/12] - Improve UI Monhtly and daily view for landscape --- .../res/layout-land/fragment_month_day.xml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 app/src/main/res/layout-land/fragment_month_day.xml diff --git a/app/src/main/res/layout-land/fragment_month_day.xml b/app/src/main/res/layout-land/fragment_month_day.xml new file mode 100644 index 000000000..9663a745e --- /dev/null +++ b/app/src/main/res/layout-land/fragment_month_day.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + From c92a3f4bda15516d877b5e1adaeef0c64bc87080 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 8 Jul 2023 21:47:09 +0000 Subject: [PATCH 03/12] Translated using Weblate (Ukrainian) Currently translated at 100.0% (245 of 245 strings) Translation: Simple Mobile Tools/Simple Calendar Translate-URL: https://hosted.weblate.org/projects/simple-mobile-tools/simple-calendar/uk/ --- app/src/main/res/values-uk/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 883f575a8..e9a377fb3 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -41,7 +41,7 @@ Дублювати завдання Позначити завершеним Позначити незавершеним - Task color + Колір завдання Повторювати Без повторень @@ -287,4 +287,4 @@ Haven't found some strings? There's more at https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res --> - + \ No newline at end of file From 48cfacdacedd6d21d5a6276d68351ea4b5662f35 Mon Sep 17 00:00:00 2001 From: elgratea Date: Thu, 13 Jul 2023 22:37:29 +0000 Subject: [PATCH 04/12] Translated using Weblate (Bulgarian) Currently translated at 100.0% (245 of 245 strings) Translation: Simple Mobile Tools/Simple Calendar Translate-URL: https://hosted.weblate.org/projects/simple-mobile-tools/simple-calendar/bg/ --- app/src/main/res/values-bg/strings.xml | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index bfa4525f6..c576d0ceb 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -9,7 +9,7 @@ Месечен и дневен изглед Годишен изглед Списък със събития - No upcoming events. + Няма предстоящи събития. Отидете на днес Отиди на дата @@ -29,9 +29,9 @@ Филтриране на събитията по тип Моля попълнете местоположение за показване на картата Предстоящо събитие - You have filtered out all event types - Event color - Default calendar color + Вие филтрирахте всички типове събития + Цвят на събитието + Цвят на календара по подразбиране Задача Задачи @@ -41,7 +41,7 @@ Дублиране на задача Означете като завършено Означете като незавършено - Task color + Цвят на задачата Повторение Без повторение @@ -54,8 +54,8 @@ години Повтаряй до Завинаги - Събитието се повтаря - The task is repeatable + Събитието e повтаряемо + Задачата e повтаряема Изборът съдържа само повтарящи се събития Изтрийте само избраното събитие Изтрийте това събитие и всички бъдещи събития @@ -130,8 +130,8 @@ Експортиране на събития в .ics файл Тип събитие по подразбиране Експортиране и на минали събития - Export tasks - Export past entries too + Експортиране на задачи + Експортиране и на минали записи Включване на типа събития Име на файла (без .ics) Игнорирайте типовете събития във файла, винаги използвайте този по подразбиране @@ -180,8 +180,8 @@ Смяна на описанието на събитието с местоположение Показване на описание или местоположение Изтриване на всички събития - Delete all events and tasks - Сигурни ли сте, че искате да изтриете всички събития\? Това ще остави типовете събития и другите ви настройки непокътнати. + Изтриване на всички събития и задачи + Сигурни ли сте, че искате да изтриете всички събития и задачи\? Това ще остави типовете събития и другите ви настройки непокътнати. Показване на решетка Циклично напомняне до отхвърляне Затъмняване на минали събития @@ -227,7 +227,7 @@ Не са намерени календари, които да могат да се синхронизират Свободно Заето - Fetching event %s failed + Изтегляне на събитие %s е неуспешно Понеделник @@ -267,7 +267,7 @@ Как мога да премахна празниците, импортирани чрез бутона \"Добавяне на празници\"\? Създадените по този начин празници се вмъкват в нов тип събитие, наречен \"Празници\". Можете да отидете в Настройки -> Управление на типове събития, да натиснете продължително дадения тип събитие и да го изтриете, като изберете кошчето за боклук. Мога ли да си синхронизирам своите събития с Google Calendar или друга услуга, поддържаща CalDAV\? - Maybe even share calendars with other people? + Може дори да споделяте календари с други хора\? Да, просто превключете \"Синхронизация с CalDAV\" в настройките на приложението и изберете календарите, които искате да синхронизирате. Ще ви е необходимо обаче приложение на трета страна, което да обработва синхронизацията между устройството и сървърите. В случай че искате да синхронизирате календар на Google, тяхното официално приложение \"Календар\" ще свърши тази работа. За други календари ще ви е необходим адаптер за синхронизиране от трета страна, например DAVx5. Виждам напомняния но не чувам звук. Какво мога да направя\? Системата оказва огромно влияние не само върху показването на действителното напомняне, но и върху възпроизвеждането на звука. Ако не можете да чуете никакъв звук, опитайте да влезете в настройките на приложението, да натиснете опцията \"Аудио поток, използван от напомнянията\" и да я промените на друга стойност. Ако все още не работи, проверете настройките на звука, дали конкретният поток не е заглушен. @@ -281,4 +281,4 @@ Haven't found some strings? There's more at https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res --> - + \ No newline at end of file From 8bc0fb0cb7b286e7b88b4668e165994c0e424a07 Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Sat, 15 Jul 2023 09:13:06 +0200 Subject: [PATCH 05/12] Added editing options for repeating events in weekly view (#2122) --- .../calendar/pro/activities/EventActivity.kt | 59 ++++-------------- .../calendar/pro/activities/TaskActivity.kt | 50 +++------------- .../pro/dialogs/EditRepeatingEventDialog.kt | 9 ++- .../calendar/pro/fragments/WeekFragment.kt | 58 ++++++++++++++---- .../calendar/pro/helpers/EventsHelper.kt | 60 +++++++++++++++++++ 5 files changed, 131 insertions(+), 105 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 12a27d099..0f00519ce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -1307,7 +1307,7 @@ class EventActivity : SimpleActivity() { // recreate the event if it was moved in a different CalDAV calendar if (mEvent.id != null && oldSource != newSource && oldSource != SOURCE_IMPORTED_ICS) { if (mRepeatInterval > 0 && wasRepeatable) { - applyOriginalStartEndTimes() + eventsHelper.applyOriginalStartEndTimes(mEvent, mOriginalStartTS, mOriginalEndTS) } eventsHelper.deleteEvent(mEvent.id!!, true) mEvent.id = null @@ -1358,68 +1358,29 @@ class EventActivity : SimpleActivity() { private fun showEditRepeatingEventDialog() { EditRepeatingEventDialog(this) { hideKeyboard() + if (it == null) { + return@EditRepeatingEventDialog + } when (it) { EDIT_SELECTED_OCCURRENCE -> { - ensureBackgroundThread { - mEvent.apply { - parentId = id!!.toLong() - id = null - repeatRule = 0 - repeatInterval = 0 - repeatLimit = 0 - } - - eventsHelper.insertEvent(mEvent, addToCalDAV = true, showToasts = true) { - finish() - } + eventsHelper.editSelectedOccurrence(mEvent, true) { + finish() } } EDIT_FUTURE_OCCURRENCES -> { - ensureBackgroundThread { - val eventId = mEvent.id!! - val originalEvent = eventsDB.getEventWithId(eventId) ?: return@ensureBackgroundThread - mEvent.maybeAdjustRepeatLimitCount(originalEvent, mEventOccurrenceTS) - mEvent.id = null - eventsHelper.apply { - addEventRepeatLimit(eventId, mEventOccurrenceTS) - if (mEventOccurrenceTS == originalEvent.startTS) { - deleteEvent(eventId, true) - } - - insertEvent(mEvent, addToCalDAV = true, showToasts = true) { - finish() - } - } + eventsHelper.editFutureOccurrences(mEvent, mEventOccurrenceTS, true) { + finish() } } EDIT_ALL_OCCURRENCES -> { - ensureBackgroundThread { - applyOriginalStartEndTimes() - eventsHelper.updateEvent(mEvent, updateAtCalDAV = true, showToasts = true) { - finish() - } + eventsHelper.editAllOccurrences(mEvent, mOriginalStartTS, mOriginalEndTS, true) { + finish() } } } } } - private fun applyOriginalStartEndTimes() { - // Shift the start and end times of the first (original) event based on the changes made - val originalEvent = eventsDB.getEventWithId(mEvent.id!!) ?: return - val originalStartTS = originalEvent.startTS - val originalEndTS = originalEvent.endTS - val oldStartTS = mOriginalStartTS - val oldEndTS = mOriginalEndTS - - mEvent.apply { - val startTSDelta = oldStartTS - startTS - val endTSDelta = oldEndTS - endTS - startTS = originalStartTS - startTSDelta - endTS = originalEndTS - endTSDelta - } - } - private fun updateStartTexts() { updateStartDateText() updateStartTimeText() 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 99b2a1edf..0caf1805b 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 @@ -471,55 +471,23 @@ class TaskActivity : SimpleActivity() { private fun showEditRepeatingTaskDialog() { EditRepeatingEventDialog(this, isTask = true) { hideKeyboard() + if (it == null) { + return@EditRepeatingEventDialog + } when (it) { EDIT_SELECTED_OCCURRENCE -> { - ensureBackgroundThread { - mTask.apply { - parentId = id!!.toLong() - id = null - repeatRule = 0 - repeatInterval = 0 - repeatLimit = 0 - } - - eventsHelper.insertTask(mTask, showToasts = true) { - finish() - } + eventsHelper.editSelectedOccurrence(mTask, true) { + finish() } } EDIT_FUTURE_OCCURRENCES -> { - ensureBackgroundThread { - val taskId = mTask.id!! - val originalTask = eventsDB.getTaskWithId(taskId) ?: return@ensureBackgroundThread - mTask.maybeAdjustRepeatLimitCount(originalTask, mTaskOccurrenceTS) - mTask.id = null - eventsHelper.apply { - addEventRepeatLimit(taskId, mTaskOccurrenceTS) - if (mTaskOccurrenceTS == originalTask.startTS) { - deleteEvent(taskId, true) - } - - insertTask(mTask, showToasts = true) { - finish() - } - } + eventsHelper.editFutureOccurrences(mTask, mTaskOccurrenceTS, true) { + finish() } } EDIT_ALL_OCCURRENCES -> { - ensureBackgroundThread { - // Shift the start and end times of the first (original) event based on the changes made - val originalEvent = eventsDB.getTaskWithId(mTask.id!!) ?: return@ensureBackgroundThread - val originalStartTS = originalEvent.startTS - val oldStartTS = mOriginalStartTS - - mTask.apply { - val startTSDelta = oldStartTS - startTS - startTS = originalStartTS - startTSDelta - endTS = startTS - } - eventsHelper.updateEvent(mTask, updateAtCalDAV = false, showToasts = true) { - finish() - } + eventsHelper.editAllOccurrences(mTask, mOriginalStartTS, showToasts = true) { + finish() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt index 5627e539e..e0cd0223d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/EditRepeatingEventDialog.kt @@ -12,7 +12,7 @@ import com.simplemobiletools.commons.extensions.hideKeyboard import com.simplemobiletools.commons.extensions.setupDialogStuff import kotlinx.android.synthetic.main.dialog_edit_repeating_event.view.* -class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean = false, val callback: (allOccurrences: Int) -> Unit) { +class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean = false, val callback: (allOccurrences: Int?) -> Unit) { private var dialog: AlertDialog? = null init { @@ -33,12 +33,15 @@ class EditRepeatingEventDialog(val activity: SimpleActivity, val isTask: Boolean activity.setupDialogStuff(view, this) { alertDialog -> dialog = alertDialog alertDialog.hideKeyboard() + alertDialog.setOnDismissListener { sendResult(null) } } } } - private fun sendResult(allOccurrences: Int) { + private fun sendResult(allOccurrences: Int?) { callback(allOccurrences) - dialog?.dismiss() + if (allOccurrences != null) { + dialog?.dismiss() + } } } 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 5433d94ef..7b32d2fc9 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 @@ -16,6 +16,9 @@ import androidx.collection.LongSparseArray import androidx.constraintlayout.widget.ConstraintLayout import androidx.fragment.app.Fragment import com.simplemobiletools.calendar.pro.R +import com.simplemobiletools.calendar.pro.activities.MainActivity +import com.simplemobiletools.calendar.pro.activities.SimpleActivity +import com.simplemobiletools.calendar.pro.dialogs.EditRepeatingEventDialog import com.simplemobiletools.calendar.pro.extensions.* import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.calendar.pro.helpers.Formatter @@ -269,12 +272,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { DragEvent.ACTION_DRAG_ENDED -> true DragEvent.ACTION_DROP -> { try { - val eventId = dragEvent.clipData.getItemAt(0).text.toString().toLong() + val (eventId, originalStartTS, originalEndTS) = dragEvent.clipData.getItemAt(0).text.toString().split(";").map { it.toLong() } val startHour = (dragEvent.y / rowHeight).toInt() ensureBackgroundThread { val event = context?.eventsDB?.getEventOrTaskWithId(eventId) - event?.let { - val currentStartTime = Formatter.getDateTimeFromTS(it.startTS) + event?.let { event -> + val currentStartTime = Formatter.getDateTimeFromTS(event.startTS) val startTime = Formatter.getDateTimeFromTS(weekTimestamp + index * DAY_SECONDS) .withTime( startHour, @@ -284,14 +287,45 @@ class WeekFragment : Fragment(), WeeklyCalendar { ).seconds() val currentEventDuration = event.endTS - event.startTS val endTime = startTime + currentEventDuration - context?.eventsHelper?.updateEvent( - it.copy( - startTS = startTime, - endTS = endTime, - flags = it.flags.removeBit(FLAG_ALL_DAY) - ), updateAtCalDAV = true, showToasts = false - ) { - updateCalendar() + val newEvent = event.copy( + startTS = startTime, + endTS = endTime, + flags = event.flags.removeBit(FLAG_ALL_DAY) + ) + if (event.repeatInterval > 0) { + val activity = this.activity as SimpleActivity + activity.runOnUiThread { + EditRepeatingEventDialog(activity) { + activity.hideKeyboard() + when (it) { + null -> { + // force update by removing hash + lastHash = 0 + updateCalendar() + } + EDIT_SELECTED_OCCURRENCE -> { + context?.eventsHelper?.editSelectedOccurrence(newEvent, false) { + updateCalendar() + } + } + EDIT_FUTURE_OCCURRENCES -> { + context?.eventsHelper?.editFutureOccurrences(newEvent, originalStartTS, false) { + // we need to refresh all fragments because they can contain future occurrences + (activity as MainActivity).refreshItems() + } + } + EDIT_ALL_OCCURRENCES -> { + context?.eventsHelper?.editAllOccurrences(newEvent, originalStartTS, originalEndTS, false) { + (activity as MainActivity).refreshItems() + } + } + } + } + } + } else { + context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) { + updateCalendar() + } } } } @@ -634,7 +668,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { setOnLongClickListener { view -> currentlyDraggedView = view val shadowBuilder = View.DragShadowBuilder(view) - val clipData = ClipData.newPlainText(WEEKLY_EVENT_ID_LABEL, event.id.toString()) + val clipData = ClipData.newPlainText(WEEKLY_EVENT_ID_LABEL, "${event.id};${event.startTS};${event.endTS}") if (isNougatPlus()) { view.startDragAndDrop(clipData, shadowBuilder, null, 0) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt index cb9927108..fb3a1e1c9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt @@ -180,6 +180,66 @@ class EventsHelper(val context: Context) { callback?.invoke() } + fun applyOriginalStartEndTimes(event: Event, oldStartTS: Long, oldEndTS: Long) { + val originalEvent = eventsDB.getEventOrTaskWithId(event.id!!) ?: return + val originalStartTS = originalEvent.startTS + val originalEndTS = originalEvent.endTS + + event.apply { + val startTSDelta = oldStartTS - startTS + val endTSDelta = oldEndTS - endTS + startTS = originalStartTS - startTSDelta + endTS = if (isTask()) startTS else originalEndTS - endTSDelta + } + } + + fun editSelectedOccurrence(event: Event, showToasts: Boolean, callback: () -> Unit) { + ensureBackgroundThread { + event.apply { + parentId = id!!.toLong() + id = null + repeatRule = 0 + repeatInterval = 0 + repeatLimit = 0 + } + if (event.isTask()) { + insertTask(event, showToasts = showToasts, callback = callback) + } else { + insertEvent(event, addToCalDAV = true, showToasts = showToasts) { + callback() + } + } + } + } + + fun editFutureOccurrences(event: Event, eventOccurrenceTS: Long, showToasts: Boolean, callback: () -> Unit) { + ensureBackgroundThread { + val eventId = event.id!! + val originalEvent = eventsDB.getEventOrTaskWithId(event.id!!) ?: return@ensureBackgroundThread + event.maybeAdjustRepeatLimitCount(originalEvent, eventOccurrenceTS) + event.id = null + addEventRepeatLimit(eventId, eventOccurrenceTS) + if (eventOccurrenceTS == originalEvent.startTS) { + deleteEvent(eventId, true) + } + + if (event.isTask()) { + insertTask(event, showToasts = showToasts, callback = callback) + } else { + insertEvent(event, addToCalDAV = true, showToasts = showToasts) { + callback() + } + } + } + } + + fun editAllOccurrences(event: Event, originalStartTS: Long, originalEndTS: Long = 0, showToasts: Boolean, callback: () -> Unit) { + ensureBackgroundThread { + applyOriginalStartEndTimes(event, originalStartTS, originalEndTS) + updateEvent(event, updateAtCalDAV = !event.isTask(), showToasts = showToasts, callback = callback) + } + } + private fun ensureEventTypeVisibility(event: Event, enableEventType: Boolean) { if (enableEventType) { val eventType = event.eventType.toString() From 2ee226d06b3ed4da55be534dc403788fcb823ce2 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 16 Jul 2023 02:54:51 +0530 Subject: [PATCH 06/12] Use local timezone to configure weekly views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses issues like https://github.com/SimpleMobileTools/Simple-Calendar/issues/2143 The weekly view originally used local timezone to configure everything but was modified to use UTC to fix a `Start week with Sunday` issue https://github.com/SimpleMobileTools/Simple-Calendar/issues/1213 where events were created on the wrong day. Since `getFirstDayOfWeek()` was rewritten to handle week preferences properly, there is no need to complicate things using UTC anymore (otherwise we'll have to handle UTC-to-local-timezone conversion in many places) This also fixes an issue with the drag-and-drop feature where the events were moved by ±1 day because the difference in timezone was not taken care of. --- .../simplemobiletools/calendar/pro/extensions/Context.kt | 7 +++---- .../calendar/pro/fragments/WeekFragment.kt | 4 ++-- .../calendar/pro/fragments/WeekFragmentsHolder.kt | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) 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 b7e79f5e3..9b1321279 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 @@ -20,7 +20,6 @@ import android.provider.CalendarContract import android.view.View import android.view.ViewGroup import android.widget.LinearLayout -import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.app.AlarmManagerCompat import androidx.core.app.NotificationCompat @@ -48,7 +47,6 @@ import com.simplemobiletools.commons.helpers.* import kotlinx.android.synthetic.main.day_monthly_event_view.view.* import org.joda.time.DateTime import org.joda.time.DateTimeConstants -import org.joda.time.DateTimeZone import org.joda.time.LocalDate import java.io.File import java.io.FileOutputStream @@ -327,7 +325,8 @@ fun Context.notifyEvent(originalEvent: Event) { val events = eventsHelper.getRepeatableEventsFor(currentSeconds - WEEK_SECONDS, currentSeconds + YEAR_SECONDS, event.id!!) for (currEvent in events) { eventStartTS = if (currEvent.getIsAllDay()) Formatter.getDayStartTS(Formatter.getDayCodeFromTS(currEvent.startTS)) else currEvent.startTS - val firstReminderMinutes = arrayOf(currEvent.reminder3Minutes, currEvent.reminder2Minutes, currEvent.reminder1Minutes).filter { it != REMINDER_OFF }.max() + val firstReminderMinutes = + arrayOf(currEvent.reminder3Minutes, currEvent.reminder2Minutes, currEvent.reminder1Minutes).filter { it != REMINDER_OFF }.max() if (eventStartTS - firstReminderMinutes * 60 > currentSeconds) { break } @@ -759,7 +758,7 @@ fun Context.editEvent(event: ListEvent) { } fun Context.getFirstDayOfWeek(date: DateTime): String { - var startOfWeek = date.withZoneRetainFields(DateTimeZone.UTC).withTimeAtStartOfDay() + var startOfWeek = date.withTimeAtStartOfDay() if (!config.startWeekWithCurrentDay) { startOfWeek = if (config.isSundayFirst) { // a workaround for Joda-time's Monday-as-first-day-of-the-week 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 5433d94ef..d3e9525a6 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 @@ -196,14 +196,14 @@ class WeekFragment : Fragment(), WeeklyCalendar { mView.week_events_columns_holder.removeAllViews() (0 until config.weeklyViewDays).forEach { val column = inflater.inflate(R.layout.weekly_view_day_column, mView.week_events_columns_holder, false) as RelativeLayout - column.tag = Formatter.getUTCDayCodeFromTS(weekTimestamp + it * DAY_SECONDS) + column.tag = Formatter.getDayCodeFromTS(weekTimestamp + it * DAY_SECONDS) mView.week_events_columns_holder.addView(column) dayColumns.add(column) } } private fun setupDayLabels() { - var curDay = Formatter.getUTCDateTimeFromTS(weekTimestamp) + var curDay = Formatter.getDateTimeFromTS(weekTimestamp) val todayCode = Formatter.getDayCodeFromDateTime(DateTime()) val screenWidth = context?.usableScreenSize?.x ?: return val dayWidth = screenWidth / config.weeklyViewDays diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index e8e5a60a3..4204e360a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -311,7 +311,7 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { override fun getCurrentDate(): DateTime? { return if (currentWeekTS != 0L) { - Formatter.getUTCDateTimeFromTS(currentWeekTS) + Formatter.getDateTimeFromTS(currentWeekTS) } else { null } From f06b7864abaf71c22abcab279cbe587b687aa389 Mon Sep 17 00:00:00 2001 From: Naveen Date: Sun, 16 Jul 2023 03:07:28 +0530 Subject: [PATCH 07/12] Reuse `getFirstDayOfWeek()` in WeekFragment --- .../calendar/pro/extensions/Context.kt | 6 +++++- .../calendar/pro/fragments/WeekFragmentsHolder.kt | 15 ++------------- 2 files changed, 7 insertions(+), 14 deletions(-) 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 9b1321279..e4ecdfafd 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 @@ -758,6 +758,10 @@ fun Context.editEvent(event: ListEvent) { } fun Context.getFirstDayOfWeek(date: DateTime): String { + return getFirstDayOfWeekDt(date).toString() +} + +fun Context.getFirstDayOfWeekDt(date: DateTime): DateTime { var startOfWeek = date.withTimeAtStartOfDay() if (!config.startWeekWithCurrentDay) { startOfWeek = if (config.isSundayFirst) { @@ -771,7 +775,7 @@ fun Context.getFirstDayOfWeek(date: DateTime): String { startOfWeek.withDayOfWeek(DateTimeConstants.MONDAY) } } - return startOfWeek.toString() + return startOfWeek } fun Context.isTaskCompleted(event: Event): Boolean { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt index 4204e360a..a06c89546 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/fragments/WeekFragmentsHolder.kt @@ -189,22 +189,11 @@ class WeekFragmentsHolder : MyFragmentHolder(), WeekFragmentListener { } private fun dateSelected(dateTime: DateTime, datePicker: DatePicker) { - val isSundayFirst = requireContext().config.isSundayFirst val month = datePicker.month + 1 val year = datePicker.year val day = datePicker.dayOfMonth - var newDateTime = dateTime.withDate(year, month, day) - - if (isSundayFirst) { - newDateTime = newDateTime.plusDays(1) - } - - var selectedWeek = newDateTime.withDayOfWeek(1).withTimeAtStartOfDay().minusDays(if (isSundayFirst) 1 else 0) - if (newDateTime.minusDays(7).seconds() > selectedWeek.seconds()) { - selectedWeek = selectedWeek.plusDays(7) - } - - currentWeekTS = selectedWeek.seconds() + val newDateTime = dateTime.withDate(year, month, day) + currentWeekTS = requireContext().getFirstDayOfWeekDt(newDateTime).seconds() setupFragment() } From b2236a2a03f3772290bf26d91d3a15d25dd53c53 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Jul 2023 15:08:56 +0200 Subject: [PATCH 08/12] correcting some variable names --- .../com/simplemobiletools/calendar/pro/helpers/Config.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt index 09cfdafde..a9d9b7c74 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/Config.kt @@ -263,11 +263,11 @@ class Config(context: Context) : BaseConfig(context) { var autoBackup: Boolean get() = prefs.getBoolean(AUTO_BACKUP, false) - set(enableAutomaticBackups) = prefs.edit().putBoolean(AUTO_BACKUP, enableAutomaticBackups).apply() + set(autoBackup) = prefs.edit().putBoolean(AUTO_BACKUP, autoBackup).apply() var autoBackupFolder: String get() = prefs.getString(AUTO_BACKUP_FOLDER, Environment.getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS).absolutePath)!! - set(autoBackupPath) = prefs.edit().putString(AUTO_BACKUP_FOLDER, autoBackupPath).apply() + set(autoBackupFolder) = prefs.edit().putString(AUTO_BACKUP_FOLDER, autoBackupFolder).apply() var autoBackupFilename: String get() = prefs.getString(AUTO_BACKUP_FILENAME, "")!! From 33cd18099ba9ad779257d3c347b699651d46c987 Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Sun, 16 Jul 2023 17:27:40 +0200 Subject: [PATCH 09/12] Reverting dragged view instead of refreshing calendar --- .../calendar/pro/fragments/WeekFragment.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 fc6dad119..681971e15 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 @@ -191,6 +191,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { fun updateCalendar() { if (context != null) { + currentlyDraggedView = null WeeklyCalendarImpl(this, requireContext()).updateWeeklyCalendar(weekTimestamp) } } @@ -299,9 +300,7 @@ class WeekFragment : Fragment(), WeeklyCalendar { activity.hideKeyboard() when (it) { null -> { - // force update by removing hash - lastHash = 0 - updateCalendar() + revertDraggedEvent() } EDIT_SELECTED_OCCURRENCE -> { context?.eventsHelper?.editSelectedOccurrence(newEvent, false) { @@ -323,8 +322,12 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } } else { - context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) { - updateCalendar() + if (event.startTS == newEvent.startTS && event.endTS == newEvent.endTS) { + revertDraggedEvent() + } else { + context?.eventsHelper?.updateEvent(newEvent, updateAtCalDAV = true, showToasts = false) { + updateCalendar() + } } } } @@ -340,6 +343,13 @@ class WeekFragment : Fragment(), WeeklyCalendar { } } + private fun revertDraggedEvent() { + activity?.runOnUiThread { + currentlyDraggedView?.beVisible() + currentlyDraggedView = null + } + } + private fun getViewGestureDetector(view: ViewGroup, index: Int): GestureDetector { return GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() { override fun onSingleTapUp(event: MotionEvent): Boolean { @@ -932,7 +942,6 @@ class WeekFragment : Fragment(), WeeklyCalendar { if (!dragEvent.result) { view.beVisible() } - currentlyDraggedView = null true } else -> false From 4591780367ea26eb7c06f2709ab9f296e4307c44 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Jul 2023 23:25:01 +0200 Subject: [PATCH 10/12] updating commons --- app/build.gradle | 8 ++++---- .../calendar/pro/activities/EventActivity.kt | 11 +++++++---- .../calendar/pro/activities/MainActivity.kt | 5 ++++- .../calendar/pro/activities/SimpleActivity.kt | 2 +- .../calendar/pro/activities/TaskActivity.kt | 2 +- .../calendar/pro/dialogs/SetRemindersDialog.kt | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e79b2ba1b..4ab7c9304 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -70,13 +70,13 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:7176c52fd8' + implementation 'com.github.SimpleMobileTools:Simple-Commons:71d66584bd' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' implementation "androidx.print:print:1.0.0" - kapt 'androidx.room:room-compiler:2.5.1' - implementation 'androidx.room:room-runtime:2.5.1' - annotationProcessor 'androidx.room:room-compiler:2.5.1' + kapt 'androidx.room:room-compiler:2.5.2' + implementation 'androidx.room:room-runtime:2.5.2' + annotationProcessor 'androidx.room:room-compiler:2.5.2' } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 0f00519ce..2e29600bb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -31,7 +31,6 @@ import com.simplemobiletools.calendar.pro.adapters.AutoCompleteTextViewAdapter import com.simplemobiletools.calendar.pro.dialogs.* import com.simplemobiletools.calendar.pro.extensions.* import com.simplemobiletools.calendar.pro.helpers.* -import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.models.* import com.simplemobiletools.commons.dialogs.ColorPickerDialog import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog @@ -42,11 +41,13 @@ import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.views.MyAutoCompleteTextView import kotlinx.android.synthetic.main.activity_event.* -import kotlinx.android.synthetic.main.activity_event.view.* +import kotlinx.android.synthetic.main.activity_event.view.event_reminder_2 +import kotlinx.android.synthetic.main.activity_event.view.event_reminder_3 import kotlinx.android.synthetic.main.item_attendee.view.* import org.joda.time.DateTime import org.joda.time.DateTimeZone -import java.util.* +import java.util.Calendar +import java.util.TimeZone import java.util.regex.Pattern class EventActivity : SimpleActivity() { @@ -1320,7 +1321,7 @@ class EventActivity : SimpleActivity() { storeEvent(wasRepeatable) } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog(this, R.string.allow_notifications_reminders, { openNotificationSettings() }) } } } else { @@ -1367,11 +1368,13 @@ class EventActivity : SimpleActivity() { finish() } } + EDIT_FUTURE_OCCURRENCES -> { eventsHelper.editFutureOccurrences(mEvent, mEventOccurrenceTS, true) { finish() } } + EDIT_ALL_OCCURRENCES -> { eventsHelper.editAllOccurrences(mEvent, mOriginalStartTS, mOriginalEndTS, true) { finish() 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 96a06617c..5127bd447 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 @@ -618,6 +618,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { updateViewPager() setupQuickFilter() } + it == -1 -> toast(R.string.no_new_birthdays) else -> toast(R.string.no_birthdays) } @@ -648,6 +649,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { updateViewPager() setupQuickFilter() } + it == -1 -> toast(R.string.no_new_anniversaries) else -> toast(R.string.no_anniversaries) } @@ -1067,7 +1069,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog(this, R.string.allow_notifications_reminders, { openNotificationSettings() }) } } } else { @@ -1104,6 +1106,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { showErrorToast(e) } } + else -> toast(R.string.invalid_file_format) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SimpleActivity.kt index d656cede8..610cc3a03 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SimpleActivity.kt @@ -85,7 +85,7 @@ open class SimpleActivity : BaseSimpleActivity() { } } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog(this, R.string.allow_notifications_reminders, { openNotificationSettings() }) } } } 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 0caf1805b..84df33745 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 @@ -433,7 +433,7 @@ class TaskActivity : SimpleActivity() { storeTask(wasRepeatable) } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog(this, R.string.allow_notifications_reminders, { openNotificationSettings() }) } } } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SetRemindersDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SetRemindersDialog.kt index bdb38ac80..16f194583 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SetRemindersDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SetRemindersDialog.kt @@ -36,7 +36,7 @@ class SetRemindersDialog(val activity: SimpleActivity, val eventType: Int, val c } } } else { - PermissionRequiredDialog(activity, R.string.allow_notifications_reminders) + PermissionRequiredDialog(activity, R.string.allow_notifications_reminders, { activity.openNotificationSettings() }) } } } From d7fa01958355a525059e518dc9e3829500c9a252 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Jul 2023 23:28:58 +0200 Subject: [PATCH 11/12] update version to 6.22.2 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4ab7c9304..f8a58aa07 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,8 +17,8 @@ android { applicationId "com.simplemobiletools.calendar.pro" minSdkVersion 23 targetSdkVersion 33 - versionCode 237 - versionName "6.22.1" + versionCode 238 + versionName "6.22.2" multiDexEnabled true setProperty("archivesBaseName", "calendar") vectorDrawables.useSupportLibrary = true From f8959bcfd437adee2f89c2abb1272e680ed9c697 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Jul 2023 23:29:05 +0200 Subject: [PATCH 12/12] updating changelog --- CHANGELOG.md | 6 ++++++ fastlane/metadata/android/en-US/changelogs/238.txt | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 fastlane/metadata/android/en-US/changelogs/238.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 61293f9c8..ef3f8890f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Changelog ========== +Version 6.22.2 *(2023-07-16)* +---------------------------- + + * Fixed a couple weekly view related glitches + * Added some translation, stability and UX improvements + Version 6.22.1 *(2023-07-02)* ---------------------------- diff --git a/fastlane/metadata/android/en-US/changelogs/238.txt b/fastlane/metadata/android/en-US/changelogs/238.txt new file mode 100644 index 000000000..6b66fccf9 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/238.txt @@ -0,0 +1,2 @@ + * Fixed a couple weekly view related glitches + * Added some translation, stability and UX improvements