diff --git a/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt b/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt index e537e8c971..ba890a355e 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/data/ProfileStore.kt @@ -1,15 +1,15 @@ package info.nightscout.androidaps.data import androidx.collection.ArrayMap -import info.nightscout.androidaps.logging.StacktraceLoggerWrapper +import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.utils.JsonHelper import org.json.JSONException import org.json.JSONObject -import org.slf4j.LoggerFactory import java.util.* +import javax.inject.Inject class ProfileStore(val data: JSONObject) { - private val log = StacktraceLoggerWrapper.getLogger(ProfileStore::class.java) + @Inject lateinit var aapsLogger: AAPSLogger private val cachedObjects = ArrayMap() @@ -17,7 +17,7 @@ class ProfileStore(val data: JSONObject) { try { if (data.has("store")) return data.getJSONObject("store") } catch (e: JSONException) { - log.error("Unhandled exception", e) + aapsLogger.error("Unhandled exception", e) } return null } diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt index f6795a83f7..e9a8590cfe 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppComponent.kt @@ -5,6 +5,7 @@ import dagger.Component import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjector import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.plugins.aps.openAPSMA.LoggerCallback import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* @@ -36,6 +37,8 @@ import javax.inject.Singleton ) interface AppComponent : AndroidInjector { + fun injectProfileStore(profileStore: ProfileStore) + fun injectCommandQueue(commandQueue: CommandQueue) fun injectCommandBolus(commandBolus: CommandBolus) fun injectCommandCancelExtendedBolus(commandCancelExtendedBolus: CommandCancelExtendedBolus) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index 26c7892619..047123fe5f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -9,6 +9,7 @@ import dagger.android.ContributesAndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.MainApp +import info.nightscout.androidaps.data.ProfileStore import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -75,6 +76,8 @@ open class AppModule { @Module interface AppBindings { + @ContributesAndroidInjector fun profileStoreInjector(): ProfileStore + @ContributesAndroidInjector fun commandQueueInjector(): CommandQueue @ContributesAndroidInjector fun commandBolusInjector(): CommandBolus @ContributesAndroidInjector diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 03c46695a6..bcfa3c859e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -146,7 +146,7 @@ class CareDialog : DialogFragmentWithDate() { json.put("glucoseType", type) } if (options == EventType.NOTE || options == EventType.EXERCISE) { - actions.add(MainApp.gs(R.string.careportal_newnstreatment_duration_label) + ": " + MainApp.gs(R.string.format_mins, actions_care_duration.value.toInt())) + actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, actions_care_duration.value.toInt())) json.put("duration", actions_care_duration.value.toInt()) } val notes = notes.text.toString() diff --git a/app/src/main/java/info/nightscout/androidaps/logging/AAPSLoggerProduction.kt b/app/src/main/java/info/nightscout/androidaps/logging/AAPSLoggerProduction.kt index dde036ef2d..8111ce60b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/logging/AAPSLoggerProduction.kt +++ b/app/src/main/java/info/nightscout/androidaps/logging/AAPSLoggerProduction.kt @@ -61,4 +61,5 @@ class AAPSLoggerProduction : AAPSLogger { fun StackTraceElement.toLogString(): String = "[${this.className.substringAfterLast(".")}.${this.methodName}():${this.lineNumber}]: " /* Needs to be inline. Don't remove even if IDE suggests it. */ +@Suppress("NOTHING_TO_INLINE") inline fun stackLogMarker() = Throwable().stackTrace[1].toLogString() \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt index 2bd537eeda..112991d903 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/comm/DanaRS_Packet_General_Get_More_Information.kt @@ -6,6 +6,7 @@ import info.nightscout.androidaps.logging.L import info.nightscout.androidaps.logging.L.isEnabled import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump +import info.nightscout.androidaps.utils.DateUtil import java.util.* class DanaRS_Packet_General_Get_More_Information( @@ -54,7 +55,7 @@ class DanaRS_Packet_General_Get_More_Information( aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U") aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes) - aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + lastBolusTime.toLocaleString()) + aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) } }