Merge remote-tracking branch 'Nightscout/dev' into IncreaseHeightUpperRows

This commit is contained in:
Philoul 2020-12-25 16:48:23 +01:00
commit 33e13748ca
27 changed files with 259 additions and 319 deletions

View file

@ -85,23 +85,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
val adapterReason = ArrayAdapter(context, R.layout.spinner_centered, reasonList)
overview_temptarget_reason.adapter = adapterReason
overview_temptarget_custom?.setOnClickListener {
overview_temptarget_temptarget.value = savedInstanceState?.getDouble("overview_temptarget_temptarget") ?: if (profileFunction.getUnits() == Constants.MMOL) Constants.MIN_TT_MMOL else Constants.MIN_TT_MGDL
overview_temptarget_duration.value = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.manual)));
}
overview_temptarget_cancel?.setOnClickListener { shortClick(it) }
overview_temptarget_eating_soon?.setOnClickListener { shortClick(it) }
overview_temptarget_activity?.setOnClickListener { shortClick(it) }
overview_temptarget_hypo?.setOnClickListener { shortClick(it) }
/*
overview_temptarget_cancel?.setOnLongClickListener {
longClick(it)
return@setOnLongClickListener true
}
*/
overview_temptarget_eating_soon?.setOnLongClickListener {
longClick(it)
return@setOnLongClickListener true
@ -124,11 +112,6 @@ class TempTargetDialog : DialogFragmentWithDate() {
private fun longClick(v:View) {
when (v.id) {
R.id.overview_temptarget_cancel -> {
overview_temptarget_temptarget.value = 0.0
overview_temptarget_duration.value = 0.0
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.cancel)))
}
R.id.overview_temptarget_eating_soon -> {
overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT()
overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()

View file

@ -146,7 +146,7 @@ class WizardDialog : DaggerDialogFragment() {
treatments_wizard_bgtrendcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
treatments_wizard_sbcheckbox.setOnCheckedChangeListener(::onCheckedChanged)
val showCalc = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_calculation_visible), false)
val showCalc = sp.getBoolean(R.string.key_wizard_calculation_visible, false)
treatments_wizard_delimiter.visibility = showCalc.toVisibility()
treatments_wizard_resulttable.visibility = showCalc.toVisibility()
treatments_wizard_calculationcheckbox.isChecked = showCalc
@ -211,8 +211,8 @@ class WizardDialog : DaggerDialogFragment() {
}
private fun loadCheckedStates() {
treatments_wizard_bgtrendcheckbox.isChecked = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_include_trend_bg), false)
treatments_wizard_cobcheckbox.isChecked = sp.getBoolean(resourceHelper.gs(R.string.key_wizard_include_cob), false)
treatments_wizard_bgtrendcheckbox.isChecked = sp.getBoolean(R.string.key_wizard_include_trend_bg, false)
treatments_wizard_cobcheckbox.isChecked = sp.getBoolean(R.string.key_wizard_include_cob, false)
}
private fun initDialog() {

View file

@ -267,8 +267,8 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("low_temptarget_lowers_sensitivity", false);
mProfile.put("sensitivity_raises_target", sp.getBoolean(resourceHelper.gs(R.string.key_sensitivity_raises_target),SMBDefaults.sensitivity_raises_target));
mProfile.put("resistance_lowers_target", sp.getBoolean(resourceHelper.gs(R.string.key_resistance_lowers_target),SMBDefaults.resistance_lowers_target));
mProfile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target,SMBDefaults.sensitivity_raises_target));
mProfile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target,SMBDefaults.resistance_lowers_target));
mProfile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments);
mProfile.put("exercise_mode", SMBDefaults.exercise_mode);
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
@ -284,7 +284,7 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("enableUAM", uamAllowed);
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
boolean smbEnabled = sp.getBoolean(resourceHelper.gs(R.string.key_use_smb), false);
boolean smbEnabled = sp.getBoolean(R.string.key_use_smb, false);
mProfile.put("SMBInterval", sp.getInt(R.string.key_smbinterval, SMBDefaults.SMBInterval));
mProfile.put("enableSMB_with_COB", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_COB, false));
mProfile.put("enableSMB_with_temptarget", smbEnabled && sp.getBoolean(R.string.key_enableSMB_with_temptarget, false));

View file

@ -123,7 +123,7 @@ class ImportExportPrefs @Inject constructor(
}
private fun prefsEncryptionIsDisabled() =
buildHelper.isEngineeringMode() && !sp.getBoolean(resourceHelper.gs(R.string.key_maintenance_encrypt_exported_prefs), true)
buildHelper.isEngineeringMode() && !sp.getBoolean(R.string.key_maintenance_encrypt_exported_prefs, true)
private fun askForMasterPass(activity: FragmentActivity, @StringRes canceledMsg: Int, then: ((password: String) -> Unit)) {
passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { password ->

View file

@ -31,11 +31,7 @@ import info.nightscout.androidaps.Config
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.dialogs.CalibrationDialog
import info.nightscout.androidaps.dialogs.CarbsDialog
import info.nightscout.androidaps.dialogs.InsulinDialog
import info.nightscout.androidaps.dialogs.TreatmentDialog
import info.nightscout.androidaps.dialogs.WizardDialog
import info.nightscout.androidaps.dialogs.*
import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
@ -187,6 +183,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overviewMenus.setupChartMenu(overview_chartMenuButton)
prepareGraphs()
overviewMenus.setupPopupMenu(overview_apsmode, requireContext(), childFragmentManager)
//overviewMenus.setupPopupMenu(overview_activeprofile, requireContext(), childFragmentManager)
overview_activeprofile?.setOnClickListener(this)
overview_activeprofile?.setOnLongClickListener(this)
overview_temptarget?.setOnClickListener(this)
overview_temptarget?.setOnLongClickListener(this)
overview_accepttempbutton?.setOnClickListener(this)
overview_treatmentbutton?.setOnClickListener(this)
overview_wizardbutton?.setOnClickListener(this)
@ -196,15 +198,14 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_carbsbutton?.setOnClickListener(this)
overview_quickwizardbutton?.setOnClickListener(this)
overview_quickwizardbutton?.setOnLongClickListener(this)
overview_apsmode?.setOnLongClickListener(this)
overview_activeprofile?.setOnLongClickListener(this)
}
override fun onPause() {
super.onPause()
disposable.clear()
loopHandler.removeCallbacksAndMessages(null)
overview_apsmode_llayout?.let { unregisterForContextMenu(it) }
overview_activeprofile?.let { unregisterForContextMenu(it) }
overview_temptarget?.let { unregisterForContextMenu(it) }
}
override fun onResume() {
@ -276,20 +277,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
loopHandler.postDelayed(refreshLoop, 60 * 1000L)
overview_apsmode_llayout?.let { registerForContextMenu(overview_apsmode) }
overview_activeprofile?.let { registerForContextMenu(it) }
overview_temptarget?.let { registerForContextMenu(it) }
updateGUI("onResume")
}
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenuInfo?) {
super.onCreateContextMenu(menu, v, menuInfo)
overviewMenus.createContextMenu(menu, v)
}
override fun onContextItemSelected(item: MenuItem): Boolean {
return if (overviewMenus.onContextItemSelected(item, childFragmentManager)) true else super.onContextItemSelected(item)
}
override fun onClick(v: View) {
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
@ -297,12 +287,20 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (childFragmentManager.isStateSaved) return
activity?.let { activity ->
when (v.id) {
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TreatmentDialog().show(childFragmentManager, "Overview") })
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { WizardDialog().show(childFragmentManager, "Overview") })
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { InsulinDialog().show(childFragmentManager, "Overview") })
R.id.overview_treatmentbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TreatmentDialog().show(childFragmentManager, "Overview") })
R.id.overview_wizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { WizardDialog().show(childFragmentManager, "Overview") })
R.id.overview_insulinbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { InsulinDialog().show(childFragmentManager, "Overview") })
R.id.overview_quickwizardbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { onClickQuickWizard() })
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { CarbsDialog().show(childFragmentManager, "Overview") })
R.id.overview_carbsbutton -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { CarbsDialog().show(childFragmentManager, "Overview") })
R.id.overview_temptarget -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { TempTargetDialog().show(childFragmentManager, "Overview") })
R.id.overview_activeprofile -> {
val args = Bundle()
args.putLong("time", DateUtil.now())
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
val pvd = ProfileViewerDialog()
pvd.arguments = args
pvd.show(childFragmentManager, "ProfileViewDialog")
}
R.id.overview_cgmbutton -> {
if (xdripPlugin.isEnabled(PluginType.BGSOURCE))
openCgmApp("com.eveningoutpost.dexdrip")
@ -370,6 +368,13 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
return true
}
R.id.overview_apsmode -> {
OverviewMenus.showOKCancel = false
v.performClick()
}
R.id.overview_temptarget -> v.performClick()
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") })}
}
return false
}

View file

@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Bundle
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.view.ContextMenu
import android.view.Menu
import android.view.MenuItem
import android.view.View
@ -38,6 +37,7 @@ import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DefaultValueHelper
import info.nightscout.androidaps.utils.ToastUtils
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
@ -75,6 +75,7 @@ class OverviewMenus @Inject constructor(
companion object {
const val MAX_GRAPHS = 5 // including main
var showOKCancel = true
}
fun enabledTypes(graph: Int): String {
@ -175,65 +176,83 @@ class OverviewMenus @Inject constructor(
}
}
fun createContextMenu(menu: ContextMenu, v: View) {
when (v.id) {
R.id.overview_apsmode -> {
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
if (!profileFunction.isProfileValid("ContextMenuCreation")) return
menu.setHeaderTitle(resourceHelper.gs(R.string.loop))
if (loopPlugin.isEnabled(PluginType.LOOP)) {
menu.add(resourceHelper.gs(R.string.disableloop))
if (!loopPlugin.isSuspended) {
menu.add(resourceHelper.gs(R.string.suspendloopfor1h))
menu.add(resourceHelper.gs(R.string.suspendloopfor2h))
menu.add(resourceHelper.gs(R.string.suspendloopfor3h))
menu.add(resourceHelper.gs(R.string.suspendloopfor10h))
} else {
fun setupPopupMenu(v: View, context: Context, manager: FragmentManager) {
v.setOnClickListener {
val popup = PopupMenu(v.context, v)
when (v.id) {
R.id.overview_apsmode -> {
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
if (profileFunction.isProfileValid("ContextMenuCreation")) {
val item = popup.menu.add(Menu.NONE,1,Menu.NONE,resourceHelper.gs(R.string.loop)) // title
val title = item.title
val s = SpannableString(title)
s.setSpan( ForegroundColorSpan(resourceHelper.gc(R.color.colorAccent)), 0, s.length, 0)
item.setTitle(s)
if (loopPlugin.isEnabled(PluginType.LOOP)) {
popup.menu.add(resourceHelper.gs(R.string.disableloop))
if (!loopPlugin.isSuspended) {
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor1h))
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor2h))
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor3h))
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor10h))
} else {
if (!loopPlugin.isDisconnected) {
popup.menu.add(resourceHelper.gs(R.string.resume))
}
}
}
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
popup.menu.add(resourceHelper.gs(R.string.enableloop))
}
if (!loopPlugin.isDisconnected) {
menu.add(resourceHelper.gs(R.string.resume))
if (pumpDescription.tempDurationStep15mAllowed) popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor15m))
if (pumpDescription.tempDurationStep30mAllowed) popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor30m))
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor1h))
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor2h))
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor3h))
} else {
popup.menu.add(resourceHelper.gs(R.string.reconnect))
}
}
}
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
menu.add(resourceHelper.gs(R.string.enableloop))
}
if (!loopPlugin.isDisconnected) {
showSuspendPump(menu, pumpDescription)
} else {
menu.add(resourceHelper.gs(R.string.reconnect))
R.id.overview_activeprofile -> {
val item = popup.menu.add(Menu.NONE,1,Menu.NONE,resourceHelper.gs(R.string.profile)) // title
val title = item.title
val s = SpannableString(title)
s.setSpan(ForegroundColorSpan(resourceHelper.gc(R.color.colorAccent)), 0, s.length, 0)
item.setTitle(s)
popup.menu.add(resourceHelper.gs(R.string.viewprofile))
if (activePlugin.activeProfileInterface.profile != null) {
popup.menu.add(resourceHelper.gs(R.string.careportal_profileswitch))
}
}
}
popup.setOnMenuItemClickListener {
if (it.itemId != 1) {
if (showOKCancel) {
when (it.title) {
resourceHelper.gs(R.string.careportal_profileswitch),
resourceHelper.gs(R.string.viewprofile) -> onItemSelected(it, manager)
R.id.overview_activeprofile -> {
menu.setHeaderTitle(resourceHelper.gs(R.string.profile))
menu.add(resourceHelper.gs(R.string.viewprofile))
if (activePlugin.activeProfileInterface.profile != null) {
menu.add(resourceHelper.gs(R.string.careportal_profileswitch))
}
}
R.id.overview_temptarget -> {
menu.setHeaderTitle(resourceHelper.gs(R.string.careportal_temporarytarget))
menu.add(resourceHelper.gs(R.string.custom))
menu.add(resourceHelper.gs(R.string.eatingsoon))
menu.add(resourceHelper.gs(R.string.activity))
menu.add(resourceHelper.gs(R.string.hypo))
if (activePlugin.activeTreatments.tempTargetFromHistory != null) {
menu.add(resourceHelper.gs(R.string.cancel))
else -> {
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.confirm), it.title.toString(),
Runnable {
onItemSelected(it, manager)
})
}
}
} else {
onItemSelected(it, manager)
}
}
return@setOnMenuItemClickListener true
}
popup.setOnDismissListener { showOKCancel = true }
popup.show()
}
}
private fun showSuspendPump(menu: ContextMenu, pumpDescription: PumpDescription) {
if (pumpDescription.tempDurationStep15mAllowed) menu.add(resourceHelper.gs(R.string.disconnectpumpfor15m))
if (pumpDescription.tempDurationStep30mAllowed) menu.add(resourceHelper.gs(R.string.disconnectpumpfor30m))
menu.add(resourceHelper.gs(R.string.disconnectpumpfor1h))
menu.add(resourceHelper.gs(R.string.disconnectpumpfor2h))
menu.add(resourceHelper.gs(R.string.disconnectpumpfor3h))
}
fun onContextItemSelected(item: MenuItem, manager: FragmentManager): Boolean {
fun onItemSelected(item: MenuItem, manager: FragmentManager): Boolean {
val profile = profileFunction.getProfile() ?: return true
when (item.title) {
resourceHelper.gs(R.string.disableloop) -> {
@ -360,60 +379,6 @@ class OverviewMenus @Inject constructor(
pvd.arguments = args
pvd.show(manager, "ProfileViewDialog")
}
resourceHelper.gs(R.string.eatingsoon) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET EATING SOON")
val target = Profile.toMgdl(defaultValueHelper.determineEatingSoonTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(System.currentTimeMillis())
.duration(defaultValueHelper.determineEatingSoonTTDuration())
.reason(resourceHelper.gs(R.string.eatingsoon))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.activity) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET ACTIVITY")
val target = Profile.toMgdl(defaultValueHelper.determineActivityTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(DateUtil.now())
.duration(defaultValueHelper.determineActivityTTDuration())
.reason(resourceHelper.gs(R.string.activity))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.hypo) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET HYPO")
val target = Profile.toMgdl(defaultValueHelper.determineHypoTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(DateUtil.now())
.duration(defaultValueHelper.determineHypoTTDuration())
.reason(resourceHelper.gs(R.string.hypo))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.custom) -> {
TempTargetDialog().show(manager, "Overview")
}
resourceHelper.gs(R.string.cancel) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET CANCEL")
val tempTarget = TempTarget()
.source(Source.USER)
.date(DateUtil.now())
.duration(0)
.low(0.0)
.high(0.0)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
}
return false
}

View file

@ -77,7 +77,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
aapsLogger.debug(LTag.CORE, "KeepAlive scheduled")
SystemClock.sleep(5000) // wait for app initialization
localAlertUtils.shortenSnoozeInterval()
localAlertUtils.presnoozeAlarms()
localAlertUtils.preSnoozeAlarms()
val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val i = Intent(context, KeepAliveReceiver::class.java)
val pi = PendingIntent.getBroadcast(context, 0, i, 0)

View file

@ -5,19 +5,21 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.min
/**
* Created by adrian on 17/12/17.
@ -31,48 +33,49 @@ class LocalAlertUtils @Inject constructor(
private val activePlugin: ActivePluginProvider,
private val profileFunction: ProfileFunction,
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
private val smsCommunicatorPlugin: SmsCommunicatorPlugin,
private val config: Config,
private val nsUpload: NSUpload,
private val dateUtil: DateUtil
) {
fun missedReadingsThreshold(): Long {
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_missed_bg_readings_threshold_minutes), Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs()
private fun missedReadingsThreshold(): Long {
return T.mins(sp.getInt(R.string.key_missed_bg_readings_threshold_minutes, Constants.DEFAULT_MISSED_BG_READINGS_THRESHOLD_MINUTES).toLong()).msecs()
}
fun pumpUnreachableThreshold(): Long {
return T.mins(sp.getInt(resourceHelper.gs(R.string.key_pump_unreachable_threshold_minutes), Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs()
private fun pumpUnreachableThreshold(): Long {
return T.mins(sp.getInt(R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong()).msecs()
}
fun checkPumpUnreachableAlarm(lastConnection: Long, isStatusOutdated: Boolean, isDisconnected: Boolean) {
val alarmTimeoutExpired = isAlarmTimeoutExpired(lastConnection, pumpUnreachableThreshold())
val nextAlarmOccurrenceReached = sp.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis()
if (config.APS && sp.getBoolean(resourceHelper.gs(R.string.key_enable_pump_unreachable_alert), true)
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) {
aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated)
val n = Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT)
n.soundId = R.raw.alarm
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
rxBus.send(EventNewNotification(n))
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
nsUpload.uploadError(n.text)
if (config.APS && isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !isDisconnected) {
if (sp.getBoolean(R.string.key_enable_pump_unreachable_alert, true)) {
aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated)
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT).also { it.soundId - R.raw.alarm }))
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true))
nsUpload.uploadError(resourceHelper.gs(R.string.pump_unreachable))
}
if (sp.getBoolean(R.string.key_smscommunicator_report_pump_ureachable, true))
smsCommunicatorPlugin.sendNotificationToAllNumbers(resourceHelper.gs(R.string.pump_unreachable))
}
if (!isStatusOutdated && !alarmTimeoutExpired) rxBus.send(EventDismissNotification(Notification.PUMP_UNREACHABLE))
}
private fun isAlarmTimeoutExpired(lastConnection: Long, unreachableThreshold: Long): Boolean {
if (activePlugin.activePump.pumpDescription.hasCustomUnreachableAlertCheck) {
return activePlugin.activePump.isUnreachableAlertTimeoutExceeded(unreachableThreshold)
return if (activePlugin.activePump.pumpDescription.hasCustomUnreachableAlertCheck) {
activePlugin.activePump.isUnreachableAlertTimeoutExceeded(unreachableThreshold)
} else {
return lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis()
lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis()
}
}
/*Presnoozes the alarms with 5 minutes if no snooze exists.
/*Pre-snoozes the alarms with 5 minutes if no snooze exists.
* Call only at startup!
*/
fun presnoozeAlarms() {
fun preSnoozeAlarms() {
if (sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis()) {
sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + 5 * 60 * 1000)
}
@ -83,10 +86,10 @@ class LocalAlertUtils @Inject constructor(
fun shortenSnoozeInterval() { //shortens alarm times in case of setting changes or future data
var nextMissedReadingsAlarm = sp.getLong("nextMissedReadingsAlarm", 0L)
nextMissedReadingsAlarm = Math.min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm)
nextMissedReadingsAlarm = min(System.currentTimeMillis() + missedReadingsThreshold(), nextMissedReadingsAlarm)
sp.putLong("nextMissedReadingsAlarm", nextMissedReadingsAlarm)
var nextPumpDisconnectedAlarm = sp.getLong("nextPumpDisconnectedAlarm", 0L)
nextPumpDisconnectedAlarm = Math.min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm)
nextPumpDisconnectedAlarm = min(System.currentTimeMillis() + pumpUnreachableThreshold(), nextPumpDisconnectedAlarm)
sp.putLong("nextPumpDisconnectedAlarm", nextPumpDisconnectedAlarm)
}
@ -104,7 +107,7 @@ class LocalAlertUtils @Inject constructor(
fun checkStaleBGAlert() {
val bgReading: BgReading? = iobCobCalculatorPlugin.lastBg()
if (sp.getBoolean(resourceHelper.gs(R.string.key_enable_missed_bg_readings_alert), false)
if (sp.getBoolean(R.string.key_enable_missed_bg_readings_alert, false)
&& bgReading != null && bgReading.date + missedReadingsThreshold() < System.currentTimeMillis() && sp.getLong("nextMissedReadingsAlarm", 0L) < System.currentTimeMillis()) {
val n = Notification(Notification.BG_READINGS_MISSED, resourceHelper.gs(R.string.missed_bg_readings), Notification.URGENT)
n.soundId = R.raw.alarm

View file

@ -12,9 +12,9 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/profilehelper_compareprofile"
style="@style/ButtonMediumFontStyle"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_compare_profiles"
@ -50,8 +50,8 @@
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/profilehelper_profiletype_title"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/profiletype"
@ -173,11 +173,11 @@
android:layout_marginStart="10dp"
android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<Button
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/profilehelper_copytolocalprofile"
style="@style/ButtonMediumFontStyle"
style="?android:attr/buttonStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_clone_48"
android:text="@string/clone_label" />

View file

@ -142,27 +142,12 @@
</LinearLayout>
<include layout="@layout/datetime" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/overview_temptarget_custom"
style="?android:attr/buttonStyle"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_marginEnd="-4dp"
android:layout_weight="0.5"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:drawableTop="@drawable/ic_target_manual"
android:text="@string/manual"
android:textColor="@color/tempTargetConfirmation"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:visibility="gone"
android:textSize="11sp" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/overview_temptarget_cancel"
style="?android:attr/buttonStyle"

View file

@ -1415,5 +1415,8 @@
<string name="copytolocalprofile_invalid">Unable to create local profile. Profile is invalid.</string>
<string name="cta_dont_kill_my_app_info">Don\'t kill my app?</string>
<string name="alarm">Alarm</string>
<string name="key_smscommunicator_report_pump_ureachable" translatable="false">smscommunicator_report_pump_ureachable</string>
<string name="smscommunicator_report_pump_ureachable_summary">Send SMS if unreachable pump event is triggered</string>
<string name="smscommunicator_pump_ureachable">Report pump ureachable</string>
</resources>

View file

@ -52,5 +52,5 @@
<item name="android:textColor">#ff0000</item>
</style>
<style name="ProfileHelperAppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"/>
<style name="ProfileHelperAppTheme" parent="Theme.MaterialComponents.NoActionBar"/>
</resources>

View file

@ -49,6 +49,12 @@
<intent android:action="info.nightscout.androidaps.plugins.general.smsCommunicator.activities.SmsCommunicatorOtpActivity" />
</Preference>
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_smscommunicator_report_pump_ureachable"
android:summary="@string/smscommunicator_report_pump_ureachable_summary"
android:title="@string/smscommunicator_pump_ureachable" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>

View file

@ -184,7 +184,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
}
protected void getBTSocketForSelectedPump() {
mDevName = sp.getString(resourceHelper.gs(R.string.key_danar_bt_name), "");
mDevName = sp.getString(R.string.key_danar_bt_name, "");
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter != null) {

View file

@ -180,7 +180,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
}
public boolean verifyConfiguration() {
public boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal) {
try {
String regexSN = "[0-9]{6}";
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
@ -316,7 +316,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
//boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on));
//MedtronicHistoryData.doubleBolusDebug = bolusDebug;
reconfigureService();
reconfigureService(forceRileyLinkAddressRenewal);
return true;
@ -327,7 +327,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
}
}
private boolean reconfigureService() {
private boolean reconfigureService(boolean forceRileyLinkAddressRenewal) {
if (!inPreInit) {
@ -336,7 +336,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
serialChanged = false;
}
if (rileyLinkAddressChanged) {
if (rileyLinkAddressChanged || forceRileyLinkAddressRenewal) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
rileyLinkAddressChanged = false;
}
@ -380,6 +380,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
public boolean setNotInPreInit() {
this.inPreInit = false;
return reconfigureService();
return reconfigureService(false);
}
}

View file

@ -109,7 +109,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
}
@Override
public boolean verifyConfiguration() {
public boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal) {
try {
errorDescription = null;
@ -133,7 +133,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod;
reconfigureService();
reconfigureService(forceRileyLinkAddressRenewal);
return true;
@ -144,9 +144,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
}
}
private boolean reconfigureService() {
private boolean reconfigureService(boolean forceRileyLinkAddressRenewal) {
if (!inPreInit) {
if (rileyLinkAddressChanged) {
if (rileyLinkAddressChanged || forceRileyLinkAddressRenewal) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
rileyLinkAddressChanged = false;
}
@ -158,6 +158,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
public boolean setNotInPreInit() {
this.inPreInit = false;
return reconfigureService();
return reconfigureService(false);
}
}

View file

@ -596,7 +596,7 @@ class OmnipodOverviewFragment : DaggerFragment() {
// FIXME ideally we should just have access to LocalAlertUtils here
private fun getPumpUnreachableTimeout(): Duration {
return Duration.standardMinutes(sp.getInt(resourceHelper.gs(R.string.key_pump_unreachable_threshold_minutes), Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong())
return Duration.standardMinutes(sp.getInt(R.string.key_pump_unreachable_threshold_minutes, Constants.DEFAULT_PUMP_UNREACHABLE_THRESHOLD_MINUTES).toLong())
}
inner class DisplayResultDialogCallback(private val errorMessagePrefix: String, private val withSoundOnError: Boolean) : Callback() {

View file

@ -79,6 +79,8 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
private String actionTitleStart, actionTitleStop;
private MenuItem menuItem;
private boolean rlDisconnected;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -106,7 +108,7 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
sp.putString(RileyLinkConst.Prefs.RileyLinkAddress, bleAddress);
RileyLinkPumpDevice rileyLinkPump = (RileyLinkPumpDevice) activePlugin.getActivePump();
rileyLinkPump.getRileyLinkService().verifyConfiguration(); // force reloading of address
rileyLinkPump.getRileyLinkService().verifyConfiguration(true); // force reloading of address to assure that the RL gets reconnected (even if the address didn't change)
rileyLinkPump.triggerPumpConfigurationChangedEvent();
finish();
@ -115,10 +117,12 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
toolbarBTScan = findViewById(R.id.rileylink_toolbarBTScan);
toolbarBTScan.setTitle(R.string.rileylink_scanner_title);
setSupportActionBar(toolbarBTScan);
prepareForScanning();
}
@Override protected void onResume() {
super.onResume();
prepareForScanning();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
@ -138,6 +142,10 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getTitle().equals(actionTitleStart)) {
// disable currently selected RL, so that we can discover it
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect, this);
rlDisconnected = true;
scanLeDevice(true);
return true;
} else if (item.getTitle().equals(actionTitleStop)) {
@ -148,8 +156,21 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
}
}
@Override public void onBackPressed() {
super.onBackPressed();
if (rlDisconnected) {
// Reconnect RL if it was disconnected for the scan
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet, this);
}
}
public void prepareForScanning() {
@Override protected void onDestroy() {
super.onDestroy();
mScanning = false;
mLEScanner.stopScan(mScanCallback2);
}
private void prepareForScanning() {
boolean checkOK = blePrecheck.prerequisitesCheck(this);
if (checkOK) {
@ -158,9 +179,6 @@ public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
filters = Collections.singletonList(new ScanFilter.Builder().setServiceUuid(
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
}
// disable currently selected RL, so that we can discover it
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnect, this);
}

View file

@ -112,7 +112,6 @@ public class RFSpy {
reader.newDataIsAvailable();
}
public Integer getBatteryLevel() {
BLECommOperationResult result = rileyLinkBle.readCharacteristic_blocking(batteryServiceUUID, batteryLevelUUID);
if (result.resultCode == BLECommOperationResult.RESULT_SUCCESS) {

View file

@ -151,8 +151,8 @@ public class RileyLinkBLE {
} else if ((newState == BluetoothProfile.STATE_CONNECTING) || //
(newState == BluetoothProfile.STATE_DISCONNECTING)) {
aapsLogger.debug(LTag.PUMPBTCOMM,"We are in {} state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" :
"Disconnecting");
aapsLogger.debug(LTag.PUMPBTCOMM, "We are in {} state.", status == BluetoothProfile.STATE_CONNECTING ? "Connecting" :
"Disconnecting");
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
rileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkDisconnected, context);
if (manualDisconnect)
@ -392,6 +392,9 @@ public class RileyLinkBLE {
if (gattDebugEnabled) {
aapsLogger.debug(LTag.PUMPBTCOMM, "Gatt Connected.");
}
rileyLinkServiceData.rileylinkAddress = bluetoothConnectionGatt.getDevice().getAddress();
rileyLinkServiceData.rileyLinkName = bluetoothConnectionGatt.getDevice().getName();
}
}

View file

@ -16,7 +16,6 @@ import java.util.List;
import javax.inject.Inject;
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.plugins.pump.common.R;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
@ -66,50 +65,14 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter
.getItem(tabLayout.getSelectedTabPosition());
selectableInterface.refreshData();
// refreshData(tabLayout.getSelectedTabPosition());
// Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(),
// Toast.LENGTH_LONG);
});
this.connectionStatus = findViewById(R.id.rls_t1_connection_status);
this.configuredAddress = findViewById(R.id.rls_t1_configured_address);
this.connectedDevice = findViewById(R.id.rls_t1_connected_device);
this.connectionError = findViewById(R.id.rls_t1_connection_error);
// // 7-12
// int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
// R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12};
//
// for (int id : ids) {
//
// TextView tv = (TextView) findViewById(id);
// tv.setText(tv.getText() + ":");
// }
// refreshData(0);
// refreshData(1);
}
public void refreshData(int position) {
if (position == 0) {
// FIXME i18n
this.connectionStatus.setText(rileyLinkServiceData.rileyLinkServiceState.name());
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
// FIXME
this.connectedDevice.setText("???");
// FIXME i18n
this.connectionError.setText(rileyLinkServiceData.rileyLinkError.name());
} else {
}
}
public void setupViewPager(ViewPager pager) {
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

View file

@ -6,6 +6,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.LocalDateTime;
import java.util.Locale;
@ -31,40 +32,39 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RileyLinkStatusGeneralFragment extends DaggerFragment implements RefreshableInterface {
private static final String PLACEHOLDER = "-";
@Inject ActivePluginProvider activePlugin;
@Inject ResourceHelper resourceHelper;
@Inject AAPSLogger aapsLogger;
@Inject RileyLinkServiceData rileyLinkServiceData;
@Inject DateUtil dateUtil;
TextView connectionStatus;
TextView configuredAddress;
TextView connectedDevice;
TextView connectionError;
TextView deviceType;
TextView deviceModel;
TextView serialNumber;
TextView pumpFrequency;
TextView lastUsedFrequency;
TextView lastDeviceContact;
TextView firmwareVersion;
boolean first = false;
private TextView connectionStatus;
private TextView configuredAddress;
private TextView connectedRileyLinkName;
private TextView connectedDevice;
private TextView connectionError;
private TextView deviceType;
private TextView deviceModel;
private TextView serialNumber;
private TextView pumpFrequency;
private TextView lastUsedFrequency;
private TextView lastDeviceContact;
private TextView firmwareVersion;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.rileylink_status_general, container, false);
return rootView;
return inflater.inflate(R.layout.rileylink_status_general, container, false);
}
@Override
public void onStart() {
super.onStart();
this.connectionStatus = getActivity().findViewById(R.id.rls_t1_connection_status);
this.configuredAddress = getActivity().findViewById(R.id.rls_t1_configured_address);
this.connectedRileyLinkName = getActivity().findViewById(R.id.rls_t1_connected_riley_link_name);
this.connectedDevice = getActivity().findViewById(R.id.rls_t1_connected_device);
this.connectionError = getActivity().findViewById(R.id.rls_t1_connection_error);
this.deviceType = getActivity().findViewById(R.id.rls_t1_device_type);
@ -75,39 +75,24 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
this.lastDeviceContact = getActivity().findViewById(R.id.rls_t1_last_device_contact);
this.firmwareVersion = getActivity().findViewById(R.id.rls_t1_firmware_version);
if (!first) {
// 7-14
int[] ids = {R.id.rls_t1_tv02, R.id.rls_t1_tv03, R.id.rls_t1_tv04, R.id.rls_t1_tv05, R.id.rls_t1_tv07, //
R.id.rls_t1_tv08, R.id.rls_t1_tv09, R.id.rls_t1_tv10, R.id.rls_t1_tv11, R.id.rls_t1_tv12, R.id.rls_t1_tv13};
for (int id : ids) {
TextView tv = getActivity().findViewById(id);
tv.setText(tv.getText() + ":");
}
first = true;
}
refreshData();
}
public void refreshData() {
RileyLinkTargetDevice targetDevice = rileyLinkServiceData.targetDevice;
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
// BS FIXME rileyLinkServiceData is injected so I suppose it cannot be null?
if (rileyLinkServiceData != null) {
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
this.configuredAddress.setText(StringUtils.isEmpty(rileyLinkServiceData.rileylinkAddress) ? PLACEHOLDER : rileyLinkServiceData.rileylinkAddress);
this.connectedRileyLinkName.setText(StringUtils.isEmpty(rileyLinkServiceData.rileyLinkName) ? PLACEHOLDER : rileyLinkServiceData.rileyLinkName);
this.connectionError.setText(rileyLinkServiceData.rileyLinkError == null ? //
"-"
PLACEHOLDER
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
if (firmwareVersion == null) {
this.firmwareVersion.setText("BLE113: -\nCC110: -");
this.firmwareVersion.setText("BLE113: " + PLACEHOLDER + "\nCC110: " + PLACEHOLDER);
} else {
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
"\nCC110: " + rileyLinkServiceData.versionCC110);

View file

@ -84,7 +84,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
}
private RileyLinkService getServiceInstance() {
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice)activePlugin.getActivePump();
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
return pumpDevice.getRileyLinkService();
}
@ -142,7 +142,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
aapsLogger.warn(LTag.PUMPBTCOMM, "RileyLinkConst.Intents.RileyLinkReady");
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
@ -153,7 +152,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
String bleVersion = rileyLinkService.rfspy.getBLEVersionCached();
RileyLinkFirmwareVersion rlVersion = rileyLinkServiceData.firmwareVersion;
// if (isLoggingEnabled())
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): " + bleVersion);
rileyLinkService.rileyLinkServiceData.versionBLE113 = bleVersion;
@ -180,7 +178,6 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnect)) {
rileyLinkService.disconnectRileyLink();
return true;
} else {
return false;

View file

@ -230,6 +230,7 @@ public abstract class RileyLinkService extends DaggerService {
if (rileyLinkBLE.isConnected()) {
rileyLinkBLE.disconnect();
rileyLinkServiceData.rileylinkAddress = null;
rileyLinkServiceData.rileyLinkName = null;
}
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.BluetoothReady);
@ -260,5 +261,9 @@ public abstract class RileyLinkService extends DaggerService {
return null;
}
public abstract boolean verifyConfiguration();
public boolean verifyConfiguration() {
return verifyConfiguration(false);
}
public abstract boolean verifyConfiguration(boolean forceRileyLinkAddressRenewal);
}

View file

@ -35,6 +35,7 @@ public class RileyLinkServiceData {
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
public String rileylinkAddress;
public String rileyLinkName;
long lastTuneUpTime = 0L;
public Double lastGoodFrequency;

View file

@ -37,7 +37,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv02"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -65,7 +64,33 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv03"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="35"
android:gravity="center_vertical"
android:text="@string/rileylink_connected_riley_link_name" />
<TextView
android:id="@+id/rls_t1_connected_riley_link_name"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="65"
android:gravity="center_vertical"
android:text=" "
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -94,7 +119,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv04"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -123,7 +147,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv05"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -151,7 +174,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv13"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -194,7 +216,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv07"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -223,7 +244,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv08"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -252,13 +272,12 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv09"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="35"
android:gravity="center_vertical"
android:text="@string/medtronic_serial_number" />
android:text="@string/rileylink_pump_serial_number" />
<TextView
android:id="@+id/rls_t1_serial_number"
@ -281,13 +300,12 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv10"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_weight="35"
android:gravity="center_vertical"
android:text="@string/medtronic_pump_frequency" />
android:text="@string/rileylink_pump_frequency" />
<TextView
android:id="@+id/rls_t1_pump_frequency"
@ -309,7 +327,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv11"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
@ -338,7 +355,6 @@
android:orientation="horizontal">
<TextView
android:id="@+id/rls_t1_tv12"
android:layout_width="58dp"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"

View file

@ -20,16 +20,19 @@
<string name="medtronic_pump_status">Pump Status</string>
<string name="title_activity_rileylink_settings">RileyLink Settings</string>
<string name="rileylink_title">RileyLink</string>
<string name="rileylink_configured_address">Configured Address</string>
<string name="rileylink_connected_device">Connected Device</string>
<string name="rileylink_connection_status">Connection Status</string>
<string name="rileylink_connection_error">Connection Error</string>
<string name="rileylink_configured_address">Configured Address:</string>
<string name="rileylink_connected_device">Connected Device:</string>
<string name="rileylink_connection_status">Connection Status:</string>
<string name="rileylink_connection_error">Connection Error:</string>
<string name="rileylink_device">Device</string>
<string name="rileylink_device_type">Device Type</string>
<string name="rileylink_device_model">Device Model</string>
<string name="rileylink_last_used_frequency">Last used frequency</string>
<string name="rileylink_last_device_contact">Last device contact</string>
<string name="rileylink_firmware_version">Firmware</string>
<string name="rileylink_device_type">Device Type:</string>
<string name="rileylink_device_model">Device Model:</string>
<string name="rileylink_last_used_frequency">Last Used Frequency:</string>
<string name="rileylink_last_device_contact">Last Device Contact:</string>
<string name="rileylink_firmware_version">Firmware Version:</string>
<string name="rileylink_connected_riley_link_name">Connected RileyLink Name:</string>
<string name="rileylink_pump_serial_number">Pump Serial Number:</string>
<string name="rileylink_pump_frequency">Pump Frequency:</string>
<!-- RL State -->