Merge branch 'dagger3' of https://github.com/MilosKozak/AndroidAPS into dagger3

This commit is contained in:
Milos Kozak 2020-02-28 18:34:08 +01:00
commit 4c4e89df98
11 changed files with 26 additions and 19 deletions

View file

@ -1,15 +1,15 @@
package info.nightscout.androidaps.data package info.nightscout.androidaps.data
import androidx.collection.ArrayMap import androidx.collection.ArrayMap
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.JsonHelper
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import org.slf4j.LoggerFactory
import java.util.* import java.util.*
import javax.inject.Inject
class ProfileStore(val data: JSONObject) { class ProfileStore(val data: JSONObject) {
private val log = StacktraceLoggerWrapper.getLogger(ProfileStore::class.java) @Inject lateinit var aapsLogger: AAPSLogger
private val cachedObjects = ArrayMap<String, Profile>() private val cachedObjects = ArrayMap<String, Profile>()
@ -17,7 +17,7 @@ class ProfileStore(val data: JSONObject) {
try { try {
if (data.has("store")) return data.getJSONObject("store") if (data.has("store")) return data.getJSONObject("store")
} catch (e: JSONException) { } catch (e: JSONException) {
log.error("Unhandled exception", e) aapsLogger.error("Unhandled exception", e)
} }
return null return null
} }

View file

@ -5,6 +5,7 @@ import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.data.ProfileStore
import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.plugins.aps.openAPSMA.LoggerCallback import info.nightscout.androidaps.plugins.aps.openAPSMA.LoggerCallback
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.* import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
@ -36,6 +37,8 @@ import javax.inject.Singleton
) )
interface AppComponent : AndroidInjector<MainApp> { interface AppComponent : AndroidInjector<MainApp> {
fun injectProfileStore(profileStore: ProfileStore)
fun injectCommandQueue(commandQueue: CommandQueue) fun injectCommandQueue(commandQueue: CommandQueue)
fun injectCommandBolus(commandBolus: CommandBolus) fun injectCommandBolus(commandBolus: CommandBolus)
fun injectCommandCancelExtendedBolus(commandCancelExtendedBolus: CommandCancelExtendedBolus) fun injectCommandCancelExtendedBolus(commandCancelExtendedBolus: CommandCancelExtendedBolus)

View file

@ -9,6 +9,7 @@ import dagger.android.ContributesAndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.data.ProfileStore
import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -75,6 +76,8 @@ open class AppModule {
@Module @Module
interface AppBindings { interface AppBindings {
@ContributesAndroidInjector fun profileStoreInjector(): ProfileStore
@ContributesAndroidInjector fun commandQueueInjector(): CommandQueue @ContributesAndroidInjector fun commandQueueInjector(): CommandQueue
@ContributesAndroidInjector fun commandBolusInjector(): CommandBolus @ContributesAndroidInjector fun commandBolusInjector(): CommandBolus
@ContributesAndroidInjector @ContributesAndroidInjector

View file

@ -22,11 +22,8 @@ import javax.inject.Inject
class CalibrationDialog : DialogFragmentWithDate() { class CalibrationDialog : DialogFragmentWithDate() {
@Inject @Inject lateinit var resourceHelper: ResourceHelper
lateinit var resourceHelper: ResourceHelper @Inject lateinit var profileFunction: ProfileFunction
@Inject
lateinit var profileFunction: ProfileFunction
override fun onSaveInstanceState(savedInstanceState: Bundle) { override fun onSaveInstanceState(savedInstanceState: Bundle) {
super.onSaveInstanceState(savedInstanceState) super.onSaveInstanceState(savedInstanceState)

View file

@ -6,7 +6,6 @@ import android.text.TextWatcher
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import androidx.annotation.StringRes import androidx.annotation.StringRes
import com.google.common.base.Joiner import com.google.common.base.Joiner
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
@ -88,12 +87,14 @@ class CareDialog : DialogFragmentWithDate() {
EventType.BGCHECK -> { EventType.BGCHECK -> {
action_care_duration_layout.visibility = View.GONE action_care_duration_layout.visibility = View.GONE
} }
EventType.SENSOR_INSERT, EventType.SENSOR_INSERT,
EventType.BATTERY_CHANGE -> { EventType.BATTERY_CHANGE -> {
action_care_bg_layout.visibility = View.GONE action_care_bg_layout.visibility = View.GONE
actions_care_bgsource.visibility = View.GONE actions_care_bgsource.visibility = View.GONE
action_care_duration_layout.visibility = View.GONE action_care_duration_layout.visibility = View.GONE
} }
EventType.NOTE, EventType.NOTE,
EventType.EXERCISE -> { EventType.EXERCISE -> {
action_care_bg_layout.visibility = View.GONE action_care_bg_layout.visibility = View.GONE
@ -145,7 +146,7 @@ class CareDialog : DialogFragmentWithDate() {
json.put("glucoseType", type) json.put("glucoseType", type)
} }
if (options == EventType.NOTE || options == EventType.EXERCISE) { 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()) json.put("duration", actions_care_duration.value.toInt())
} }
val notes = notes.text.toString() val notes = notes.text.toString()

View file

@ -47,11 +47,11 @@ class ErrorDialog : DaggerDialogFragment() {
error_title.text = title error_title.text = title
overview_error_ok.setOnClickListener { overview_error_ok.setOnClickListener {
aapsLogger.debug("Error dialog ok button pressed") aapsLogger.debug("USER ENTRY: Error dialog ok button pressed")
dismiss() dismiss()
} }
overview_error_mute.setOnClickListener { overview_error_mute.setOnClickListener {
aapsLogger.debug("Error dialog mute button pressed") aapsLogger.debug("USER ENTRY: Error dialog mute button pressed")
stopAlarm() stopAlarm()
} }
startAlarm() startAlarm()

View file

@ -61,4 +61,5 @@ class AAPSLoggerProduction : AAPSLogger {
fun StackTraceElement.toLogString(): String = "[${this.className.substringAfterLast(".")}.${this.methodName}():${this.lineNumber}]: " fun StackTraceElement.toLogString(): String = "[${this.className.substringAfterLast(".")}.${this.methodName}():${this.lineNumber}]: "
/* Needs to be inline. Don't remove even if IDE suggests it. */ /* Needs to be inline. Don't remove even if IDE suggests it. */
@Suppress("NOTHING_TO_INLINE")
inline fun stackLogMarker() = Throwable().stackTrace[1].toLogString() inline fun stackLogMarker() = Throwable().stackTrace[1].toLogString()

View file

@ -27,15 +27,14 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.OKDialog import info.nightscout.androidaps.utils.OKDialog
import info.nightscout.androidaps.utils.SingleClickButton import info.nightscout.androidaps.utils.SingleClickButton
import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.extensions.plusAssign import info.nightscout.androidaps.utils.extensions.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.toVisibility import info.nightscout.androidaps.utils.toVisibility
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.actions_fragment.* import kotlinx.android.synthetic.main.actions_fragment.*
import kotlinx.android.synthetic.main.careportal_stats_fragment.* import kotlinx.android.synthetic.main.careportal_stats_fragment.*
import org.slf4j.LoggerFactory
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject

View file

@ -954,7 +954,7 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
final PumpInterface pump = configBuilderPlugin.getActivePump(); final PumpInterface pump = configBuilderPlugin.getActivePump();
final QuickWizardEntry quickWizardEntry = quickWizard.getActive(); final QuickWizardEntry quickWizardEntry = quickWizard.getActive();
if (quickWizardEntry != null && actualBg != null && profile != null && pump != null) { if (quickWizardEntry != null && actualBg != null && profile != null) {
quickWizardButton.setVisibility(View.VISIBLE); quickWizardButton.setVisibility(View.VISIBLE);
final BolusWizard wizard = quickWizardEntry.doCalc(profile, profileName, actualBg, true); final BolusWizard wizard = quickWizardEntry.doCalc(profile, profileName, actualBg, true);

View file

@ -6,6 +6,7 @@ import info.nightscout.androidaps.logging.L
import info.nightscout.androidaps.logging.L.isEnabled import info.nightscout.androidaps.logging.L.isEnabled
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
import info.nightscout.androidaps.utils.DateUtil
import java.util.* import java.util.*
class DanaRS_Packet_General_Get_More_Information( 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, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U")
aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress)
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes) 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) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount)
} }
} }

View file

@ -313,6 +313,7 @@ class BolusWizard @Inject constructor(
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.boluswizard), confirmMessage, Runnable { OKDialog.showConfirmation(context, resourceHelper.gs(R.string.boluswizard), confirmMessage, Runnable {
if (insulinAfterConstraints > 0 || carbs > 0) { if (insulinAfterConstraints > 0 || carbs > 0) {
if (useSuperBolus) { if (useSuperBolus) {
aapsLogger.debug("USER ENTRY: SUPERBOLUS TBR")
if (loopPlugin.isEnabled(PluginType.LOOP)) { if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
rxBus.send(EventRefreshOverview("WizardDialog")) rxBus.send(EventRefreshOverview("WizardDialog"))
@ -358,7 +359,8 @@ class BolusWizard @Inject constructor(
detailedBolusInfo.boluscalc = nsJSON() detailedBolusInfo.boluscalc = nsJSON()
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes detailedBolusInfo.notes = notes
if (detailedBolusInfo.insulin > 0 || pump.pumpDescription.storesCarbInfo == true) { aapsLogger.debug("USER ENTRY: BOLUS insulin $insulinAfterConstraints carbs: $carbs")
if (detailedBolusInfo.insulin > 0 || pump.pumpDescription.storesCarbInfo) {
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {