mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 20:30:58 +01:00
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) {
|
if (config.wasAlarmWarningShown) {
|
||||||
showReminder1Dialog()
|
showReminder1Dialog()
|
||||||
} else {
|
} else {
|
||||||
ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) {
|
ReminderWarningDialog(this) {
|
||||||
config.wasAlarmWarningShown = true
|
config.wasAlarmWarningShown = true
|
||||||
showReminder1Dialog()
|
showReminder1Dialog()
|
||||||
}
|
}
|
||||||
@ -1058,7 +1058,7 @@ class EventActivity : SimpleActivity() {
|
|||||||
saveEvent()
|
saveEvent()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ConfirmationDialog(this, messageId = R.string.reminder_warning, positive = R.string.ok, negative = 0) {
|
ReminderWarningDialog(this) {
|
||||||
config.wasAlarmWarningShown = true
|
config.wasAlarmWarningShown = true
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
saveEvent()
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
app/src/main/res/layout/dialog_reminder_warning.xml
Normal file
12
app/src/main/res/layout/dialog_reminder_warning.xml
Normal file
@ -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…
x
Reference in New Issue
Block a user