This commit is contained in:
Milos Kozak 2021-02-14 15:09:06 +01:00
parent ed9c8a1d05
commit af1ee97d83
24 changed files with 65 additions and 192 deletions

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -92,12 +91,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -161,12 +160,7 @@ class FillDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
@ -206,12 +205,7 @@ class InsulinDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.view.LayoutInflater import android.view.LayoutInflater
@ -14,7 +13,8 @@ import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.databinding.DialogLoopBinding import info.nightscout.androidaps.databinding.DialogLoopBinding
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
@ -53,6 +53,7 @@ class LoopDialog : DaggerDialogFragment() {
private var _binding: DialogLoopBinding? = null private var _binding: DialogLoopBinding? = null
private var loopHandler = Handler() private var loopHandler = Handler()
private var refreshDialog: Runnable? = null private var refreshDialog: Runnable? = null
// This property is only valid between onCreateView and // This property is only valid between onCreateView and
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
@ -293,12 +294,7 @@ class LoopDialog : DaggerDialogFragment() {
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -121,12 +120,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
val callback: Callback = object : Callback() { val callback: Callback = object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dialogs package info.nightscout.androidaps.dialogs
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
@ -142,12 +141,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -613,12 +613,7 @@ open class LoopPlugin @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, durationInMinutes, true, profile!!, object : Callback() { commandQueue.tempBasalAbsolute(0.0, durationInMinutes, true, profile!!, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })
@ -626,12 +621,7 @@ open class LoopPlugin @Inject constructor(
commandQueue.tempBasalPercent(0, durationInMinutes, true, profile!!, object : Callback() { commandQueue.tempBasalPercent(0, durationInMinutes, true, profile!!, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })
@ -640,12 +630,7 @@ open class LoopPlugin @Inject constructor(
commandQueue.cancelExtended(object : Callback() { commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.extendedbolusdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.extendedbolusdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })
@ -658,12 +643,7 @@ open class LoopPlugin @Inject constructor(
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })

View file

@ -33,7 +33,6 @@ import info.nightscout.androidaps.skins.SkinProvider
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import io.reactivex.rxkotlin.plusAssign
import info.nightscout.androidaps.utils.extensions.toVisibility import info.nightscout.androidaps.utils.extensions.toVisibility
import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -42,6 +41,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.ui.SingleClickButton import info.nightscout.androidaps.utils.ui.SingleClickButton
import info.nightscout.androidaps.utils.ui.UIRunnable import info.nightscout.androidaps.utils.ui.UIRunnable
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -158,12 +158,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelExtended(object : Callback() { commandQueue.cancelExtended(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.extendedbolusdeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.extendedbolusdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })
@ -178,12 +173,7 @@ class ActionsFragment : DaggerFragment() {
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.general.automation.actions package info.nightscout.androidaps.plugins.general.automation.actions
import android.content.Context import android.content.Context
import android.content.Intent
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -29,6 +28,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
constructor(injector: HasAndroidInjector, text: String) : this(injector) { constructor(injector: HasAndroidInjector, text: String) : this(injector) {
this.text = InputString(injector, text) this.text = InputString(injector, text)
} }
override fun friendlyName(): Int = R.string.alarm override fun friendlyName(): Int = R.string.alarm
override fun shortDescription(): String = resourceHelper.gs(R.string.alarm_message, text.value) override fun shortDescription(): String = resourceHelper.gs(R.string.alarm_message, text.value)
@DrawableRes override fun icon(): Int = R.drawable.ic_access_alarm_24dp @DrawableRes override fun icon(): Int = R.drawable.ic_access_alarm_24dp
@ -36,13 +36,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
override fun isValid(): Boolean = text.value.isNotEmpty() override fun isValid(): Boolean = text.value.isNotEmpty()
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, text.value, resourceHelper.gs(R.string.alarm), R.raw.modern_alarm)
i.putExtra("soundid", R.raw.modern_alarm)
i.putExtra("status", text.value)
i.putExtra("title", resourceHelper.gs(R.string.alarm))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.treatments package info.nightscout.androidaps.plugins.treatments
import android.content.Context import android.content.Context
import android.content.Intent
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
@ -47,12 +46,7 @@ class CarbsGenerator @Inject constructor(
commandQueue.bolus(carbInfo, object : Callback() { commandQueue.bolus(carbInfo, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.treatments; package info.nightscout.androidaps.plugins.treatments;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -679,12 +678,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date)); String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date));
Intent i = new Intent(context, ErrorHelperActivity.class); ErrorHelperActivity.Companion.runAlarm(context, status, resourceHelper.gs(R.string.error_adding_treatment_title), R.raw.error);
i.putExtra("soundid", R.raw.error);
i.putExtra("title", resourceHelper.gs(R.string.error_adding_treatment_title));
i.putExtra("status", status);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "TreatmentClash"); bundle.putString(FirebaseAnalytics.Param.ITEM_LIST_ID, "TreatmentClash");

View file

@ -116,12 +116,7 @@ class CommandQueue @Inject constructor(
setProfile(it, object : Callback() { setProfile(it, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.failedupdatebasalprofile), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.failedupdatebasalprofile))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
if (result.enacted) rxBus.send(EventNewBasalProfile()) if (result.enacted) rxBus.send(EventNewBasalProfile())
} }

View file

@ -361,12 +361,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} else } else
scheduleEatReminder() scheduleEatReminder()
} }
@ -394,12 +389,7 @@ class BolusWizard @Inject constructor(
commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() { commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.tempbasaldeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })
@ -409,9 +399,9 @@ class BolusWizard @Inject constructor(
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) val i = Intent(ctx, ErrorHelperActivity::class.java)
i.putExtra("soundid", R.raw.boluserror) i.putExtra(ErrorHelperActivity.SOUND_ID, R.raw.boluserror)
i.putExtra("status", result.comment) i.putExtra(ErrorHelperActivity.STATUS, result.comment)
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror)) i.putExtra(ErrorHelperActivity.TITLE, resourceHelper.gs(R.string.tempbasaldeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i) ctx.startActivity(i)
} }
@ -435,12 +425,7 @@ class BolusWizard @Inject constructor(
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(ctx, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
}) })

View file

@ -1,6 +1,9 @@
package info.nightscout.androidaps.activities package info.nightscout.androidaps.activities
import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.annotation.RawRes
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.dialogs.ErrorDialog import info.nightscout.androidaps.dialogs.ErrorDialog
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
@ -16,13 +19,28 @@ class ErrorHelperActivity : DialogAppCompatActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val errorDialog = ErrorDialog() val errorDialog = ErrorDialog()
errorDialog.helperActivity = this errorDialog.helperActivity = this
errorDialog.status = intent.getStringExtra("status") errorDialog.status = intent.getStringExtra(STATUS)
errorDialog.sound = intent.getIntExtra("soundid", R.raw.error) errorDialog.sound = intent.getIntExtra(SOUND_ID, R.raw.error)
errorDialog.title = intent.getStringExtra("title") errorDialog.title = intent.getStringExtra(TITLE)
errorDialog.show(supportFragmentManager, "Error") errorDialog.show(supportFragmentManager, "Error")
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
nsUpload.uploadError(intent.getStringExtra("status")) nsUpload.uploadError(intent.getStringExtra(STATUS))
}
}
companion object {
const val SOUND_ID = "soundId"
const val STATUS = "status"
const val TITLE = "title"
fun runAlarm(ctx: Context, status: String, title : String, @RawRes soundId: Int = 0) {
val i = Intent(ctx, ErrorHelperActivity::class.java)
i.putExtra(SOUND_ID, soundId)
i.putExtra(STATUS, status)
i.putExtra(TITLE, title)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
ctx.startActivity(i)
} }
} }
} }

View file

@ -8,6 +8,7 @@ import android.os.Binder
import android.os.Handler import android.os.Handler
import android.os.IBinder import android.os.IBinder
import dagger.android.DaggerService import dagger.android.DaggerService
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.interfaces.NotificationHolderInterface
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -69,7 +70,7 @@ class AlarmSoundService : DaggerService() {
player?.let { if (it.isPlaying) it.stop() } player?.let { if (it.isPlaying) it.stop() }
if (intent?.hasExtra("soundid") == true) resourceId = intent.getIntExtra("soundid", R.raw.error) if (intent?.hasExtra(ErrorHelperActivity.SOUND_ID) == true) resourceId = intent.getIntExtra(ErrorHelperActivity.SOUND_ID, R.raw.error)
player = MediaPlayer() player = MediaPlayer()
try { try {
val afd = resourceHelper.openRawResourceFd(resourceId) ?: return START_STICKY val afd = resourceHelper.openRawResourceFd(resourceId) ?: return START_STICKY

View file

@ -7,6 +7,7 @@ import android.content.ServiceConnection
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.interfaces.NotificationHolderInterface import info.nightscout.androidaps.interfaces.NotificationHolderInterface
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -67,7 +68,7 @@ class AlarmSoundServiceHelper @Inject constructor(
private fun getServiceIntent(context: Context, sound: Int): Intent { private fun getServiceIntent(context: Context, sound: Int): Intent {
val alarm = Intent(context, AlarmSoundService::class.java) val alarm = Intent(context, AlarmSoundService::class.java)
alarm.putExtra("soundid", sound) alarm.putExtra(ErrorHelperActivity.SOUND_ID, sound)
return alarm return alarm
} }
} }

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.dana.activities package info.nightscout.androidaps.dana.activities
import android.content.Context import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
@ -18,9 +17,9 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import io.reactivex.rxkotlin.plusAssign
import info.nightscout.androidaps.utils.rx.AapsSchedulers import info.nightscout.androidaps.utils.rx.AapsSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import java.text.DecimalFormat import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject
import kotlin.math.max import kotlin.math.max
@ -154,12 +153,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
commandQueue.setUserOptions(object : Callback() { commandQueue.setUserOptions(object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, result.comment, resourceHelper.gs(R.string.pumperror), R.raw.boluserror)
i.putExtra("soundid", R.raw.boluserror)
i.putExtra("status", result.comment)
i.putExtra("title", resourceHelper.gs(R.string.pumperror))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
} }
} }
}) })

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.danaRv2.services; package info.nightscout.androidaps.danaRv2.services;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Binder; import android.os.Binder;
import android.os.SystemClock; import android.os.SystemClock;
@ -205,12 +204,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (Math.abs(timeDiff) > 60 * 60 * 1.5) { if (Math.abs(timeDiff) > 60 * 60 * 1.5) {
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds - large difference"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds - large difference");
//If time-diff is very large, warn user until we can synchronize history readings properly //If time-diff is very large, warn user until we can synchronize history readings properly
Intent i = new Intent(context, ErrorHelperActivity.class); ErrorHelperActivity.Companion.runAlarm(context, resourceHelper.gs(R.string.largetimediff), resourceHelper.gs(R.string.largetimedifftitle), R.raw.error);
i.putExtra("soundid", R.raw.error);
i.putExtra("status", resourceHelper.gs(R.string.largetimediff));
i.putExtra("title", resourceHelper.gs(R.string.largetimedifftitle));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
//deinitialize pump //deinitialize pump
danaPump.reset(); danaPump.reset();

View file

@ -168,12 +168,7 @@ class DanaRSService : DaggerService() {
if (abs(timeDiff) > 60 * 60 * 1.5) { if (abs(timeDiff) > 60 * 60 * 1.5) {
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference") aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: $timeDiff seconds - large difference")
//If time-diff is very large, warn user until we can synchronize history readings properly //If time-diff is very large, warn user until we can synchronize history readings properly
val i = Intent(context, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(context, resourceHelper.gs(R.string.largetimediff), resourceHelper.gs(R.string.largetimedifftitle), R.raw.error)
i.putExtra("soundid", R.raw.error)
i.putExtra("status", resourceHelper.gs(R.string.largetimediff))
i.putExtra("title", resourceHelper.gs(R.string.largetimedifftitle))
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(i)
//de-initialize pump //de-initialize pump
danaPump.reset() danaPump.reset()

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.medtronic;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.IBinder; import android.os.IBinder;
import android.os.SystemClock; import android.os.SystemClock;
@ -876,13 +875,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog. Context: " // LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog. Context: "
// + MainApp.instance().getApplicationContext()); // + MainApp.instance().getApplicationContext());
Intent i = new Intent(context, ErrorHelperActivity.class); ErrorHelperActivity.Companion.runAlarm(context,getResourceHelper().gs(R.string.medtronic_cmd_cancel_bolus_not_supported), getResourceHelper().gs(R.string.medtronic_warning), R.raw.boluserror);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", getResourceHelper().gs(R.string.medtronic_cmd_cancel_bolus_not_supported));
i.putExtra("title", getResourceHelper().gs(R.string.medtronic_warning));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}).start(); }).start();
} }
@ -1563,12 +1556,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (rileyLinkMedtronicService.verifyConfiguration()) { if (rileyLinkMedtronicService.verifyConfiguration()) {
serviceTaskExecutor.startTask(new WakeAndTuneTask(getInjector())); serviceTaskExecutor.startTask(new WakeAndTuneTask(getInjector()));
} else { } else {
Intent i = new Intent(context, ErrorHelperActivity.class); ErrorHelperActivity.Companion.runAlarm(context, getResourceHelper().gs(R.string.medtronic_error_operation_not_possible_no_configuration), getResourceHelper().gs(R.string.medtronic_warning), R.raw.boluserror);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", getResourceHelper().gs(R.string.medtronic_error_operation_not_possible_no_configuration));
i.putExtra("title", getResourceHelper().gs(R.string.medtronic_warning));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
} }
} }
break; break;

View file

@ -878,9 +878,9 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements PumpInterfa
} }
Intent i = new Intent(context, ErrorHelperActivity.class); Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra("soundid", 0); i.putExtra(ErrorHelperActivity.SOUND_ID, 0);
i.putExtra("status", resourceHelper.gs(R.string.omnipod_pulse_log_value) + ":\n" + result.toString()); i.putExtra(ErrorHelperActivity.STATUS, resourceHelper.gs(R.string.omnipod_pulse_log_value) + ":\n" + result.toString());
i.putExtra("title", resourceHelper.gs(R.string.omnipod_pulse_log)); i.putExtra(ErrorHelperActivity.TITLE, resourceHelper.gs(R.string.omnipod_pulse_log));
i.putExtra("clipboardContent", result.toString()); i.putExtra("clipboardContent", result.toString());
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i); context.startActivity(i);

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager; package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
@ -957,12 +956,7 @@ public class AapsOmnipodManager {
} }
private void showErrorDialog(String message, Integer sound) { private void showErrorDialog(String message, Integer sound) {
Intent intent = new Intent(context, ErrorHelperActivity.class); ErrorHelperActivity.Companion.runAlarm(context, message, resourceHelper.gs(R.string.error), sound);
intent.putExtra("soundid", sound);
intent.putExtra("status", message);
intent.putExtra("title", resourceHelper.gs(R.string.error));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} }
private void showPodFaultNotification(FaultEventCode faultEventCode) { private void showPodFaultNotification(FaultEventCode faultEventCode) {

View file

@ -537,12 +537,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
private fun displayErrorDialog(title: String, message: String, withSound: Boolean) { private fun displayErrorDialog(title: String, message: String, withSound: Boolean) {
context?.let { context?.let {
val i = Intent(it, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
i.putExtra("soundid", if (withSound) R.raw.boluserror else 0)
i.putExtra("status", message)
i.putExtra("title", title)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
it.startActivity(i)
} }
} }

View file

@ -209,12 +209,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
private fun displayErrorDialog(title: String, message: String, @Suppress("SameParameterValue") withSound: Boolean) { private fun displayErrorDialog(title: String, message: String, @Suppress("SameParameterValue") withSound: Boolean) {
context.let { context.let {
val i = Intent(it, ErrorHelperActivity::class.java) ErrorHelperActivity.runAlarm(it, message, title, if (withSound) R.raw.boluserror else 0)
i.putExtra("soundid", if (withSound) R.raw.boluserror else 0)
i.putExtra("status", message)
i.putExtra("title", title)
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
it.startActivity(i)
} }
} }