mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
show a warning dialog if app notifications are disabled by the system
This commit is contained in:
@@ -6,6 +6,7 @@ import android.app.TimePickerDialog
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.support.v4.app.NotificationManagerCompat
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@@ -120,12 +121,14 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() }
|
event_repetition_limit_holder.setOnClickListener { showRepetitionTypePicker() }
|
||||||
|
|
||||||
event_reminder_1.setOnClickListener {
|
event_reminder_1.setOnClickListener {
|
||||||
if (config.wasAlarmWarningShown) {
|
handleNotificationAvailability() {
|
||||||
showReminder1Dialog()
|
if (config.wasAlarmWarningShown) {
|
||||||
} else {
|
|
||||||
ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) {
|
|
||||||
config.wasAlarmWarningShown = true
|
|
||||||
showReminder1Dialog()
|
showReminder1Dialog()
|
||||||
|
} else {
|
||||||
|
ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) {
|
||||||
|
config.wasAlarmWarningShown = true
|
||||||
|
showReminder1Dialog()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,6 +270,16 @@ class EventActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleNotificationAvailability(callback: () -> Unit) {
|
||||||
|
if (NotificationManagerCompat.from(applicationContext).areNotificationsEnabled()) {
|
||||||
|
callback()
|
||||||
|
} else {
|
||||||
|
ConfirmationDialog(this, messageId = R.string.notifications_disabled, positive = R.string.ok, negative = 0) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun showReminder1Dialog() {
|
private fun showReminder1Dialog() {
|
||||||
showPickSecondsDialogHelper(mReminder1Minutes) {
|
showPickSecondsDialogHelper(mReminder1Minutes) {
|
||||||
mReminder1Minutes = if (it <= 0) it else it / 60
|
mReminder1Minutes = if (it <= 0) it else it / 60
|
||||||
|
Reference in New Issue
Block a user