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 260d89c37..b87b91161 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 @@ -187,7 +187,7 @@ class EventActivity : SimpleActivity() { if (config.wasAlarmWarningShown) { showReminder1Dialog() } else { - ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) { + ReminderWarningDialog(this) { config.wasAlarmWarningShown = true showReminder1Dialog() } @@ -1058,7 +1058,7 @@ class EventActivity : SimpleActivity() { saveEvent() } } else { - ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) { + ReminderWarningDialog(this) { config.wasAlarmWarningShown = true ensureBackgroundThread { saveEvent() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ReminderWarningDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ReminderWarningDialog.kt new file mode 100644 index 000000000..a56ec878e --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ReminderWarningDialog.kt @@ -0,0 +1,47 @@ +package com.simplemobiletools.calendar.pro.dialogs + +import android.app.Activity +import android.content.Intent +import android.net.Uri +import android.provider.Settings +import androidx.appcompat.app.AlertDialog +import com.simplemobiletools.calendar.pro.R +import com.simplemobiletools.commons.extensions.hideKeyboard +import com.simplemobiletools.commons.extensions.setupDialogStuff +import com.simplemobiletools.commons.extensions.showErrorToast + +class ReminderWarningDialog(val activity: Activity, val callback: () -> Unit) { + var dialog: AlertDialog + + init { + val view = activity.layoutInflater.inflate(R.layout.dialog_reminder_warning, null) + + dialog = AlertDialog.Builder(activity) + .setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() } + .setNeutralButton(R.string.settings, null) + .create().apply { + activity.setupDialogStuff(view, this, cancelOnTouchOutside = false) + getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener { + redirectToSettings() + } + } + } + + private fun dialogConfirmed() { + dialog.dismiss() + callback() + } + + private fun redirectToSettings() { + activity.hideKeyboard() + Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { + data = Uri.fromParts("package", activity.packageName, null) + + try { + activity.startActivity(this) + } catch (e: Exception) { + activity.showErrorToast(e) + } + } + } +} diff --git a/app/src/main/res/layout/dialog_reminder_warning.xml b/app/src/main/res/layout/dialog_reminder_warning.xml new file mode 100644 index 000000000..929e638b7 --- /dev/null +++ b/app/src/main/res/layout/dialog_reminder_warning.xml @@ -0,0 +1,12 @@ + +