diff --git a/app/src/main/assets/OpenAPSSMB/determine-basal.js b/app/src/main/assets/OpenAPSSMB/determine-basal.js index 00a9c1d0a2..fbc0a4de9f 100644 --- a/app/src/main/assets/OpenAPSSMB/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMB/determine-basal.js @@ -407,6 +407,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ , 'bg': bg , 'tick': tick , 'eventualBG': eventualBG + , 'targetBG': target_bg , 'insulinReq': 0 , 'reservoir' : reservoir_data // The expected reservoir volume at which to deliver the microbolus (the reservoir volume from right before the last pumphistory run) , 'deliverAt' : deliverAt // The time at which the microbolus should be delivered diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index c78aaedaf5..f25cf49fc9 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -49,7 +49,7 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicato import info.nightscout.androidaps.setupwizard.SetupWizardActivity import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 126ba47d22..6b78a50599 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -37,7 +37,7 @@ import info.nightscout.androidaps.receivers.NetworkChangeReceiver; import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver; import info.nightscout.androidaps.services.Intents; import info.nightscout.androidaps.utils.ActivityMonitor; -import info.nightscout.androidaps.utils.LocaleHelper; +import info.nightscout.androidaps.utils.locale.LocaleHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; public class MainApp extends DaggerApplication { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt index ad3961c883..ea90f4b250 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt @@ -5,7 +5,7 @@ import android.os.Bundle import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceScreen import info.nightscout.androidaps.R -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt index 9e62f16c97..0193b690a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SingleFragmentActivity.kt @@ -9,7 +9,7 @@ import dagger.android.support.DaggerAppCompatActivity import info.nightscout.androidaps.R import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.plugins.configBuilder.PluginStore -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.protection.ProtectionCheck import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 50a7d3ed47..4b8d637c47 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -1531,7 +1531,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { //add last one without duration ProfileSwitch last = getLastProfileSwitchWithoutDuration(); if (last != null) { - if (!profileSwitches.contains(last)) + if (!isInList(profileSwitches, last)) profileSwitches.add(last); } return profileSwitches; @@ -1541,6 +1541,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { return new ArrayList<>(); } + boolean isInList(List profileSwitches, ProfileSwitch last) { + for (ProfileSwitch ps : profileSwitches) { + if (ps.isEqual(last)) return true; + } + return false; + } + @Nullable private ProfileSwitch getLastProfileSwitchWithoutDuration() { try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java index 6b5f5363b0..8b894e8579 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalAdapterSMBJS.java @@ -259,8 +259,8 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("low_temptarget_lowers_sensitivity", false); - mProfile.put("sensitivity_raises_target", SMBDefaults.sensitivity_raises_target); - mProfile.put("resistance_lowers_target", SMBDefaults.resistance_lowers_target); + 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("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); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java index dae170d5d9..f8f72c6c87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java @@ -51,6 +51,9 @@ public class DetermineBasalResultSMB extends APSResult { } else { smb = 0d; } + if (result.has("targetBG")) { + targetBG = result.getDouble("targetBG"); + } if (result.has("deliverAt")) { String date = result.getString("deliverAt"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt index 5166248e7d..3958f17d78 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/PluginStore.kt @@ -108,7 +108,7 @@ class PluginStore @Inject constructor( (activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true) aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface") } - setFragmentVisiblities((activeSensitivity as PluginBase).name, pluginsInCategory, PluginType.PROFILE) + setFragmentVisiblities((activeProfile as PluginBase).name, pluginsInCategory, PluginType.PROFILE) // PluginType.BGSOURCE pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt index 7703166d04..6be8b5e020 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt @@ -19,7 +19,7 @@ import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsFormatsHandler import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsStatus -import info.nightscout.androidaps.utils.LocaleHelper +import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.resources.ResourceHelper import kotlinx.android.synthetic.main.maintenance_importlist_activity.* import javax.inject.Inject diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java index 7195435515..757692e655 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSDeviceStatus.java @@ -331,7 +331,7 @@ public class NSDeviceStatus { // test warning level int level = Levels.INFO; long now = System.currentTimeMillis(); - if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 16) * 60 * 1000L < now) + if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_urgent_staledatavalue, 31) * 60 * 1000L < now) level = Levels.URGENT; else if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_staledatavalue, 16) * 60 * 1000L < now) level = Levels.WARN; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java index cc5057f7eb..7c4d41ca86 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/services/NSClientService.java @@ -842,33 +842,42 @@ public class NSClientService extends DaggerService { } private void handleAnnouncement(JSONObject announcement) { - NSAlarm nsAlarm = new NSAlarm(announcement); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); - rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, announcement.toString()); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) { + NSAlarm nsAlarm = new NSAlarm(announcement); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, announcement.toString()); + } } private void handleAlarm(JSONObject alarm) { - long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); - if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { - NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) { + long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); + if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { + NSAlarm nsAlarm = new NSAlarm(alarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + } + rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } - rxBus.send(new EventNSClientNewLog("ALARM", JsonHelper.safeGetString(alarm, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } private void handleUrgentAlarm(JSONObject alarm) { - long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); - if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { - NSAlarm nsAlarm = new NSAlarm(alarm); - Notification notification = new NotificationWithAction(injector, nsAlarm); - rxBus.send(new EventNewNotification(notification)); + boolean defaultVal = config.getNSCLIENT(); + if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) { + long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L); + if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) { + NSAlarm nsAlarm = new NSAlarm(alarm); + Notification notification = new NotificationWithAction(injector, nsAlarm); + rxBus.send(new EventNewNotification(notification)); + } + rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received"))); + aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } - rxBus.send(new EventNSClientNewLog("URGENTALARM", JsonHelper.safeGetString(alarm, "message", "received"))); - aapsLogger.debug(LTag.NSCLIENT, alarm.toString()); } public void handleNewCal(JSONArray cals, boolean isDelta) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 93c112f745..c9ea872345 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -646,6 +646,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } else { overview_apsmode_text?.visibility = View.GONE } + val lastRun = loopPlugin.lastRun // temp target val tempTarget = treatmentsPlugin.tempTargetFromHistory @@ -654,9 +655,18 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning)) overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper) } else { - overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) - overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) - overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + // If the target is not the same as set in the profile then oref has overridden it + val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0 + + if (targetUsed != 0.0 && profile.targetMgdl != targetUsed) { + overview_temptarget?.text = Profile.toTargetRangeString(targetUsed, targetUsed, Constants.MGDL, units) + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.tempTargetBackground)) + } else { + overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault)) + overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault)) + overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units) + } } // Basal, TBR @@ -677,7 +687,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList if (activeTemp != null) overview_basebasal_icon.setImageResource(if (activeTemp.tempBasalConvertedToPercent(System.currentTimeMillis(), profile) > 100) R.drawable.icon_cp_basal_tbr_high else R.drawable.icon_cp_basal_tbr_low) else - overview_basebasal_icon.setImageResource( R.drawable.icon_cp_basal_no_tbr ) + overview_basebasal_icon.setImageResource(R.drawable.icon_cp_basal_no_tbr) // Extended bolus val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) @@ -741,7 +751,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } overview_cob?.text = cobText - val lastRun = loopPlugin.lastRun val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT // pump status from ns @@ -759,7 +768,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList // Sensitivity if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) { overview_sensitivity_icon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green) - }else { + } else { overview_sensitivity_icon.setImageResource(R.drawable.ic_x_swap_vert_48px_green) } @@ -883,4 +892,4 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList } } } -} \ No newline at end of file +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt index f492196b29..4e85b03b5c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/NotificationWithAction.kt @@ -22,8 +22,6 @@ class NotificationWithAction constructor( @Inject lateinit var defaultValueHelper: DefaultValueHelper @Inject lateinit var nsClientPlugin: NSClientPlugin - private var nsAlarm: NSAlarm? = null - init { injector.androidInjector().inject(this) } @@ -36,7 +34,6 @@ class NotificationWithAction constructor( } constructor (injector: HasAndroidInjector, nsAlarm: NSAlarm) : this(injector) { - this.nsAlarm = nsAlarm date = System.currentTimeMillis() when (nsAlarm.level()) { 0 -> { @@ -50,14 +47,14 @@ class NotificationWithAction constructor( id = NSALARM level = NORMAL text = nsAlarm.title() - if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.alarm + soundId = R.raw.alarm } 2 -> { id = NSURGENTALARM level = URGENT text = nsAlarm.title() - if (nsAlarm.low() && sp.getBoolean(R.string.key_nsalarm_urgent_low, false) || nsAlarm.high() && sp.getBoolean(R.string.key_nsalarm_urgent_high, false) || nsAlarm.timeago() && sp.getBoolean(R.string.key_nsalarm_staledata, false)) soundId = R.raw.urgentalarm + soundId = R.raw.urgentalarm } } buttonText = R.string.snooze diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index f8d1cf1ce5..1b4e537f0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -597,6 +597,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(0); bolusMessage.setExtendedAmount(0); bolusMessage.setImmediateAmount(insulin); + bolusMessage.setVibration(sp.getBoolean(detailedBolusInfo.isSMB ? R.string.key_disable_vibration_auto : R.string.key_disable_vibration ,false)); bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); bolusCancelled = false; } @@ -720,7 +721,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, PumpEnactResult cancelTBRResult = cancelTempBasalOnly(); if (cancelTBRResult.success) { PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D - * ((double) durationInMinutes), durationInMinutes); + * ((double) durationInMinutes), durationInMinutes, + sp.getBoolean(R.string.key_disable_vibration_auto,false)); if (ebResult.success) { result.success = true; result.enacted = true; @@ -798,7 +800,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, @NonNull @Override public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { PumpEnactResult result = cancelExtendedBolusOnly(); - if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes); + if (result.success) result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_disable_vibration,false)); try { fetchStatus(); readHistory(); @@ -812,7 +814,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, return result; } - public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes) { + public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) { PumpEnactResult result = new PumpEnactResult(getInjector()); try { DeliverBolusMessage bolusMessage = new DeliverBolusMessage(); @@ -820,6 +822,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface, bolusMessage.setDuration(durationInMinutes); bolusMessage.setExtendedAmount(insulin); bolusMessage.setImmediateAmount(0); + bolusMessage.setVibration(disableVibration); int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId(); InsightBolusID insightBolusID = new InsightBolusID(); insightBolusID.bolusID = bolusID; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java index e0d0f2461a..6a4973b42b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/app_layer/remote_control/DeliverBolusMessage.java @@ -14,6 +14,7 @@ public class DeliverBolusMessage extends AppLayerMessage { private double extendedAmount; private int duration; private int bolusId; + private boolean disableVibration = false; public DeliverBolusMessage() { super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL); @@ -22,7 +23,11 @@ public class DeliverBolusMessage extends AppLayerMessage { @Override protected ByteBuf getData() { ByteBuf byteBuf = new ByteBuf(22); - byteBuf.putUInt16LE(252); + // 805 => Old value with vibration (2.6.1 and earlier), 252 => new value without vibrations for firmware 3.x + if (disableVibration) + byteBuf.putUInt16LE(252); + else + byteBuf.putUInt16LE(805); byteBuf.putUInt16LE(BolusTypeIDs.IDS.getID(bolusType)); byteBuf.putUInt16LE(31); byteBuf.putUInt16LE(0); @@ -57,6 +62,8 @@ public class DeliverBolusMessage extends AppLayerMessage { this.duration = duration; } + public void setVibration(boolean disableVibration) { this.disableVibration = disableVibration;} + public int getBolusId() { return bolusId; } diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index c8e406881b..d0f8c29138 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -34,7 +34,7 @@ import info.nightscout.androidaps.setupwizard.elements.* import info.nightscout.androidaps.setupwizard.events.EventSWUpdate import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.CryptoUtil -import info.nightscout.androidaps.utils.LocaleHelper.update +import info.nightscout.androidaps.utils.locale.LocaleHelper.update import info.nightscout.androidaps.utils.extensions.isRunningTest import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index b265af0d4c..44af0e1312 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -20,7 +20,7 @@ import info.nightscout.androidaps.setupwizard.elements.SWItem import info.nightscout.androidaps.setupwizard.events.EventSWUpdate import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocaleHelper.update +import info.nightscout.androidaps.utils.locale.LocaleHelper.update import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation import info.nightscout.androidaps.utils.resources.ResourceHelper diff --git a/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java b/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java index 9b754ac47a..db1f6af239 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/JSONFormatter.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps.utils; -import android.os.Build; import android.text.Html; import android.text.Spanned; @@ -8,7 +7,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Iterator; @@ -24,33 +22,24 @@ public class JSONFormatter { final JsonVisitor visitor = new JsonVisitor(1, '\t'); try { if (jsonString.equals("undefined")) - return Html.fromHtml("undefined"); + return HtmlHelper.INSTANCE.fromHtml("undefined"); else if (jsonString.getBytes()[0] == '[') - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0), Html.FROM_HTML_MODE_COMPACT); - } else { - return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0)); - } - else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0), Html.FROM_HTML_MODE_COMPACT); - } else { - return Html.fromHtml(visitor.visit(new JSONObject(jsonString), 0)); - } - } + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONArray(jsonString), 0)); + else + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONObject(jsonString), 0)); } catch (JSONException e) { log.error("Unhandled exception", e); - return Html.fromHtml(""); + return HtmlHelper.INSTANCE.fromHtml(""); } } public static Spanned format(final JSONObject object) { final JsonVisitor visitor = new JsonVisitor(1, '\t'); try { - return Html.fromHtml(visitor.visit(object, 0)); + return HtmlHelper.INSTANCE.fromHtml(visitor.visit(object, 0)); } catch (JSONException e) { log.error("Unhandled exception", e); - return Html.fromHtml(""); + return HtmlHelper.INSTANCE.fromHtml(""); } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 7ca80a7af9..0d8f4134a1 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -22,6 +22,7 @@ + @string/default_lang @string/en_lang @string/af_lang @string/bg_lang @@ -45,6 +46,7 @@ @string/zh_lang + default en af bg diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4a4595fab4..4908f7d04f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ + System default English Czech Afrikaans @@ -548,20 +549,12 @@ Do Profile Switch Pump battery age Alarm options - nsalarm_urgent_high - nsalarm_high - nsalarm_low - nsalarm_urgent_low - nsalarm_staledata - nsalarm_urgent_staledata + ns_announcements + ns_alarms nsalarm_staledatavalue nsalarm_urgent_staledatavalue - Urgent high - High - Low - Urgent low - Stale data - Urgent stale data + Create notifications from NS alarms + Create notifications from NS announcements Stale data threshold [min] Urgent stale data threshold [min] Interval for autosens [h] @@ -1016,6 +1009,12 @@ Log alerts Enable TBR emulation Use extended boluses instead of TBRs to bypass the 250%% limit + insight_disable_vibration + Disable vibrations on manual bolus delivery + For bolus and extended bolus (only available with Insight firmware 3.x) + insight_disable_vibration_auto + Disable vibrations on automated bolus delivery + For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x) Disconnect delay [s] Serial number Release software version diff --git a/app/src/main/res/xml/pref_insight_local_full.xml b/app/src/main/res/xml/pref_insight_local_full.xml index ceaba15e38..820c12d422 100644 --- a/app/src/main/res/xml/pref_insight_local_full.xml +++ b/app/src/main/res/xml/pref_insight_local_full.xml @@ -48,6 +48,18 @@ android:summary="@string/enable_tbr_emulation_summary" android:title="@string/enable_tbr_emulation" /> + + + + + + + android:key="@string/key_ns_alarms" + android:title="@string/ns_alarms" /> - - - - - - + android:key="@string/key_ns_announcements" + android:title="@string/ns_announcements" /> - - inputConstraints; @@ -184,6 +185,7 @@ public class APSResult { newResult.smbConstraint = smbConstraint; newResult.percent = percent; newResult.usePercent = usePercent; + newResult.targetBG = targetBG; } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt index b79fe884b4..dd0da3b72f 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/HtmlHelper.kt @@ -6,11 +6,6 @@ import android.text.Spanned object HtmlHelper { fun fromHtml(source: String): Spanned { - // API level 24 to replace call - @Suppress("DEPRECATION") - return when { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY) - else -> Html.fromHtml(source) - } + return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt index 7180bf7927..d7bc0a8ce5 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/locale/LocaleHelper.kt @@ -1,22 +1,23 @@ -package info.nightscout.androidaps.utils +package info.nightscout.androidaps.utils.locale import android.content.Context import android.content.ContextWrapper -import android.os.Build import android.os.LocaleList import androidx.preference.PreferenceManager import info.nightscout.androidaps.core.R import java.util.* object LocaleHelper { - private fun currentLanguage(context: Context): String = - PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "en") - ?: "en" + private fun selectedLanguage(context: Context): String = + PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "default") + ?: "default" // injection not possible because of use in attachBaseContext //SP.getString(R.string.key_language, Locale.getDefault().language) private fun currentLocale(context: Context): Locale { - val language = currentLanguage(context) + val language = selectedLanguage(context) + if (language == "default") return Locale.getDefault() + var locale = Locale(language) if (language.contains("_")) { // language with country like pt_BR defined in arrays.xml @@ -27,8 +28,10 @@ object LocaleHelper { return locale } - @Suppress("DEPRECATION") fun update(context: Context) { + // no action for system default language + if (selectedLanguage(context) == "default") return + val locale = currentLocale(context) Locale.setDefault(locale) val resources = context.resources @@ -39,20 +42,18 @@ object LocaleHelper { resources.updateConfiguration(configuration, resources.displayMetrics) } - fun wrap(ctx: Context): ContextWrapper { + fun wrap(ctx: Context): Context { + // no action for system default language + if (selectedLanguage(ctx) == "default") return ctx + val res = ctx.resources val configuration = res.configuration val newLocale = currentLocale(ctx) - val context = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - configuration.setLocale(newLocale) - val localeList = LocaleList(newLocale) - LocaleList.setDefault(localeList) - configuration.locales = localeList - ctx.createConfigurationContext(configuration) - } else { - configuration.setLocale(newLocale) - ctx.createConfigurationContext(configuration) - } + configuration.setLocale(newLocale) + val localeList = LocaleList(newLocale) + LocaleList.setDefault(localeList) + configuration.locales = localeList + val context = ctx.createConfigurationContext(configuration) return ContextWrapper(context) } } \ No newline at end of file