diff --git a/app/src/main/java/info/nightscout/androidaps/Constants.java b/app/src/main/java/info/nightscout/androidaps/Constants.java
index adcb7a883f..a59ed64b01 100644
--- a/app/src/main/java/info/nightscout/androidaps/Constants.java
+++ b/app/src/main/java/info/nightscout/androidaps/Constants.java
@@ -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";
+
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
index 457c70d7c1..cc50c98b65 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java
@@ -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();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
index d3882450a9..f0738c01a4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java
@@ -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();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
index 709037362b..ba7fbf6671 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
@@ -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);
diff --git a/app/src/main/res/drawable-mdpi-v11/temptargetborderdisabled.xml b/app/src/main/res/drawable-mdpi-v11/temptargetborderdisabled.xml
new file mode 100644
index 0000000000..60a46f667e
--- /dev/null
+++ b/app/src/main/res/drawable-mdpi-v11/temptargetborderdisabled.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/actions_fragment.xml b/app/src/main/res/layout/actions_fragment.xml
index 78b6fa00ae..17405dcfd2 100644
--- a/app/src/main/res/layout/actions_fragment.xml
+++ b/app/src/main/res/layout/actions_fragment.xml
@@ -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" />
+ android:layout_weight="0.1" />
+ android:orientation="horizontal"
+ android:gravity="center_horizontal">