Merge pull request #340 from MilosKozak/move-to-range-in-profile

Move to range in profile - WIP
This commit is contained in:
Milos Kozak 2017-08-06 11:21:55 +02:00 committed by GitHub
commit 1bfc0011a1
16 changed files with 46 additions and 109 deletions

View file

@ -33,14 +33,6 @@ public class Constants {
public static final int CPP_MIN_PERCENTAGE = 50;
public static final int CPP_MAX_PERCENTAGE = 200;
// Defaults for settings
public static final Double MAX_BG_DEFAULT_MGDL = 180d;
public static final Double MAX_BG_DEFAULT_MMOL = 10d;
public static final Double MIN_BG_DEFAULT_MGDL = 100d;
public static final Double MIN_BG_DEFAULT_MMOL = 5d;
public static final Double TARGET_BG_DEFAULT_MGDL = 150d;
public static final Double TARGET_BG_DEFAULT_MMOL = 7d;
// Very Hard Limits Ranges
// First value is the Lowest and second value is the Highest a Limit can define
public static final int[] VERY_HARD_LIMIT_MIN_BG = {72,180};

View file

@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Services.AlarmSoundService;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui;
@ -79,6 +80,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Manifest.permission.WRITE_EXTERNAL_STORAGE}, CASE_STORAGE);
}
askForBatteryOptimizationPermission();
checkUpgradeToProfileTarget();
if (Config.logFunctionCalls)
log.debug("onCreate");
@ -154,6 +156,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
}
private void checkUpgradeToProfileTarget() { // TODO: can be removed in the future
boolean oldKeyExists = SP.contains("openapsma_min_bg");
if (oldKeyExists) {
Profile profile = MainApp.getConfigBuilder().getProfile();
String oldRange = SP.getDouble("openapsma_min_bg", 0d) + " - " + SP.getDouble("openapsma_max_bg", 0d);
String newRange = "";
if (profile != null) {
newRange = profile.getTargetLow() + " - " + profile.getTargetHigh();
}
String message = "Target range is changed in current version.\n\nIt's not taken from preferences but from profile.\n\n!!! REVIEW YOUR SETTINGS !!!";
message += "\n\nOld settings: " + oldRange;
message += "\nProfile settings: " + newRange;
OKDialog.show(this, "Target range change", message, new Runnable() {
@Override
public void run() {
SP.remove("openapsma_min_bg");
SP.remove("openapsma_max_bg");
SP.remove("openapsma_target_bg");
}
});
}
}
//check for sms permission if enable in prefernces
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {

View file

@ -158,22 +158,11 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
String units = profile.getUnits();
double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SP.getDouble("openapsma_max_basal", 1d);
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d);
@ -248,6 +237,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalAdapterAMAJS.release();
Date now = new Date();
try {
determineBasalResultAMA.json.put("timestamp", DateUtil.toISOString(now));
} catch (JSONException e) {

View file

@ -156,22 +156,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
String units = profile.getUnits();
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();
double maxIob = SP.getDouble("openapsma_max_iob", 1.5d);
double maxBasal = SafeParse.stringToDouble(SP.getString("openapsma_max_basal", "1"));
double minBg = Profile.toMgdl(SP.getDouble("openapsma_min_bg", minBgDefault), units);
double maxBg = Profile.toMgdl(SP.getDouble("openapsma_max_bg", maxBgDefault), units);
double targetBg = Profile.toMgdl(SP.getDouble("openapsma_target_bg", targetBgDefault), units);
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
double targetBg = (minBg + maxBg) / 2;
minBg = Round.roundTo(minBg, 0.1d);
maxBg = Round.roundTo(maxBg, 0.1d);

View file

@ -959,16 +959,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
else
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
} else {
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
}
tempTargetView.setTextColor(Color.WHITE);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
double low = SP.getDouble("openapsma_min_bg", minBgDefault);
double high = SP.getDouble("openapsma_max_bg", maxBgDefault);
double low = MainApp.getConfigBuilder().getProfile().getTargetLow();
double high = MainApp.getConfigBuilder().getProfile().getTargetHigh();
if (low == high)
tempTargetView.setText("" + low);
else

View file

@ -477,18 +477,9 @@ public class ActionStringHandler {
ret += "\n\n";
}
//Default Range/Target
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
Double targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!profile.getUnits().equals(Constants.MGDL)) {
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
ret += "DEFAULT RANGE: ";
ret += SP.getDouble("openapsma_min_bg", minBgDefault) + " - " + SP.getDouble("openapsma_max_bg", maxBgDefault);
ret += " target: " + SP.getDouble("openapsma_target_bg", targetBgDefault);
ret += profile.getTargetLow() + " - " + profile.getTargetHigh();
ret += " target: " + (profile.getTargetLow() + profile.getTargetHigh()) / 2;
return ret;
}

View file

@ -88,12 +88,6 @@ public class SP {
editor.apply();
}
static public void removeBoolean(int resourceID) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(MainApp.sResources.getString(resourceID));
editor.apply();
}
static public void putLong(String key, long value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putLong(key, value);
@ -130,9 +124,15 @@ public class SP {
editor.apply();
}
static public void removeString(int resourceID) {
static public void remove(int resourceID) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(MainApp.sResources.getString(resourceID));
editor.apply();
}
static public void remove(String key) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.remove(key);
editor.apply();
}
}

View file

@ -68,7 +68,6 @@
<string name="openapsma_nopump">Няма избана помпа</string>
<string name="nochangerequested">Не се изисква промяна</string>
<string name="openapsma_request_label">Искане</string>
<string name="openapsma_minbg_label">Долна граница(КЗ)</string>
<string name="rate">Стойност</string>
<string name="duration">Срок</string>
<string name="reason">Основание</string>
@ -204,8 +203,6 @@
<string name="el_lang">Greek</string>
<string name="it_lang">Italian</string>
<string name="ru_lang">Russian</string>
<string name="openapsma_low_summary">Мин. стойност, която е в границите</string>
<string name="openapsma_high_summary">Максималната стойност на КЗ за да бъде в границите.</string>
<string name="openapsma_maxbasal_title">Максимално позволен временен базал Е</string>
<string name="openapsma_maxbasal_summary">Макс. лимит на временен базал [Е/ч] </string>
<string name="openapsma_maxiob_title">Максимален IOB</string>
@ -311,7 +308,6 @@
<string name="objectives_5_gate">Една седмица успешно дневно използване с редовно въвеждане на въглехидрати</string>
<string name="objectives_6_objective">Активиране на допълнителни функции за дневно използване, включително и advanced meal assist </string>
<string name="youareonallowedlimit">Достигнахте лимита</string>
<string name="openapsma_target_bg">Целева стойност използвана в изчисленията</string>
<string name="noprofileselected">Няма избран профил</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>

View file

@ -104,7 +104,6 @@
<string name="openapsma_lastenact_label">Poslední provedení</string>
<string name="openapsma_lastrun_label">Poslední spuštění</string>
<string name="openapsma_mealdata_label">Data o jídle</string>
<string name="openapsma_minbg_label">Cílová nízká glykémie</string>
<string name="openapsma_noglucosedata">Nedostupná data o glykémiích</string>
<string name="openapsma_noprofile">Nedostupný profil</string>
<string name="openapsma_nopump">Žádná pumpa</string>
@ -184,8 +183,6 @@
<string name="nav_export">Exportovat nastavení</string>
<string name="nav_import">Importovat nastavení</string>
<string name="de_lang">German</string>
<string name="openapsma_high_summary">Maximální hodnota glykémie ještě v rozsahu</string>
<string name="openapsma_low_summary">Minimální hodnota glykémie ještě v rozsahu</string>
<string name="bg_lang">Bulgarian</string>
<string name="dismiss">POTVRDIT</string>
<string name="language">Jazyk</string>
@ -282,7 +279,6 @@
<string name="objectives_5_objective">Upravit bazály a koeficinty, když bude potřeba a povolit automatickou detekci citlivosti na inzulín</string>
<string name="objectives_6_objective">Povolit další fukce pro běžné používání jako AMA</string>
<string name="youareonallowedlimit">Dosaženo limitu</string>
<string name="openapsma_target_bg">Cílová hodnota pro výpočty</string>
<string name="bolusdelivering" formatted="false">Aplikováno %.2fU</string>
<string name="smscommunicator_loophasbeendisabled">Smyčka byla zakázána</string>
<string name="smscommunicator_loophasbeenenabled">Smyčka byla povolena</string>

View file

@ -128,7 +128,6 @@
<string name="openapsma_nopump">Keine Pumpe verfügbar</string>
<string name="openapsma_noprofile">Kein Profil verfügbar</string>
<string name="openapsma_noglucosedata">Keine BZ Daten verfügbar</string>
<string name="openapsma_minbg_label">Low target</string>
<string name="openapsma_mealdata_label">Mahlzeiten Daten</string>
<string name="openapsma_lastrun_label">Last run</string>
<string name="openapsma_lastenact_label">Last enacted</string>
@ -185,8 +184,6 @@
<string name="de_lang">Deutsch</string>
<string name="openapsma_maxbasal_summary">Max U/hr die man für eine Temp Basal setzen kann</string>
<string name="openapsma_maxiob_summary">Maximale Menge von nicht bolus IOB die OpenAPs abgeben kann</string>
<string name="openapsma_high_summary">Maximalwert für deinen persönlichen Zielbereich.</string>
<string name="openapsma_low_summary">Minimalwert für deinen persönlichen Zielbereich.</string>
<string name="bg_lang">Bulgarian</string>
<string name="nightscout">Nightscout</string>
<string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string>

View file

@ -66,7 +66,6 @@
<string name="openapsma_nopump">No se dispone de bomba</string>
<string name="nochangerequested">Ninguna acción requerida</string>
<string name="openapsma_request_label">Solicitud</string>
<string name="openapsma_minbg_label">Objetivo mínimo</string>
<string name="rate">Dosis</string>
<string name="duration">Duración</string>
<string name="reason">Razón</string>
@ -192,8 +191,6 @@
<string name="nav_export">Exportar ajustes</string>
<string name="nav_import">Importar ajustes</string>
<string name="de_lang">German</string>
<string name="openapsma_low_summary">Valor mínimo de BG para estar en rango</string>
<string name="openapsma_high_summary">Valor máximo BG para estar en rango</string>
<string name="openapsma_maxbasal_summary">Max valor U / hr en Basal temporal</string>
<string name="openapsma_maxiob_summary">Máximos basales IOB para OpenAPS [U]</string>
<string name="bg_lang">Bulgarian</string>
@ -294,7 +291,6 @@
<string name="objectives_5_gate">1 semana lazo cerrado completado con entrada regular de carbohidratos</string>
<string name="objectives_6_objective">Habilitar funciones adicionales para su uso durante el día, como asistente de comida avanzado</string>
<string name="youareonallowedlimit">Alcanzado el límite permitido</string>
<string name="openapsma_target_bg">Valor objetivo para los cálculos</string>
<string name="noprofileselected">Sin perfil seleccionado</string>
<string name="ko_lang">Korean</string>
<string name="actions">Acciones</string>

View file

@ -264,12 +264,9 @@
<string name="openapsma">OpenAPS MA</string>
<string name="openapsma_disabled">Plugin e\' disabilitato</string>
<string name="openapsma_glucosestatus_label">Stato glucosio</string>
<string name="openapsma_high_summary">Valore massimo di Bg nel range</string>
<string name="openapsma_inputparameters_label">Entrata parametro</string>
<string name="openapsma_low_summary">Valore minimo di Bg nel range</string>
<string name="openapsma_maxbasal_summary">Il valore e\' chiamati basale in OpenAPS</string>
<string name="openapsma_maxiob_title">Basale Massima in IOB OpenAPS</string>
<string name="openapsma_minbg_label">Obbietivo minimo</string>
<string name="openapsma_iobdata_label">IOB dati</string>
<string name="openapsma_lastenact_label">Ultimo attuato</string>
<string name="openapsma_lastrun_label">Ultimo corsa</string>
@ -344,7 +341,6 @@
<string name="objectives_0_objective">Impostazione di visualizzazione, monitoraggio e analisi basali e rapporti</string>
<string name="objectives_1_gate">Eseguire in modalità Open Loop per alcuni giorni e impostare manualmente la basale tempor</string>
<string name="openapsma_scriptdebugdata_label">Script debug</string>
<string name="openapsma_target_bg">Target per calcolare</string>
<string name="smscommunicator">Comunicazioni SMS</string>
<string name="smscommunicator_allowednumbers">Numero di telefono acettato</string>
<string name="smscommunicator_bolusfailed">Bolo fallito</string>

View file

@ -68,7 +68,6 @@
<string name="openapsma_nopump">No pump available</string>
<string name="nochangerequested">변경사항 없음</string>
<string name="openapsma_request_label">요청</string>
<string name="openapsma_minbg_label">Low target</string>
<string name="rate">Rate</string>
<string name="duration">기간</string>
<string name="reason">근거</string>
@ -195,8 +194,6 @@
<string name="de_lang">German</string>
<string name="es_lang">Spanish</string>
<string name="el_lang">Greek</string>
<string name="openapsma_low_summary">목표범위 최소 혈당값</string>
<string name="openapsma_high_summary">목표범위 최대 혈당값</string>
<string name="openapsma_maxbasal_title">임시기초주입 최대량 [U/hr]</string>
<string name="openapsma_maxbasal_summary">이 값은 OpenAPS에서 Max Basal(임시기초주입 최대량)로 설정되는 값입니다</string>
<string name="openapsma_maxiob_title">OpenAPS가 주입할수 있는 최대 기초주입 IOB [U]</string>
@ -304,7 +301,6 @@
<string name="objectives_5_gate">평소 먹는 탄수화물 입력하면서 Loop를 실행하고 1주일간 성공적으로 낮시간을 관리한다.</string>
<string name="objectives_6_objective">AMA(Advanced Meal Assist)같은 주간용을 위한 추가적인 기능들을 실행하여 본다.</string>
<string name="youareonallowedlimit">허용된 제한값에 도달하였습니다</string>
<string name="openapsma_target_bg">계산을 위한 목표 혈당 값</string>
<string name="noprofileselected">프로파일이 선택되지 않았습니다</string>
<string name="smscommunicator_loophasbeendisabled">Loop가 중지되었습니다.</string>
<string name="smscommunicator_loophasbeenenabled">Loop가 실행되었습니다.</string>

View file

@ -345,19 +345,16 @@
<string name="openapsma_currenttemp_label">текущий врем базал</string>
<string name="openapsma_disabled">модуль не активен</string>
<string name="openapsma_glucosestatus_label">статус гликемии</string>
<string name="openapsma_high_summary">макс значение СК диапазона</string>
<string name="openapsma_inputparameters_label">параметры ввода</string>
<string name="openapsma_iobdata_label">данные IOB (активн инс)</string>
<string name="openapsma_lastenact_label">последнее заданное</string>
<string name="openapsma_lastrun_label">последнее выполненное</string>
<string name="openapsma_low_summary">мин значение СК диапазона</string>
<string name="openapsma_maxbasal_summary">в контексте OpenAPS называется макс базал</string>
<string name="openapsma_maxbasal_title">макс разрешенный врем базал Е</string>
<string name="openapsma_maxiob_summary">эта величина называется макс IOB (макс активн инс) в OpenAPS. Значение по умолчанию 0. Через несколько дней или недель пользования величину можно юстировать в зависимости от вашего уровня комфорта.</string>
<string name="openapsma_maxiob_title">макс базал активн инс подаваемый с OpenAPS (ед)</string>
<string name="openapsma_mealdata_label">данные приема пищи</string>
<string name="openapsma_minbg_label">нижнее целевое значение СК</string>
<string name="openapsma_noglucosedata">данные гликемии недоступны</string>
<string name="openapsma_noglucosedata">данные гликемии недоступны</string>
<string name="openapsma_noprofile">профиль недоступен</string>
<string name="openapsma_nopump">помпа недоступна</string>
<string name="openapsma_profile_label">профиль</string>
@ -365,7 +362,6 @@
<string name="result">результат</string>
<string name="openapsma_run">выполнить сейчас</string>
<string name="openapsma_scriptdebugdata_label">отладка скрипта</string>
<string name="openapsma_target_bg">целевое значение для расчетов</string>
<string name="openapsma_valuelimitedto" formatted="false">%.2f ограничено до %.2f</string>
<string name="openapsma_valueoutofrange" formatted="false">величина %s недопустима</string>
<string name="openloop">открытый цикл</string>

View file

@ -69,8 +69,7 @@
<string name="openapsma_nopump">No pump available</string>
<string name="nochangerequested">No change requested</string>
<string name="openapsma_request_label">Request</string>
<string name="openapsma_minbg_label">Low target</string>
<string name="rate">Rate</string>
<string name="rate">Rate</string>
<string name="duration">Duration</string>
<string name="reason">Reason</string>
<string name="glucose">Glucose</string>
@ -209,8 +208,6 @@
<string name="el_lang">Greek</string>
<string name="it_lang">Italian</string>
<string name="ru_lang">Russian</string>
<string name="openapsma_low_summary">The minimum BG value to be in range.</string>
<string name="openapsma_high_summary">The maximum BG value to be in range.</string>
<string name="openapsma_maxbasal_title">Max U/hr a Temp Basal can be set to</string>
<string name="openapsma_maxbasal_summary">This value is called max basal in OpenAPS context</string>
<string name="openapsma_maxiob_title">Maximum basal IOB OpenAPS can deliver [U]</string>
@ -318,7 +315,6 @@
<string name="objectives_5_gate">1 week successful daytime looping with regular carb entry</string>
<string name="objectives_6_objective">Enabling additional features for daytime use, such as advanced meal assist</string>
<string name="youareonallowedlimit">You reached allowed limit</string>
<string name="openapsma_target_bg">Target value for calculations</string>
<string name="noprofileselected">No profile selected</string>
<string name="smscommunicator_loophasbeendisabled">Loop has been disabled</string>
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>

View file

@ -3,22 +3,6 @@
<PreferenceCategory
android:key="openaps"
android:title="@string/openapsma">
<EditTextPreference
android:defaultValue=""
android:key="openapsma_min_bg"
android:numeric="decimal"
android:title="@string/openapsma_low_summary" />
<EditTextPreference
android:defaultValue=""
android:key="openapsma_max_bg"
android:numeric="decimal"
android:title="@string/openapsma_high_summary" />
<EditTextPreference
android:defaultValue=""
android:key="openapsma_target_bg"
android:numeric="decimal"
android:title="@string/openapsma_target_bg" />
<EditTextPreference
android:defaultValue="1"