From 85f3086dac0544d73ad80908c3cb85002c713e4c Mon Sep 17 00:00:00 2001 From: David Zafrani Date: Thu, 19 Nov 2015 14:01:25 -0800 Subject: [PATCH 1/4] Changed graph look. [ref #107442248] --- .../is/hello/sense/ui/fragments/SensorHistoryFragment.java | 2 +- .../java/is/hello/sense/ui/widget/graphing/GraphView.java | 4 ++-- .../sense/ui/widget/graphing/drawables/LineGraphDrawable.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java index b1da3fdb9..06f15b603 100644 --- a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java +++ b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java @@ -348,7 +348,7 @@ public void onGraphHighlightBegin() { @Override public void onGraphValueHighlighted(int section, int position) { final SensorGraphSample instant = getSection(section).get(position); - if (instant.isValuePlaceholder()) { + if (instant.isValuePlaceholder() || instant.getValue() == 0) { readingText.setText(R.string.missing_data_placeholder); } else { final UnitPrinter printer = unitFormatter.getUnitPrinterForSensor(sensor); diff --git a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java index 07d7f6736..23a8ecde9 100644 --- a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java +++ b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java @@ -251,8 +251,8 @@ protected void onDraw(Canvas canvas) { highlightedSection, highlightedSegment); - pointBounds.set(segmentX - markerPointHalf, minY + (segmentY - markerPointHalf), - segmentX + markerPointHalf, minY + (segmentY + markerPointHalf)); + pointBounds.set(segmentX - markerPointHalf, minY * 2 + (segmentY - markerPointHalf), + segmentX + markerPointHalf, minY * 2 + (segmentY + markerPointHalf)); canvas.drawOval(pointBounds, highlightPaint); canvas.drawRect(pointBounds.centerX(), 0f, diff --git a/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java b/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java index bfb380a2f..79d683976 100644 --- a/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java +++ b/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java @@ -85,7 +85,7 @@ public void draw(Canvas canvas) { float segmentWidth = sectionWidth / (float) pointCount; for (int position = 0; position < pointCount; position++) { float currentX = adapterCache.calculateSegmentX(sectionWidth, segmentWidth, section, position); - float currentY = minY + adapterCache.calculateSegmentY(height, section, position); + float currentY = minY * 2 + adapterCache.calculateSegmentY(height, section, position); if (section == 0 && position == 0) { linePath.moveTo(currentX, currentY); From c802e69a2ab425eeabf83820f833963d2154e734 Mon Sep 17 00:00:00 2001 From: David Zafrani Date: Thu, 19 Nov 2015 15:52:49 -0800 Subject: [PATCH 2/4] PR changes that are not working --- .../ui/fragments/SensorHistoryFragment.java | 39 ++----------------- .../sense/ui/widget/graphing/GraphView.java | 4 +- .../graphing/drawables/LineGraphDrawable.java | 2 +- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java index 06f15b603..e8fb4d6f4 100644 --- a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java +++ b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java @@ -113,10 +113,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa this.graphPlaceholder = (TextView) view.findViewById(R.id.fragment_sensor_history_placeholder); this.graphView = (GraphView) view.findViewById(R.id.fragment_sensor_history_graph); + graphView.setWantsFooters(false); + graphView.setWantsHeaders(false); graphView.setGraphDrawable(new LineGraphDrawable(getResources())); graphView.setAdapter(sensorDataSource); - graphView.setHeaderFooterProvider(sensorDataSource); - graphView.setHighlightListener(sensorDataSource); graphView.setTintColor(getResources().getColor(R.color.sensor_unknown)); this.historyModeSelector = (SelectorView) view.findViewById(R.id.fragment_sensor_history_mode); @@ -249,7 +249,7 @@ public void onSelectionChanged(int newSelectionIndex) { } - public class SensorDataSource extends SensorHistoryAdapter implements GraphView.HeaderFooterProvider, GraphView.HighlightListener { + public class SensorDataSource extends SensorHistoryAdapter implements GraphView.HighlightListener { private boolean use24Time = false; public void bindHistory(@NonNull ArrayList history) { @@ -287,39 +287,6 @@ public void setUse24Time(boolean use24Time) { notifyDataChanged(); } - @Override - public int getSectionHeaderFooterCount() { - return getSectionCount(); - } - - @ColorInt - @Override - public int getSectionHeaderTextColor(int section) { - return Color.TRANSPARENT; - } - - @NonNull - @Override - public String getSectionHeader(int section) { - return ""; - } - - @ColorInt - @Override - public int getSectionFooterTextColor(int section) { - if (section == getSectionHeaderFooterCount() - 1) { - return Color.BLACK; - } else { - return Color.GRAY; - } - } - - @NonNull - @Override - public String getSectionFooter(int section) { - return ""; - } - //endregion diff --git a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java index 23a8ecde9..07d7f6736 100644 --- a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java +++ b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java @@ -251,8 +251,8 @@ protected void onDraw(Canvas canvas) { highlightedSection, highlightedSegment); - pointBounds.set(segmentX - markerPointHalf, minY * 2 + (segmentY - markerPointHalf), - segmentX + markerPointHalf, minY * 2 + (segmentY + markerPointHalf)); + pointBounds.set(segmentX - markerPointHalf, minY + (segmentY - markerPointHalf), + segmentX + markerPointHalf, minY + (segmentY + markerPointHalf)); canvas.drawOval(pointBounds, highlightPaint); canvas.drawRect(pointBounds.centerX(), 0f, diff --git a/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java b/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java index 79d683976..bfb380a2f 100644 --- a/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java +++ b/app/src/main/java/is/hello/sense/ui/widget/graphing/drawables/LineGraphDrawable.java @@ -85,7 +85,7 @@ public void draw(Canvas canvas) { float segmentWidth = sectionWidth / (float) pointCount; for (int position = 0; position < pointCount; position++) { float currentX = adapterCache.calculateSegmentX(sectionWidth, segmentWidth, section, position); - float currentY = minY * 2 + adapterCache.calculateSegmentY(height, section, position); + float currentY = minY + adapterCache.calculateSegmentY(height, section, position); if (section == 0 && position == 0) { linePath.moveTo(currentX, currentY); From c37a537843362cc06cfc9e20ab094ee21151c9e8 Mon Sep 17 00:00:00 2001 From: km Date: Thu, 19 Nov 2015 16:03:29 -0800 Subject: [PATCH 3/4] tweaks to updated graph --- .../is/hello/sense/ui/fragments/SensorHistoryFragment.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java index e8fb4d6f4..10f4f7e6a 100644 --- a/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java +++ b/app/src/main/java/is/hello/sense/ui/fragments/SensorHistoryFragment.java @@ -1,7 +1,6 @@ package is.hello.sense.ui.fragments; import android.content.res.Resources; -import android.graphics.Color; import android.os.Bundle; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; @@ -114,8 +113,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa this.graphView = (GraphView) view.findViewById(R.id.fragment_sensor_history_graph); graphView.setWantsFooters(false); - graphView.setWantsHeaders(false); graphView.setGraphDrawable(new LineGraphDrawable(getResources())); + graphView.setHighlightListener(sensorDataSource); graphView.setAdapter(sensorDataSource); graphView.setTintColor(getResources().getColor(R.color.sensor_unknown)); @@ -315,7 +314,7 @@ public void onGraphHighlightBegin() { @Override public void onGraphValueHighlighted(int section, int position) { final SensorGraphSample instant = getSection(section).get(position); - if (instant.isValuePlaceholder() || instant.getValue() == 0) { + if (instant.isValuePlaceholder()) { readingText.setText(R.string.missing_data_placeholder); } else { final UnitPrinter printer = unitFormatter.getUnitPrinterForSensor(sensor); From d99f465558768203f1324013c7a221475c9e9f92 Mon Sep 17 00:00:00 2001 From: km Date: Thu, 19 Nov 2015 16:08:16 -0800 Subject: [PATCH 4/4] make header/footer inset behavior consistent --- .../sense/ui/widget/graphing/GraphView.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java index 07d7f6736..2764c3b3c 100644 --- a/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java +++ b/app/src/main/java/is/hello/sense/ui/widget/graphing/GraphView.java @@ -186,27 +186,27 @@ protected void onDraw(Canvas canvas) { graphDrawable.draw(canvas); } + final int headerHeight = calculateHeaderHeight(), + footerHeight = calculateFooterHeight(); + + if (wantsHeaders) { + height -= headerHeight; + minY += headerHeight; + } else { + final int topSpacing = (int) Math.ceil(markerPointHalf); + height -= topSpacing; + minY += topSpacing; + } + + if (wantsFooters) { + height -= footerHeight; + } + if (headerFooterProvider != null) { final int sectionCount = headerFooterProvider.getSectionHeaderFooterCount(); if (sectionCount > 0) { - final int headerHeight = calculateHeaderHeight(), - footerHeight = calculateFooterHeight(); - final float sectionWidth = width / sectionCount; - if (wantsHeaders) { - height -= headerHeight; - minY += headerHeight; - } else { - final int topSpacing = (int) Math.ceil(markerPointHalf); - height -= topSpacing; - minY += topSpacing; - } - - if (wantsFooters) { - height -= footerHeight; - } - for (int section = 0; section < sectionCount; section++) { if (wantsHeaders) { final int savedAlpha = headerTextPaint.getAlpha();