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

Commit

Permalink
Browse files Browse the repository at this point in the history
…rdia into group_11
  • Loading branch information
yashvadaria committed Nov 20, 2023
2 parents 6cb2ea5 + c6653e0 commit 077b5de
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 12 deletions.
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/.DS_Store
Binary file not shown.
Binary file added src/main/java/de/.DS_Store
Binary file not shown.
Binary file added src/main/java/de/dennisguse/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.dennisguse.opentracks.settings;

import android.os.Bundle;

import androidx.preference.PreferenceFragmentCompat;

import de.dennisguse.opentracks.BuildConfig;
import de.dennisguse.opentracks.R;

public class AggregatedStatsSettingsFragment extends PreferenceFragmentCompat {

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.settings_aggregated_stats);
}

@Override
public void onStart() {
super.onStart();
((SettingsActivity) getActivity()).getSupportActionBar().setTitle(R.string.settings_aggregated_stats);
findPreference(getString(R.string.settings_aggregated_stats_key));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
((SettingsActivity) getActivity()).openScreen(getString(R.string.settings_api_key));
return true;
});

findPreference(getString(R.string.settings_aggregated_stats_key)).setOnPreferenceClickListener(preference -> {
((SettingsActivity) getActivity()).openScreen(getString(R.string.settings_aggregated_stats_key));
return true;
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,15 @@ public static void setVoiceAnnounceAverageHeartRate(boolean value) {
setBoolean(R.string.voice_announce_average_heart_rate_key, value);
}

public static boolean shouldElevationGain() {
return getBoolean(R.string.aggregated_stats_package_key, false);
}

@VisibleForTesting
public static void setElevationGain(boolean value) {
setBoolean(R.string.aggregated_stats_package_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 @@ -94,6 +94,8 @@ private PreferenceFragmentCompat getPreferenceScreen(String key) {
fragment = new ImportExportSettingsFragment();
} else if (key.equals(getString(R.string.settings_api_key))) {
fragment = new PublicAPISettingsFragment();
} else if (key.equals(getString(R.string.settings_aggregated_stats_key))) {
fragment = new AggregatedStatsSettingsFragment();
}

return fragment;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import de.dennisguse.opentracks.settings.UnitSystem;
import de.dennisguse.opentracks.stats.TrackStatistics;
import de.dennisguse.opentracks.util.StringUtils;
import static de.dennisguse.opentracks.settings.PreferencesUtils.shouldElevationGain;

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

Expand Down Expand Up @@ -49,9 +50,9 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
String type = aggregatedStatistic.getActivityTypeLocalized();
if (ActivityType.findByLocalizedString(context, type).isShowSpeedPreferred()) {
viewHolder.setSpeed(aggregatedStatistic);
viewHolder.setElevation(aggregatedStatistic);


if(shouldElevationGain()) {
viewHolder.setElevation(aggregatedStatistic);
}
} else {
viewHolder.setPace(aggregatedStatistic);
}
Expand Down Expand Up @@ -93,9 +94,9 @@ private class ViewHolder extends RecyclerView.ViewHolder {
private final TextView maxSpeedUnit;
private final TextView maxSpeedLabel;

private final TextView elevationGain;
private final TextView elevationLabel;
private final TextView elevationUnit;
private TextView elevationGain = null;
private TextView elevationLabel = null;
private TextView elevationUnit = null;

private UnitSystem unitSystem = UnitSystem.defaultUnitSystem();
private boolean reportSpeed;
Expand All @@ -114,13 +115,14 @@ public ViewHolder(View view) {
maxSpeed = view.findViewById(R.id.aggregated_stats_max_rate);
maxSpeedUnit = view.findViewById(R.id.aggregated_stats_max_rate_unit);
maxSpeedLabel = view.findViewById(R.id.aggregated_stats_max_rate_label);
elevationGain = view.findViewById(R.id.aggregated_stats_elevation_gain);
elevationLabel = view.findViewById(R.id.aggregated_stats_elevation_gain_label);
elevationUnit = view.findViewById(R.id.aggregated_stats_elevation_gain_unit);

elevationLabel.setText("Elevation Gain");
elevationUnit.setText("ft");
if(shouldElevationGain()) {
elevationGain = view.findViewById(R.id.aggregated_stats_elevation_gain);
elevationLabel = view.findViewById(R.id.aggregated_stats_elevation_gain_label);
elevationUnit = view.findViewById(R.id.aggregated_stats_elevation_gain_unit);

elevationLabel.setText("Elevation Gain");
elevationUnit.setText("ft");
}
}
public void setElevation(AggregatedStatistics.AggregatedStatistic aggregatedStatistic) {
if(aggregatedStatistic.getTrackStatistics().getTotalAltitudeGain()==null)
Expand Down
Binary file added src/main/res/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

<string name="settings_import_export_key" translatable="false">settingsImportExport</string>

<string name="settings_aggregated_stats_key" translatable="false">settingsAggregatedStats</string>

<!-- Setting's categories -->

<string name="settings_reset_key" translatable="false">settingsReset</string>
Expand Down Expand Up @@ -286,6 +288,8 @@
<string name="settings_api_key" translatable="false">settingsAPI</string>
<string name="publicapi_package_key" translatable="false">apiPackageKey</string>
<string name="publicapi_enabled_key" translatable="false">apiEnabledKey</string>
<string name="aggregated_stats_package_key" translatable="false">AggregatedStatsPackageKey</string>
<bool name="aggregated_stats_enabled_default">false</bool>
<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/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ limitations under the License.
<string name="settings_stats_units_nautical">Nautical (NM, ft)</string>
<string name="settings_stats_units_title">Preferred units</string>

<!-- Settings Aggregated stats -->
<string name="settings_aggregated_stats">Aggregated Stats</string>
<string name="settings_aggregated_stats_summary">Choose your own stats</string>
<string name="settings_elevation_gain">Elevation Gain</string>

<!-- Settings public api -->
<string name="settings_api_title">Public API</string>
<string name="settings_api_summary">Remote control and statistics API for other apps</string>
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
android:summary="@string/settings_api_summary"
android:title="@string/settings_api_title" />

<Preference
android:icon="@drawable/ic_statistics_24dp"
android:key="@string/settings_aggregated_stats_key"
android:summary="@string/settings_aggregated_stats_summary"
android:title="@string/settings_aggregated_stats" />

<Preference
android:icon="@drawable/ic_baseline_info_24"
android:summary="@string/settings_open_tracks_summary"
Expand Down
25 changes: 25 additions & 0 deletions src/main/res/xml/settings_aggregated_stats.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_aggregated_stats">

<Preference
android:key="@string/aggregated_stats_package_key"
android:selectable="false"
android:persistent="false"
android:title="@string/settings_aggregated_stats" />


<SwitchPreference
android:defaultValue="false"
android:key="@string/aggregated_stats_package_key"
android:title="@string/settings_elevation_gain" />

<!--<SwitchPreferenceCompat-->
<!-- android:title="@string/settings_public_api_dashboard_enabled_title"-->
<!-- android:summaryOn="@string/settings_public_api_dashboard_enabled_summary_on"-->
<!-- android:summaryOff="@string/settings_public_api_dashboard_enabled_summary_off"-->
<!-- android:defaultValue="@bool/publicapi_dashboard_enabled_default"-->
<!-- android:key="@string/publicapi_dashboard_enabled_key" />-->

</PreferenceScreen>

0 comments on commit 077b5de

Please sign in to comment.