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 1e0ca9c97..a22aaf7ce 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 @@ -20,7 +20,6 @@ import android.view.WindowManager import android.view.inputmethod.EditorInfo import android.widget.ImageView import android.widget.RelativeLayout -import androidx.core.app.NotificationManagerCompat import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.calendar.pro.R @@ -31,7 +30,6 @@ import com.simplemobiletools.calendar.pro.helpers.* import com.simplemobiletools.calendar.pro.helpers.Formatter import com.simplemobiletools.calendar.pro.models.* import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog -import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* @@ -1168,7 +1166,20 @@ class EventActivity : SimpleActivity() { eventsHelper.deleteEvent(mEvent.id!!, true) mEvent.id = null } - storeEvent(wasRepeatable) + + if (mEvent.getReminders().isNotEmpty()) { + handleNotificationPermission { granted -> + if (granted) { + ensureBackgroundThread { + storeEvent(wasRepeatable) + } + } else { + toast(R.string.no_post_notifications_permissions) + } + } + } else { + storeEvent(wasRepeatable) + } } private fun storeEvent(wasRepeatable: Boolean) { 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 89722ad62..7e83e5df4 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 @@ -6,7 +6,6 @@ import android.content.Intent import android.graphics.Color import android.os.Bundle import android.view.WindowManager -import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.dialogs.* @@ -17,7 +16,6 @@ import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.EventType import com.simplemobiletools.calendar.pro.models.Reminder import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog -import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.* @@ -406,7 +404,19 @@ class TaskActivity : SimpleActivity() { repeatRule = mRepeatRule } - storeTask(wasRepeatable) + if (mTask.getReminders().isNotEmpty()) { + handleNotificationPermission { granted -> + if (granted) { + ensureBackgroundThread { + storeTask(wasRepeatable) + } + } else { + toast(R.string.no_post_notifications_permissions) + } + } + } else { + storeTask(wasRepeatable) + } } private fun storeTask(wasRepeatable: Boolean) {