Use no value as auto oc

This commit is contained in:
Mygod
2018-04-27 20:36:05 -07:00
parent eed49a7338
commit 989408accc
4 changed files with 10 additions and 14 deletions

View File

@@ -30,7 +30,6 @@ class App : Application() {
deviceContext.moveSharedPreferencesFrom(this, PreferenceManager.getDefaultSharedPreferencesName(this))
} else deviceContext = this
// workaround for support lib PreferenceDataStore bug
operatingChannel = operatingChannel
dns = dns
ServiceNotification.updateNotificationChannels()
}
@@ -45,12 +44,10 @@ class App : Application() {
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceContext) }
val connectivity by lazy { getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager }
var operatingChannel: Int
get() {
val result = pref.getString(KEY_OPERATING_CHANNEL, null)?.toIntOrNull() ?: 0
return if (result in 0..165) result else 0
}
set(value) = pref.edit().putString(KEY_OPERATING_CHANNEL, value.toString()).apply()
val operatingChannel: Int get() {
val result = pref.getString(KEY_OPERATING_CHANNEL, null)?.toIntOrNull() ?: 0
return if (result in 1..165) result else 0
}
var dns: String
get() = pref.getString(KEY_DNS, "8.8.8.8")
set(value) = pref.edit().putString(KEY_DNS, value).apply()