temp target overview
This commit is contained in:
parent
58282e23ee
commit
d36a515d45
7 changed files with 70 additions and 16 deletions
|
@ -42,4 +42,12 @@ public class Constants {
|
||||||
// Circadian Percentage Profile
|
// Circadian Percentage Profile
|
||||||
public static final int CPP_MIN_PERCENTAGE = 50;
|
public static final int CPP_MIN_PERCENTAGE = 50;
|
||||||
public static final int CPP_MAX_PERCENTAGE = 200;
|
public static final int CPP_MAX_PERCENTAGE = 200;
|
||||||
|
|
||||||
|
public static final String MAX_BG_DEFAULT_MGDL = "180";
|
||||||
|
public static final String MAX_BG_DEFAULT_MMOL = "10";
|
||||||
|
public static final String MIN_BG_DEFAULT_MGDL = "100";
|
||||||
|
public static final String MIN_BG_DEFAULT_MMOL = "5";
|
||||||
|
public static final String TARGET_BG_DEFAULT_MGDL = "150";
|
||||||
|
public static final String TARGET_BG_DEFAULT_MMOL = "7";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,13 +146,13 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = "180";
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = "100";
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = "150";
|
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = "10";
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = "5";
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
targetBgDefault = "7";
|
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
|
@ -145,13 +145,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
String units = profile.getUnits();
|
String units = profile.getUnits();
|
||||||
|
|
||||||
String maxBgDefault = "180";
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
String minBgDefault = "100";
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
String targetBgDefault = "150";
|
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
|
||||||
if (!units.equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = "10";
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = "5";
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
targetBgDefault = "7";
|
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
|
|
@ -83,6 +83,7 @@ import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLab
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
||||||
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsPlugin;
|
import info.nightscout.androidaps.plugins.TempBasals.TempBasalsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -431,6 +432,9 @@ public class OverviewFragment extends Fragment {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
|
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onStatusEvent(final EventTempTargetRangeChange ev) {updateGUIIfVisible();}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
|
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
|
||||||
|
|
||||||
|
@ -526,11 +530,25 @@ public class OverviewFragment extends Fragment {
|
||||||
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
|
tempTargetView.setTextColor(Color.BLACK);
|
||||||
|
tempTargetView.setBackgroundResource(R.drawable.temptargetborder);
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
tempTargetView.setText(NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
||||||
} else {
|
} else {
|
||||||
tempTargetView.setVisibility(View.GONE);
|
|
||||||
|
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
|
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
|
if (!profile.getUnits().equals(Constants.MGDL)) {
|
||||||
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
|
}
|
||||||
|
tempTargetView.setTextColor(Color.WHITE);
|
||||||
|
tempTargetView.setBackgroundResource(R.drawable.temptargetborderdisabled);
|
||||||
|
tempTargetView.setText(prefs.getString("openapsma_min_bg", minBgDefault) + " - " + prefs.getString("openapsma_max_bg", maxBgDefault));
|
||||||
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tempTargetView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// **** Temp button ****
|
// **** Temp button ****
|
||||||
|
@ -583,6 +601,25 @@ public class OverviewFragment extends Fragment {
|
||||||
});
|
});
|
||||||
activeProfileView.setLongClickable(true);
|
activeProfileView.setLongClickable(true);
|
||||||
|
|
||||||
|
|
||||||
|
tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||||
|
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||||
|
final OptionsToShow temptarget = new OptionsToShow(R.id.careportal_temptarget, R.string.careportal_temptarget, false, false, false, false, true, false, false, false, false, true);
|
||||||
|
temptarget.executeTempTarget = true;
|
||||||
|
newTTDialog.setOptions(temptarget);
|
||||||
|
newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (profile == null || !pump.isInitialized()) {
|
if (profile == null || !pump.isInitialized()) {
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
// disable all treatment buttons because we are not able to check constraints without profile
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
wizardButton.setVisibility(View.INVISIBLE);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||||
|
<solid android:color="@color/colorPrimaryDark" />
|
||||||
|
<stroke android:width="1dip" android:color="@android:color/white"/>
|
||||||
|
<corners
|
||||||
|
android:radius="2dp" >
|
||||||
|
</corners>
|
||||||
|
</shape>
|
|
@ -33,7 +33,7 @@
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.5"
|
||||||
android:text="@string/careportal_temptarget"
|
android:text="@string/careportal_temptarget"
|
||||||
android:textColor="@color/colorTempTargetButton" />
|
android:textColor="@color/colorWizardButton" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/actions_settempbasal"
|
android:id="@+id/actions_settempbasal"
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
android:id="@+id/overview_apsmode"
|
android:id="@+id/overview_apsmode"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:background="@drawable/loopmodeborder"
|
android:background="@drawable/loopmodeborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:text="Open Loop"
|
android:text="Open Loop"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:layout_weight="0.2" />
|
android:layout_weight="0.1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_activeprofile"
|
android:id="@+id/overview_activeprofile"
|
||||||
|
@ -73,7 +74,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_bg"
|
android:id="@+id/overview_bg"
|
||||||
|
|
Loading…
Reference in a new issue