Skip to content

Commit

Permalink
fix: Reinitialize Safe to prevent crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Feb 12, 2024
1 parent 18c08a3 commit 2c63565
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class MainActivity : AppCompatActivity() {

override fun onResume() {
super.onResume()
Safe.initialize(applicationContext)
val restored = restoreLightLevelUi()
if (!restored) executeAppOpenFlash()
intentFlash = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ internal class SettingsActivity : AppCompatActivity(), OnSharedPreferenceChangeL
setPreferencesFromResource(R.xml.preferences, rootKey)

findPreference<Preference>(Safe.INITIAL_LEVEL)?.apply {
Safe.initialize(myContext)
if (!Safe.getBoolean(Safe.MULTILEVEL, false)) {
isEnabled = false
return@apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class VolumeButtonService : AccessibilityService() {
if ((event.keyCode == KeyEvent.KEYCODE_VOLUME_UP) ||
(event.keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
) {
Safe.initialize(applicationContext)
val pressed = event.action == KeyEvent.ACTION_DOWN
when (event.keyCode) {
KeyEvent.KEYCODE_VOLUME_UP -> volumeUpPressed = pressed
Expand Down

0 comments on commit 2c63565

Please sign in to comment.