From ba688cb868d85caaeffe7f01cdf02248b18eb0dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Glavatkii=20Fran=C3=A7ois?=
<108989231+ProgRaizell@users.noreply.github.com>
Date: Thu, 9 Nov 2023 15:21:01 +0100
Subject: [PATCH 1/8] Update strings.xml
---
app/src/main/res/values-fr/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index a1a4287d5..c9fd107e4 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -159,7 +159,7 @@
Ajouter des jours fériés
Jours fériés nationaux
Jours fériés religieux
- Les jours fériés ont été correctement importés dans le type d'évènement \'Jours fériés\'
+ Les jours fériés ont été correctement importés dans le type d\'évènement \'Jours fériés\'
L\'importation de certains évènements a échoué
L\'importation des jours fériés a échoué
From aebe52bf8027907bd3b966a5d90d32db4e4ca5a9 Mon Sep 17 00:00:00 2001
From: ProgRaizell
Date: Thu, 9 Nov 2023 17:19:56 +0100
Subject: [PATCH 2/8] Solution pour l issue #2258
---
.../calendar/pro/views/SmallMonthView.kt | 21 +++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
index c6ed6dc0d..50dfaef2d 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
@@ -90,8 +90,25 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
canvas.drawText(curId.toString(), x * dayWidth - (dayWidth / 4), y * dayWidth, paint)
if (curId == todaysId && !isPrintVersion) {
- val dividerConstant = if (isLandscape) 6 else 4
- canvas.drawCircle(x * dayWidth - dayWidth / 2, y * dayWidth - dayWidth / dividerConstant, dayWidth * 0.41f, todayCirclePaint)
+ val array_1_to_9= listOf(1, 2, 3, 4, 5,6,7,8,9)
+ val array_10_to_19= listOf(10, 11, 12, 13, 14,15,16,17,18,19)
+
+ if(todaysId in array_1_to_9){
+ val dividerConstantX = if (isLandscape) 2.6f else 2.8f
+ val dividerConstantY = if (isLandscape) 6.0f else 5.1f
+ canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
+ }else if (todaysId in array_10_to_19){
+ val dividerConstantX = if (isLandscape) 2.0f else 2.1f
+ val dividerConstantY = if (isLandscape) 6.0f else 5.2f
+ canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
+
+ }else {
+ val dividerConstantX = if (isLandscape) 2.0f else 2.0f
+ val dividerConstantY = if (isLandscape) 6.0f else 5.4f
+ canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
+ }
+
+
}
}
curId++
From cf884d8cf3d31685f8b045308d5eb12439d2c7d3 Mon Sep 17 00:00:00 2001
From: MariemMARZOUGUI <127297843+MariemMARZOUGUI@users.noreply.github.com>
Date: Tue, 28 Nov 2023 22:37:42 +0100
Subject: [PATCH 3/8] tentative de delete events
---
.../pro/activities/SettingsActivity.kt | 65 ++++++++++++++++++-
.../calendar/pro/helpers/EventsHelper.kt | 8 +++
.../calendar/pro/interfaces/EventsDao.kt | 3 +
app/src/main/res/layout/activity_settings.xml | 29 +++++++++
4 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
index 2b956c784..b41e09696 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
@@ -1,13 +1,20 @@
package com.simplemobiletools.calendar.pro.activities
import android.app.Activity
+import android.app.DatePickerDialog
import android.app.TimePickerDialog
import android.content.ActivityNotFoundException
import android.content.Intent
+import android.icu.util.Calendar
import android.media.AudioManager
import android.media.RingtoneManager
+import android.os.Build
import android.os.Bundle
+import android.util.Log
+import android.widget.Button
+import android.widget.DatePicker
import android.widget.Toast
+import androidx.annotation.RequiresApi
import com.google.android.material.timepicker.MaterialTimePicker
import com.google.android.material.timepicker.TimeFormat
import com.simplemobiletools.calendar.pro.R
@@ -27,7 +34,6 @@ import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.text.SimpleDateFormat
-import java.util.Calendar
import java.util.Locale
import kotlin.system.exitProcess
@@ -43,6 +49,9 @@ class SettingsActivity : SimpleActivity() {
private val binding by viewBinding(ActivitySettingsBinding::inflate)
+ public var chosenDateTimestamp = 0L
+
+ @RequiresApi(Build.VERSION_CODES.N)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
@@ -51,14 +60,56 @@ class SettingsActivity : SimpleActivity() {
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
+ val selectDateButton: Button = findViewById(R.id.selectDateButton)
+
+ selectDateButton.setOnClickListener {
+ showDatePickerDialog()
+
+
+ }
+
+
}
+ @RequiresApi(Build.VERSION_CODES.N)
+ private fun showDatePickerDialog() {
+ val currentDate = Calendar.getInstance()
+ val year = currentDate.get(Calendar.YEAR)
+ val month = currentDate.get(Calendar.MONTH)
+ val day = currentDate.get(Calendar.DAY_OF_MONTH)
+
+ val datePickerDialog = DatePickerDialog(
+ this,
+ { _, year, month, day ->
+ val selectedDate = Calendar.getInstance()
+ selectedDate.set(year, month, day)
+ chosenDateTimestamp = selectedDate.timeInMillis
+
+ // You can display the selected date if needed
+ Toast.makeText(this, selectedDate.toString(), Toast.LENGTH_SHORT).show()
+ Log.d("MyApp", "Toast displayed: ${selectedDate.toString()}")
+ },
+ year,
+ month,
+ day
+ )
+
+ datePickerDialog.show()
+
+ // Now, you can use chosenDateTimestamp in other parts of your code if needed.
+ setupDeleteEventsFromDate(chosenDateTimestamp)
+
+ }
+
+
+ @RequiresApi(Build.VERSION_CODES.N)
override fun onResume() {
super.onResume()
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
setupSettingItems()
}
+ @RequiresApi(Build.VERSION_CODES.N)
private fun setupSettingItems() {
setupCustomizeColors()
setupCustomizeNotifications()
@@ -72,6 +123,7 @@ class SettingsActivity : SimpleActivity() {
setupHighlightWeekends()
setupHighlightWeekendsColor()
setupDeleteAllEvents()
+ setupDeleteEventsFromDate(chosenDateTimestamp)
setupDisplayDescription()
setupReplaceDescription()
setupWeekNumbers()
@@ -144,6 +196,7 @@ class SettingsActivity : SimpleActivity() {
config.defaultReminder3 = reminders.getOrElse(2) { REMINDER_OFF }
}
+ @RequiresApi(Build.VERSION_CODES.N)
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
super.onActivityResult(requestCode, resultCode, resultData)
if (requestCode == GET_RINGTONE_URI && resultCode == RESULT_OK && resultData != null) {
@@ -402,10 +455,16 @@ class SettingsActivity : SimpleActivity() {
settingsDeleteAllEventsHolder.setOnClickListener {
ConfirmationDialog(this@SettingsActivity, messageId = R.string.delete_all_events_confirmation) {
eventsHelper.deleteAllEvents()
+
}
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
+ private fun setupDeleteEventsFromDate(choosendateTimestamp: Long) = binding.apply {
+ eventsHelper.deleteEventsFromDate(choosendateTimestamp)
+ }
+
private fun setupDisplayDescription() = binding.apply {
settingsDisplayDescription.isChecked = config.displayDescription
settingsReplaceDescriptionHolder.beVisibleIf(config.displayDescription)
@@ -424,6 +483,7 @@ class SettingsActivity : SimpleActivity() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
private fun setupWeeklyStart() = binding.apply {
settingsStartWeeklyAt.text = getHoursString(config.startWeeklyAt)
settingsStartWeeklyAtHolder.setOnClickListener {
@@ -620,6 +680,7 @@ class SettingsActivity : SimpleActivity() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
private fun getHoursString(hours: Int): String {
return if (config.use24HourFormat) {
String.format("%02d:00", hours)
@@ -972,6 +1033,7 @@ class SettingsActivity : SimpleActivity() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
private fun setupImportSettings() {
binding.settingsImportHolder.setOnClickListener {
if (isQPlus()) {
@@ -1001,6 +1063,7 @@ class SettingsActivity : SimpleActivity() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
private fun parseFile(inputStream: InputStream?) {
if (inputStream == null) {
toast(com.simplemobiletools.commons.R.string.unknown_error_occurred)
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 1abff94d4..2443ad7c1 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
@@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.pro.helpers
import android.app.Activity
import android.content.Context
+import android.util.Log
import android.widget.Toast
import androidx.annotation.ColorRes
import androidx.collection.LongSparseArray
@@ -13,6 +14,7 @@ import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.CHOPPED_LIST_DEFAULT_SIZE
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
+import java.util.Calendar
class EventsHelper(val context: Context) {
private val config = context.config
@@ -257,6 +259,12 @@ class EventsHelper(val context: Context) {
}
}
+ fun deleteEventsFromDate(choosendateTimestamp: Long) {
+ ensureBackgroundThread {
+ val eventIds = eventsDB.getEventIdsWhereDate(choosendateTimestamp).toMutableList()
+ deleteEvents(eventIds, true)
+ }
+ }
fun deleteEvent(id: Long, deleteFromCalDAV: Boolean) = deleteEvents(arrayListOf(id), deleteFromCalDAV)
fun deleteEvents(ids: MutableList, deleteFromCalDAV: Boolean) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
index 956e4257e..cd43aebc1 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
@@ -136,4 +136,7 @@ interface EventsDao {
@Query("DELETE FROM events WHERE source = :source AND import_id = :importId")
fun deleteBirthdayAnniversary(source: String, importId: String): Int
+
+ @Query("SELECT id FROM events WHERE start_ts > :chosenDateTimestamp")
+ fun getEventIdsWhereDate( chosenDateTimestamp : Long) :List
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 5a351c751..17d8de75e 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -884,6 +884,35 @@
+
+
+
+
+
+
+
+
+
+
From 75ab6fac7e2bd47eb39e60ff142ca3f1659e5867 Mon Sep 17 00:00:00 2001
From: MariemMARZOUGUI <127297843+MariemMARZOUGUI@users.noreply.github.com>
Date: Sat, 2 Dec 2023 16:39:01 +0100
Subject: [PATCH 4/8] delete events from date resolved
---
.../pro/activities/SettingsActivity.kt | 34 +++++++------------
.../calendar/pro/helpers/EventsHelper.kt | 4 +--
.../calendar/pro/interfaces/EventsDao.kt | 4 +--
app/src/main/res/layout/activity_settings.xml | 20 +++--------
4 files changed, 20 insertions(+), 42 deletions(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
index b41e09696..31539b584 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
@@ -1,5 +1,6 @@
package com.simplemobiletools.calendar.pro.activities
+import android.annotation.SuppressLint
import android.app.Activity
import android.app.DatePickerDialog
import android.app.TimePickerDialog
@@ -11,8 +12,10 @@ import android.media.RingtoneManager
import android.os.Build
import android.os.Bundle
import android.util.Log
+import android.widget.RelativeLayout
import android.widget.Button
import android.widget.DatePicker
+import android.widget.ImageButton
import android.widget.Toast
import androidx.annotation.RequiresApi
import com.google.android.material.timepicker.MaterialTimePicker
@@ -42,15 +45,11 @@ class SettingsActivity : SimpleActivity() {
private val PICK_SETTINGS_IMPORT_SOURCE_INTENT = 2
private val PICK_EVENTS_IMPORT_SOURCE_INTENT = 3
private val PICK_EVENTS_EXPORT_FILE_INTENT = 4
-
private var mStoredPrimaryColor = 0
-
private var eventTypesToExport = listOf()
-
private val binding by viewBinding(ActivitySettingsBinding::inflate)
- public var chosenDateTimestamp = 0L
-
+ @SuppressLint("WrongViewCast")
@RequiresApi(Build.VERSION_CODES.N)
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
@@ -60,12 +59,10 @@ class SettingsActivity : SimpleActivity() {
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
- val selectDateButton: Button = findViewById(R.id.selectDateButton)
+ val settingsDeleteEventsFromDateHolder: RelativeLayout = findViewById(R.id.settings_delete_events_from_date_holder)
- selectDateButton.setOnClickListener {
+ settingsDeleteEventsFromDateHolder.setOnClickListener {
showDatePickerDialog()
-
-
}
@@ -77,28 +74,20 @@ class SettingsActivity : SimpleActivity() {
val year = currentDate.get(Calendar.YEAR)
val month = currentDate.get(Calendar.MONTH)
val day = currentDate.get(Calendar.DAY_OF_MONTH)
-
val datePickerDialog = DatePickerDialog(
this,
{ _, year, month, day ->
val selectedDate = Calendar.getInstance()
selectedDate.set(year, month, day)
- chosenDateTimestamp = selectedDate.timeInMillis
+ val chosenDateTimestamp = selectedDate.timeInMillis
+ setupDeleteEventsFromDate(chosenDateTimestamp)
- // You can display the selected date if needed
- Toast.makeText(this, selectedDate.toString(), Toast.LENGTH_SHORT).show()
- Log.d("MyApp", "Toast displayed: ${selectedDate.toString()}")
},
year,
month,
day
)
-
datePickerDialog.show()
-
- // Now, you can use chosenDateTimestamp in other parts of your code if needed.
- setupDeleteEventsFromDate(chosenDateTimestamp)
-
}
@@ -123,7 +112,6 @@ class SettingsActivity : SimpleActivity() {
setupHighlightWeekends()
setupHighlightWeekendsColor()
setupDeleteAllEvents()
- setupDeleteEventsFromDate(chosenDateTimestamp)
setupDisplayDescription()
setupReplaceDescription()
setupWeekNumbers()
@@ -164,6 +152,7 @@ class SettingsActivity : SimpleActivity() {
setupExportSettings()
setupImportSettings()
+
arrayOf(
binding.settingsColorCustomizationSectionLabel,
binding.settingsGeneralSettingsLabel,
@@ -461,8 +450,9 @@ class SettingsActivity : SimpleActivity() {
}
@RequiresApi(Build.VERSION_CODES.N)
- private fun setupDeleteEventsFromDate(choosendateTimestamp: Long) = binding.apply {
- eventsHelper.deleteEventsFromDate(choosendateTimestamp)
+ private fun setupDeleteEventsFromDate(chosenDateTimestamp: Long) = binding.apply {
+ Log.d("MyApp", "Deleting events after timestamp: $chosenDateTimestamp")
+ eventsHelper.deleteEventsFromDate(chosenDateTimestamp)
}
private fun setupDisplayDescription() = binding.apply {
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 2443ad7c1..a3f29cee2 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
@@ -259,9 +259,9 @@ class EventsHelper(val context: Context) {
}
}
- fun deleteEventsFromDate(choosendateTimestamp: Long) {
+ fun deleteEventsFromDate(chosenDateTimestamp: Long) {
ensureBackgroundThread {
- val eventIds = eventsDB.getEventIdsWhereDate(choosendateTimestamp).toMutableList()
+ val eventIds = eventsDB.getEventIdsWhereDate(chosenDateTimestamp).toMutableList()
deleteEvents(eventIds, true)
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
index cd43aebc1..81ab126b7 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
@@ -137,6 +137,6 @@ interface EventsDao {
@Query("DELETE FROM events WHERE source = :source AND import_id = :importId")
fun deleteBirthdayAnniversary(source: String, importId: String): Int
- @Query("SELECT id FROM events WHERE start_ts > :chosenDateTimestamp")
- fun getEventIdsWhereDate( chosenDateTimestamp : Long) :List
+ @Query("SELECT id FROM events WHERE start_ts*1000 > :chosenDateTimestamp")
+ fun getEventIdsWhereDate(chosenDateTimestamp: Long): List
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 17d8de75e..75bf1dab2 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -884,35 +884,23 @@
+
+ android:layout_height="wrap_content"
+ android:clickable="true">
-
-
+ android:text="Delete events and tasks after a specific date" />
-
-
From 28bbb1d10cfc24b0288fda7de212801e8f3b0669 Mon Sep 17 00:00:00 2001
From: MariemMARZOUGUI <127297843+MariemMARZOUGUI@users.noreply.github.com>
Date: Sat, 2 Dec 2023 17:39:39 +0100
Subject: [PATCH 5/8] removed settings feature back to the second commit -
circle issue resolved
---
.../pro/activities/SettingsActivity.kt | 32 -------------------
.../calendar/pro/helpers/EventsHelper.kt | 6 ----
.../calendar/pro/interfaces/EventsDao.kt | 2 --
app/src/main/res/layout/activity_settings.xml | 16 ----------
4 files changed, 56 deletions(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
index 31539b584..cd26166d3 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
@@ -59,36 +59,9 @@ class SettingsActivity : SimpleActivity() {
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
- val settingsDeleteEventsFromDateHolder: RelativeLayout = findViewById(R.id.settings_delete_events_from_date_holder)
-
- settingsDeleteEventsFromDateHolder.setOnClickListener {
- showDatePickerDialog()
- }
-
}
- @RequiresApi(Build.VERSION_CODES.N)
- private fun showDatePickerDialog() {
- val currentDate = Calendar.getInstance()
- val year = currentDate.get(Calendar.YEAR)
- val month = currentDate.get(Calendar.MONTH)
- val day = currentDate.get(Calendar.DAY_OF_MONTH)
- val datePickerDialog = DatePickerDialog(
- this,
- { _, year, month, day ->
- val selectedDate = Calendar.getInstance()
- selectedDate.set(year, month, day)
- val chosenDateTimestamp = selectedDate.timeInMillis
- setupDeleteEventsFromDate(chosenDateTimestamp)
-
- },
- year,
- month,
- day
- )
- datePickerDialog.show()
- }
@RequiresApi(Build.VERSION_CODES.N)
@@ -449,11 +422,6 @@ class SettingsActivity : SimpleActivity() {
}
}
- @RequiresApi(Build.VERSION_CODES.N)
- private fun setupDeleteEventsFromDate(chosenDateTimestamp: Long) = binding.apply {
- Log.d("MyApp", "Deleting events after timestamp: $chosenDateTimestamp")
- eventsHelper.deleteEventsFromDate(chosenDateTimestamp)
- }
private fun setupDisplayDescription() = binding.apply {
settingsDisplayDescription.isChecked = config.displayDescription
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 a3f29cee2..c43b70cb9 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
@@ -259,12 +259,6 @@ class EventsHelper(val context: Context) {
}
}
- fun deleteEventsFromDate(chosenDateTimestamp: Long) {
- ensureBackgroundThread {
- val eventIds = eventsDB.getEventIdsWhereDate(chosenDateTimestamp).toMutableList()
- deleteEvents(eventIds, true)
- }
- }
fun deleteEvent(id: Long, deleteFromCalDAV: Boolean) = deleteEvents(arrayListOf(id), deleteFromCalDAV)
fun deleteEvents(ids: MutableList, deleteFromCalDAV: Boolean) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
index 81ab126b7..6d9059441 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
@@ -137,6 +137,4 @@ interface EventsDao {
@Query("DELETE FROM events WHERE source = :source AND import_id = :importId")
fun deleteBirthdayAnniversary(source: String, importId: String): Int
- @Query("SELECT id FROM events WHERE start_ts*1000 > :chosenDateTimestamp")
- fun getEventIdsWhereDate(chosenDateTimestamp: Long): List
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 75bf1dab2..324dc6cc9 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -885,22 +885,6 @@
-
-
-
-
-
-
From 0ebb0081b0b68b3959e0aa934472f06e3a138ec6 Mon Sep 17 00:00:00 2001
From: MariemMARZOUGUI <127297843+MariemMARZOUGUI@users.noreply.github.com>
Date: Sat, 2 Dec 2023 17:50:24 +0100
Subject: [PATCH 6/8] feature request : add option to remove events and tasks
after a specific date
---
.../pro/activities/SettingsActivity.kt | 37 +++++++++++++++++++
.../calendar/pro/helpers/EventsHelper.kt | 8 ++++
.../calendar/pro/interfaces/EventsDao.kt | 3 ++
app/src/main/res/layout/activity_settings.xml | 18 +++++++++
4 files changed, 66 insertions(+)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
index cd26166d3..a66f17fbb 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
@@ -60,10 +60,40 @@ class SettingsActivity : SimpleActivity() {
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
+ val settingsDeleteEventsFromDateHolder: RelativeLayout = findViewById(R.id.settings_delete_events_from_date_holder)
+ settingsDeleteEventsFromDateHolder.setOnClickListener {
+ showDatePickerDialog()
+ }
+ }
+
+ @RequiresApi(Build.VERSION_CODES.N)
+ private fun showDatePickerDialog() {
+ val currentDate = Calendar.getInstance()
+ val year = currentDate.get(Calendar.YEAR)
+ val month = currentDate.get(Calendar.MONTH)
+ val day = currentDate.get(Calendar.DAY_OF_MONTH)
+ val datePickerDialog = DatePickerDialog(
+ this,
+ { _, year, month, day ->
+ val selectedDate = Calendar.getInstance()
+ selectedDate.set(year, month, day)
+ val chosenDateTimestamp = selectedDate.timeInMillis
+ setupDeleteEventsFromDate(chosenDateTimestamp)
+
+
+ },
+ year,
+ month,
+ day
+ )
+ datePickerDialog.show()
}
+
+
+
@RequiresApi(Build.VERSION_CODES.N)
override fun onResume() {
super.onResume()
@@ -422,6 +452,13 @@ class SettingsActivity : SimpleActivity() {
}
}
+ @RequiresApi(Build.VERSION_CODES.N)
+ private fun setupDeleteEventsFromDate(chosenDateTimestamp: Long) = binding.apply {
+ Log.d("MyApp", "Deleting events after timestamp: $chosenDateTimestamp")
+ eventsHelper.deleteEventsFromDate(chosenDateTimestamp)
+ }
+
+
private fun setupDisplayDescription() = binding.apply {
settingsDisplayDescription.isChecked = config.displayDescription
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 c43b70cb9..d63028b15 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
@@ -259,6 +259,14 @@ class EventsHelper(val context: Context) {
}
}
+ fun deleteEventsFromDate(chosenDateTimestamp: Long) {
+ ensureBackgroundThread {
+ val eventIds = eventsDB.getEventIdsWhereDate(chosenDateTimestamp).toMutableList()
+ deleteEvents(eventIds, true)
+ }
+ }
+
+
fun deleteEvent(id: Long, deleteFromCalDAV: Boolean) = deleteEvents(arrayListOf(id), deleteFromCalDAV)
fun deleteEvents(ids: MutableList, deleteFromCalDAV: Boolean) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
index 6d9059441..17d26760c 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
@@ -137,4 +137,7 @@ interface EventsDao {
@Query("DELETE FROM events WHERE source = :source AND import_id = :importId")
fun deleteBirthdayAnniversary(source: String, importId: String): Int
+ @Query("SELECT id FROM events WHERE start_ts*1000 > :chosenDateTimestamp")
+ fun getEventIdsWhereDate(chosenDateTimestamp: Long): List
+
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index 324dc6cc9..e55a898f3 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -884,6 +884,24 @@
+
+
+
+
+
+
+
+
Date: Sat, 2 Dec 2023 17:55:49 +0100
Subject: [PATCH 7/8] removed the edits on the SmallMonthView
---
.../calendar/pro/views/SmallMonthView.kt | 21 ++-----------------
1 file changed, 2 insertions(+), 19 deletions(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
index 50dfaef2d..c6ed6dc0d 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/views/SmallMonthView.kt
@@ -90,25 +90,8 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
canvas.drawText(curId.toString(), x * dayWidth - (dayWidth / 4), y * dayWidth, paint)
if (curId == todaysId && !isPrintVersion) {
- val array_1_to_9= listOf(1, 2, 3, 4, 5,6,7,8,9)
- val array_10_to_19= listOf(10, 11, 12, 13, 14,15,16,17,18,19)
-
- if(todaysId in array_1_to_9){
- val dividerConstantX = if (isLandscape) 2.6f else 2.8f
- val dividerConstantY = if (isLandscape) 6.0f else 5.1f
- canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
- }else if (todaysId in array_10_to_19){
- val dividerConstantX = if (isLandscape) 2.0f else 2.1f
- val dividerConstantY = if (isLandscape) 6.0f else 5.2f
- canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
-
- }else {
- val dividerConstantX = if (isLandscape) 2.0f else 2.0f
- val dividerConstantY = if (isLandscape) 6.0f else 5.4f
- canvas.drawCircle(x * dayWidth - dayWidth / dividerConstantX, y * dayWidth - dayWidth / dividerConstantY, dayWidth * 0.41f, todayCirclePaint)
- }
-
-
+ val dividerConstant = if (isLandscape) 6 else 4
+ canvas.drawCircle(x * dayWidth - dayWidth / 2, y * dayWidth - dayWidth / dividerConstant, dayWidth * 0.41f, todayCirclePaint)
}
}
curId++
From 1ac0f6c973ca8ea5e11aa0adecd3c5f0bbedbdde Mon Sep 17 00:00:00 2001
From: MariemMARZOUGUI <127297843+MariemMARZOUGUI@users.noreply.github.com>
Date: Tue, 5 Dec 2023 21:02:19 +0100
Subject: [PATCH 8/8] last modifications
---
.../pro/activities/SettingsActivity.kt | 20 +++++--------------
.../calendar/pro/helpers/EventsHelper.kt | 5 ++---
.../calendar/pro/interfaces/EventsDao.kt | 6 ++----
app/src/main/res/layout/activity_settings.xml | 9 +++------
4 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
index a66f17fbb..5009b03d1 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt
@@ -60,8 +60,8 @@ class SettingsActivity : SimpleActivity() {
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
- val settingsDeleteEventsFromDateHolder: RelativeLayout = findViewById(R.id.settings_delete_events_from_date_holder)
- settingsDeleteEventsFromDateHolder.setOnClickListener {
+ val settingsDeleteEventsBeforeDateHolder: RelativeLayout = findViewById(R.id.settings_delete_events_before_date_holder)
+ settingsDeleteEventsBeforeDateHolder.setOnClickListener {
showDatePickerDialog()
}
}
@@ -78,9 +78,7 @@ class SettingsActivity : SimpleActivity() {
val selectedDate = Calendar.getInstance()
selectedDate.set(year, month, day)
val chosenDateTimestamp = selectedDate.timeInMillis
- setupDeleteEventsFromDate(chosenDateTimestamp)
-
-
+ setupDeleteEventsBeforeDate(chosenDateTimestamp)
},
year,
month,
@@ -89,11 +87,6 @@ class SettingsActivity : SimpleActivity() {
datePickerDialog.show()
}
-
-
-
-
-
@RequiresApi(Build.VERSION_CODES.N)
override fun onResume() {
super.onResume()
@@ -453,13 +446,10 @@ class SettingsActivity : SimpleActivity() {
}
@RequiresApi(Build.VERSION_CODES.N)
- private fun setupDeleteEventsFromDate(chosenDateTimestamp: Long) = binding.apply {
- Log.d("MyApp", "Deleting events after timestamp: $chosenDateTimestamp")
- eventsHelper.deleteEventsFromDate(chosenDateTimestamp)
+ private fun setupDeleteEventsBeforeDate(chosenDateTimestamp: Long) = binding.apply {
+ eventsHelper.deleteEventsBeforeDate(chosenDateTimestamp)
}
-
-
private fun setupDisplayDescription() = binding.apply {
settingsDisplayDescription.isChecked = config.displayDescription
settingsReplaceDescriptionHolder.beVisibleIf(config.displayDescription)
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 d63028b15..10a1c0e3d 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
@@ -259,14 +259,13 @@ class EventsHelper(val context: Context) {
}
}
- fun deleteEventsFromDate(chosenDateTimestamp: Long) {
+ fun deleteEventsBeforeDate(chosenDateTimestamp: Long) {
ensureBackgroundThread {
- val eventIds = eventsDB.getEventIdsWhereDate(chosenDateTimestamp).toMutableList()
+ val eventIds = eventsDB.getEventIdsBeforeDate(chosenDateTimestamp).toMutableList()
deleteEvents(eventIds, true)
}
}
-
fun deleteEvent(id: Long, deleteFromCalDAV: Boolean) = deleteEvents(arrayListOf(id), deleteFromCalDAV)
fun deleteEvents(ids: MutableList, deleteFromCalDAV: Boolean) {
diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
index 17d26760c..ff57ec2ad 100644
--- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/interfaces/EventsDao.kt
@@ -136,8 +136,6 @@ interface EventsDao {
@Query("DELETE FROM events WHERE source = :source AND import_id = :importId")
fun deleteBirthdayAnniversary(source: String, importId: String): Int
-
- @Query("SELECT id FROM events WHERE start_ts*1000 > :chosenDateTimestamp")
- fun getEventIdsWhereDate(chosenDateTimestamp: Long): List
-
+ @Query("SELECT id FROM events WHERE start_ts*1000 < :chosenDateTimestamp")
+ fun getEventIdsBeforeDate(chosenDateTimestamp: Long): List
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index e55a898f3..527a20f28 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -885,24 +885,21 @@
-
-
+ android:text="Delete events and tasks before a specific date" />
-