temp target overview

This commit is contained in:
AdrianLxM 2017-01-17 21:28:57 +01:00
parent 58282e23ee
commit d36a515d45
7 changed files with 70 additions and 16 deletions

View file

@ -42,4 +42,12 @@ public class Constants {
// Circadian Percentage Profile
public static final int CPP_MIN_PERCENTAGE = 50;
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";
}

View file

@ -146,13 +146,13 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
String units = profile.getUnits();
String maxBgDefault = "180";
String minBgDefault = "100";
String targetBgDefault = "150";
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = "10";
minBgDefault = "5";
targetBgDefault = "7";
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();

View file

@ -145,13 +145,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
String units = profile.getUnits();
String maxBgDefault = "180";
String minBgDefault = "100";
String targetBgDefault = "150";
String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL;
if (!units.equals(Constants.MGDL)) {
maxBgDefault = "10";
minBgDefault = "5";
targetBgDefault = "7";
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL;
}
Date now = new Date();

View file

@ -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.TempBasals.TempBasalsPlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil;
@ -431,6 +432,9 @@ public class OverviewFragment extends Fragment {
@Subscribe
public void onStatusEvent(final EventNewBasalProfile ev) { updateGUIIfVisible(); }
@Subscribe
public void onStatusEvent(final EventTempTargetRangeChange ev) {updateGUIIfVisible();}
@Subscribe
public void onStatusEvent(final EventNewNotification n) { updateNotifications(); }
@ -526,11 +530,25 @@ public class OverviewFragment extends Fragment {
if (tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) {
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
if (tempTarget != null) {
tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundResource(R.drawable.temptargetborder);
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()));
} 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 ****
@ -583,6 +601,25 @@ public class OverviewFragment extends Fragment {
});
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()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);

View file

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

View file

@ -33,7 +33,7 @@
android:layout_marginTop="3dp"
android:layout_weight="0.5"
android:text="@string/careportal_temptarget"
android:textColor="@color/colorTempTargetButton" />
android:textColor="@color/colorWizardButton" />
<Button
android:id="@+id/actions_settempbasal"

View file

@ -30,6 +30,7 @@
android:id="@+id/overview_apsmode"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/loopmodeborder"
android:gravity="center_vertical|center_horizontal"
@ -37,7 +38,7 @@
android:paddingRight="10dp"
android:text="Open Loop"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="0.2" />
android:layout_weight="0.1" />
<TextView
android:id="@+id/overview_activeprofile"
@ -73,7 +74,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:id="@+id/overview_bg"