From 627938e535f02f3716e34bc6c9f65417da60c9eb Mon Sep 17 00:00:00 2001 From: merkost Date: Wed, 19 Jul 2023 16:12:13 +1000 Subject: [PATCH] Updated commons and refactored PermissionRequiredDialog --- app/build.gradle | 2 +- .../calendar/pro/activities/EventActivity.kt | 19 +++++++++++++++---- .../calendar/pro/activities/MainActivity.kt | 10 +++++++++- .../calendar/pro/activities/SimpleActivity.kt | 10 +++++++++- .../calendar/pro/activities/TaskActivity.kt | 10 +++++++++- .../pro/dialogs/SetRemindersDialog.kt | 10 +++++++++- 6 files changed, 52 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7b36c3af7..c9da05d67 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,7 +72,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:7176c52fd8' + implementation 'com.github.SimpleMobileTools:Simple-Commons:8814cd2d4b' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' 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..5cf7deedf 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,15 @@ class EventActivity : SimpleActivity() { storeEvent(wasRepeatable) } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog( + this, + R.string.allow_notifications_reminders, + positiveActionCallback = { + handleNotificationPermission { + openNotificationSettings() + } + } + ) } } } else { @@ -1374,6 +1383,7 @@ class EventActivity : SimpleActivity() { } } } + EDIT_FUTURE_OCCURRENCES -> { ensureBackgroundThread { val eventId = mEvent.id!! @@ -1392,6 +1402,7 @@ class EventActivity : SimpleActivity() { } } } + EDIT_ALL_OCCURRENCES -> { ensureBackgroundThread { applyOriginalStartEndTimes() 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..0cc9f4412 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 @@ -1067,7 +1067,15 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { } } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog( + this, + R.string.allow_notifications_reminders, + positiveActionCallback = { + handleNotificationPermission { + openNotificationSettings() + } + } + ) } } } else { 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..e8c8d1b3b 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,15 @@ open class SimpleActivity : BaseSimpleActivity() { } } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog( + this, + R.string.allow_notifications_reminders, + positiveActionCallback = { + handleNotificationPermission { + 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 99b2a1edf..5985ed3af 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,15 @@ class TaskActivity : SimpleActivity() { storeTask(wasRepeatable) } } else { - PermissionRequiredDialog(this, R.string.allow_notifications_reminders) + PermissionRequiredDialog( + this, + R.string.allow_notifications_reminders, + positiveActionCallback = { + handleNotificationPermission { + 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..357dc92de 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,15 @@ 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, + positiveActionCallback = { + activity.handleNotificationPermission { + activity.openNotificationSettings() + } + } + ) } } }