split menu for 1st & secondary graphs

This commit is contained in:
Paulus 2019-07-09 13:25:00 +02:00
parent 4ff9206dad
commit fc1dd360b3
31 changed files with 138 additions and 29 deletions

View file

@ -104,7 +104,7 @@ android {
targetSdkVersion 25
multiDexEnabled true
versionCode 1500
version "2.3"
version "2.3-IABG"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'

View file

@ -358,14 +358,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
else
predictionsAvailable = false;
MenuItem item;
MenuItem item,dividerItem;
CharSequence title;
int titleMaxChars = 0;
SpannableString s;
PopupMenu popup = new PopupMenu(v.getContext(), v);
if (predictionsAvailable) {
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.PRE.ordinal(), Menu.NONE, "Predictions");
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.prediction, null)), 0, s.length(), 0);
item.setTitle(s);
@ -375,14 +376,28 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(SP.getBoolean("showbasals", true));
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.ACT.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(SP.getBoolean("showactivity", true));
dividerItem = popup.getMenu().add("");
dividerItem.setEnabled(false);
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
item.setTitle(s);
@ -391,6 +406,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
item.setTitle(s);
@ -399,6 +415,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
item.setTitle(s);
@ -407,23 +424,17 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(SP.getBoolean("showratios", false));
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.ACT.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
title = item.getTitle();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(SP.getBoolean("showactivity", true));
if (MainApp.devBranch) {
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
title = item.getTitle();
if (titleMaxChars < title.length()) titleMaxChars = title.length();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
item.setTitle(s);
@ -431,6 +442,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item.setChecked(SP.getBoolean("showdevslope", false));
}
// Fairly good guestimate for required divider text size...
title = new String(new char[titleMaxChars+10]).replace("\0", "_");
dividerItem.setTitle(title);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
@ -1534,7 +1549,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
graphData.formatAxis(fromTime, endTime);
if(SP.getBoolean("showactivity", true)) {
graphData.addActivity(fromTime, endTime, graphData.maxY);
graphData.addActivity(fromTime, endTime, 1d);
}
// Treatments

View file

@ -47,6 +47,7 @@ import info.nightscout.androidaps.plugins.general.overview.graphExtensions.TimeA
import info.nightscout.androidaps.plugins.treatments.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.SP;
/**
* Created by mike on 18.10.2017.
@ -346,9 +347,12 @@ public class GraphData {
}
public void addActivity(long fromTime, long toTime, double scale) {
FixedLineGraphSeries<ScaledDataPoint> actSeries;
List<ScaledDataPoint> actArray = new ArrayList<>();
double lastAct = 0;
FixedLineGraphSeries<ScaledDataPoint> actSeriesHist;
List<ScaledDataPoint> actArrayHist = new ArrayList<>();
FixedLineGraphSeries<ScaledDataPoint> actSeriesPred;
List<ScaledDataPoint> actArrayPred = new ArrayList<>();
double now = System.currentTimeMillis();
Scale actScale = new Scale();
IobTotal total = null;
@ -359,19 +363,36 @@ public class GraphData {
total = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(time, profile);
act = total.activity;
actArray.add(new ScaledDataPoint(time, act, actScale));
lastAct = act;
if(time<=now)
actArrayHist.add(new ScaledDataPoint(time, act, actScale));
else
actArrayPred.add(new ScaledDataPoint(time, act, actScale));
}
ScaledDataPoint[] actData = new ScaledDataPoint[actArray.size()];
actData = actArray.toArray(actData);
actSeries = new FixedLineGraphSeries<>(actData);
actSeries.setDrawBackground(false);
actSeries.setColor(MainApp.gc(R.color.activity));
actSeries.setThickness(3);
actScale.setMultiplier(scale / 0.04d); //TODO for clarity should be fixed scale, but what max? For now 0.04d seems reasonable.
double maxIAValue = SP.getDouble(R.string.key_scale_insulin_activity, 0.05);
actScale.setMultiplier(maxY*scale / maxIAValue);
addSeries(actSeries);
ScaledDataPoint[] actData = new ScaledDataPoint[actArrayHist.size()];
actData = actArrayHist.toArray(actData);
actSeriesHist = new FixedLineGraphSeries<>(actData);
actSeriesHist.setDrawBackground(false);
actSeriesHist.setColor(MainApp.gc(R.color.activity));
actSeriesHist.setThickness(3);
addSeries(actSeriesHist);
actData = new ScaledDataPoint[actArrayPred.size()];
actData = actArrayPred.toArray(actData);
actSeriesPred = new FixedLineGraphSeries<>(actData);
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
paint.setPathEffect(new DashPathEffect(new float[]{4, 4}, 0));
paint.setColor(MainApp.gc(R.color.activity));
actSeriesPred.setCustomPaint(paint);
addSeries(actSeriesPred);
}
// scale in % of vertical size (like 0.3)

View file

@ -1149,6 +1149,8 @@
<string name="sms_wrongcode">Verkeerde kode. Opdrag gekanselleer.</string>
<string name="notconfigured">Nie gekonfigureer nie</string>
<string name="profileswitchcreated">Profiel skakelaar geskep</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d dae</item>
<item quantity="other">%1$d dae</item>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">стара версия</string>
<string name="very_old_version">много стара версия</string>
<string name="new_version_warning">Има нова версия от най-малко %1$d дни! Връщане към LGS след 60 дни, цикълът ще бъде изключен след 90 дни</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d дeн</item>
<item quantity="other">%1$d дни</item>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">stará verze</string>
<string name="very_old_version">velmi stará verze</string>
<string name="new_version_warning">Nová verze je dostupná minimálně %1$d dní! Přepnutí na ochranu před nízkou glykémií po 60 dnech, vypnutí smyčky po 90 dnech</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d den</item>
<item quantity="few">%1$d dnů</item>

View file

@ -1162,6 +1162,8 @@ Unerwartetes Verhalten.</string>
<string name="old_version">Vorherige Version</string>
<string name="very_old_version">sehr alte Version</string>
<string name="new_version_warning">Neue Version für mindestens %1$d Tage verfügbar! Rückfall zur sensorunterstützten Pumpentherapie nach 60 Tagen, Loop wird nach 90 Tagen deaktiviert</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d Tag</item>
<item quantity="other">%1$d Tage</item>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">παλιά έκδοση</string>
<string name="very_old_version">πολύ παλιά έκδοση</string>
<string name="new_version_warning">Νέα έκδοση για τουλάχιστον %1$d ημέρες διαθέσιμη! Επιστροφή σε LGS μετά από 60 ημέρες, το κύκλωμα θα απενεργοποιηθεί μετά από 90 ημέρες</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d ημέρα</item>
<item quantity="other">%1$d ημέρες</item>

View file

@ -1110,6 +1110,8 @@
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="storage">restricción de almacenamiento interno</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d día</item>
<item quantity="other">%1$d días</item>

View file

@ -1,3 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<resources></resources>
<resources>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1161,6 +1161,8 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
<string name="old_version">ancienne version</string>
<string name="very_old_version">très ancienne version</string>
<string name="new_version_warning">Une nouvelle version est disponible depuis au moins %1$d jours ! Retour au traitement par pompe assistée par capteur (Arrêt par Glycémie Basse (AGB), Low Glucose Suspend (LGS) ) après 60 jours et la Boucle sera désactivée après 90 jours</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d jour</item>
<item quantity="other">%1$d jours</item>

View file

@ -1,3 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<resources></resources>
<resources>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -8,4 +8,6 @@
<string name="description_loop">להפעיל או לכבות את הלולאה.</string>
<string name="description_ns_client">מסנכרן את הנתונים שלך עם Nightscout</string>
<string name="description_profile_nightscout">יבא פרופיל מ- Nightscout</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1021,6 +1021,8 @@
<string name="loop_openmode_min_change">Cambiare richiesta minima [%]</string>
<string name="loop_openmode_min_change_summary">Loop sarà nuova richiesta di modifica popup solo se il cambiamento è più grande di questo valore. Valore predefinito è 20%</string>
<string name="short_status_battery">Batt: %1$d%%</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d giorni</item>
<item quantity="other">%1$d giorni</item>

View file

@ -1,3 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<resources></resources>
<resources>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1020,6 +1020,8 @@
<string name="insulinlimitviolation">인슐린 제한 위반</string>
<string name="loop_openmode_min_change">최소 요청 변화 [%]</string>
<string name="loop_openmode_min_change_summary">이 값보다 변화가 클때만 Loop가 새 변화 요청창을 띄울것 입니다. 기본 값은 20%입니다.</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="other">%1$d 일</item>
</plurals>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">sena versija</string>
<string name="very_old_version">labai sena versija</string>
<string name="new_version_warning">Nauja versija pasiekiama mažiausiai %1$d dienų! Po 60 d. grįšite prie stabdymo prie žemo, po 90 d. ciklas bus išjungtas.</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d diena</item>
<item quantity="few">%1$d diena</item>

View file

@ -1115,6 +1115,8 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport
<string name="dst_in_24h_warning">Zomer/wintertijd omschakeling binnen 24 uur</string>
<string name="storage">interne opslag bijna vol</string>
<string name="diskfull">Maak minstens %1$d MB vrij in interne opslag! Loop is uitgeschakeld!</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d dag</item>
<item quantity="other">%1$d dag</item>

View file

@ -1161,6 +1161,8 @@
<string name="old_version">stara wersja</string>
<string name="very_old_version">bardzo stara wersja</string>
<string name="new_version_warning">Nowa wersja dostępna co najmniej %1$d dni! Powrót do LGS (zawieszania podawania bazy przy niskim poziomie) po 60 dniach, pętla zostanie wyłączona po 90 dniach</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d dzień</item>
<item quantity="few">%1$d dni</item>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">versão antiga</string>
<string name="very_old_version">versão muito antiga</string>
<string name="new_version_warning">Nova versão para pelo menos %1$d dias disponíveis! Voltar para o LGS após 60 dias, o loop será desativado após 90 dias</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d dia</item>
<item quantity="other">%1$d dias</item>

View file

@ -1071,6 +1071,8 @@
<string name="delete_pairing">Șterge asocierea</string>
<string name="pairing_information">Informații despre asociere</string>
<string name="refreh_status">Reîmprospătare stare</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d zi</item>
<item quantity="few">%1$d zi</item>

View file

@ -1162,4 +1162,6 @@ Context | Edit Context</string>
<string name="old_version">старая версия</string>
<string name="very_old_version">очень старая версия</string>
<string name="new_version_warning">Новая версия доступна не менее %1$d дней! После 60 дней переход на остановку при низкой гликемии LGS, замкнутый цикл будет отключен через 90 дней</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1160,6 +1160,8 @@
<string name="old_version">stará verzia</string>
<string name="very_old_version">veľmi stará verzia</string>
<string name="new_version_warning">Nová verzia dostupná najmenej %1$d dní! Návrat k liečbe inzulínovou pumpou s podporou senzora po 60 dňoch, okruh bude deaktivovaný po 90 dňoch.</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d deň</item>
<item quantity="few">%1$d dní</item>

View file

@ -1150,6 +1150,8 @@ Eversense-appen.</string>
<string name="sms_wrongcode">Fel kod. Kommandot avbrutet.</string>
<string name="notconfigured">Inte konfigurerad</string>
<string name="profileswitchcreated">Skapade ett profilbyte</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d dag</item>
<item quantity="other">%1$d dagar</item>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1033,6 +1033,8 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d
<string name="profile_per_unit">/U</string>
<string name="tomato">Tomato (MiaoMiao)</string>
<string name="tomato_short">Tomato</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d gün</item>
<item quantity="other">%1$d gün</item>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
</resources>

View file

@ -1138,6 +1138,8 @@
<string name="sms_wrongcode">错误的代码。命令取消</string>
<string name="notconfigured">未配置</string>
<string name="profileswitchcreated">配置文件切换已创建</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="other">%1$d </item>
</plurals>

View file

@ -9,7 +9,7 @@
<color name="uam">#c9bd60</color>
<color name="zt">#00d2d2</color>
<color name="ratio">#FFFFFF</color>
<color name="activity">#d3f166</color>
<color name="activity">#FFFFFF</color>
<color name="devslopepos">#FFFFFF00</color>
<color name="devslopeneg">#FFFF00FF</color>
<color name="inrange">#00FF00</color>

View file

@ -1335,6 +1335,8 @@
<string name="old_version">old version</string>
<string name="very_old_version">very old version</string>
<string name="new_version_warning">New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days</string>
<string name="key_scale_insulin_activity">key_scale_insulin_activity</string>
<string name="scale_insulin_activity">Graph scale insulin activity [U/min]</string>
<plurals name="objective_days">
<item quantity="one">%1$d day</item>

View file

@ -10,6 +10,18 @@
android:title="@string/keep_screen_on_title"
android:summary="@string/keep_screen_on_summary"/>
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="0.05"
android:inputType="numberDecimal"
android:key="@string/key_scale_insulin_activity"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/scale_insulin_activity"
validate:floatmaxNumber="10.0"
validate:floatminNumber="0.0"
validate:testType="floatNumericRange" />
<PreferenceScreen android:title="@string/overview_buttons_selection">
<SwitchPreference