diff options
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/Application.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/Application.kt | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/Application.kt b/app/src/main/java/com/zeapo/pwdstore/Application.kt index 91e47793..3f3963d0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/Application.kt +++ b/app/src/main/java/com/zeapo/pwdstore/Application.kt @@ -14,27 +14,31 @@ import com.github.ajalt.timberkt.Timber.DebugTree import com.github.ajalt.timberkt.Timber.plant import com.zeapo.pwdstore.git.sshj.setUpBouncyCastleForSshj import com.zeapo.pwdstore.utils.PreferenceKeys +import com.zeapo.pwdstore.utils.ProxyUtils import com.zeapo.pwdstore.utils.getString import com.zeapo.pwdstore.utils.sharedPrefs @Suppress("Unused") class Application : android.app.Application(), SharedPreferences.OnSharedPreferenceChangeListener { + private val prefs by lazy { sharedPrefs } + override fun onCreate() { super.onCreate() instance = this if (BuildConfig.ENABLE_DEBUG_FEATURES || - sharedPrefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false)) { + prefs.getBoolean(PreferenceKeys.ENABLE_DEBUG_LOGGING, false)) { plant(DebugTree()) } - sharedPrefs.registerOnSharedPreferenceChangeListener(this) + prefs.registerOnSharedPreferenceChangeListener(this) setNightMode() setUpBouncyCastleForSshj() runMigrations(applicationContext) + ProxyUtils.setDefaultProxy() } override fun onTerminate() { - sharedPrefs.unregisterOnSharedPreferenceChangeListener(this) + prefs.unregisterOnSharedPreferenceChangeListener(this) super.onTerminate() } @@ -45,7 +49,7 @@ class Application : android.app.Application(), SharedPreferences.OnSharedPrefere } private fun setNightMode() { - AppCompatDelegate.setDefaultNightMode(when (sharedPrefs.getString(PreferenceKeys.APP_THEME) + AppCompatDelegate.setDefaultNightMode(when (prefs.getString(PreferenceKeys.APP_THEME) ?: getString(R.string.app_theme_def)) { "light" -> MODE_NIGHT_NO "dark" -> MODE_NIGHT_YES |
