This commit is contained in:
Milos Kozak 2020-05-24 17:51:10 +02:00
commit 848ac2adbd
31 changed files with 150 additions and 131 deletions

View file

@ -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

View file

@ -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

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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<ProfileSwitch> profileSwitches, ProfileSwitch last) {
for (ProfileSwitch ps : profileSwitches) {
if (ps.isEqual(last)) return true;
}
return false;
}
@Nullable
private ProfileSwitch getLastProfileSwitchWithoutDuration() {
try {

View file

@ -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);

View file

@ -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");

View file

@ -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)

View file

@ -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

View file

@ -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;

View file

@ -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) {

View file

@ -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
}
}
}
}
}

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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("");
}
}

View file

@ -22,6 +22,7 @@
</string-array>
<string-array name="languagesArray">
<item>@string/default_lang</item>
<item>@string/en_lang</item>
<item>@string/af_lang</item>
<item>@string/bg_lang</item>
@ -45,6 +46,7 @@
<item>@string/zh_lang</item>
</string-array>
<string-array name="languagesValues" translatable="false">
<item>default</item>
<item>en</item>
<item>af</item>
<item>bg</item>

View file

@ -1,4 +1,5 @@
<resources>
<string name="default_lang" translatable="false">System default</string>
<string name="en_lang" translatable="false">English</string>
<string name="cs_lang" translatable="false">Czech</string>
<string name="af_lang" translatable="false">Afrikaans</string>
@ -548,20 +549,12 @@
<string name="doprofileswitch">Do Profile Switch</string>
<string name="careportal_pbage_label">Pump battery age</string>
<string name="ns_alarmoptions">Alarm options</string>
<string name="key_nsalarm_urgent_high" translatable="false">nsalarm_urgent_high</string>
<string name="key_nsalarm_high" translatable="false">nsalarm_high</string>
<string name="key_nsalarm_low" translatable="false">nsalarm_low</string>
<string name="key_nsalarm_urgent_low" translatable="false">nsalarm_urgent_low</string>
<string name="key_nsalarm_staledata" translatable="false">nsalarm_staledata</string>
<string name="key_nsalarm_urgent_staledata" translatable="false">nsalarm_urgent_staledata</string>
<string name="key_ns_announcements" translatable="false">ns_announcements</string>
<string name="key_ns_alarms" translatable="false">ns_alarms</string>
<string name="key_nsalarm_staledatavalue" translatable="false">nsalarm_staledatavalue</string>
<string name="key_nsalarm_urgent_staledatavalue" translatable="false">nsalarm_urgent_staledatavalue</string>
<string name="nsalarm_urgenthigh">Urgent high</string>
<string name="nsalarm_high">High</string>
<string name="nsalarm_low">Low</string>
<string name="nsalarm_urgentlow">Urgent low</string>
<string name="nsalarm_staledata">Stale data</string>
<string name="nsalarm_urgentstaledata">Urgent stale data</string>
<string name="ns_alarms">Create notifications from NS alarms</string>
<string name="ns_announcements">Create notifications from NS announcements</string>
<string name="nsalarm_staledatavalue_label">Stale data threshold [min]</string>
<string name="nsalarm_urgent_staledatavalue_label">Urgent stale data threshold [min]</string>
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
@ -1016,6 +1009,12 @@
<string name="log_alerts">Log alerts</string>
<string name="enable_tbr_emulation">Enable TBR emulation</string>
<string name="enable_tbr_emulation_summary">Use extended boluses instead of TBRs to bypass the 250%% limit</string>
<string name="key_disable_vibration" translatable="false">insight_disable_vibration</string>
<string name="disable_vibration">Disable vibrations on manual bolus delivery</string>
<string name="disable_vibration_summary">For bolus and extended bolus (only available with Insight firmware 3.x)</string>
<string name="key_disable_vibration_auto" translatable="false">insight_disable_vibration_auto</string>
<string name="disable_vibration_auto">Disable vibrations on automated bolus delivery</string>
<string name="disable_vibration_auto_summary">For SMB and Temp Basal with TBR emulation (only available with Insight firmware 3.x)</string>
<string name="disconnect_delay">Disconnect delay [s]</string>
<string name="serial_number">Serial number</string>
<string name="release_software_version">Release software version</string>

View file

@ -48,6 +48,18 @@
android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration_auto"
android:summary="@string/disable_vibration_auto_summary"
android:title="@string/disable_vibration_auto" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"

View file

@ -48,6 +48,12 @@
android:summary="@string/enable_tbr_emulation_summary"
android:title="@string/enable_tbr_emulation" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_disable_vibration"
android:summary="@string/disable_vibration_summary"
android:title="@string/disable_vibration" />
<EditTextPreference
android:defaultValue="5"
android:inputType="number"

View file

@ -42,29 +42,12 @@
android:title="@string/ns_alarmoptions">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_high"
android:title="@string/nsalarm_urgenthigh" />
android:key="@string/key_ns_alarms"
android:title="@string/ns_alarms" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_high"
android:title="@string/nsalarm_high" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_low"
android:title="@string/nsalarm_low" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_low"
android:title="@string/nsalarm_urgentlow" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_staledata"
android:title="@string/nsalarm_staledata" />
android:key="@string/key_ns_announcements"
android:title="@string/ns_announcements" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="16"
@ -79,11 +62,6 @@
validate:minNumber="15"
validate:testType="numericRange" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_staledata"
android:title="@string/nsalarm_urgentstaledata" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="31"
android:digits="0123456789"

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.activities
import android.content.Context
import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.utils.LocaleHelper
import info.nightscout.androidaps.utils.locale.LocaleHelper
open class DialogAppCompatActivity : DaggerAppCompatActivity() {
public override fun attachBaseContext(newBase: Context) {

View file

@ -4,7 +4,7 @@ import android.content.Context
import android.os.Bundle
import dagger.android.support.DaggerAppCompatActivity
import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.utils.LocaleHelper
import info.nightscout.androidaps.utils.locale.LocaleHelper
//@Suppress("registered")
open class NoSplashAppCompatActivity : DaggerAppCompatActivity() {

View file

@ -530,7 +530,6 @@ public class Profile {
public double getTargetMgdl(int timeAsSeconds) {
return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units);
}
public double getTargetLowMgdl() {
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units);
}

View file

@ -1,3 +1,3 @@
package info.nightscout.androidaps.events
class EventRebuildTabs @JvmOverloads constructor(var recreate: Boolean = false) : Event()
class EventRebuildTabs constructor(var recreate: Boolean = false) : Event()

View file

@ -62,6 +62,7 @@ public class APSResult {
public boolean hasPredictions = false;
public double smb = 0d; // super micro bolus in units
public long deliverAt = 0;
public double targetBG = 0d;
public Constraint<Double> inputConstraints;
@ -184,6 +185,7 @@ public class APSResult {
newResult.smbConstraint = smbConstraint;
newResult.percent = percent;
newResult.usePercent = usePercent;
newResult.targetBG = targetBG;
}

View file

@ -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)
}
}

View file

@ -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)
}
}