Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Added toggle for moving speed
Browse files Browse the repository at this point in the history
  • Loading branch information
udisha0606 committed Nov 26, 2023
1 parent 7078064 commit 534d6d3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ public static void setMaxSpeed(boolean value) {
setBoolean(R.string.distance_preference_key, value);
}

public static boolean shouldMovingSpeed() {
return getBoolean(R.string.moving_speed_preference_key, false);
}

@VisibleForTesting
public static void setMovingSpeed(boolean value) {
setBoolean(R.string.moving_speed_preference_key, value);
}
public static Distance getRecordingDistanceInterval() {
return Distance.of(getInt(R.string.recording_distance_interval_key, getRecordingDistanceIntervalDefaultInternal()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldElevationGain;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldDistance;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldMaxSpeed;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldMovingSpeed;
import static de.dennisguse.opentracks.settings.PreferencesUtils.setMovingSpeed;

public class AggregatedStatisticsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

Expand Down Expand Up @@ -70,6 +72,12 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
else {
viewHolder.setMaxSpeed(aggregatedStatistic, false);
}
if(shouldMovingSpeed()){
viewHolder.setMovingSpeed(aggregatedStatistic, true);
}
else {
viewHolder.setMovingSpeed(aggregatedStatistic, false);
}
} else {
viewHolder.setPace(aggregatedStatistic);
}
Expand Down Expand Up @@ -192,6 +200,26 @@ public void setMaxSpeed(AggregatedStatistics.AggregatedStatistic aggregatedStati

}

public void setMovingSpeed(AggregatedStatistics.AggregatedStatistic aggregatedStatistic, Boolean visibility) {
SpeedFormatter formatter = SpeedFormatter.Builder().setUnit(unitSystem).setReportSpeedOrPace(reportSpeed).build(context);
if(visibility){
if(aggregatedStatistic.getTrackStatistics().getMaxSpeed() ==null)
avgSpeed.setText("0.0");
else
{
Pair<String, String> parts = formatter.getSpeedParts(aggregatedStatistic.getTrackStatistics().getMaxSpeed());
avgSpeed.setText(parts.first);
avgSpeedUnit.setText(parts.second);
avgSpeedLabel.setText(context.getString(R.string.stats_max_speed));
}
}
else{
avgSpeed.setText("");
avgSpeedUnit.setText("");
avgSpeedLabel.setText("");
}

}
public void setSpeed(AggregatedStatistics.AggregatedStatistic aggregatedStatistic) {
setCommonValues(aggregatedStatistic);

Expand Down
2 changes: 2 additions & 0 deletions src/main/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@
<bool name="aggregated_stats_enabled_default">false</bool>
<string name="distance_preference_key" translatable="false">DistancePreferenceKey</string>
<string name="max_speed_preference_key" translatable="false">MaxSpeedPreferenceKey</string>
<string name="moving_speed_preference_key" translatable="false">MovingSpeedPreferenceKey</string>
<string name="stats_moving_speed" translatable="false">Moving Speed</string>
<bool name="publicapi_enabled_default">false</bool>
<string name="publicapi_dashboard_enabled_key" translatable="false">apiDashboardEnabledKey</string>
<bool name="publicapi_dashboard_enabled_default">false</bool>
Expand Down
5 changes: 5 additions & 0 deletions src/main/res/xml/settings_aggregated_stats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ android:title="@string/settings_aggregated_stats">
android:key="@string/max_speed_preference_key"
android:title="@string/stats_max_speed" />

<SwitchPreference
android:defaultValue="false"
android:key="@string/moving_speed_preference_key"
android:title="@string/stats_moving_speed" />

<!--<SwitchPreferenceCompat-->
<!-- android:title="@string/settings_public_api_dashboard_enabled_title"-->
<!-- android:summaryOn="@string/settings_public_api_dashboard_enabled_summary_on"-->
Expand Down

0 comments on commit 534d6d3

Please sign in to comment.