Skip to content

Commit

Permalink
Improve UX when changing "pref_key_hide_launcher_icon"
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Feb 9, 2021
1 parent 946e5c1 commit 7e84592
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions app/src/main/java/moe/haruue/wadb/component/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,24 @@ class HomeFragment : PreferenceFragment(), WadbStateChangedEvent, WadbFailureEve
launcherIconPreference.isChecked = !launcherActivityEnabled
launcherIconPreference.setOnPreferenceChangeListener { _, newValue ->
if (newValue as Boolean) {
wadbApplication.disableLauncherActivity()

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
AlertDialog.Builder(requireContext())
.setMessage(R.string.dialog_hide_icon_message_q)
.setPositiveButton(android.R.string.ok, null)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok) { _, _ ->
wadbApplication.disableLauncherActivity()
launcherIconPreference.isChecked = true
}
.show()
false
} else {
wadbApplication.disableLauncherActivity()
true
}
} else {
wadbApplication.enableLauncherActivity()
true
}
true
}

val bootCompletedReceiverPreference = findPreference("start_on_boot") as TwoStatePreference
Expand Down

0 comments on commit 7e84592

Please sign in to comment.