From 870aaa20323d4d5e983933b923de5b2c21ec7029 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 31 Jul 2023 10:21:06 +0200 Subject: [PATCH] gradle:8.1.0 --- build.gradle | 2 +- .../ui/viewmodel/EopatchOverviewViewModel.kt | 8 +++--- .../eopatch/ui/viewmodel/EopatchViewModel.kt | 27 +++++++------------ 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index c6e2ad070f..a7e4cb0fb5 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'com.android.tools.build:gradle:8.1.0' classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7' diff --git a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt index 5ca6574b2c..4a49e46391 100644 --- a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt +++ b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchOverviewViewModel.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.eopatch.ui.viewmodel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations +import androidx.lifecycle.map import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPreferenceManager @@ -83,7 +83,7 @@ class EopatchOverviewViewModel @Inject constructor( private var mBasalRateDisposable: Disposable? = null val patchRemainingInsulin: LiveData - get() = Transformations.map(_patchRemainingInsulin) { insulin -> + get() = _patchRemainingInsulin.map { insulin -> when { insulin > 50f -> "50+ U" insulin < 1f -> "0 U" @@ -217,7 +217,7 @@ class EopatchOverviewViewModel @Inject constructor( .observeOn(aapsSchedulers.main) .subscribe({ response -> if (response.isSuccess) { - var result = pumpSync.syncTemporaryBasalWithPumpId( + val result = pumpSync.syncTemporaryBasalWithPumpId( timestamp = dateUtil.now(), rate = 0.0, duration = T.mins((pauseDurationHour * 60).toLong()).msecs(), @@ -251,7 +251,7 @@ class EopatchOverviewViewModel @Inject constructor( pumpType = PumpType.EOFLOW_EOPATCH2, pumpSerial = patchManager.patchConfig.patchSerialNumber ) - UIEvent(EventType.RESUME_BASAL_SUCCESS).let { _eventHandler.postValue(it) } + UIEvent(EventType.RESUME_BASAL_SUCCESS).let { event -> _eventHandler.postValue(event) } stopPauseTimeUpdate() } else { _eventHandler.postValue(UIEvent(EventType.RESUME_BASAL_FAILED)) diff --git a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchViewModel.kt b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchViewModel.kt index 392f4f9242..3f797be6e8 100644 --- a/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchViewModel.kt +++ b/pump/eopatch/src/main/java/info/nightscout/androidaps/plugins/pump/eopatch/ui/viewmodel/EopatchViewModel.kt @@ -4,8 +4,7 @@ import android.content.res.Resources import androidx.annotation.StringRes import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Transformations -import info.nightscout.shared.interfaces.ResourceHelper +import androidx.lifecycle.map import info.nightscout.androidaps.plugins.pump.eopatch.CommonUtils import info.nightscout.androidaps.plugins.pump.eopatch.R import info.nightscout.androidaps.plugins.pump.eopatch.RxAction @@ -49,6 +48,7 @@ import info.nightscout.androidaps.plugins.pump.eopatch.vo.PatchState import info.nightscout.rx.AapsSchedulers import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.LTag +import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.sharedPreferences.SP import io.reactivex.rxjava3.core.Maybe import io.reactivex.rxjava3.core.Observable @@ -77,7 +77,7 @@ class EopatchViewModel @Inject constructor( var isInAlarmHandling = false var connectionTryCnt = 0 - val patchConfig: PatchConfig = patchManager.patchConfig + private val patchConfig: PatchConfig = patchManager.patchConfig val patchState: PatchState = patchManager.patchState private val _isActivated = MutableLiveData(patchConfig.isActivated) @@ -93,7 +93,7 @@ class EopatchViewModel @Inject constructor( val isConnected = patchManager.patchConnectionState.isConnected val patchRemainedInsulin: LiveData - get() = Transformations.map(_isActivated) { + get() = _isActivated.map { it.takeOne(patchManager.patchState.remainedInsulin.let { insulin -> when { insulin > 50f -> 51 @@ -106,12 +106,12 @@ class EopatchViewModel @Inject constructor( private val _patchExpirationTimestamp = MutableLiveData(patchManager.patchExpiredTime) val patchRemainedDays: LiveData - get() = Transformations.map(_patchExpirationTimestamp) { + get() = _patchExpirationTimestamp.map { it.getDiffDays().toInt() } val patchRemainedTime: LiveData - get() = Transformations.map(_patchExpirationTimestamp) { + get() = _patchExpirationTimestamp.map { it.diffTime(MAX_ELAPSED_MILLIS_AFTER_EXPIRATION) } @@ -131,7 +131,7 @@ class EopatchViewModel @Inject constructor( get() = !patchConfig.lifecycleEvent.isShutdown val commCheckCancelLabel: LiveData - get() = Transformations.map(patchStep) { + get() = patchStep.map { rh.gs(when (it) { PatchStep.CONNECT_NEW -> { isBonded.takeOne(R.string.cancel, R.string.patch_cancel_pairing) @@ -512,12 +512,12 @@ class EopatchViewModel @Inject constructor( PatchStep.COMPLETE, PatchStep.BASAL_SCHEDULE -> { val now = System.currentTimeMillis() val expireTimeStamp = patchConfig.expireTimestamp - val milllisBeforeExpiration = TimeUnit.HOURS.toMillis(sp.getInt(EXPIRATION_REMINDERS, 0).toLong()) + val millisBeforeExpiration = TimeUnit.HOURS.toMillis(sp.getInt(EXPIRATION_REMINDERS, 0).toLong()) Maybe.just(AlarmCode.B012) .flatMap { alarmRegistry.remove(it) } .flatMap { alarmRegistry.remove(AlarmCode.A020) } - .flatMap { alarmRegistry.add(AlarmCode.B000, expireTimeStamp - now - milllisBeforeExpiration) } + .flatMap { alarmRegistry.add(AlarmCode.B000, expireTimeStamp - now - millisBeforeExpiration) } .flatMap { alarmRegistry.add(AlarmCode.B005, expireTimeStamp - now) } .flatMap { alarmRegistry.add(AlarmCode.B006, expireTimeStamp - now + IPatchConstant.SERVICE_TIME_MILLI - TimeUnit.HOURS.toMillis(1)) } .flatMap { alarmRegistry.add(AlarmCode.A003, expireTimeStamp - now + IPatchConstant.SERVICE_TIME_MILLI) } @@ -622,13 +622,6 @@ class EopatchViewModel @Inject constructor( .addTo() } - fun deactivateInDisconnected() { - mOnCommCheckSuccessListener = { - deactivate(false) { moveStep((PatchStep.DISCARDED_FOR_CHANGE)) } - } - showPatchCommCheckDialog(true, R.string.string_discard_patch) - } - @Synchronized fun retryScan() { if (mRetryCount <= mMaxRetryCount) { @@ -660,7 +653,7 @@ class EopatchViewModel @Inject constructor( .onErrorReturnItem("") .doOnSubscribe { updateSetupStep(SCAN_STARTED) } .subscribeDefault(aapsLogger) { - if (!it.isNullOrEmpty()) { + if (it.isNotEmpty()) { startBond(it) } else { updateSetupStep(SCAN_FAILED)