Show restart dialog on setting change
This commit is contained in:
@@ -78,33 +78,15 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
|
||||
findPreference(getString(R.string.setting_key_notification_channels))
|
||||
messageLayout?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, _ ->
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.setting_message_layout_dialog_title)
|
||||
.setMessage(R.string.setting_message_layout_dialog_message)
|
||||
.setPositiveButton(
|
||||
getString(R.string.setting_message_layout_dialog_button1)
|
||||
) { _, _ ->
|
||||
restartApp()
|
||||
}
|
||||
.setNegativeButton(
|
||||
getString(R.string.setting_message_layout_dialog_button2),
|
||||
null
|
||||
)
|
||||
.show()
|
||||
showRestartDialog()
|
||||
true
|
||||
}
|
||||
notificationChannels?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, _ ->
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
return@OnPreferenceChangeListener true
|
||||
return@OnPreferenceChangeListener false
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.setting_notification_channels_dialog_title)
|
||||
.setMessage(R.string.setting_notification_channels_dialog_message)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
|
||||
showRestartDialog()
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -127,6 +109,17 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
|
||||
)
|
||||
}
|
||||
|
||||
private fun showRestartDialog() {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.setting_restart_dialog_title)
|
||||
.setMessage(R.string.setting_restart_dialog_message)
|
||||
.setPositiveButton(getString(R.string.setting_restart_dialog_button1)) { _, _ ->
|
||||
restartApp()
|
||||
}
|
||||
.setNegativeButton(getString(R.string.setting_restart_dialog_button2), null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun restartApp() {
|
||||
val packageManager = requireContext().packageManager
|
||||
val packageName = requireContext().packageName
|
||||
|
||||
@@ -74,17 +74,15 @@
|
||||
<string name="setting_key_theme">theme</string>
|
||||
<string name="setting_message_layout">Message layout</string>
|
||||
<string name="setting_key_message_layout">message_layout</string>
|
||||
<string name="setting_message_layout_dialog_title">Restart App?</string>
|
||||
<string name="setting_message_layout_dialog_message">The change will be effective on next app start.\n\nDo you want to restart now?</string>
|
||||
<string name="setting_message_layout_dialog_button1">Restart</string>
|
||||
<string name="setting_message_layout_dialog_button2">Later</string>
|
||||
<string name="setting_restart_dialog_title">Restart App?</string>
|
||||
<string name="setting_restart_dialog_message">The change will be effective on next app start.\n\nDo you want to restart now?</string>
|
||||
<string name="setting_restart_dialog_button1">Restart</string>
|
||||
<string name="setting_restart_dialog_button2">Later</string>
|
||||
<string name="setting_time_format">Time format</string>
|
||||
<string name="setting_key_time_format">time_format</string>
|
||||
<string name="setting_notifications">Notifications</string>
|
||||
<string name="setting_notification_channels">Separate app notification channels</string>
|
||||
<string name="setting_key_notification_channels">notification_channels</string>
|
||||
<string name="setting_notification_channels_dialog_title">Manual refresh required</string>
|
||||
<string name="setting_notification_channels_dialog_message">For the change to take effect you must manually refresh the apps using the refresh button in the main menu.</string>
|
||||
<string name="push_message">Push message</string>
|
||||
<string name="appListDescription">App:</string>
|
||||
<string name="priorityDescription">Priority:</string>
|
||||
|
||||
Reference in New Issue
Block a user