From 563c3bb2098d14f748dc15a66c1c5062567f0cea Mon Sep 17 00:00:00 2001 From: Thanh Phan Date: Sat, 10 Feb 2024 20:27:48 -0500 Subject: [PATCH 01/11] Rename method "fromCSV" to prevent any misunderstanding with method "fromCsv" --- .../ui/customRecordingLayout/RecordingLayoutIO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java index fd30e6610..7fba8611d 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java +++ b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java @@ -32,7 +32,7 @@ public static RecordingLayout fromCsv(@NonNull String csvLine, @NonNull Resource Log.e(TAG, "Invalid CSV layout. It shouldn't happen: " + csvLine); return recordingLayout; } - recordingLayout.addField(fromCSV(fieldParts, resources)); + recordingLayout.addField(getFieldFromCSVRecord(fieldParts, resources)); } return recordingLayout; } @@ -41,7 +41,7 @@ public static String toCSV(List recordingLayouts) { return recordingLayouts.stream().map(RecordingLayout::toCsv).collect(Collectors.joining(CsvLayoutUtils.LINE_SEPARATOR)); } - private static DataField fromCSV(String[] fieldParts, @NonNull Resources resources) { + private static DataField getFieldFromCSVRecord(String[] fieldParts, @NonNull Resources resources) { return new DataField( fieldParts[0], YES_VALUE.equals(fieldParts[1]), From 5142b22ab8826f9dd10d77c9f69d91621d280c47 Mon Sep 17 00:00:00 2001 From: gaurav Date: Thu, 8 Feb 2024 16:25:44 -0500 Subject: [PATCH 02/11] Replace this switch statement by if statement --- .../opentracks/ui/markers/MarkerEditActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java b/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java index 97d597ebe..e270b920a 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java +++ b/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java @@ -138,14 +138,16 @@ protected void onCreate(Bundle savedInstanceState) { takePictureFromCamera = registerForActivityResult( new ActivityResultContracts.StartActivityForResult(), result -> { - switch (result.getResultCode()) { - case RESULT_CANCELED -> - Toast.makeText(this, R.string.marker_add_photo_canceled, Toast.LENGTH_LONG).show(); - case RESULT_OK -> viewModel.onNewCameraPhoto(cameraPhotoUri, + int resultCode = result.getResultCode(); + if (resultCode == RESULT_CANCELED) { + Toast.makeText(this, R.string.marker_add_photo_canceled, Toast.LENGTH_LONG).show(); + } else if (resultCode == RESULT_OK) { + viewModel.onNewCameraPhoto(cameraPhotoUri, viewBinding.markerEditName.getText().toString(), viewBinding.markerEditMarkerType.getText().toString(), viewBinding.markerEditDescription.getText().toString()); } + } }); takePictureFromGallery = registerForActivityResult( From 91e1b983499d4d315dd6cd1d43f9de547fd642b1 Mon Sep 17 00:00:00 2001 From: gaurav Date: Thu, 8 Feb 2024 16:37:22 -0500 Subject: [PATCH 03/11] Removed Unnecessary Bracket --- .../de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java b/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java index e270b920a..acc0168dd 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java +++ b/src/main/java/de/dennisguse/opentracks/ui/markers/MarkerEditActivity.java @@ -147,7 +147,6 @@ protected void onCreate(Bundle savedInstanceState) { viewBinding.markerEditMarkerType.getText().toString(), viewBinding.markerEditDescription.getText().toString()); } - } }); takePictureFromGallery = registerForActivityResult( From a6b1cb330eb9df24ecb591fcdbdbeb7a43df1961 Mon Sep 17 00:00:00 2001 From: Akshar Patel <53969601+aksharpatel17@users.noreply.github.com> Date: Mon, 12 Feb 2024 19:04:55 -0500 Subject: [PATCH 04/11] Refactor: Change type of 'items' to interface 'List' from implementation 'ArrayList' --- .../ui/aggregatedStatistics/FilterDialogFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java index 75dd378d4..e043e2387 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java +++ b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java @@ -38,7 +38,7 @@ public static void showDialog(FragmentManager fragmentManager) { filterDialogFragment.show(fragmentManager, TAG); } - public static void showDialog(FragmentManager fragmentManager, ArrayList items) { + public static void showDialog(FragmentManager fragmentManager, List items) { Bundle bundle = new Bundle(); bundle.putParcelableArrayList(KEY_FILTER_ITEMS, items); From 2c55e3c8e02dac07fbb040a478a0abfb5e1073af Mon Sep 17 00:00:00 2001 From: Pranav Sakariya Date: Sun, 11 Feb 2024 13:50:55 -0500 Subject: [PATCH 05/11] Declare "lastInterval" on a separate line. --- .../opentracks/ui/intervals/IntervalStatistics.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalStatistics.java b/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalStatistics.java index cbb07bd06..863e74f3b 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalStatistics.java +++ b/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalStatistics.java @@ -18,8 +18,9 @@ public class IntervalStatistics { private TrackStatisticsUpdater trackStatisticsUpdater = new TrackStatisticsUpdater(); private final List intervalList; private final Distance distanceInterval; - private Interval interval, lastInterval; - + private Interval interval; + private Interval lastInterval; + /** * @param distanceInterval distance of every interval. */ From 77a0df7a12a998b165dce96fb277d9daa88b589e Mon Sep 17 00:00:00 2001 From: jaedusandoval <114364007+jaedusandoval@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:21:14 -0500 Subject: [PATCH 06/11] Add a private constructor to hide the implicit public one (#28) Add a private constructor to hide the implicit public one --- .../ui/customRecordingLayout/RecordingLayoutIO.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java index 7fba8611d..892d96885 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java +++ b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayoutIO.java @@ -18,6 +18,11 @@ public class RecordingLayoutIO { private static final String YES_VALUE = "1"; private static final String NOT_VALUE = "0"; + // Private constructor to hide the implicit public one + private RecordingLayoutIO() { + throw new AssertionError("This class should not be instantiated."); + } + public static RecordingLayout fromCsv(@NonNull String csvLine, @NonNull Resources resources) { List csvParts = CsvLayoutUtils.getCsvLineParts(csvLine); if (csvParts == null) { From 31600ff2dea869b645c26f6a46093b5aecb3c107 Mon Sep 17 00:00:00 2001 From: jaedusandoval <114364007+jaedusandoval@users.noreply.github.com> Date: Tue, 13 Feb 2024 23:46:03 -0500 Subject: [PATCH 07/11] Replace this usage of Stream.collect(Collectors.toList()) with Stream.toList() (#30) --- .../opentracks/ui/customRecordingLayout/RecordingLayout.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayout.java b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayout.java index bc05ffd10..2cbaa2db5 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayout.java +++ b/src/main/java/de/dennisguse/opentracks/ui/customRecordingLayout/RecordingLayout.java @@ -68,7 +68,7 @@ public List getFields() { public RecordingLayout toRecordingLayout(boolean visibility) { RecordingLayout result = new RecordingLayout(this.getName()); - result.addFields(dataFields.stream().filter(f -> f.isVisible() == visibility).collect(Collectors.toList())); + result.addFields(dataFields.stream().filter(f -> f.isVisible() == visibility).toList()); return result; } From 1e1627fbd074028c5f16e87a8826814a6e79fcfc Mon Sep 17 00:00:00 2001 From: Arik kantesaria <73924950+Arik39@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:36:36 -0500 Subject: [PATCH 08/11] Add the missing deprecated Javadoc tag (#25) --- .../opentracks/ui/intervals/IntervalsFragment.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalsFragment.java b/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalsFragment.java index 96f6aea58..d9c65a503 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalsFragment.java +++ b/src/main/java/de/dennisguse/opentracks/ui/intervals/IntervalsFragment.java @@ -97,6 +97,16 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, return viewBinding.getRoot(); } + /** + * This method is deprecated. + * + * This method is marked as deprecated and should be re-implemented with updated functionality. + * Deprecated methods are discouraged from use as they may be removed or replaced in future versions. + * Developers are advised to find alternative approaches or update the method to meet current requirements. + * + * @deprecated This method is deprecated and should be re-implemented. + * + */ @Deprecated //TODO This method must be re-implemented. @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { From 854b46262004f3da51eb055a313fcbda7539f96c Mon Sep 17 00:00:00 2001 From: Goutham Susarla Date: Thu, 15 Feb 2024 13:15:20 -0500 Subject: [PATCH 09/11] Update ScrollVisibleViews to use inclusive range for visible views Merge this if statement with the enclosing one --- .../opentracks/ui/util/ScrollVisibleViews.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/util/ScrollVisibleViews.java b/src/main/java/de/dennisguse/opentracks/ui/util/ScrollVisibleViews.java index 18c449777..663ca136e 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/util/ScrollVisibleViews.java +++ b/src/main/java/de/dennisguse/opentracks/ui/util/ScrollVisibleViews.java @@ -6,7 +6,8 @@ import androidx.annotation.NonNull; /** - * AbsListView.OnScrollListener class that can be used to know what views in a ListView are currently visible while scrolling. + * AbsListView.OnScrollListener class that can be used to know what views in a + * ListView are currently visible while scrolling. */ public class ScrollVisibleViews implements AbsListView.OnScrollListener { private int from = -1; @@ -20,12 +21,12 @@ public ScrollVisibleViews(@NonNull VisibleViewsListener visibleViewsListener) { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { - if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { - if (from >= 0 && to >= 0) { - for (int i = from; i < to; i++) { - View viewChild = view.getChildAt(i - from); - visibleViewsListener.onViewVisible(viewChild, i); - } + if ((scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE + || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING + || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) && (from >= 0 && to >= 0)) { + for (int i = from; i < to; i++) { + View viewChild = view.getChildAt(i - from); + visibleViewsListener.onViewVisible(viewChild, i); } } } From 4c90de0b4e6e5bd053fddcf517e518c36b3e7474 Mon Sep 17 00:00:00 2001 From: Vishwas Tomar <84849356+VishwasTomar@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:39:54 -0500 Subject: [PATCH 10/11] Change the visibility of this constructor to "protected" (#39) --- .../opentracks/ui/util/RecyclerViewSwipeDeleteCallback.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/util/RecyclerViewSwipeDeleteCallback.java b/src/main/java/de/dennisguse/opentracks/ui/util/RecyclerViewSwipeDeleteCallback.java index b5b3dc0ad..982cc2a05 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/util/RecyclerViewSwipeDeleteCallback.java +++ b/src/main/java/de/dennisguse/opentracks/ui/util/RecyclerViewSwipeDeleteCallback.java @@ -25,7 +25,7 @@ abstract public class RecyclerViewSwipeDeleteCallback extends ItemTouchHelper.Ca private final int intrinsicWidth; private final int intrinsicHeight; - public RecyclerViewSwipeDeleteCallback(Context context) { + protected RecyclerViewSwipeDeleteCallback(Context context) { background = new ColorDrawable(); backgroundColor = ContextCompat.getColor(context, R.color.colorBackgroundDelete); clearPaint = new Paint(); From 24054a65bd334c6f327ecd6bf80e2a436880a097 Mon Sep 17 00:00:00 2001 From: Akshar Patel <53969601+aksharpatel17@users.noreply.github.com> Date: Thu, 15 Feb 2024 20:31:44 -0500 Subject: [PATCH 11/11] Fix/#19 Import error for List resolved (#33) --- .../ui/aggregatedStatistics/FilterDialogFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java index e043e2387..e4d399323 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java +++ b/src/main/java/de/dennisguse/opentracks/ui/aggregatedStatistics/FilterDialogFragment.java @@ -18,6 +18,7 @@ import java.time.ZoneOffset; import java.time.temporal.WeekFields; import java.util.ArrayList; +import java.util.List; import java.util.Locale; import de.dennisguse.opentracks.R; @@ -40,7 +41,7 @@ public static void showDialog(FragmentManager fragmentManager) { public static void showDialog(FragmentManager fragmentManager, List items) { Bundle bundle = new Bundle(); - bundle.putParcelableArrayList(KEY_FILTER_ITEMS, items); + bundle.putParcelableArrayList(KEY_FILTER_ITEMS,(ArrayList) items); FilterDialogFragment filterDialogFragment = new FilterDialogFragment(); filterDialogFragment.setArguments(bundle);