Use graphical Toast
This commit is contained in:
parent
4f1cc50d76
commit
511dd08ae7
32 changed files with 90 additions and 77 deletions
|
@ -175,29 +175,29 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
|
|||
for (i in 0..1) {
|
||||
if (typeSelected[i] == ProfileType.MOTOL_DEFAULT) {
|
||||
if (ageUsed[i] < 1 || ageUsed[i] > 18) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidage)
|
||||
ToastUtils.warnToast(this, R.string.invalidage)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if ((weightUsed[i] < 5 || weightUsed[i] > 150) && tddUsed[i] == 0.0) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if ((tddUsed[i] < 5 || tddUsed[i] > 150) && weightUsed[i] == 0.0) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
if (typeSelected[i] == ProfileType.DPV_DEFAULT) {
|
||||
if (ageUsed[i] < 1 || ageUsed[i] > 18) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidage)
|
||||
ToastUtils.warnToast(this, R.string.invalidage)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (tddUsed[i] < 5 || tddUsed[i] > 150) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if ((pctUsed[i] < 32 || pctUsed[i] > 37)) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidpct)
|
||||
ToastUtils.warnToast(this, R.string.invalidpct)
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
|
|||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidinput)
|
||||
ToastUtils.warnToast(this, R.string.invalidinput)
|
||||
}
|
||||
binding.ageLabel.labelFor = binding.age.editTextId
|
||||
binding.tddLabel.labelFor = binding.tdd.editTextId
|
||||
|
|
|
@ -52,15 +52,15 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
|||
val weight = SafeParse.stringToDouble(binding.weight.text.toString())
|
||||
val tdd = SafeParse.stringToDouble(binding.tdd.text.toString())
|
||||
if (age < 1 || age > 120) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidage)
|
||||
ToastUtils.warnToast(this, R.string.invalidage)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if ((weight < 5 || weight > 150) && tdd == 0.0) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if ((tdd < 5 || tdd > 150) && weight == 0.0) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
profileFunction.getProfile()?.let { runningProfile ->
|
||||
|
@ -84,11 +84,11 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
|||
r.age = SafeParse.stringToInt(binding.age.text.toString())
|
||||
r.weight = SafeParse.stringToInt(binding.weight.text.toString())
|
||||
if (r.age < 1 || r.age > 120) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidage)
|
||||
ToastUtils.warnToast(this, R.string.invalidage)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (r.weight < 5 || r.weight > 150) {
|
||||
ToastUtils.showToastInUiThread(this, R.string.invalidweight)
|
||||
ToastUtils.warnToast(this, R.string.invalidweight)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
|
|||
database.child("survey").child(r.id).setValue(r)
|
||||
} else {
|
||||
aapsLogger.error("signInAnonymously:failure", task.exception!!)
|
||||
ToastUtils.showToastInUiThread(this, "Authentication failed.")
|
||||
ToastUtils.warnToast(this, "Authentication failed.")
|
||||
//updateUI(null)
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.hide_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.hide_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ class TreatmentsCareportalFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.hide_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.hide_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.hide_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.hide_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.hide_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.hide_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class TreatmentsTempTargetFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_invalidated -> {
|
||||
showInvalidated = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.show_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_invalidated -> {
|
||||
showInvalidated = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.hide_invalidated_records))
|
||||
ToastUtils.infoToast(context, R.string.hide_invalidated_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ class TreatmentsUserEntryFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_show_loop -> {
|
||||
showLoop = true
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_loop_records))
|
||||
ToastUtils.infoToast(context, R.string.show_loop_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ class TreatmentsUserEntryFragment : DaggerFragment(), MenuProvider {
|
|||
R.id.nav_hide_loop -> {
|
||||
showLoop = false
|
||||
updateMenuVisibility()
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.show_hide_records))
|
||||
ToastUtils.infoToast(context, R.string.show_hide_records)
|
||||
swapAdapter()
|
||||
true
|
||||
}
|
||||
|
|
|
@ -78,15 +78,15 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
val time = binding.time.value.toInt()
|
||||
if (time > 12 * 60 || time < -7 * 24 * 60) {
|
||||
binding.time.value = 0.0
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.constraintapllied))
|
||||
ToastUtils.warnToast(ctx, R.string.constraintapllied)
|
||||
}
|
||||
if (binding.duration.value > 10) {
|
||||
binding.duration.value = 0.0
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.constraintapllied))
|
||||
ToastUtils.warnToast(ctx, R.string.constraintapllied)
|
||||
}
|
||||
if (binding.carbs.value.toInt() > maxCarbs) {
|
||||
binding.carbs.value = 0.0
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.carbsconstraintapplied))
|
||||
ToastUtils.warnToast(ctx, R.string.carbsconstraintapplied)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -120,7 +120,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -208,7 +208,7 @@ class FillDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -83,11 +83,11 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||
if (abs(binding.time.value.toInt()) > 12 * 60) {
|
||||
binding.time.value = 0.0
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.constraintapllied))
|
||||
ToastUtils.warnToast(context, R.string.constraintapllied)
|
||||
}
|
||||
if (binding.amount.value > maxInsulin) {
|
||||
binding.amount.value = 0.0
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.bolusconstraintapplied))
|
||||
ToastUtils.warnToast(context, R.string.bolusconstraintapplied)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -304,7 +304,7 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.tempbasaldeliveryerror))
|
||||
ToastUtils.errorToast(ctx, rh.gs(R.string.tempbasaldeliveryerror))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -449,7 +449,7 @@ class LoopDialog : DaggerDialogFragment() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -258,7 +258,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -153,7 +153,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -230,7 +230,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -72,11 +72,11 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
val maxInsulin = constraintChecker.getMaxBolusAllowed().value()
|
||||
if (SafeParse.stringToInt(binding.carbs.text) > maxCarbs) {
|
||||
binding.carbs.value = 0.0
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.carbsconstraintapplied))
|
||||
ToastUtils.warnToast(context, R.string.carbsconstraintapplied)
|
||||
}
|
||||
if (SafeParse.stringToDouble(binding.insulin.text) > maxInsulin) {
|
||||
binding.insulin.value = 0.0
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.bolusconstraintapplied))
|
||||
ToastUtils.warnToast(context, R.string.bolusconstraintapplied)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -335,7 +335,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
|
||||
|
||||
if (profile == null || profileStore == null) {
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.noprofile))
|
||||
ToastUtils.errorToast(ctx, R.string.noprofile)
|
||||
dismiss()
|
||||
return
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val carbsAfterConstraint = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value()
|
||||
if (abs(carbs - carbsAfterConstraint) > 0.01) {
|
||||
binding.carbsInput.value = 0.0
|
||||
ToastUtils.showToastInUiThread(ctx, rh.gs(R.string.carbsconstraintapplied))
|
||||
ToastUtils.warnToast(ctx, R.string.carbsconstraintapplied)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -511,7 +511,7 @@ class WizardDialog : DaggerDialogFragment() {
|
|||
val cancelFail = {
|
||||
queryingProtection = false
|
||||
aapsLogger.debug(LTag.APS, "Dialog canceled on resume protection: ${this.javaClass.name}")
|
||||
ToastUtils.showToastInUiThread(ctx, R.string.dialog_canceled)
|
||||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
|
|
|
@ -109,7 +109,7 @@ class ObjectivesExamDialog : DaggerDialogFragment() {
|
|||
task.answered = result
|
||||
if (!result) {
|
||||
task.disabledTo = dateUtil.now() + T.hours(1).msecs()
|
||||
context?.let { it1 -> ToastUtils.showToastInUiThread(it1, R.string.wronganswer) }
|
||||
context?.let { it1 -> ToastUtils.infoToast(it1, R.string.wronganswer) }
|
||||
} else task.disabledTo = 0
|
||||
updateGui()
|
||||
rxBus.send(EventObjectivesUpdateGui())
|
||||
|
|
|
@ -379,7 +379,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
dexcomMediator.findDexcomPackageName()?.let {
|
||||
openCgmApp(it)
|
||||
}
|
||||
?: ToastUtils.showToastInUiThread(activity, rh.gs(R.string.dexcom_app_not_installed))
|
||||
?: ToastUtils.infoToast(activity, rh.gs(R.string.dexcom_app_not_installed))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,9 +395,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
)
|
||||
}
|
||||
?: ToastUtils.showToastInUiThread(activity, rh.gs(R.string.dexcom_app_not_installed))
|
||||
?: ToastUtils.infoToast(activity, rh.gs(R.string.dexcom_app_not_installed))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
ToastUtils.showToastInUiThread(activity, rh.gs(R.string.g5appnotdetected))
|
||||
ToastUtils.infoToast(activity, rh.gs(R.string.g5appnotdetected))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class GraphData(
|
|||
addSeries(overviewData.bgReadingGraphSeries)
|
||||
if (addPredictions) addSeries(overviewData.predictionsGraphSeries)
|
||||
overviewData.bgReadingGraphSeries.setOnDataPointTapListener { _, dataPoint ->
|
||||
if (dataPoint is GlucoseValueDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.label)
|
||||
if (dataPoint is GlucoseValueDataPoint) ToastUtils.infoToast(context, dataPoint.label)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,14 +93,14 @@ class GraphData(
|
|||
maxY = maxOf(maxY, overviewData.maxTreatmentsValue)
|
||||
addSeries(overviewData.treatmentsSeries)
|
||||
overviewData.treatmentsSeries.setOnDataPointTapListener { _, dataPoint ->
|
||||
if (dataPoint is BolusDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.label)
|
||||
if (dataPoint is BolusDataPoint) ToastUtils.infoToast(context, dataPoint.label)
|
||||
}
|
||||
}
|
||||
|
||||
fun addEps(context: Context?, scale: Double) {
|
||||
addSeries(overviewData.epsSeries)
|
||||
overviewData.epsSeries.setOnDataPointTapListener { _, dataPoint ->
|
||||
if (dataPoint is EffectiveProfileSwitchDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.data.originalCustomizedName)
|
||||
if (dataPoint is EffectiveProfileSwitchDataPoint) ToastUtils.infoToast(context, dataPoint.data.originalCustomizedName)
|
||||
}
|
||||
overviewData.epsScale.multiplier = maxY * scale / overviewData.maxEpsValue
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ class XDripBroadcast @Inject constructor(
|
|||
context.sendBroadcast(intent)
|
||||
val q = context.packageManager.queryBroadcastReceivers(intent, 0)
|
||||
return if (q.size < 1) {
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.xdripnotinstalled))
|
||||
ToastUtils.errorToast(context, R.string.xdripnotinstalled)
|
||||
aapsLogger.debug(rh.gs(R.string.xdripnotinstalled))
|
||||
false
|
||||
} else {
|
||||
ToastUtils.showToastInUiThread(context, rh.gs(R.string.calibrationsent))
|
||||
ToastUtils.errorToast(context, R.string.calibrationsent)
|
||||
aapsLogger.debug(rh.gs(R.string.calibrationsent))
|
||||
true
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class EditEventDialog : DialogFragmentWithDate() {
|
|||
// check for title
|
||||
val title = binding.inputEventTitle.text?.toString() ?: return false
|
||||
if (title.isEmpty()) {
|
||||
context?.let { ToastUtils.showToastInUiThread(it, R.string.automation_missing_task_name) }
|
||||
context?.let { ToastUtils.errorToast(it, R.string.automation_missing_task_name) }
|
||||
return false
|
||||
}
|
||||
event.title = title
|
||||
|
@ -137,12 +137,12 @@ class EditEventDialog : DialogFragmentWithDate() {
|
|||
// check for at least one trigger
|
||||
val con = event.trigger
|
||||
if (con.size() == 0 && !event.userAction) {
|
||||
context?.let { ToastUtils.showToastInUiThread(it, R.string.automation_missing_trigger) }
|
||||
context?.let { ToastUtils.errorToast(it, R.string.automation_missing_trigger) }
|
||||
return false
|
||||
}
|
||||
// check for at least one action
|
||||
if (event.actions.isEmpty()) {
|
||||
context?.let { ToastUtils.showToastInUiThread(it, R.string.automation_missing_action) }
|
||||
context?.let { ToastUtils.errorToast(it, R.string.automation_missing_action) }
|
||||
return false
|
||||
}
|
||||
// store
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.widget.ImageView
|
|||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
|
@ -27,10 +28,18 @@ object ToastUtils {
|
|||
graphicalToast(ctx, string, R.drawable.ic_toast_warn, true)
|
||||
}
|
||||
|
||||
fun warnToast(ctx: Context?, @StringRes id: Int) {
|
||||
graphicalToast(ctx, ctx?.getString(id), R.drawable.ic_toast_warn, true)
|
||||
}
|
||||
|
||||
fun infoToast(ctx: Context?, string: String?) {
|
||||
graphicalToast(ctx, string, R.drawable.ic_toast_info, true)
|
||||
}
|
||||
|
||||
fun infoToast(ctx: Context?, @StringRes id: Int) {
|
||||
graphicalToast(ctx, ctx?.getString(id), R.drawable.ic_toast_info, true)
|
||||
}
|
||||
|
||||
fun okToast(ctx: Context?, string: String?) {
|
||||
graphicalToast(ctx, string, R.drawable.ic_toast_check, true)
|
||||
}
|
||||
|
@ -39,6 +48,10 @@ object ToastUtils {
|
|||
graphicalToast(ctx, string, R.drawable.ic_toast_error, true)
|
||||
}
|
||||
|
||||
fun errorToast(ctx: Context?, @StringRes id: Int) {
|
||||
graphicalToast(ctx, ctx?.getString(id), R.drawable.ic_toast_error, true)
|
||||
}
|
||||
|
||||
fun graphicalToast(ctx: Context?, string: String?, @DrawableRes iconId: Int) {
|
||||
graphicalToast(ctx, string, iconId, true)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ object BiometricCheck {
|
|||
ERROR_VENDOR,
|
||||
ERROR_LOCKOUT_PERMANENT,
|
||||
ERROR_USER_CANCELED -> {
|
||||
ToastUtils.showToastInUiThread(activity.baseContext, errString.toString())
|
||||
ToastUtils.errorToast(activity.baseContext, errString.toString())
|
||||
// fallback to master password
|
||||
runOnUiThread {
|
||||
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() })
|
||||
|
@ -34,7 +34,7 @@ object BiometricCheck {
|
|||
cancel?.run()
|
||||
|
||||
ERROR_NO_DEVICE_CREDENTIAL -> {
|
||||
ToastUtils.showToastInUiThread(activity.baseContext, errString.toString())
|
||||
ToastUtils.errorToast(activity.baseContext, errString.toString())
|
||||
// no pin set
|
||||
// fallback to master password
|
||||
runOnUiThread {
|
||||
|
|
|
@ -148,7 +148,7 @@ class PasswordCheck @Inject constructor(
|
|||
.setNegativeButton(context.getString(R.string.cancel)
|
||||
) { dialog, _ ->
|
||||
val msg = if (pinInput) R.string.pin_not_changed else R.string.password_not_changed
|
||||
ToastUtils.infoToast(context, context.getString(msg))
|
||||
ToastUtils.infoToast(context, msg)
|
||||
cancel?.invoke()
|
||||
dialog.cancel()
|
||||
}
|
||||
|
|
|
@ -173,13 +173,13 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
currentValue = SafeParse.stringToDouble(binding.editText.text.toString())
|
||||
if (currentValue > maxValue) {
|
||||
currentValue = maxValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
updateEditText()
|
||||
okButton?.visibility = VISIBLE
|
||||
}
|
||||
if (currentValue < minValue) {
|
||||
currentValue = minValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
updateEditText()
|
||||
okButton?.visibility = VISIBLE
|
||||
}
|
||||
|
@ -216,11 +216,11 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
get() {
|
||||
if (currentValue > maxValue) {
|
||||
currentValue = maxValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
}
|
||||
if (currentValue < minValue) {
|
||||
currentValue = minValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
}
|
||||
return currentValue
|
||||
}
|
||||
|
@ -229,11 +229,11 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
currentValue = value
|
||||
if (currentValue > maxValue) {
|
||||
currentValue = maxValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
}
|
||||
if (currentValue < minValue) {
|
||||
currentValue = minValue
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
}
|
||||
callValueChangedListener()
|
||||
updateEditText()
|
||||
|
@ -248,7 +248,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
if (currentValue > maxValue) {
|
||||
currentValue = maxValue
|
||||
callValueChangedListener()
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
stopUpdating()
|
||||
}
|
||||
updateEditText()
|
||||
|
@ -259,7 +259,7 @@ open class NumberPicker(context: Context, attrs: AttributeSet? = null) : LinearL
|
|||
if (currentValue < minValue) {
|
||||
currentValue = minValue
|
||||
callValueChangedListener()
|
||||
ToastUtils.showToastInUiThread(context, context.getString(R.string.youareonallowedlimit))
|
||||
ToastUtils.warnToast(context, R.string.youareonallowedlimit)
|
||||
stopUpdating()
|
||||
}
|
||||
updateEditText()
|
||||
|
|
|
@ -215,13 +215,13 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), rh.gs(R.string.nobtadapter));
|
||||
ToastUtils.INSTANCE.errorToast(context.getApplicationContext(), R.string.nobtadapter);
|
||||
}
|
||||
if (mBTDevice == null) {
|
||||
ToastUtils.INSTANCE.showToastInUiThread(context.getApplicationContext(), rh.gs(R.string.devicenotfound));
|
||||
ToastUtils.INSTANCE.errorToast(context.getApplicationContext(), R.string.devicenotfound);
|
||||
}
|
||||
} else {
|
||||
ToastUtils.INSTANCE.errorToast(context, context.getString(R.string.needconnectpermission));
|
||||
ToastUtils.INSTANCE.errorToast(context, R.string.needconnectpermission);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.PUMP, "RS connect from: $reason")
|
||||
if (danaRSService != null && mDeviceAddress != "" && mDeviceName != "") {
|
||||
val success = danaRSService?.connect(reason, mDeviceAddress) ?: false
|
||||
if (!success) ToastUtils.showToastInUiThread(context, rh.gs(R.string.ble_not_supported_or_not_paired))
|
||||
if (!success) ToastUtils.errorToast(context, R.string.ble_not_supported_or_not_paired)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class BLEComm @Inject internal constructor(
|
|||
// assume pairing keys are invalid
|
||||
val lastClearRequest = sp.getLong(R.string.key_rs_last_clear_key_request, 0)
|
||||
if (lastClearRequest != 0L && dateUtil.isOlderThan(lastClearRequest, 5)) {
|
||||
ToastUtils.showToastInUiThread(context, R.string.invalidpairing)
|
||||
ToastUtils.errorToast(context, R.string.invalidpairing)
|
||||
danaRSPlugin.changePump()
|
||||
removeBond()
|
||||
} else if (lastClearRequest == 0L) {
|
||||
|
@ -175,7 +175,7 @@ class BLEComm @Inject internal constructor(
|
|||
sp.remove(rh.gs(R.string.key_danars_v3_randompairingkey) + danaRSPlugin.mDeviceName)
|
||||
sp.remove(rh.gs(R.string.key_danars_v3_pairingkey) + danaRSPlugin.mDeviceName)
|
||||
sp.remove(rh.gs(R.string.key_danars_v3_randomsynckey) + danaRSPlugin.mDeviceName)
|
||||
ToastUtils.showToastInUiThread(context, R.string.invalidpairing)
|
||||
ToastUtils.errorToast(context, R.string.invalidpairing)
|
||||
danaRSPlugin.changePump()
|
||||
} else if (lastClearRequest == 0L) {
|
||||
aapsLogger.error("Clearing pairing keys postponed")
|
||||
|
|
|
@ -131,7 +131,7 @@ class DiaconnG8Plugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.PUMP, "Diaconn G8 connect from: $reason")
|
||||
if(diaconnG8Service != null && mDeviceAddress != "" && mDeviceName != "") {
|
||||
val success = diaconnG8Service?.connect(reason, mDeviceAddress) ?: false
|
||||
if(!success) ToastUtils.showToastInUiThread(context, rh.gs(R.string.ble_not_supported))
|
||||
if(!success) ToastUtils.errorToast(context, R.string.ble_not_supported)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue