fix build

This commit is contained in:
Milos Kozak 2022-11-12 09:07:37 +01:00
parent 6fab5a9b8d
commit fcd75c35d6
21 changed files with 47 additions and 52 deletions

View file

@ -0,0 +1,8 @@
package info.nightscout.rx.events
import android.content.Context
// pass string to startup wizard
abstract class EventStatus : Event() {
abstract fun getStatus(context: Context) : String
}

View file

@ -75,7 +75,6 @@ import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.JsonHelper import info.nightscout.interfaces.utils.JsonHelper
import info.nightscout.interfaces.utils.TrendCalculator import info.nightscout.interfaces.utils.TrendCalculator
@ -145,7 +144,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@Inject lateinit var notificationStore: NotificationStore @Inject lateinit var notificationStore: NotificationStore
@Inject lateinit var quickWizard: QuickWizard @Inject lateinit var quickWizard: QuickWizard
@Inject lateinit var buildHelper: BuildHelper @Inject lateinit var buildHelper: BuildHelper
@Inject lateinit var commandQueue: CommandQueue
@Inject lateinit var protectionCheck: ProtectionCheck @Inject lateinit var protectionCheck: ProtectionCheck
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var overviewMenus: OverviewMenus @Inject lateinit var overviewMenus: OverviewMenus
@ -318,7 +316,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.delay(30, TimeUnit.MILLISECONDS, aapsSchedulers.main) .delay(30, TimeUnit.MILLISECONDS, aapsSchedulers.main)
.subscribe({ .subscribe({
overviewData.pumpStatus = it.getStatus(rh) overviewData.pumpStatus = it.getStatus(requireContext())
updatePumpStatus() updatePumpStatus()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus

View file

@ -50,7 +50,8 @@ class OverviewPlugin @Inject constructor(
rh: ResourceHelper, rh: ResourceHelper,
private val config: Config, private val config: Config,
private val overviewData: OverviewData, private val overviewData: OverviewData,
private val overviewMenus: OverviewMenus private val overviewMenus: OverviewMenus,
private val context: Context
) : PluginBase( ) : PluginBase(
PluginDescription() PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
@ -69,12 +70,6 @@ class OverviewPlugin @Inject constructor(
override val overviewBus = RxBus(aapsSchedulers, aapsLogger) override val overviewBus = RxBus(aapsSchedulers, aapsLogger)
@FunctionalInterface
interface RunnableWithContext : Runnable {
var context: Context?
}
override fun addNotificationWithDialogResponse(id: Int, text: String, level: Int, @StringRes actionButtonId: Int, title: String, message: String) { override fun addNotificationWithDialogResponse(id: Int, text: String, level: Int, @StringRes actionButtonId: Int, title: String, message: String) {
rxBus.send( rxBus.send(
EventNewNotification( EventNewNotification(
@ -131,7 +126,7 @@ class OverviewPlugin @Inject constructor(
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ .subscribe({
overviewData.pumpStatus = it.getStatus(rh) overviewData.pumpStatus = it.getStatus(context)
}, fabricPrivacy::logException) }, fabricPrivacy::logException)
} }

View file

@ -1,13 +1,14 @@
package info.nightscout.androidaps.setupwizard package info.nightscout.androidaps.setupwizard
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context
import android.view.View import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView import android.widget.TextView
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.events.EventStatus
import info.nightscout.androidaps.setupwizard.elements.SWItem import info.nightscout.androidaps.setupwizard.elements.SWItem
import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.events.EventStatus
import io.reactivex.rxjava3.disposables.CompositeDisposable import io.reactivex.rxjava3.disposables.CompositeDisposable
import javax.inject.Inject import javax.inject.Inject
@ -23,6 +24,7 @@ class SWEventListener constructor(
private var visibilityValidator: SWValidator? = null private var visibilityValidator: SWValidator? = null
@Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var context: Context
// TODO: Adrian how to clear disposable in this case? // TODO: Adrian how to clear disposable in this case?
init { init {
@ -30,7 +32,7 @@ class SWEventListener constructor(
.toObservable(clazz) .toObservable(clazz)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe { event: Any -> .subscribe { event: Any ->
status = (event as EventStatus).getStatus(rh) status = (event as EventStatus).getStatus(context)
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
textView?.text = (if (textLabel != 0) rh.gs(textLabel) else "") + " " + status textView?.text = (if (textLabel != 0) rh.gs(textLabel) else "") + " " + status
} }

View file

@ -67,9 +67,6 @@ dependencies {
api 'com.madgag.spongycastle:core:1.58.0.0' api 'com.madgag.spongycastle:core:1.58.0.0'
api "com.google.crypto.tink:tink-android:$tink_version" api "com.google.crypto.tink:tink-android:$tink_version"
// pumpCommon
api "com.google.code.gson:gson:$gson_version"
//WorkManager //WorkManager
api "androidx.work:work-runtime:$work_version" api "androidx.work:work-runtime:$work_version"
api "androidx.work:work-runtime-ktx:$work_version" api "androidx.work:work-runtime-ktx:$work_version"

View file

@ -120,7 +120,7 @@ class BolusProgressDialog : DaggerDialogFragment() {
disposable += rxBus disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe { binding.status.text = it.getStatus(rh) } .subscribe { binding.status.text = it.getStatus(requireContext()) }
disposable += rxBus disposable += rxBus
.toObservable(EventDismissBolusProgressIfRunning::class.java) .toObservable(EventDismissBolusProgressIfRunning::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)

View file

@ -1,7 +1,8 @@
package info.nightscout.androidaps.events package info.nightscout.androidaps.events
import android.content.Context
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.rx.events.EventStatus
class EventPumpStatusChanged : EventStatus { class EventPumpStatusChanged : EventStatus {
@ -45,14 +46,14 @@ class EventPumpStatusChanged : EventStatus {
} }
// status for startup wizard // status for startup wizard
override fun getStatus(rh: ResourceHelper): String { override fun getStatus(context: Context): String {
return when (status) { return when (status) {
Status.CONNECTING -> rh.gs(R.string.connectingfor, secondsElapsed) Status.CONNECTING -> context.getString(R.string.connectingfor, secondsElapsed)
Status.HANDSHAKING -> rh.gs(R.string.handshaking) Status.HANDSHAKING -> context.getString(R.string.handshaking)
Status.CONNECTED -> rh.gs(R.string.connected) Status.CONNECTED -> context.getString(R.string.connected)
Status.PERFORMING -> performingAction Status.PERFORMING -> performingAction
Status.WAITING_FOR_DISCONNECTION -> rh.gs(R.string.waiting_for_disconnection) Status.WAITING_FOR_DISCONNECTION -> context.getString(R.string.waiting_for_disconnection)
Status.DISCONNECTING -> rh.gs(R.string.disconnecting) Status.DISCONNECTING -> context.getString(R.string.disconnecting)
Status.DISCONNECTED -> "" Status.DISCONNECTED -> ""
} }
} }

View file

@ -1,9 +0,0 @@
package info.nightscout.androidaps.events
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.rx.events.Event
// pass string to startup wizard
abstract class EventStatus : Event() {
abstract fun getStatus(rh: ResourceHelper) : String
}

View file

@ -10,6 +10,6 @@ annotation class DbOpenClass
/** /**
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing. * Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
*/ */
@info.nightscout.database.annotations.DbOpenClass @DbOpenClass
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
annotation class DbOpenForTesting annotation class DbOpenForTesting

View file

@ -1,5 +1,6 @@
package info.nightscout.database.impl package info.nightscout.database.impl
import info.nightscout.database.annotations.DbOpenForTesting
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.Carbs
@ -31,7 +32,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.roundToInt import kotlin.math.roundToInt
@info.nightscout.database.annotations.DbOpenForTesting @DbOpenForTesting
@Singleton class AppRepository @Inject internal constructor( @Singleton class AppRepository @Inject internal constructor(
internal val database: AppDatabase internal val database: AppDatabase
) { ) {

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.sync.nsShared.events package info.nightscout.plugins.sync.nsShared.events
import info.nightscout.androidaps.events.EventStatus import android.content.Context
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.rx.events.EventStatus
class EventNSClientStatus(var text: String, val version: NsClient.Version) : EventStatus() { class EventNSClientStatus(var text: String, val version: NsClient.Version) : EventStatus() {
override fun getStatus(rh: ResourceHelper): String = text override fun getStatus(context: Context): String = text
} }

View file

@ -93,7 +93,7 @@ class NSClientPlugin @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event: EventNSClientStatus -> .subscribe({ event: EventNSClientStatus ->
if (event.version == NsClient.Version.V1) { if (event.version == NsClient.Version.V1) {
status = event.getStatus(rh) status = event.getStatus(context)
rxBus.send(EventNSClientUpdateGUI()) rxBus.send(EventNSClientUpdateGUI())
} }
}, fabricPrivacy::logException) }, fabricPrivacy::logException)

View file

@ -146,7 +146,7 @@ class NSClientV3Plugin @Inject constructor(
.observeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io)
.subscribe({ event -> .subscribe({ event ->
if (event.version == NsClient.Version.V3) { if (event.version == NsClient.Version.V3) {
status = event.getStatus(rh) status = event.getStatus(context)
rxBus.send(EventNSClientUpdateGUI()) rxBus.send(EventNSClientUpdateGUI())
} }
}, fabricPrivacy::logException) }, fabricPrivacy::logException)

View file

@ -168,7 +168,7 @@ class DanaFragment : DaggerFragment() {
"{fa-bluetooth-b}" "{fa-bluetooth-b}"
} }
binding.btConnection.text = pumpStatusIcon binding.btConnection.text = pumpStatusIcon
pumpStatus = it.getStatus(rh) pumpStatus = it.getStatus(requireContext())
binding.pumpStatus.text = pumpStatus binding.pumpStatus.text = pumpStatus
binding.pumpStatusLayout.visibility = (pumpStatus != "").toVisibility() binding.pumpStatusLayout.visibility = (pumpStatus != "").toVisibility()
}, fabricPrivacy::logException) }, fabricPrivacy::logException)

View file

@ -61,7 +61,7 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
disposable += rxBus disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ binding.status.text = it.getStatus(rh) }, fabricPrivacy::logException) .subscribe({ binding.status.text = it.getStatus(this@DanaHistoryActivity) }, fabricPrivacy::logException)
disposable += rxBus disposable += rxBus
.toObservable(EventDanaRSyncStatus::class.java) .toObservable(EventDanaRSyncStatus::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)

View file

@ -128,8 +128,8 @@ class DiaconnG8Fragment : DaggerFragment() {
else -> {} else -> {}
} }
if (it.getStatus(rh) != "") { if (it.getStatus(requireContext()) != "") {
binding.diaconnG8Pumpstatus.text = it.getStatus(rh) binding.diaconnG8Pumpstatus.text = it.getStatus(requireContext())
binding.diaconnG8Pumpstatuslayout.visibility = View.VISIBLE binding.diaconnG8Pumpstatuslayout.visibility = View.VISIBLE
} else { } else {
binding.diaconnG8Pumpstatuslayout.visibility = View.GONE binding.diaconnG8Pumpstatuslayout.visibility = View.GONE

View file

@ -56,7 +56,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() {
disposable += rxBus disposable += rxBus
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ binding.status.text = it.getStatus(rh) }) { fabricPrivacy.logException(it) } .subscribe({ binding.status.text = it.getStatus(this@DiaconnG8HistoryActivity) }) { fabricPrivacy.logException(it) }
swapAdapter(showingType) swapAdapter(showingType)
} }

View file

@ -252,7 +252,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
} }
private fun updateBluetoothConnectionStatus(event: EventPumpStatusChanged) { private fun updateBluetoothConnectionStatus(event: EventPumpStatusChanged) {
val status = event.getStatus(rh) val status = event.getStatus(requireContext())
bluetoothStatusBinding.omnipodDashBluetoothStatus.text = status bluetoothStatusBinding.omnipodDashBluetoothStatus.text = status
} }

View file

@ -25,4 +25,6 @@ dependencies {
implementation('com.thoughtworks.xstream:xstream:1.4.19') { implementation('com.thoughtworks.xstream:xstream:1.4.19') {
exclude group: 'xmlpull', module: 'xmlpull' exclude group: 'xmlpull', module: 'xmlpull'
} }
api "com.google.code.gson:gson:$gson_version"
} }

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.pump.common.events package info.nightscout.androidaps.plugins.pump.common.events
import info.nightscout.androidaps.events.EventStatus import android.content.Context
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
import info.nightscout.pump.core.defs.PumpDeviceState import info.nightscout.pump.core.defs.PumpDeviceState
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.rx.events.EventStatus
open class EventRileyLinkDeviceStatusChange : EventStatus { open class EventRileyLinkDeviceStatusChange : EventStatus {
@ -33,16 +33,16 @@ open class EventRileyLinkDeviceStatusChange : EventStatus {
this.errorDescription = errorDescription this.errorDescription = errorDescription
} }
override fun getStatus(rh: ResourceHelper): String { override fun getStatus(context: Context): String {
val rileyLinkServiceState = this.rileyLinkServiceState ?: return "" val rileyLinkServiceState = this.rileyLinkServiceState ?: return ""
val resourceId = rileyLinkServiceState.resourceId val resourceId = rileyLinkServiceState.resourceId
val rileyLinkError = this.rileyLinkError val rileyLinkError = this.rileyLinkError
if (rileyLinkServiceState.isError && rileyLinkError != null) { if (rileyLinkServiceState.isError && rileyLinkError != null) {
val rileyLinkTargetDevice = this.rileyLinkTargetDevice ?: return "" val rileyLinkTargetDevice = this.rileyLinkTargetDevice ?: return ""
return rh.gs(rileyLinkError.getResourceId(rileyLinkTargetDevice)) return context.getString(rileyLinkError.getResourceId(rileyLinkTargetDevice))
} }
return rh.gs(resourceId) return context.getString(resourceId)
} }
} }

View file

@ -196,7 +196,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() {
rxBus rxBus
.toObservable(EventPumpStatusChanged::class.java) .toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)
.subscribe({ event -> binding.connectionStatus.text = event.getStatus(rh) }, fabricPrivacy::logException) .subscribe({ event -> binding.connectionStatus.text = event.getStatus(this@TDDStatsActivity) }, fabricPrivacy::logException)
) )
disposable.add( disposable.add(
rxBus rxBus