Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
848ac2adbd
31 changed files with 150 additions and 131 deletions
|
@ -407,6 +407,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
, 'bg': bg
|
, 'bg': bg
|
||||||
, 'tick': tick
|
, 'tick': tick
|
||||||
, 'eventualBG': eventualBG
|
, 'eventualBG': eventualBG
|
||||||
|
, 'targetBG': target_bg
|
||||||
, 'insulinReq': 0
|
, '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)
|
, '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
|
, 'deliverAt' : deliverAt // The time at which the microbolus should be delivered
|
||||||
|
|
|
@ -49,7 +49,7 @@ import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicato
|
||||||
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
import info.nightscout.androidaps.setupwizard.SetupWizardActivity
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission
|
import info.nightscout.androidaps.utils.AndroidPermission
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
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.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
|
import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest
|
||||||
|
|
|
@ -37,7 +37,7 @@ import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
|
||||||
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver;
|
||||||
import info.nightscout.androidaps.services.Intents;
|
import info.nightscout.androidaps.services.Intents;
|
||||||
import info.nightscout.androidaps.utils.ActivityMonitor;
|
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;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
public class MainApp extends DaggerApplication {
|
public class MainApp extends DaggerApplication {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import android.os.Bundle
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import info.nightscout.androidaps.R
|
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 info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import dagger.android.support.DaggerAppCompatActivity
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore
|
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 info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
|
@ -1531,7 +1531,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
//add last one without duration
|
//add last one without duration
|
||||||
ProfileSwitch last = getLastProfileSwitchWithoutDuration();
|
ProfileSwitch last = getLastProfileSwitchWithoutDuration();
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
if (!profileSwitches.contains(last))
|
if (!isInList(profileSwitches, last))
|
||||||
profileSwitches.add(last);
|
profileSwitches.add(last);
|
||||||
}
|
}
|
||||||
return profileSwitches;
|
return profileSwitches;
|
||||||
|
@ -1541,6 +1541,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isInList(List<ProfileSwitch> profileSwitches, ProfileSwitch last) {
|
||||||
|
for (ProfileSwitch ps : profileSwitches) {
|
||||||
|
if (ps.isEqual(last)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ProfileSwitch getLastProfileSwitchWithoutDuration() {
|
private ProfileSwitch getLastProfileSwitchWithoutDuration() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -259,8 +259,8 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("low_temptarget_lowers_sensitivity", false);
|
mProfile.put("low_temptarget_lowers_sensitivity", false);
|
||||||
|
|
||||||
|
|
||||||
mProfile.put("sensitivity_raises_target", SMBDefaults.sensitivity_raises_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", SMBDefaults.resistance_lowers_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("adv_target_adjustments", SMBDefaults.adv_target_adjustments);
|
||||||
mProfile.put("exercise_mode", SMBDefaults.exercise_mode);
|
mProfile.put("exercise_mode", SMBDefaults.exercise_mode);
|
||||||
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
|
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
|
||||||
|
|
|
@ -51,6 +51,9 @@ public class DetermineBasalResultSMB extends APSResult {
|
||||||
} else {
|
} else {
|
||||||
smb = 0d;
|
smb = 0d;
|
||||||
}
|
}
|
||||||
|
if (result.has("targetBG")) {
|
||||||
|
targetBG = result.getDouble("targetBG");
|
||||||
|
}
|
||||||
|
|
||||||
if (result.has("deliverAt")) {
|
if (result.has("deliverAt")) {
|
||||||
String date = result.getString("deliverAt");
|
String date = result.getString("deliverAt");
|
||||||
|
|
|
@ -108,7 +108,7 @@ class PluginStore @Inject constructor(
|
||||||
(activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true)
|
(activeProfile as PluginBase).setPluginEnabled(PluginType.PROFILE, true)
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface")
|
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting ProfileInterface")
|
||||||
}
|
}
|
||||||
setFragmentVisiblities((activeSensitivity as PluginBase).name, pluginsInCategory, PluginType.PROFILE)
|
setFragmentVisiblities((activeProfile as PluginBase).name, pluginsInCategory, PluginType.PROFILE)
|
||||||
|
|
||||||
// PluginType.BGSOURCE
|
// PluginType.BGSOURCE
|
||||||
pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE)
|
pluginsInCategory = getSpecificPluginsList(PluginType.BGSOURCE)
|
||||||
|
|
|
@ -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.PrefsFormatsHandler
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey
|
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsMetadataKey
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.formats.PrefsStatus
|
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 info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import kotlinx.android.synthetic.main.maintenance_importlist_activity.*
|
import kotlinx.android.synthetic.main.maintenance_importlist_activity.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
|
@ -331,7 +331,7 @@ public class NSDeviceStatus {
|
||||||
// test warning level
|
// test warning level
|
||||||
int level = Levels.INFO;
|
int level = Levels.INFO;
|
||||||
long now = System.currentTimeMillis();
|
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;
|
level = Levels.URGENT;
|
||||||
else if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_staledatavalue, 16) * 60 * 1000L < now)
|
else if (deviceStatusOpenAPSData.clockSuggested != 0 && deviceStatusOpenAPSData.clockSuggested + sp.getInt(R.string.key_nsalarm_staledatavalue, 16) * 60 * 1000L < now)
|
||||||
level = Levels.WARN;
|
level = Levels.WARN;
|
||||||
|
|
|
@ -842,33 +842,42 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAnnouncement(JSONObject announcement) {
|
private void handleAnnouncement(JSONObject announcement) {
|
||||||
NSAlarm nsAlarm = new NSAlarm(announcement);
|
boolean defaultVal = config.getNSCLIENT();
|
||||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
|
||||||
rxBus.send(new EventNewNotification(notification));
|
NSAlarm nsAlarm = new NSAlarm(announcement);
|
||||||
rxBus.send(new EventNSClientNewLog("ANNOUNCEMENT", JsonHelper.safeGetString(announcement, "message", "received")));
|
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
||||||
aapsLogger.debug(LTag.NSCLIENT, announcement.toString());
|
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) {
|
private void handleAlarm(JSONObject alarm) {
|
||||||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
boolean defaultVal = config.getNSCLIENT();
|
||||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) {
|
||||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||||
rxBus.send(new EventNewNotification(notification));
|
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) {
|
private void handleUrgentAlarm(JSONObject alarm) {
|
||||||
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
boolean defaultVal = config.getNSCLIENT();
|
||||||
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
if (sp.getBoolean(R.string.key_ns_alarms, defaultVal)) {
|
||||||
NSAlarm nsAlarm = new NSAlarm(alarm);
|
long snoozedTo = sp.getLong(R.string.key_snoozedTo, 0L);
|
||||||
Notification notification = new NotificationWithAction(injector, nsAlarm);
|
if (snoozedTo == 0L || System.currentTimeMillis() > snoozedTo) {
|
||||||
rxBus.send(new EventNewNotification(notification));
|
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) {
|
public void handleNewCal(JSONArray cals, boolean isDelta) {
|
||||||
|
|
|
@ -646,6 +646,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
} else {
|
} else {
|
||||||
overview_apsmode_text?.visibility = View.GONE
|
overview_apsmode_text?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
val lastRun = loopPlugin.lastRun
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
val tempTarget = treatmentsPlugin.tempTargetFromHistory
|
val tempTarget = treatmentsPlugin.tempTargetFromHistory
|
||||||
|
@ -654,9 +655,18 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
|
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)
|
overview_temptarget?.text = Profile.toTargetRangeString(tempTarget.low, tempTarget.high, Constants.MGDL, units) + " " + DateUtil.untilString(tempTarget.end(), resourceHelper)
|
||||||
} else {
|
} else {
|
||||||
overview_temptarget?.setTextColor(resourceHelper.gc(R.color.ribbonTextDefault))
|
// If the target is not the same as set in the profile then oref has overridden it
|
||||||
overview_temptarget?.setBackgroundColor(resourceHelper.gc(R.color.ribbonDefault))
|
val targetUsed = lastRun?.constraintsProcessed?.targetBG ?: 0.0
|
||||||
overview_temptarget?.text = Profile.toTargetRangeString(profile.targetLowMgdl, profile.targetHighMgdl, Constants.MGDL, units)
|
|
||||||
|
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
|
// Basal, TBR
|
||||||
|
@ -677,7 +687,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
if (activeTemp != null)
|
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)
|
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
|
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
|
// Extended bolus
|
||||||
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||||
|
@ -741,7 +751,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
overview_cob?.text = cobText
|
overview_cob?.text = cobText
|
||||||
|
|
||||||
val lastRun = loopPlugin.lastRun
|
|
||||||
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
||||||
|
|
||||||
// pump status from ns
|
// pump status from ns
|
||||||
|
@ -759,7 +768,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
// Sensitivity
|
// Sensitivity
|
||||||
if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) {
|
if (sp.getBoolean(R.string.key_openapsama_useautosens, false) && constraintChecker.isAutosensModeEnabled().value()) {
|
||||||
overview_sensitivity_icon.setImageResource(R.drawable.ic_swap_vert_black_48dp_green)
|
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)
|
overview_sensitivity_icon.setImageResource(R.drawable.ic_x_swap_vert_48px_green)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,6 @@ class NotificationWithAction constructor(
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
@Inject lateinit var nsClientPlugin: NSClientPlugin
|
||||||
|
|
||||||
private var nsAlarm: NSAlarm? = null
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
injector.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +34,6 @@ class NotificationWithAction constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor (injector: HasAndroidInjector, nsAlarm: NSAlarm) : this(injector) {
|
constructor (injector: HasAndroidInjector, nsAlarm: NSAlarm) : this(injector) {
|
||||||
this.nsAlarm = nsAlarm
|
|
||||||
date = System.currentTimeMillis()
|
date = System.currentTimeMillis()
|
||||||
when (nsAlarm.level()) {
|
when (nsAlarm.level()) {
|
||||||
0 -> {
|
0 -> {
|
||||||
|
@ -50,14 +47,14 @@ class NotificationWithAction constructor(
|
||||||
id = NSALARM
|
id = NSALARM
|
||||||
level = NORMAL
|
level = NORMAL
|
||||||
text = nsAlarm.title()
|
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 -> {
|
2 -> {
|
||||||
id = NSURGENTALARM
|
id = NSURGENTALARM
|
||||||
level = URGENT
|
level = URGENT
|
||||||
text = nsAlarm.title()
|
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
|
buttonText = R.string.snooze
|
||||||
|
|
|
@ -597,6 +597,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
bolusMessage.setDuration(0);
|
bolusMessage.setDuration(0);
|
||||||
bolusMessage.setExtendedAmount(0);
|
bolusMessage.setExtendedAmount(0);
|
||||||
bolusMessage.setImmediateAmount(insulin);
|
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();
|
bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
||||||
bolusCancelled = false;
|
bolusCancelled = false;
|
||||||
}
|
}
|
||||||
|
@ -720,7 +721,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
PumpEnactResult cancelTBRResult = cancelTempBasalOnly();
|
PumpEnactResult cancelTBRResult = cancelTempBasalOnly();
|
||||||
if (cancelTBRResult.success) {
|
if (cancelTBRResult.success) {
|
||||||
PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D
|
PumpEnactResult ebResult = setExtendedBolusOnly((absoluteRate - getBaseBasalRate()) / 60D
|
||||||
* ((double) durationInMinutes), durationInMinutes);
|
* ((double) durationInMinutes), durationInMinutes,
|
||||||
|
sp.getBoolean(R.string.key_disable_vibration_auto,false));
|
||||||
if (ebResult.success) {
|
if (ebResult.success) {
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -798,7 +800,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
PumpEnactResult result = cancelExtendedBolusOnly();
|
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 {
|
try {
|
||||||
fetchStatus();
|
fetchStatus();
|
||||||
readHistory();
|
readHistory();
|
||||||
|
@ -812,7 +814,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolusOnly(Double insulin, Integer durationInMinutes, boolean disableVibration) {
|
||||||
PumpEnactResult result = new PumpEnactResult(getInjector());
|
PumpEnactResult result = new PumpEnactResult(getInjector());
|
||||||
try {
|
try {
|
||||||
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
|
DeliverBolusMessage bolusMessage = new DeliverBolusMessage();
|
||||||
|
@ -820,6 +822,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
bolusMessage.setDuration(durationInMinutes);
|
bolusMessage.setDuration(durationInMinutes);
|
||||||
bolusMessage.setExtendedAmount(insulin);
|
bolusMessage.setExtendedAmount(insulin);
|
||||||
bolusMessage.setImmediateAmount(0);
|
bolusMessage.setImmediateAmount(0);
|
||||||
|
bolusMessage.setVibration(disableVibration);
|
||||||
int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
int bolusID = connectionService.requestMessage(bolusMessage).await().getBolusId();
|
||||||
InsightBolusID insightBolusID = new InsightBolusID();
|
InsightBolusID insightBolusID = new InsightBolusID();
|
||||||
insightBolusID.bolusID = bolusID;
|
insightBolusID.bolusID = bolusID;
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class DeliverBolusMessage extends AppLayerMessage {
|
||||||
private double extendedAmount;
|
private double extendedAmount;
|
||||||
private int duration;
|
private int duration;
|
||||||
private int bolusId;
|
private int bolusId;
|
||||||
|
private boolean disableVibration = false;
|
||||||
|
|
||||||
public DeliverBolusMessage() {
|
public DeliverBolusMessage() {
|
||||||
super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL);
|
super(MessagePriority.NORMAL, true, true, Service.REMOTE_CONTROL);
|
||||||
|
@ -22,7 +23,11 @@ public class DeliverBolusMessage extends AppLayerMessage {
|
||||||
@Override
|
@Override
|
||||||
protected ByteBuf getData() {
|
protected ByteBuf getData() {
|
||||||
ByteBuf byteBuf = new ByteBuf(22);
|
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(BolusTypeIDs.IDS.getID(bolusType));
|
||||||
byteBuf.putUInt16LE(31);
|
byteBuf.putUInt16LE(31);
|
||||||
byteBuf.putUInt16LE(0);
|
byteBuf.putUInt16LE(0);
|
||||||
|
@ -57,6 +62,8 @@ public class DeliverBolusMessage extends AppLayerMessage {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVibration(boolean disableVibration) { this.disableVibration = disableVibration;}
|
||||||
|
|
||||||
public int getBolusId() {
|
public int getBolusId() {
|
||||||
return bolusId;
|
return bolusId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import info.nightscout.androidaps.setupwizard.elements.*
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission
|
import info.nightscout.androidaps.utils.AndroidPermission
|
||||||
import info.nightscout.androidaps.utils.CryptoUtil
|
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.extensions.isRunningTest
|
||||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
|
@ -20,7 +20,7 @@ import info.nightscout.androidaps.setupwizard.elements.SWItem
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission
|
import info.nightscout.androidaps.utils.AndroidPermission
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
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.show
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog.showConfirmation
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.utils;
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
import android.os.Build;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
|
||||||
|
@ -8,7 +7,6 @@ import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -24,33 +22,24 @@ public class JSONFormatter {
|
||||||
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
||||||
try {
|
try {
|
||||||
if (jsonString.equals("undefined"))
|
if (jsonString.equals("undefined"))
|
||||||
return Html.fromHtml("undefined");
|
return HtmlHelper.INSTANCE.fromHtml("undefined");
|
||||||
else if (jsonString.getBytes()[0] == '[')
|
else if (jsonString.getBytes()[0] == '[')
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONArray(jsonString), 0));
|
||||||
return Html.fromHtml(visitor.visit(new JSONArray(jsonString), 0), Html.FROM_HTML_MODE_COMPACT);
|
else
|
||||||
} else {
|
return HtmlHelper.INSTANCE.fromHtml(visitor.visit(new JSONObject(jsonString), 0));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
return Html.fromHtml("");
|
return HtmlHelper.INSTANCE.fromHtml("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned format(final JSONObject object) {
|
public static Spanned format(final JSONObject object) {
|
||||||
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
||||||
try {
|
try {
|
||||||
return Html.fromHtml(visitor.visit(object, 0));
|
return HtmlHelper.INSTANCE.fromHtml(visitor.visit(object, 0));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
return Html.fromHtml("");
|
return HtmlHelper.INSTANCE.fromHtml("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="languagesArray">
|
<string-array name="languagesArray">
|
||||||
|
<item>@string/default_lang</item>
|
||||||
<item>@string/en_lang</item>
|
<item>@string/en_lang</item>
|
||||||
<item>@string/af_lang</item>
|
<item>@string/af_lang</item>
|
||||||
<item>@string/bg_lang</item>
|
<item>@string/bg_lang</item>
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
<item>@string/zh_lang</item>
|
<item>@string/zh_lang</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="languagesValues" translatable="false">
|
<string-array name="languagesValues" translatable="false">
|
||||||
|
<item>default</item>
|
||||||
<item>en</item>
|
<item>en</item>
|
||||||
<item>af</item>
|
<item>af</item>
|
||||||
<item>bg</item>
|
<item>bg</item>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="default_lang" translatable="false">System default</string>
|
||||||
<string name="en_lang" translatable="false">English</string>
|
<string name="en_lang" translatable="false">English</string>
|
||||||
<string name="cs_lang" translatable="false">Czech</string>
|
<string name="cs_lang" translatable="false">Czech</string>
|
||||||
<string name="af_lang" translatable="false">Afrikaans</string>
|
<string name="af_lang" translatable="false">Afrikaans</string>
|
||||||
|
@ -548,20 +549,12 @@
|
||||||
<string name="doprofileswitch">Do Profile Switch</string>
|
<string name="doprofileswitch">Do Profile Switch</string>
|
||||||
<string name="careportal_pbage_label">Pump battery age</string>
|
<string name="careportal_pbage_label">Pump battery age</string>
|
||||||
<string name="ns_alarmoptions">Alarm options</string>
|
<string name="ns_alarmoptions">Alarm options</string>
|
||||||
<string name="key_nsalarm_urgent_high" translatable="false">nsalarm_urgent_high</string>
|
<string name="key_ns_announcements" translatable="false">ns_announcements</string>
|
||||||
<string name="key_nsalarm_high" translatable="false">nsalarm_high</string>
|
<string name="key_ns_alarms" translatable="false">ns_alarms</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_nsalarm_staledatavalue" translatable="false">nsalarm_staledatavalue</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="key_nsalarm_urgent_staledatavalue" translatable="false">nsalarm_urgent_staledatavalue</string>
|
||||||
<string name="nsalarm_urgenthigh">Urgent high</string>
|
<string name="ns_alarms">Create notifications from NS alarms</string>
|
||||||
<string name="nsalarm_high">High</string>
|
<string name="ns_announcements">Create notifications from NS announcements</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="nsalarm_staledatavalue_label">Stale data threshold [min]</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="nsalarm_urgent_staledatavalue_label">Urgent stale data threshold [min]</string>
|
||||||
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
|
<string name="openapsama_autosens_period">Interval for autosens [h]</string>
|
||||||
|
@ -1016,6 +1009,12 @@
|
||||||
<string name="log_alerts">Log alerts</string>
|
<string name="log_alerts">Log alerts</string>
|
||||||
<string name="enable_tbr_emulation">Enable TBR emulation</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="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="disconnect_delay">Disconnect delay [s]</string>
|
||||||
<string name="serial_number">Serial number</string>
|
<string name="serial_number">Serial number</string>
|
||||||
<string name="release_software_version">Release software version</string>
|
<string name="release_software_version">Release software version</string>
|
||||||
|
|
|
@ -48,6 +48,18 @@
|
||||||
android:summary="@string/enable_tbr_emulation_summary"
|
android:summary="@string/enable_tbr_emulation_summary"
|
||||||
android:title="@string/enable_tbr_emulation" />
|
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
|
<EditTextPreference
|
||||||
android:defaultValue="5"
|
android:defaultValue="5"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
|
|
|
@ -48,6 +48,12 @@
|
||||||
android:summary="@string/enable_tbr_emulation_summary"
|
android:summary="@string/enable_tbr_emulation_summary"
|
||||||
android:title="@string/enable_tbr_emulation" />
|
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
|
<EditTextPreference
|
||||||
android:defaultValue="5"
|
android:defaultValue="5"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
|
|
|
@ -42,29 +42,12 @@
|
||||||
android:title="@string/ns_alarmoptions">
|
android:title="@string/ns_alarmoptions">
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:key="@string/key_ns_alarms"
|
||||||
android:key="@string/key_nsalarm_urgent_high"
|
android:title="@string/ns_alarms" />
|
||||||
android:title="@string/nsalarm_urgenthigh" />
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:key="@string/key_ns_announcements"
|
||||||
android:key="@string/key_nsalarm_high"
|
android:title="@string/ns_announcements" />
|
||||||
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" />
|
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:defaultValue="16"
|
android:defaultValue="16"
|
||||||
|
@ -79,11 +62,6 @@
|
||||||
validate:minNumber="15"
|
validate:minNumber="15"
|
||||||
validate:testType="numericRange" />
|
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
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:defaultValue="31"
|
android:defaultValue="31"
|
||||||
android:digits="0123456789"
|
android:digits="0123456789"
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.android.support.DaggerAppCompatActivity
|
import dagger.android.support.DaggerAppCompatActivity
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper
|
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||||
|
|
||||||
open class DialogAppCompatActivity : DaggerAppCompatActivity() {
|
open class DialogAppCompatActivity : DaggerAppCompatActivity() {
|
||||||
public override fun attachBaseContext(newBase: Context) {
|
public override fun attachBaseContext(newBase: Context) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import dagger.android.support.DaggerAppCompatActivity
|
import dagger.android.support.DaggerAppCompatActivity
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper
|
import info.nightscout.androidaps.utils.locale.LocaleHelper
|
||||||
|
|
||||||
//@Suppress("registered")
|
//@Suppress("registered")
|
||||||
open class NoSplashAppCompatActivity : DaggerAppCompatActivity() {
|
open class NoSplashAppCompatActivity : DaggerAppCompatActivity() {
|
||||||
|
|
|
@ -530,7 +530,6 @@ public class Profile {
|
||||||
public double getTargetMgdl(int timeAsSeconds) {
|
public double getTargetMgdl(int timeAsSeconds) {
|
||||||
return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units);
|
return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetLowMgdl() {
|
public double getTargetLowMgdl() {
|
||||||
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units);
|
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package info.nightscout.androidaps.events
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
class EventRebuildTabs @JvmOverloads constructor(var recreate: Boolean = false) : Event()
|
class EventRebuildTabs constructor(var recreate: Boolean = false) : Event()
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class APSResult {
|
||||||
public boolean hasPredictions = false;
|
public boolean hasPredictions = false;
|
||||||
public double smb = 0d; // super micro bolus in units
|
public double smb = 0d; // super micro bolus in units
|
||||||
public long deliverAt = 0;
|
public long deliverAt = 0;
|
||||||
|
public double targetBG = 0d;
|
||||||
|
|
||||||
public Constraint<Double> inputConstraints;
|
public Constraint<Double> inputConstraints;
|
||||||
|
|
||||||
|
@ -184,6 +185,7 @@ public class APSResult {
|
||||||
newResult.smbConstraint = smbConstraint;
|
newResult.smbConstraint = smbConstraint;
|
||||||
newResult.percent = percent;
|
newResult.percent = percent;
|
||||||
newResult.usePercent = usePercent;
|
newResult.usePercent = usePercent;
|
||||||
|
newResult.targetBG = targetBG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,6 @@ import android.text.Spanned
|
||||||
|
|
||||||
object HtmlHelper {
|
object HtmlHelper {
|
||||||
fun fromHtml(source: String): Spanned {
|
fun fromHtml(source: String): Spanned {
|
||||||
// API level 24 to replace call
|
return Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY)
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
return when {
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> Html.fromHtml(source, Html.FROM_HTML_MODE_LEGACY)
|
|
||||||
else -> Html.fromHtml(source)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,22 +1,23 @@
|
||||||
package info.nightscout.androidaps.utils
|
package info.nightscout.androidaps.utils.locale
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
import android.os.Build
|
|
||||||
import android.os.LocaleList
|
import android.os.LocaleList
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
object LocaleHelper {
|
object LocaleHelper {
|
||||||
private fun currentLanguage(context: Context): String =
|
private fun selectedLanguage(context: Context): String =
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "en")
|
PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "default")
|
||||||
?: "en"
|
?: "default"
|
||||||
// injection not possible because of use in attachBaseContext
|
// injection not possible because of use in attachBaseContext
|
||||||
//SP.getString(R.string.key_language, Locale.getDefault().language)
|
//SP.getString(R.string.key_language, Locale.getDefault().language)
|
||||||
|
|
||||||
private fun currentLocale(context: Context): Locale {
|
private fun currentLocale(context: Context): Locale {
|
||||||
val language = currentLanguage(context)
|
val language = selectedLanguage(context)
|
||||||
|
if (language == "default") return Locale.getDefault()
|
||||||
|
|
||||||
var locale = Locale(language)
|
var locale = Locale(language)
|
||||||
if (language.contains("_")) {
|
if (language.contains("_")) {
|
||||||
// language with country like pt_BR defined in arrays.xml
|
// language with country like pt_BR defined in arrays.xml
|
||||||
|
@ -27,8 +28,10 @@ object LocaleHelper {
|
||||||
return locale
|
return locale
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
fun update(context: Context) {
|
fun update(context: Context) {
|
||||||
|
// no action for system default language
|
||||||
|
if (selectedLanguage(context) == "default") return
|
||||||
|
|
||||||
val locale = currentLocale(context)
|
val locale = currentLocale(context)
|
||||||
Locale.setDefault(locale)
|
Locale.setDefault(locale)
|
||||||
val resources = context.resources
|
val resources = context.resources
|
||||||
|
@ -39,20 +42,18 @@ object LocaleHelper {
|
||||||
resources.updateConfiguration(configuration, resources.displayMetrics)
|
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 res = ctx.resources
|
||||||
val configuration = res.configuration
|
val configuration = res.configuration
|
||||||
val newLocale = currentLocale(ctx)
|
val newLocale = currentLocale(ctx)
|
||||||
val context = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
configuration.setLocale(newLocale)
|
||||||
configuration.setLocale(newLocale)
|
val localeList = LocaleList(newLocale)
|
||||||
val localeList = LocaleList(newLocale)
|
LocaleList.setDefault(localeList)
|
||||||
LocaleList.setDefault(localeList)
|
configuration.locales = localeList
|
||||||
configuration.locales = localeList
|
val context = ctx.createConfigurationContext(configuration)
|
||||||
ctx.createConfigurationContext(configuration)
|
|
||||||
} else {
|
|
||||||
configuration.setLocale(newLocale)
|
|
||||||
ctx.createConfigurationContext(configuration)
|
|
||||||
}
|
|
||||||
return ContextWrapper(context)
|
return ContextWrapper(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue