From 880d8e54f1f6bf83b5fb08ca40895dcdf74c22b1 Mon Sep 17 00:00:00 2001 From: yashbhavsar20 <88206430+yashbhavsar20@users.noreply.github.com> Date: Wed, 11 Oct 2023 17:24:00 -0400 Subject: [PATCH 001/103] Added missing @deprecated javadoc tag Added 'since' and/or 'ForRemoval' arguments to the @Deprecated annotation. --- .../java/de/dennisguse/opentracks/chart/ChartPoint.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/chart/ChartPoint.java b/src/main/java/de/dennisguse/opentracks/chart/ChartPoint.java index af44edb12..923513c42 100644 --- a/src/main/java/de/dennisguse/opentracks/chart/ChartPoint.java +++ b/src/main/java/de/dennisguse/opentracks/chart/ChartPoint.java @@ -21,12 +21,19 @@ public class ChartPoint { private Double cadence; private Double power; - @Deprecated + /** + * This class represents a chart point. + * + * @deprecated This constructor is deprecated and will be removed in a future version. + * Use an alternative constructor or method to create ChartPoint instances. + */ + @Deprecated(since = "1.0", forRemoval = true) @VisibleForTesting ChartPoint(double altitude) { this.altitude = altitude; } + public ChartPoint(@NonNull TrackStatistics trackStatistics, @NonNull TrackPoint trackPoint, Speed smoothedSpeed, boolean chartByDistance, UnitSystem unitSystem) { if (chartByDistance) { timeOrDistance = trackStatistics.getTotalDistance().toKM_Miles(unitSystem); From 5c90fc92d95c5458489f541f0bf442d4aca131a0 Mon Sep 17 00:00:00 2001 From: Deniz Date: Tue, 14 Nov 2023 22:21:18 -0500 Subject: [PATCH 002/103] #183: [ADD] Ignore IDE files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fc0db155f..82e9e5a54 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ captures/ /out/ # User-specific configurations +.idea .idea/.name .idea/caches/ .idea/compiler.xml From 4d0a84417eb63d1978eb1476e165a4d2f84fa307 Mon Sep 17 00:00:00 2001 From: VarunAggarwal1998 <117046986+VarunAggarwal1998@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:19:11 -0500 Subject: [PATCH 003/103] Add new string resources for the titles and units for weight and temperature; #187 - subtask. --- src/main/res/values/strings.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 4db8181a7..6b16d3ffa 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -532,6 +532,15 @@ limitations under the License. min/km min/mi min/NM + + + Preferred weight + Preferred Temperature + Pound (lb) + Kilogram (kg) + Celsius (°C) + Fahrenheit (°F) + %1$s° %1$s, %2$s From 9773c06bab404b293d48ca6e0f20e22355e6335d Mon Sep 17 00:00:00 2001 From: Deepanshu Sehgal Date: Thu, 16 Nov 2023 16:56:04 -0500 Subject: [PATCH 004/103] Define the options and values for the new settings; #187 - subtask. --- src/main/res/values/settings.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/main/res/values/settings.xml b/src/main/res/values/settings.xml index 95ea4ecc1..2148a83d0 100644 --- a/src/main/res/values/settings.xml +++ b/src/main/res/values/settings.xml @@ -184,6 +184,35 @@ @string/settings_stats_units_nautical + + weightUnit + @string/unit_kilogram + + @string/unit_kilogram + @string/unit_pound + + + + @string/unit_kilogram + @string/unit_pound + + + + + temperatureUnit + @string/unit_celsius + + @string/unit_celsius + @string/unit_fahrenheit + + + + + @string/unit_celsius + @string/unit_fahrenheit + + + trackName @string/settings_recording_track_name_date_iso_8601_value DATE_ISO_8601 From ec631f6a95f4ab67ff02e492de1ee53ded54a82f Mon Sep 17 00:00:00 2001 From: jasmanpreet0209 Date: Thu, 16 Nov 2023 21:11:16 -0500 Subject: [PATCH 005/103] Add the corresponding ListPreference items for the updated settings; #187 - subtask --- src/main/res/xml/settings_defaults.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/res/xml/settings_defaults.xml b/src/main/res/xml/settings_defaults.xml index 778b55528..16e02c605 100644 --- a/src/main/res/xml/settings_defaults.xml +++ b/src/main/res/xml/settings_defaults.xml @@ -19,6 +19,20 @@ android:key="@string/stats_rate_key" android:title="@string/settings_stats_rate_title" app:useSimpleSummaryProvider="true" /> + + From 5655e0824063b7a735ee7d063ef81ee7463448db Mon Sep 17 00:00:00 2001 From: nishabhatia98 <38858543+nishabhatia98@users.noreply.github.com> Date: Thu, 16 Nov 2023 22:08:51 -0500 Subject: [PATCH 006/103] Create a new enum WeightUnit ; #187 - subtask. --- .../opentracks/settings/WeightUnit.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/de/dennisguse/opentracks/settings/WeightUnit.java diff --git a/src/main/java/de/dennisguse/opentracks/settings/WeightUnit.java b/src/main/java/de/dennisguse/opentracks/settings/WeightUnit.java new file mode 100644 index 000000000..3eafd9f01 --- /dev/null +++ b/src/main/java/de/dennisguse/opentracks/settings/WeightUnit.java @@ -0,0 +1,23 @@ +package de.dennisguse.opentracks.settings; + +import de.dennisguse.opentracks.R; + +public enum WeightUnit { + POUND(R.string.unit_pound), + KILOGRAM(R.string.unit_kilogram); + + private final int preferenceIdentifier; + + WeightUnit(int preferenceIdentifier) { + this.preferenceIdentifier = preferenceIdentifier; + } + + public int getPreferenceId() { + return preferenceIdentifier; + } + + // If you need a default value, you can define it here + public static WeightUnit defaultWeightUnit() { + return KILOGRAM; + } +} From 3e80dc03fbc7f8045a5f88caa757c1555af7696b Mon Sep 17 00:00:00 2001 From: knvramana Date: Thu, 16 Nov 2023 22:52:49 -0500 Subject: [PATCH 007/103] Create a new enum TemperatureUnit ; #187 - subtask. --- .../opentracks/settings/TemperatureUnit.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/de/dennisguse/opentracks/settings/TemperatureUnit.java diff --git a/src/main/java/de/dennisguse/opentracks/settings/TemperatureUnit.java b/src/main/java/de/dennisguse/opentracks/settings/TemperatureUnit.java new file mode 100644 index 000000000..19836ff04 --- /dev/null +++ b/src/main/java/de/dennisguse/opentracks/settings/TemperatureUnit.java @@ -0,0 +1,23 @@ +package de.dennisguse.opentracks.settings; + +import de.dennisguse.opentracks.R; + +public enum TemperatureUnit { + CELSIUS(R.string.unit_celsius), + FAHRENHEIT(R.string.unit_fahrenheit); + + private final int preferenceIdentifier; + + TemperatureUnit(int preferenceIdentifier) { + this.preferenceIdentifier = preferenceIdentifier; + } + + public int getPreferenceId() { + return preferenceIdentifier; + } + + // If you need a default value, you can define it here + public static TemperatureUnit defaultTemperatureUnit() { + return CELSIUS; + } +} From 55fa4d31b89da271ff1f62bc807900d834ec5151 Mon Sep 17 00:00:00 2001 From: Habeeb Dashti Date: Thu, 16 Nov 2023 23:15:48 -0500 Subject: [PATCH 008/103] Managing and retrieving the unit system preferences for Temperature unit; #187 - subtask. --- .../opentracks/settings/PreferencesUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java index e0303a261..bec231152 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java @@ -233,7 +233,19 @@ public static void applyDefaultUnit() { } } } + public static TemperatureUnit getTemperatureUnit() { + final String TEMPERATURE_UNIT_DEFAULT = resources.getString(R.string.temperature_unit_default); + final String VALUE = getString(R.string.temperature_unit_key, TEMPERATURE_UNIT_DEFAULT); + return Arrays.stream(TemperatureUnit.values()) + .filter(d -> VALUE.equals(resources.getString(d.getPreferenceId(), TEMPERATURE_UNIT_DEFAULT))) + .findFirst() + .orElse(TemperatureUnit.defaultTemperatureUnit()); + } + + public static void setTemperatureUnit(TemperatureUnit temperatureUnit) { + setString(R.string.temperature_unit_key, temperatureUnit.getPreferenceId()); + } public static boolean isReportSpeed(String activityTypeLocalized) { final String STATS_RATE_DEFAULT = resources.getString(R.string.stats_rate_default); String currentStatsRate = getString(R.string.stats_rate_key, STATS_RATE_DEFAULT); From e33bec8a48959c42cecc49f73745b55d3e9db138 Mon Sep 17 00:00:00 2001 From: mohduvas Date: Fri, 17 Nov 2023 13:06:08 -0500 Subject: [PATCH 009/103] Managing and retrieving the unit system preferences for weight unit; #187 - subtask. --- .../opentracks/settings/PreferencesUtils.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java index bec231152..2df14dd95 100644 --- a/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java +++ b/src/main/java/de/dennisguse/opentracks/settings/PreferencesUtils.java @@ -233,6 +233,21 @@ public static void applyDefaultUnit() { } } } + + public static WeightUnit getWeightUnit() { + final String WEIGHT_UNIT_DEFAULT = resources.getString(R.string.weight_unit_default); + + final String VALUE = getString(R.string.weight_unit_key, WEIGHT_UNIT_DEFAULT); + return Arrays.stream(WeightUnit.values()) + .filter(d -> VALUE.equals(resources.getString(d.getPreferenceId(), WEIGHT_UNIT_DEFAULT))) + .findFirst() + .orElse(WeightUnit.defaultWeightUnit()); + } + + public static void setWeightUnit(WeightUnit weightUnit) { + setString(R.string.weight_unit_key, weightUnit.getPreferenceId()); + } + public static TemperatureUnit getTemperatureUnit() { final String TEMPERATURE_UNIT_DEFAULT = resources.getString(R.string.temperature_unit_default); From 141361e9a184c3398aaa8d90b72841656029fcf8 Mon Sep 17 00:00:00 2001 From: jatin51997 Date: Fri, 17 Nov 2023 18:09:54 -0500 Subject: [PATCH 010/103] initial changes to start screen --- .../opentracks/TrackListActivity.java | 38 ++++++- .../opentracks/TrackRecordingActivity.java | 100 ++++++++++++++---- src/main/res/layout/track_recording.xml | 7 +- 3 files changed, 123 insertions(+), 22 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java index bf10ba549..25c20d000 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackListActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackListActivity.java @@ -247,10 +247,9 @@ public void bindView(View view, Context context, Cursor cursor) { // Not Recording -> Recording updateGpsMenuItem(false, true); new TrackRecordingServiceConnection((service, connection) -> { - Track.Id trackId = service.startNewTrack(); - + // Track.Id trackId = service.startNewTrack(); Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); - newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + //newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); startActivity(newIntent); connection.unbind(this); @@ -271,7 +270,22 @@ public void bindView(View view, Context context, Cursor cursor) { }); setSupportActionBar(viewBinding.trackListToolbar); + if (recordingStatus.isRecording()) { + Toast.makeText(TrackListActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); + return; + } + // Not Recording -> Recording + updateGpsMenuItem(false, true); + new TrackRecordingServiceConnection((service, connection) -> { + //Track.Id trackId = service.startNewTrack(); + + Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + startActivity(newIntent); + + connection.unbind(this); + }).startAndBind(this, true); loadData(getIntent()); } @@ -329,6 +343,24 @@ public boolean onCreateOptionsMenu(Menu menu) { return super.onCreateOptionsMenu(menu); } + void startRecording() { + if (recordingStatus.isRecording()) { + Toast.makeText(TrackListActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); + return; + } + + // Not Recording -> Recording + updateGpsMenuItem(false, true); + new TrackRecordingServiceConnection((service, connection) -> { + Track.Id trackId = service.startNewTrack(); + + Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); + newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); + startActivity(newIntent); + + connection.unbind(this); + }).startAndBind(this, true); + } @Override public boolean onPrepareOptionsMenu(Menu menu) { diff --git a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java index d6e686008..dc7733a41 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackRecordingActivity.java @@ -5,11 +5,11 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Build; import android.os.Bundle; -import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.WindowManager; +import android.widget.Button; import android.widget.Toast; import androidx.annotation.NonNull; @@ -112,25 +112,25 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); contentProviderUtils = new ContentProviderUtils(this); - trackId = getIntent().getParcelableExtra(EXTRA_TRACK_ID); - if (trackId == null) { - throw new RuntimeException("TrackId is mandatory"); - } - if (contentProviderUtils.getTrack(trackId) == null) { - Log.w(TAG, "TrackId does not exists."); - finish(); - } + // trackId = getIntent().getParcelableExtra(EXTRA_TRACK_ID); +// if (trackId == null) { +// throw new RuntimeException("TrackId is mandatory"); +// } +// if (contentProviderUtils.getTrack(trackId) == null) { +// Log.w(TAG, "TrackId does not exists."); +// finish(); +// } - trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); + // trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); trackDataHub = new TrackDataHub(this); CustomFragmentPagerAdapter pagerAdapter = new CustomFragmentPagerAdapter(this); - viewBinding.trackDetailActivityViewPager.setAdapter(pagerAdapter); - new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, - (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); - if (savedInstanceState != null) { - viewBinding.trackDetailActivityViewPager.setCurrentItem(savedInstanceState.getInt(CURRENT_TAB_TAG_KEY)); - } + viewBinding.trackDetailActivityViewPager.setAdapter(pagerAdapter); +// new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, +// (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); +// if (savedInstanceState != null) { +// viewBinding.trackDetailActivityViewPager.setCurrentItem(savedInstanceState.getInt(CURRENT_TAB_TAG_KEY)); +// } viewBinding.trackRecordingFabAction.setImageResource(R.drawable.ic_baseline_stop_24); viewBinding.trackRecordingFabAction.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.opentracks)); @@ -149,8 +149,72 @@ protected void onCreate(Bundle savedInstanceState) { viewBinding.bottomAppBar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_24); setSupportActionBar(viewBinding.bottomAppBar); + Button startRecordingButton = findViewById(R.id.startRecordingButton); + startRecordingButton.setOnClickListener(v -> startRecording(pagerAdapter)); + + startRecordingButton.setOnLongClickListener((view) -> { + ActivityUtils.vibrate(this, 1000); + trackRecordingServiceConnection.stopRecording(TrackRecordingActivity.this); + Intent newIntent = IntentUtils.newIntent(TrackRecordingActivity.this, TrackStoppedActivity.class) + .putExtra(TrackStoppedActivity.EXTRA_TRACK_ID, trackId); + startActivity(newIntent); + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); + finish(); + return true; + }); + + viewBinding.bottomAppBar.setVisibility(View.GONE); + viewBinding.trackRecordingFabAction.hide(); + } + void startRecording(CustomFragmentPagerAdapter pagerAdapter) { +// // ((TrackListActivity) getParent()).startRecording(); +// new TrackRecordingServiceConnection((service, connection) -> { +// Track.Id trackId = service.startNewTrack(); +// +//// Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +//// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); +//// startActivity(newIntent); +// +// connection.unbind(this); +// }).startAndBind(this, true); + + + if (recordingStatus.isRecording()) { + Toast.makeText(TrackRecordingActivity.this, getString(R.string.hold_to_stop), Toast.LENGTH_LONG).show(); + return; + } + // Not Recording -> Recording + // updateGpsMenuItem(false, true); + new TrackRecordingServiceConnection((service, connection) -> { + trackId = service.startNewTrack(); + trackRecordingServiceConnection = new TrackRecordingServiceConnection(bindChangedCallback); + trackRecordingServiceConnection.startConnection(this); + + //trackId = trackId; +// Intent newIntent = IntentUtils.newIntent(TrackListActivity.this, TrackRecordingActivity.class); +// newIntent.putExtra(TrackRecordingActivity.EXTRA_TRACK_ID, trackId); +// startActivity(newIntent); + + // connection.unbind(this); + }).startAndBind(this, true); + // CustomFragmentPagerAdapter pagerAdapter = new CustomFragmentPagerAdapter(this); + // viewBinding.trackDetailActivityViewPager.setAdapter(pagerAdapter); + new TabLayoutMediator(viewBinding.trackDetailActivityTablayout, viewBinding.trackDetailActivityViewPager, + (tab, position) -> tab.setText(pagerAdapter.getPageTitle(position))).attach(); + viewBinding.bottomAppBar.setVisibility(View.VISIBLE); + Button startRecordingButton = findViewById(R.id.startRecordingButton); + + startRecordingButton.setText("Stop Recording"); + +//// Change text color +// startRecordingButton.setTextColor(getResources().getColor(R.color.your_text_color)); +// +//// Change background color +// startRecordingButton.setBackgroundColor(getResources().getColor(R.color.your_background_color)); + + } @Override public void onAttachedToWindow() { setLockscreenPolicy(); @@ -208,7 +272,7 @@ protected void onStart() { PreferencesUtils.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - trackRecordingServiceConnection.startConnection(this); + // trackRecordingServiceConnection.startConnection(this); trackDataHub.start(); } @@ -225,7 +289,7 @@ protected void onResume() { trackDataHub.setRecordingStatus(recordingStatus); } - trackRecordingServiceConnection.startAndBindWithCallback(this); + // trackRecordingServiceConnection.startAndBindWithCallback(this); } @Override diff --git a/src/main/res/layout/track_recording.xml b/src/main/res/layout/track_recording.xml index 360a056dc..e7d41e3c7 100644 --- a/src/main/res/layout/track_recording.xml +++ b/src/main/res/layout/track_recording.xml @@ -28,7 +28,12 @@ android:layout_height="match_parent" /> - +