Skip to content

Commit

Permalink
Merge pull request #3 from NightscoutFoundation/adrian-historytooltips
Browse files Browse the repository at this point in the history
Tooltips for sensor values and treatments visible in history again
  • Loading branch information
jamorham committed Sep 26, 2016
2 parents 15e1893 + 2a9c4a0 commit 501ed75
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
Expand Up @@ -137,7 +137,7 @@ private void setupCharts() {
previewChart.setZoomType(ZoomType.HORIZONTAL);

chart.setLineChartData(bgGraphBuilder.lineData());
chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener());
chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(false));
previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData()));

previewChart.setViewportCalculationEnabled(true);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/eveningoutpost/dexdrip/Home.java
Expand Up @@ -1371,7 +1371,7 @@ public int getOpacity() {
previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview);

chart.setLineChartData(bgGraphBuilder.lineData());
chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener());
chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(true));

previewChart.setBackgroundColor(getCol(X.color_home_chart_background));
previewChart.setZoomType(ZoomType.HORIZONTAL);
Expand Down
Expand Up @@ -1537,13 +1537,18 @@ public String unit() {

}

public OnValueSelectTooltipListener getOnValueSelectTooltipListener() {
return new OnValueSelectTooltipListener();
public OnValueSelectTooltipListener getOnValueSelectTooltipListener(boolean interactive) {
return new OnValueSelectTooltipListener(interactive);
}

public class OnValueSelectTooltipListener implements LineChartOnValueSelectListener {

private Toast tooltip;
private boolean interactive;

public OnValueSelectTooltipListener(boolean interactive) {
this.interactive = interactive;
}

@Override
public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
Expand Down Expand Up @@ -1574,26 +1579,25 @@ public synchronized void onValueSelected(int i, int i1, PointValue pointValue) {
} else {
message = timeFormat.format(time) + " " + (Math.round(pointValue.getY() * 10) / 10d) + " "+unit() + filtered;
}
if (interactive) {
final View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, time.toString(), Double.toString(ypos));
}
};
Home.snackBar(message, mOnClickListener);
} else {

final View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, time.toString(), Double.toString(ypos) );
if (tooltip != null) {
tooltip.cancel();
}
};
Home.snackBar(message,mOnClickListener);

/* if (tooltip != null) {
tooltip.cancel();
}
if (alternate.length()>0) {
tooltip = Toast.makeText(context, timeFormat.format(time) + ": "+alternate, Toast.LENGTH_LONG);
} else {
tooltip = Toast.makeText(context, timeFormat.format(time) + ": " + Math.round(pointValue.getY() * 10) / 10d + filtered, Toast.LENGTH_LONG);
tooltip = Toast.makeText(context, message, Toast.LENGTH_LONG);
View view = tooltip.getView();
view.setBackgroundColor(getCol(X.color_home_chart_background));
tooltip.show();
}
View view = tooltip.getView();
view.setBackgroundColor(getCol(X.color_home_chart_background));
tooltip.show();*/
}

@Override
Expand Down

0 comments on commit 501ed75

Please sign in to comment.