add a Settings button for quick redirection to app settings
This commit is contained in:
parent
a24c551cea
commit
127c62a9c9
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.commons.views.MyTextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/reminder_warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:lineSpacingExtra="3dp"
|
||||
android:paddingLeft="@dimen/bigger_margin"
|
||||
android:paddingTop="@dimen/bigger_margin"
|
||||
android:paddingRight="@dimen/bigger_margin"
|
||||
android:paddingBottom="@dimen/normal_margin"
|
||||
android:text="@string/reminder_warning"
|
||||
android:textSize="@dimen/bigger_text_size" />
|
Loading…
Reference in New Issue