Remove deprecation

This commit is contained in:
Milos Kozak 2020-03-30 10:10:50 +02:00
parent 71be72cd03
commit 23946f6c2a
2 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.logging package info.nightscout.androidaps.logging
import info.nightscout.androidaps.utils.SP import androidx.preference.PreferenceManager
import info.nightscout.androidaps.MainApp
import java.util.* import java.util.*
object L { object L {
@ -53,7 +54,9 @@ object L {
this.name = tag.tag this.name = tag.tag
this.defaultValue = tag.defaultValue this.defaultValue = tag.defaultValue
this.requiresRestart = tag.requiresRestart this.requiresRestart = tag.requiresRestart
enabled = SP.getBoolean(getSPName(), defaultValue) //TODO: remove after getting rid of old logging style "if (L.isEnabled(...))"
@Suppress("DEPRECATION")
enabled = PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).getBoolean(getSPName(), defaultValue)
} }
internal constructor(defaultValue: Boolean) { internal constructor(defaultValue: Boolean) {
@ -66,7 +69,8 @@ object L {
fun enable(enabled: Boolean) { fun enable(enabled: Boolean) {
this.enabled = enabled this.enabled = enabled
SP.putBoolean(getSPName(), enabled) @Suppress("DEPRECATION")
PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).edit().putBoolean(getSPName(), enabled).apply()
} }
fun resetToDefault() { fun resetToDefault() {

View file

@ -39,6 +39,7 @@ object OKDialog {
} }
fun runOnUiThread(theRunnable: Runnable?) { fun runOnUiThread(theRunnable: Runnable?) {
@Suppress("DEPRECATION"
val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper) val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper)
theRunnable?.let { mainHandler.post(it) } theRunnable?.let { mainHandler.post(it) }
} }