handle notifications permission with the default 10 minutes too

This commit is contained in:
tibbi 2022-09-12 09:19:25 +02:00
parent 31a3590805
commit 5d75f3e7a8
2 changed files with 27 additions and 6 deletions

View File

@ -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) {

View File

@ -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) {