Skip to content

Commit

Permalink
Refactor: Improve ACRA configuration in Mlauncher.kt
Browse files Browse the repository at this point in the history
This commit refactors the ACRA configuration in the Mlauncher.kt file to enhance readability and maintainability. Specifically, it restructures the code related to dialog and notification handling based on the value of the 'enableNotifications' preference. This change aims to streamline the ACRA setup process and make it more modular.
  • Loading branch information
HeCodes2Much committed Apr 18, 2024
1 parent fb9407d commit 52e1abb
Showing 1 changed file with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,34 @@ class Mlauncher : Application() {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.KEY_VALUE_LIST
//each plugin you chose above can be configured in a block like this:
dialog {
//required
text = getString(R.string.acra_dialog_text).format(pkgName)
//optional, enables the dialog title
title = getString(R.string.acra_crash)
//defaults to android.R.string.ok
positiveButtonText = getString(R.string.acra_send_report)
//defaults to android.R.string.cancel
negativeButtonText = getString(R.string.acra_dont_send)
//optional, defaults to @android:style/Theme.Dialog
resTheme = R.style.MaterialDialogTheme
}

notification {
//required
title = getString(R.string.acra_dialog_text).format(pkgName)
//required
text = getString(R.string.acra_crash)
//required
channelName = getString(R.string.acra_send_report)
//defaults to android.R.string.ok
sendButtonText = getString(R.string.acra_send_report)
//defaults to android.R.string.cancel
discardButtonText = getString(R.string.acra_dont_send)
//defaults to false
sendOnClick = true
if (prefs.enableNotifications) {
notification {
//required
title = getString(R.string.acra_dialog_text).format(pkgName)
//required
text = getString(R.string.acra_crash)
//required
channelName = getString(R.string.acra_send_report)
//defaults to android.R.string.ok
sendButtonText = getString(R.string.acra_send_report)
//defaults to android.R.string.cancel
discardButtonText = getString(R.string.acra_dont_send)
//defaults to false
sendOnClick = true
}
} else {
dialog {
//required
text = getString(R.string.acra_dialog_text).format(pkgName)
//optional, enables the dialog title
title = getString(R.string.acra_crash)
//defaults to android.R.string.ok
positiveButtonText = getString(R.string.acra_send_report)
//defaults to android.R.string.cancel
negativeButtonText = getString(R.string.acra_dont_send)
//optional, defaults to @android:style/Theme.Dialog
resTheme = R.style.MaterialDialogTheme
}
}

mailSender {
Expand Down

0 comments on commit 52e1abb

Please sign in to comment.