diff --git a/app/build.gradle b/app/build.gradle
index 5cd4c9af95..bfe6d58ee3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -188,6 +188,7 @@ dependencies {
compile "com.android.support:design:${supportLibraryVersion}"
compile "com.android.support:percent:${supportLibraryVersion}"
compile "com.wdullaer:materialdatetimepicker:2.3.0"
+ compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.squareup:otto:1.3.7"
compile "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
compile "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8290c46004..a36bdee3aa 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -61,6 +61,7 @@
+
24 ? 6 : rangeToDisplay;
+ updateGUI("rangeChange");
+ }
+
+ @OnLongClick(R.id.historybrowse_zoom)
+ boolean onLongClickZoom() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(start);
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ start = calendar.getTimeInMillis();
+ updateGUI("resetToMidnight");
+ return true;
+ }
+
+ @OnClick(R.id.historybrowse_date)
+ void onClickDate() {
+ }
+
+ @OnClick({R.id.overview_showbasals, R.id.overview_showprediction, R.id.overview_showiob, R.id.overview_showcob, R.id.overview_showdeviations, R.id.overview_showratios})
+ void onClickDate(View view) {
+ //((CheckBox) view).toggle();
+ updateGUI("checkboxToggle");
+ }
+
+
+ void loadData() {
+
+ }
+
+ void updateGUI(String from) {
+ final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
+ final Profile profile = MainApp.getConfigBuilder().getProfile();
+ final String units = profile.getUnits();
+
+ double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
+ double highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units));
+
+ if (lowLineSetting < 1)
+ lowLineSetting = Profile.fromMgdlToUnits(76d, units);
+ if (highLineSetting < 1)
+ highLineSetting = Profile.fromMgdlToUnits(180d, units);
+
+ final double lowLine = lowLineSetting;
+ final double highLine = highLineSetting;
+
+ final boolean showPrediction = false;
+
+ int hoursToFetch;
+ final long toTime;
+ final long fromTime;
+ //if (showPrediction) {
+ //int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
+ //predHours = Math.min(2, predHours);
+ //predHours = Math.max(0, predHours);
+ //hoursToFetch = rangeToDisplay - predHours;
+ //toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
+ //fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
+ //endTime = toTime + predHours * 60 * 60 * 1000L;
+ //} else {
+ fromTime = start + 100000;
+ toTime = start + rangeToDisplay * 60 * 60 * 1000L;
+ //}
+
+ buttonDate.setText(DateUtil.dateAndTimeString(start));
+ buttonZoom.setText(String.valueOf(rangeToDisplay));
+
+ log.debug("Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime));
+
+ final long pointer = System.currentTimeMillis();
+
+ // ------------------ 1st graph
+
+ final GraphData graphData = new GraphData(bgGraph);
+
+ // **** In range Area ****
+ graphData.addInRangeArea(fromTime, toTime, lowLine, highLine);
+
+ // **** BG ****
+ if (showPrediction)
+//graphData.addBgReadings(fromTime, toTime, lowLine, highLine, (DetermineBasalResultAMA) finalLastRun.constraintsProcessed);
+ ;
+ else
+ graphData.addBgReadings(fromTime, toTime, lowLine, highLine, null);
+
+ // set manual x bounds to have nice steps
+ graphData.formatAxis(fromTime, toTime);
+
+ // Treatments
+ graphData.addTreatments(fromTime, toTime);
+
+ // add basal data
+ if (pump.getPumpDescription().isTempBasalCapable && showBasalsCheckbox.isChecked()) {
+ graphData.addBasals(fromTime, toTime, lowLine / graphData.maxY / 1.2d);
+ }
+
+ // **** NOW line ****
+ graphData.addNowLine(pointer);
+
+ // ------------------ 2nd graph
+
+ final GraphData secondGraphData = new GraphData(iobGraph);
+
+ boolean useIobForScale = false;
+ boolean useCobForScale = false;
+ boolean useDevForScale = false;
+ boolean useRatioForScale = false;
+
+ if (showIobCheckbox.isChecked()) {
+ useIobForScale = true;
+ } else if (showCobCheckbox.isChecked()) {
+ useCobForScale = true;
+ } else if (showDeviationsCheckbox.isChecked()) {
+ useDevForScale = true;
+ } else if (showRatiosCheckbox.isChecked()) {
+ useRatioForScale = true;
+ }
+
+ if (showIobCheckbox.isChecked())
+ secondGraphData.addIob(fromTime, toTime, useIobForScale, 1d);
+ if (showCobCheckbox.isChecked())
+ secondGraphData.addCob(fromTime, toTime, useCobForScale, useCobForScale ? 1d : 0.5d);
+ if (showDeviationsCheckbox.isChecked())
+ secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d);
+ if (showRatiosCheckbox.isChecked())
+ secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
+
+ // **** NOW line ****
+ // set manual x bounds to have nice steps
+ secondGraphData.formatAxis(fromTime, toTime);
+ secondGraphData.addNowLine(pointer);
+
+ // do GUI update
+ if (showIobCheckbox.isChecked() || showCobCheckbox.isChecked() || showDeviationsCheckbox.isChecked() || showRatiosCheckbox.isChecked()) {
+ iobGraph.setVisibility(View.VISIBLE);
+ } else {
+ iobGraph.setVisibility(View.GONE);
+ }
+ // finally enforce drawing of graphs
+ graphData.performUpdate();
+ secondGraphData.performUpdate();
+ }
+}
diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
index e77be36ba6..ddf768c77f 100644
--- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java
+++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java
@@ -112,9 +112,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
runOnUiThread(new Runnable() {
@Override
public void run() {
- if(ev.recreate) {
+ if (ev.recreate) {
recreate();
- }else {
+ } else {
try { // activity may be destroyed
setUpTabs(true);
} catch (IllegalStateException e) {
@@ -171,7 +171,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Added in 1.57 at 21.01.2018
Integer unreachable_threshold = SP.getInt(R.string.key_pump_unreachable_threshold, 30);
SP.remove(R.string.key_pump_unreachable_threshold);
- if(unreachable_threshold < 30) unreachable_threshold = 30;
+ if (unreachable_threshold < 30) unreachable_threshold = 30;
SP.putString(R.string.key_pump_unreachable_threshold, unreachable_threshold.toString());
}
@@ -358,6 +358,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
}, null);
break;
+ case R.id.nav_historybrowser:
+ startActivity(new Intent(v.getContext(), HistoryBrowseActivity.class));
+ break;
case R.id.nav_resetdb:
new AlertDialog.Builder(v.getContext())
.setTitle(R.string.nav_resetdb)
@@ -386,7 +389,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
case R.id.nav_about:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION);
- if (Config.NSCLIENT|| Config.G5UPLOADER)
+ if (Config.NSCLIENT || Config.G5UPLOADER)
builder.setIcon(R.mipmap.yellowowl);
else
builder.setIcon(R.mipmap.blueowl);
diff --git a/app/src/main/res/drawable/ic_chevron_left_black_24dp.xml b/app/src/main/res/drawable/ic_chevron_left_black_24dp.xml
new file mode 100644
index 0000000000..e6bb3ca920
--- /dev/null
+++ b/app/src/main/res/drawable/ic_chevron_left_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml b/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml
new file mode 100644
index 0000000000..24835127dd
--- /dev/null
+++ b/app/src/main/res/drawable/ic_chevron_right_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_first_page_black_24dp.xml b/app/src/main/res/drawable/ic_first_page_black_24dp.xml
new file mode 100644
index 0000000000..483f56c7c2
--- /dev/null
+++ b/app/src/main/res/drawable/ic_first_page_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_last_page_black_24dp.xml b/app/src/main/res/drawable/ic_last_page_black_24dp.xml
new file mode 100644
index 0000000000..0d04354c14
--- /dev/null
+++ b/app/src/main/res/drawable/ic_last_page_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/activity_historybrowse.xml b/app/src/main/res/layout/activity_historybrowse.xml
new file mode 100644
index 0000000000..0dde0a1b10
--- /dev/null
+++ b/app/src/main/res/layout/activity_historybrowse.xml
@@ -0,0 +1,213 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
index 3300ab132d..227eef537f 100644
--- a/app/src/main/res/menu/menu_main.xml
+++ b/app/src/main/res/menu/menu_main.xml
@@ -4,6 +4,9 @@
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 554b7f759f..540d72543d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -861,5 +861,6 @@
Recovering from connection loss
Not enough insulin for bolus left in reservoir
Extended bolus delivery error
+ History browser