Merge remote-tracking branch 'origin/dev' into ns15
This commit is contained in:
commit
9757428577
3 changed files with 86 additions and 37 deletions
|
@ -173,18 +173,22 @@ class NSAndroidClientImpl(
|
|||
// because utcOffset is mandatory and cannot be change, try 0
|
||||
nsSgvV3.utcOffset = 0
|
||||
return@callWrapper createSvg(nsSgvV3)
|
||||
} else if (response.code() == 400 && errorResponse?.contains("Field utcOffset cannot be modified by the client") == true) {
|
||||
// there is different utcOffset than in AAPS and zero
|
||||
} else if (response.code() == 400 && errorResponse?.contains("cannot be modified by the client") == true) {
|
||||
// there is different field to field in AAPS
|
||||
// not possible to upload
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = errorResponse
|
||||
)
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = errorResponse ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(errorResponse ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun updateSvg(nsSgvV3: NSSgvV3): CreateUpdateResponse = callWrapper(dispatcher) {
|
||||
|
@ -213,10 +217,14 @@ class NSAndroidClientImpl(
|
|||
deduplicatedIdentifier = null,
|
||||
lastModified = null
|
||||
)
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun getTreatmentsNewerThan(createdAt: String, limit: Long): NSAndroidClient.ReadResponse<List<NSTreatment>> = callWrapper(dispatcher) {
|
||||
|
@ -280,10 +288,14 @@ class NSAndroidClientImpl(
|
|||
lastModified = response.body()?.result?.lastModified
|
||||
)
|
||||
} else throw UnknownResponseNightscoutException()
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun createTreatment(nsTreatment: NSTreatment): CreateUpdateResponse = callWrapper(dispatcher) {
|
||||
|
@ -311,18 +323,22 @@ class NSAndroidClientImpl(
|
|||
// because utcOffset is mandatory and cannot be change, try 0
|
||||
nsTreatment.utcOffset = 0
|
||||
return@callWrapper createTreatment(nsTreatment)
|
||||
} else if (response.code() == 400 && errorResponse?.contains("Field utcOffset cannot be modified by the client") == true) {
|
||||
// there is different utcOffset than in AAPS and zero
|
||||
} else if (response.code() == 400 && errorResponse?.contains("cannot be modified by the client") == true) {
|
||||
// there is different field to field in AAPS
|
||||
// not possible to upload
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = errorResponse
|
||||
)
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = errorResponse ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(errorResponse ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun updateTreatment(nsTreatment: NSTreatment): CreateUpdateResponse = callWrapper(dispatcher) {
|
||||
|
@ -351,10 +367,14 @@ class NSAndroidClientImpl(
|
|||
deduplicatedIdentifier = null,
|
||||
lastModified = null
|
||||
)
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun getFoods(limit: Long): NSAndroidClient.ReadResponse<List<NSFood>> = callWrapper(dispatcher) {
|
||||
|
@ -404,9 +424,14 @@ class NSAndroidClientImpl(
|
|||
lastModified = response.body()?.result?.lastModified
|
||||
)
|
||||
} else throw UnsuccessfullNightscoutException()
|
||||
} else {
|
||||
throw UnsuccessfullNightscoutException()
|
||||
}
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun updateFood(nsFood: NSFood): CreateUpdateResponse = callWrapper(dispatcher) {
|
||||
|
@ -432,10 +457,14 @@ class NSAndroidClientImpl(
|
|||
deduplicatedIdentifier = null,
|
||||
lastModified = null
|
||||
)
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun createProfileStore(remoteProfileStore: JSONObject): CreateUpdateResponse = callWrapper(dispatcher) {
|
||||
|
@ -459,10 +488,14 @@ class NSAndroidClientImpl(
|
|||
lastModified = response.body()?.result?.lastModified
|
||||
)
|
||||
} else throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499)
|
||||
throw InvalidParameterNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
else
|
||||
throw UnsuccessfullNightscoutException()
|
||||
} else if (response.code() in 400..499) {
|
||||
return@callWrapper CreateUpdateResponse(
|
||||
response = response.code(),
|
||||
identifier = null,
|
||||
errorResponse = response.errorBody()?.string() ?: response.message()
|
||||
)
|
||||
} else
|
||||
throw UnsuccessfullNightscoutException(response.errorBody()?.string() ?: response.message())
|
||||
}
|
||||
|
||||
override suspend fun getLastProfileStore(): NSAndroidClient.ReadResponse<List<JSONObject>> = callWrapper(dispatcher) {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
package info.nightscout.sdk.exceptions
|
||||
|
||||
class UnsuccessfullNightscoutException : NightscoutException()
|
||||
class UnsuccessfullNightscoutException : NightscoutException {
|
||||
constructor() : super()
|
||||
constructor(message: String) : super(message)
|
||||
constructor(message: String, cause: Throwable) : super(message, cause)
|
||||
constructor(cause: Throwable?) : super(cause)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import info.nightscout.shared.extensions.toVisibility
|
|||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import info.nightscout.shared.utils.T
|
||||
import info.nightscout.ui.R
|
||||
import info.nightscout.ui.databinding.DialogWizardBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
@ -171,8 +172,18 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
?: 0.0, 0.0, maxCarbs.toDouble(), 1.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher
|
||||
)
|
||||
|
||||
// If there is no BG using % lower that 100% leads to high BGs
|
||||
// because loop doesn't add missing insulin
|
||||
var percentage = sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100).toDouble()
|
||||
repository.getLastGlucoseValueWrapped().blockingGet().let {
|
||||
// if last value is older than 6 min or there is no bg
|
||||
if (it is ValueWrapper.Existing)
|
||||
if (it.value.timestamp < dateUtil.now() - T.mins(6).msecs())
|
||||
percentage = 100.0
|
||||
}
|
||||
|
||||
if (usePercentage) {
|
||||
calculatedPercentage = sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100).toDouble()
|
||||
calculatedPercentage = percentage
|
||||
binding.correctionInput.setParams(calculatedPercentage, 10.0, 200.0, 5.0, DecimalFormat("0"), false, binding.okcancel.ok, textWatcher)
|
||||
binding.correctionInput.value = calculatedPercentage
|
||||
binding.correctionUnit.text = "%"
|
||||
|
|
Loading…
Reference in a new issue