From 23946f6c2a026a264d0afe68b27916be8691e38e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 30 Mar 2020 10:10:50 +0200 Subject: [PATCH] Remove deprecation --- .../java/info/nightscout/androidaps/logging/L.kt | 12 ++++++++---- .../info/nightscout/androidaps/utils/OKDialog.kt | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/logging/L.kt b/app/src/main/java/info/nightscout/androidaps/logging/L.kt index 4ae358ba02..2411e76c5e 100644 --- a/app/src/main/java/info/nightscout/androidaps/logging/L.kt +++ b/app/src/main/java/info/nightscout/androidaps/logging/L.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.logging -import info.nightscout.androidaps.utils.SP +import androidx.preference.PreferenceManager +import info.nightscout.androidaps.MainApp import java.util.* object L { @@ -49,11 +50,13 @@ object L { var enabled: Boolean private var requiresRestart = false - internal constructor(tag:LTag) { + internal constructor(tag: LTag) { this.name = tag.tag this.defaultValue = tag.defaultValue 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) { @@ -66,7 +69,8 @@ object L { fun enable(enabled: Boolean) { this.enabled = enabled - SP.putBoolean(getSPName(), enabled) + @Suppress("DEPRECATION") + PreferenceManager.getDefaultSharedPreferences(MainApp.instance()).edit().putBoolean(getSPName(), enabled).apply() } fun resetToDefault() { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt b/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt index 4ce0071900..b3f8393862 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt @@ -39,6 +39,7 @@ object OKDialog { } fun runOnUiThread(theRunnable: Runnable?) { + @Suppress("DEPRECATION" val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper) theRunnable?.let { mainHandler.post(it) } }