Refactor and cleanup (#850)

* Move google play check to extension

* Extract launching bug report dialog

* Add missing extension for fdroid flavor
This commit is contained in:
Davis 2024-02-13 14:41:40 -07:00 committed by GitHub
parent 2bfda9784f
commit 11e31675ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 24 deletions

View file

@ -372,7 +372,7 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
val app = (requireContext().applicationContext as GeeksvilleApplication)
val isGooglePlayAvailable = isGooglePlayAvailable(requireContext())
val isGooglePlayAvailable = requireContext().isGooglePlayAvailable()
val isAnalyticsAllowed = app.isAnalyticsAllowed && isGooglePlayAvailable
// Set analytics checkbox
@ -387,19 +387,21 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
// report bug button only enabled if analytics is allowed
binding.reportBugButton.isEnabled = isAnalyticsAllowed
binding.reportBugButton.setOnClickListener {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.report_a_bug)
.setMessage(getString(R.string.report_bug_text))
.setNeutralButton(R.string.cancel) { _, _ ->
debug("Decided not to report a bug")
}
.setPositiveButton(getString(R.string.report)) { _, _ ->
reportError("Clicked Report A Bug")
model.showSnackbar("Bug report sent!")
}
.show()
}
binding.reportBugButton.setOnClickListener(::showReportBugDialog)
}
private fun showReportBugDialog(view: View) {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.report_a_bug)
.setMessage(getString(R.string.report_bug_text))
.setNeutralButton(R.string.cancel) { _, _ ->
debug("Decided not to report a bug")
}
.setPositiveButton(getString(R.string.report)) { _, _ ->
reportError("Clicked Report A Bug")
model.showSnackbar("Bug report sent!")
}
.show()
}
private fun addDeviceButton(device: BTScanModel.DeviceListEntry, enabled: Boolean) {