From 4b7de188fd85f4cc6cd41dafd93bb0a6bb90f99d Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Wed, 2 Sep 2020 23:29:28 +0200 Subject: [PATCH] Elevation gain adheres to visibility setting. --- .../fragments/StatisticsRecordedFragment.java | 9 ++++++++- .../fragments/StatisticsRecordingFragment.java | 10 +++++----- src/main/res/layout/statistics_recorded.xml | 4 ++-- src/main/res/layout/statistics_recording.xml | 12 ++++-------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordedFragment.java b/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordedFragment.java index f167098a2..ba4fb1bf3 100644 --- a/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordedFragment.java +++ b/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordedFragment.java @@ -29,6 +29,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.constraintlayout.widget.Group; import androidx.fragment.app.Fragment; import de.dennisguse.opentracks.R; @@ -87,7 +88,7 @@ public class StatisticsRecordedFragment extends Fragment { private TextView speedMovingValue; private TextView speedMovingUnit; - private TextView elevationCurrentGroup; + private Group elevationGroup; private TextView elevationTotalGainValue; private TextView elevationTotalGainUnit; @@ -135,6 +136,7 @@ public class StatisticsRecordedFragment extends Fragment { speedMovingValue = view.findViewById(R.id.stats_moving_speed_value); speedMovingUnit = view.findViewById(R.id.stats_moving_speed_unit); + elevationGroup = view.findViewById(R.id.stats_elevation_group); elevationTotalGainValue = view.findViewById(R.id.stats_elevation_gain_value); elevationTotalGainUnit = view.findViewById(R.id.stats_elevation_gain_unit); } @@ -195,6 +197,7 @@ public class StatisticsRecordedFragment extends Fragment { speedMovingValue = null; speedMovingUnit = null; + elevationGroup = null; elevationTotalGainValue = null; elevationTotalGainUnit = null; } @@ -277,6 +280,10 @@ public class StatisticsRecordedFragment extends Fragment { // Set elevation gain { + // Make elevation visible? + boolean showElevation = PreferencesUtils.isShowStatsElevation(getContext()); + elevationGroup.setVisibility(showElevation ? View.VISIBLE : View.GONE); + double elevationGain_m = trackStatistics != null ? trackStatistics.getTotalElevationGain() : 0f; Pair parts = StringUtils.formatElevation(getContext(), elevationGain_m, metricUnits); diff --git a/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordingFragment.java b/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordingFragment.java index d68c13826..170c051f5 100644 --- a/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordingFragment.java +++ b/src/main/java/de/dennisguse/opentracks/fragments/StatisticsRecordingFragment.java @@ -135,7 +135,7 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi private TextView speedLabel; private TextView speedValue; private TextView speedUnit; - private Group elevationCurrentGroup; + private Group elevationGroup; private TextView elevationCurrentValue; private TextView elevationCurrentUnit; private TextView elevationTotalGainValue; @@ -184,7 +184,7 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi speedValue = view.findViewById(R.id.stats_speed_value); speedUnit = view.findViewById(R.id.stats_speed_unit); - elevationCurrentGroup = view.findViewById(R.id.stats_elevation_current_group); + elevationGroup = view.findViewById(R.id.stats_elevation_group); elevationCurrentValue = view.findViewById(R.id.stats_elevation_current_value); elevationCurrentUnit = view.findViewById(R.id.stats_elevation_current_unit); @@ -284,7 +284,7 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi speedValue = null; speedUnit = null; - elevationCurrentGroup = null; + elevationGroup = null; elevationCurrentValue = null; elevationCurrentUnit = null; @@ -586,7 +586,7 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi { // Make elevation visible? boolean showElevation = PreferencesUtils.isShowStatsElevation(getContext()); - elevationCurrentGroup.setVisibility(showElevation ? View.VISIBLE : View.GONE); + elevationGroup.setVisibility(showElevation ? View.VISIBLE : View.GONE); } } @@ -622,7 +622,7 @@ public class StatisticsRecordingFragment extends Fragment implements TrackDataLi // Set elevation boolean showElevation = PreferencesUtils.isShowStatsElevation(getContext()); - elevationCurrentGroup.setVisibility(showElevation ? View.VISIBLE : View.GONE); + elevationGroup.setVisibility(showElevation ? View.VISIBLE : View.GONE); if (showElevation) { // Current elevation diff --git a/src/main/res/layout/statistics_recorded.xml b/src/main/res/layout/statistics_recorded.xml index b960a47d6..50e4aada6 100644 --- a/src/main/res/layout/statistics_recorded.xml +++ b/src/main/res/layout/statistics_recorded.xml @@ -219,10 +219,10 @@ app:layout_constraintTop_toBottomOf="@+id/stats_moving_speed_value" /> + app:constraint_referenced_ids="stats_elevation_horizontal_line,stats_elevation_gain_label,stats_elevation_gain_value,stats_elevation_gain_unit" /> - + + app:constraint_referenced_ids="stats_elevation_horizontal_line,stats_elevation_current_label,stats_elevation_current_value,stats_elevation_current_unit,stats_elevation_gain_label,stats_elevation_gain_value,stats_elevation_gain_unit" /> + -