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/7] 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/7] 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/7] 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 @@ + + + + +