Skip to content

Commit

Permalink
Fix: Group9 issues: #1 #2 #6 #9 #11 #13 #14 #15 (#50)
Browse files Browse the repository at this point in the history
This PR consists of changes for issues resolved by Group9.


[#1](tarekFerdous#1)
Define a constant instead of duplicating this literal "<open>1</open>" 3
times.

[#2](tarekFerdous#2)
Replace this usage of 'Stream.collect(Collectors.toList())' with
'Stream.toList()' Group 09

[#6](tarekFerdous#6)
Either re-interrupt this method or rethrow the "InterruptedException"
that can be caught here.

[#9](tarekFerdous#9)
Remove unused "TAG" private field.

[#11](tarekFerdous#11)
Use isEmpty() to check whether the collection is empty or not.

[#13](tarekFerdous#13)
Fixing technical debts for io/file/impoter/importService.java and
io/file/importer/importViewModel.java

[#14](tarekFerdous#14)
io/file/importer/KmlTrackImporter and io/file/importer/KmzTrackImporter

[#15](tarekFerdous#15)
Removing the Deprecated lines in the code Group(09)
  • Loading branch information
Sharanyu authored Feb 17, 2024
2 parents c64eb44 + 86aa596 commit 35390eb
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ private void storeTrackMetaData(ContentProviderUtils contentProviderUtils, Track
viewBinding.trackEditActivityType.getText().toString(), viewBinding.trackEditDescription.getText().toString(),
contentProviderUtils);
}

@Override
//Deprecated this method beacause its deprecated
@Deprecated
public void onBackPressed() {
if (isDiscarding) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
Expand Down Expand Up @@ -232,9 +231,9 @@ private void createExportTasks(boolean allInOneFile) {
exportTasks = new ArrayList<>();
if (allInOneFile) {
String filename = "OpenTracks-Backup";
exportTasks.add(new ExportTask(filename, trackFileFormat, tracks.stream().map(Track::getId).collect(Collectors.toList())));
exportTasks.add(new ExportTask(filename, trackFileFormat, tracks.stream().map(Track::getId).toList()));
} else {
exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.getId()))).collect(Collectors.toList()));
exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.getId()))).toList());
}
trackExportTotalCount = exportTasks.size();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class KMLTrackExporter implements TrackExporter {
public static final String EXTENDED_DATA_TYPE_ACCURACY_HORIZONTAL = "accuracy_horizontal";
public static final String EXTENDED_DATA_TYPE_ACCURACY_VERTICAL = "accuracy_vertical";

public static final String constant_variable= "<open>1</open>";
private static final NumberFormat SENSOR_DATA_FORMAT = NumberFormat.getInstance(Locale.US);

static {
Expand Down Expand Up @@ -238,7 +239,7 @@ private void writeHeader(List<Track> tracks) {
http://opentracksapp.com/xmlschemas/v1 http://opentracksapp.com/xmlschemas/OpenTracks_v1.xsd">
"""); //TODO ADD xsi:schemaLocation for atom
printWriter.println("<Document>");
printWriter.println("<open>1</open>");
printWriter.println(constant_variable);
printWriter.println("<visibility>1</visibility>");

Track track = tracks.get(0);
Expand All @@ -265,7 +266,7 @@ private void writeFooter() {
private void writeBeginMarkers(Track track) {
printWriter.println("<Folder>");
printWriter.println("<name>" + StringUtils.formatCData(context.getString(R.string.track_markers, track.getName())) + "</name>");
printWriter.println("<open>1</open>");
printWriter.println(constant_variable);
}

private void writeMarker(Marker marker, ZoneOffset zoneOffset) {
Expand All @@ -285,7 +286,7 @@ private void writeEndMarkers() {
private void writeMultiTrackBegin() {
printWriter.println("<Folder id=\"tracks\">");
printWriter.println("<name>" + context.getString(R.string.generic_tracks) + "</name>");
printWriter.println("<open>1</open>");
printWriter.println(constant_variable);
}

private void writeMultiTrackEnd() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream
return true;
} catch (InterruptedException | IOException e) {
Log.e(TAG, "Unable to write track", e);
Thread.currentThread().interrupt();
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
*/
public class ImportActivity extends FragmentActivity {

private static final String TAG = ImportActivity.class.getSimpleName();

public static final String EXTRA_DIRECTORY_URI_KEY = "directory_uri";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void importFile(DocumentFile file) {
String fileExtension = FileUtils.getExtension(file);
try {
Distance maxRecordingDistance = PreferencesUtils.getMaxRecordingDistance();
Distance recordingDistanceInterval = PreferencesUtils.getRecordingDistanceInterval();
// Distance recordingDistanceInterval = PreferencesUtils.getRecordingDistanceInterval();
boolean preventReimport = PreferencesUtils.getPreventReimportTracks();

TrackImporter trackImporter = new TrackImporter(this, new ContentProviderUtils(this), maxRecordingDistance, preventReimport);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void cancel() {
private void loadData(List<DocumentFile> documentFiles) {
List<ArrayList<DocumentFile>> nestedFileList = documentFiles.stream()
.map(FileUtils::getFiles)
.collect(Collectors.toList());
.toList();

List<DocumentFile> fileList = new ArrayList<>();
nestedFileList.forEach(fileList::addAll);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class KmlTrackImporter extends DefaultHandler implements XMLImporter.Trac
private static final String TAG_PHOTO_OVERLAY = "PhotoOverlay";
private static final String TAG_PLACEMARK = "Placemark";
private static final String TAG_STYLE_URL = "styleUrl";
// private static final String TAG_VALUE = "value"; TODO
// private static final String TAG_VALUE = "value";
private static final String TAG_WHEN = "when";
private static final String TAG_UUID = "opentracks:trackid";

Expand Down Expand Up @@ -258,7 +258,7 @@ private void onMarkerEnd() {
return;
}

Marker marker = new Marker(null, new TrackPoint(TrackPoint.Type.TRACKPOINT, location, whenList.get(0))); //TODO Creating marker without need
Marker marker = new Marker(null, new TrackPoint(TrackPoint.Type.TRACKPOINT, location, whenList.get(0)));
marker.setName(name != null ? name : "");
marker.setDescription(description != null ? description : "");
marker.setCategory(activityTypeLocalized != null ? activityTypeLocalized : "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public List<Track.Id> importFile(InputStream inputStream) throws ImportParserExc
return parser.getImportTrackIds();
} catch (SAXException | ParserConfigurationException | ParsingException e) {
Log.e(TAG, "Unable to import file", e);
if (parser.getImportTrackIds().size() > 0) {
if (parser.getImportTrackIds().isEmpty()) {
parser.cleanImport();
}
throw new ImportParserException(e);
Expand Down

0 comments on commit 35390eb

Please sign in to comment.