Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features and unit tests enhancements #289

Merged
merged 90 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
fc27982
Changes per code review
FJBDev Dec 27, 2020
b832400
Removing the harmless ResourceNotFoundException
FJBDev Dec 27, 2020
c63ee69
Putting it back
FJBDev Dec 27, 2020
f39e032
We clear the browser session so that a user can log in with different
FJBDev Dec 28, 2020
d802121
Misc
FJBDev Dec 28, 2020
360fb27
Useless
FJBDev Dec 28, 2020
26e7937
Merge remote-tracking branch 'Wolfgang/main' into main
FJBDev Dec 28, 2020
7a41cb4
Making the Strava upload asynchronous to speed up the upload
FJBDev Dec 28, 2020
c893b98
Renaming the field per Wolfgang suggestion
FJBDev Dec 28, 2020
ce20539
Putting fields, which belong together, into { ... }, for better
FJBDev Dec 28, 2020
7bffbe1
displaying the account user name in the upload dialog
FJBDev Dec 28, 2020
6fd934f
Misc
FJBDev Dec 28, 2020
47fc47a
Export Unit tests update and successful
FJBDev Dec 28, 2020
d9d8639
Unit tests
FJBDev Dec 28, 2020
0035cfe
Unit tests update after this fix
FJBDev Dec 28, 2020
86b8882
XML Unit 2.8.2
FJBDev Dec 28, 2020
3313418
Using OauthConstants
FJBDev Dec 29, 2020
9c41791
Merge remote-tracking branch 'Wolfgang/main' into main
FJBDev Dec 29, 2020
909003c
Typo
FJBDev Dec 29, 2020
7d34a46
Merge remote-tracking branch 'wolfgang/main' into main
FJBDev Dec 30, 2020
65173ea
Unit tests update
FJBDev Dec 30, 2020
1c228e8
Dropbox Authentication modifications (Using external browser and PKCE…
FJBDev Dec 30, 2020
fc1e6fa
Readme update
FJBDev Dec 30, 2020
c9d50c9
Misc
FJBDev Dec 30, 2020
a60a2cf
Merge remote-tracking branch 'wolfgang/main' into main
FJBDev Jan 1, 2021
7654e68
Adding the number of tours in the progress bar message
FJBDev Jan 2, 2021
a137a05
Translation typos
FJBDev Jan 3, 2021
5c6a6c7
Trying to renew the token right before uploading the tours
FJBDev Jan 3, 2021
e7b97e1
Default button is now at the bottom of the page
FJBDev Jan 3, 2021
4032e9d
Putting constructLocalExpireAtDateTime in TimeTools for reuse
FJBDev Jan 3, 2021
2d75210
the icon is at the beginning of the line and the dots are removed
FJBDev Jan 3, 2021
f8c3bb1
removing the prefstore listener when closed
FJBDev Jan 3, 2021
f0d004b
Merge remote-tracking branch 'wolfgang/FJBDev' into main
FJBDev Jan 3, 2021
09121b3
2021
FJBDev Jan 3, 2021
0f6a412
Removing the colons from the labels
FJBDev Jan 3, 2021
959f6ea
Misc
FJBDev Jan 3, 2021
b6d495c
Use a more random number for the port (4917) and displyaing an error
FJBDev Jan 3, 2021
c228098
Misc
FJBDev Jan 3, 2021
3c347f6
Changing the Dropbox Url
FJBDev Jan 3, 2021
248ebd5
Using the external browser for Strava as well
FJBDev Jan 4, 2021
6ee94c5
Misc
FJBDev Jan 4, 2021
d1e69c7
Misc
FJBDev Jan 4, 2021
b08f680
Upper case for public fields
FJBDev Jan 4, 2021
ef4476f
Protected
FJBDev Jan 4, 2021
81c81ce
Misc improvements
FJBDev Jan 4, 2021
cad2c51
English typos
FJBDev Jan 4, 2021
19e358e
Merge remote-tracking branch 'Wolfgang/FJBDev' into main
FJBDev Jan 5, 2021
17c39a9
Removing the code that is too context specific
FJBDev Jan 5, 2021
909b43e
Expires At is now at the bottom
FJBDev Jan 5, 2021
ff82b6d
V2 ?
FJBDev Jan 5, 2021
9966acf
Merge remote-tracking branch 'Wolfgang/main' into main
FJBDev Jan 6, 2021
dc00380
Per code review
FJBDev Jan 6, 2021
3e78aac
Removing slf4j warnings
FJBDev Jan 6, 2021
5122495
Adding the ability to upload manual tours to Strava (#40)
FJBDev Jan 8, 2021
6d40566
Merge remote-tracking branch 'Wolfgang/FJBDev' into main
FJBDev Jan 8, 2021
ca1ce34
Renaming
FJBDev Jan 8, 2021
7d3fc01
No dot
FJBDev Jan 11, 2021
166fb1d
Merge remote-tracking branch 'Wolfgang/FJBDev' into main
FJBDev Jan 11, 2021
b4cfb92
TCX Export Enhancement and fixes (#41)
FJBDev Jan 11, 2021
666a78e
Readme update
FJBDev Jan 11, 2021
2a908c8
Misc
FJBDev Jan 11, 2021
585a0c8
Stopping the server when leaving the preference page
FJBDev Jan 13, 2021
e916980
SOnarLint
FJBDev Jan 13, 2021
ab59d3d
Misc
FJBDev Jan 13, 2021
91ac9bc
Date
FJBDev Jan 13, 2021
62a8c67
TCX Export Enhancement and fixes (#287)
FJBDev Jan 13, 2021
2c36c56
Missed commiting that file
FJBDev Jan 13, 2021
1152eaa
Merge remote-tracking branch 'wolfgang/FJBDev' into main
FJBDev Jan 13, 2021
8773aa4
Merge remote-tracking branch 'Wolfgang/main' into main
FJBDev Jan 14, 2021
bd7c7d9
Adding the possibility to configure a User Agent for each map provide…
FJBDev Jan 14, 2021
73a613c
Added the possibility to export the current map view to an image file…
FJBDev Jan 14, 2021
539bc04
Activating the FitLog and FitLogEx unit tests (#45)
FJBDev Jan 16, 2021
974d316
Renaming the action text and adding a tooltip
FJBDev Jan 17, 2021
bee7361
Improvements after more testing
FJBDev Jan 17, 2021
ebe1984
Adding the action to export the map view in the clipboard
FJBDev Jan 17, 2021
777ce74
No image
FJBDev Jan 17, 2021
b8c2955
2 in 1
FJBDev Jan 17, 2021
62e1bb5
Adding source
FJBDev Jan 17, 2021
c70a0ce
French translation
FJBDev Jan 17, 2021
f6281db
Merge remote-tracking branch 'wolfgang/main' into main
FJBDev Jan 18, 2021
c7acf09
Indentation
FJBDev Jan 18, 2021
e2d7614
Code improvement
FJBDev Jan 18, 2021
944b772
Revert
FJBDev Jan 18, 2021
0f1b3ec
Fixed a bug where the authentication would not work if the browser's
FJBDev Jan 18, 2021
a6c1b5f
Using the Http Constant
FJBDev Jan 18, 2021
0d99f8f
Using the Http Constant
FJBDev Jan 18, 2021
123352d
Code improvements
FJBDev Jan 18, 2021
33a7ef8
putting the export actions into a submenu action
FJBDev Jan 18, 2021
42f6d80
Found code to polish when I inspired myself for the export map submenu
FJBDev Jan 18, 2021
c4bb41b
Adding tooltip for the searchtourbylocation
FJBDev Jan 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,19 @@ public void update(final ViewerCell cell) {

final Metadata entry = ((Metadata) cell.getElement());

String entryName = null;
Image entryImage = null;

entryName = entry.getName();
String imageName = UI.EMPTY_STRING;

if (entry instanceof FolderMetadata) {

entryImage =
Activator.getImageDescriptor(Messages.Image__Dropbox_Folder).createImage();
imageName = Messages.Image__Dropbox_Folder;
} else if (entry instanceof FileMetadata) {

entryImage =
Activator.getImageDescriptor(Messages.Image__Dropbox_File).createImage();
imageName = Messages.Image__Dropbox_File;
}

cell.setText(entryName);
final Image entryImage = StringUtils.hasContent(imageName) ? Activator.getImageDescriptor(imageName).createImage() : null;

cell.setText(entry.getName());
cell.setImage(entryImage);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ public void init(final IWorkbench workbench) {
//Not needed
}

@Override
public boolean okToLeave() {

if (_server != null) {
_server.stopCallBackServer();
}

return super.okToLeave();
}

/**
* When the user clicks on the "Authorize" button, a browser is opened
* so that the user can allow the MyTourbook Dropbox app to have access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Optional;

import net.tourbook.cloud.Messages;
import net.tourbook.common.UI;
import net.tourbook.common.util.StatusUtil;

import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
Expand Down Expand Up @@ -71,17 +71,20 @@ private Tokens handleGetRequest(final HttpExchange httpExchange) {

private void handleResponse(final HttpExchange httpExchange) throws IOException {

final OutputStream outputStream = httpExchange.getResponseBody();

final StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.append("<html><body><h1>" + Messages.Html_CloseBrowser_Text + "</h1></body></html>"); //$NON-NLS-1$ //$NON-NLS-2$
htmlBuilder.append("<html><head><meta charset=\"UTF-8\"></head><body><h1>" + Messages.Html_CloseBrowser_Text + "</h1></body></html>"); //$NON-NLS-1$ //$NON-NLS-2$

final byte[] response = htmlBuilder.toString().getBytes(StandardCharsets.UTF_8);

// this line is a must
httpExchange.sendResponseHeaders(200, htmlBuilder.length());
httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, response.length);

try (OutputStream outputStream = httpExchange.getResponseBody()) {

try (Writer writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {
writer.write(htmlBuilder.toString());
outputStream.write(response);
outputStream.flush();
} catch (final Exception e) {
StatusUtil.log(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ public void init(final IWorkbench workbench) {
//Not needed
}

@Override
public boolean okToLeave() {

if (_server != null) {
_server.stopCallBackServer();
}

return super.okToLeave();
}

/**
* When the user clicks on the "Authorize" button, a browser is opened
* so that the user can allow the MyTourbook Strava app to have access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ public static StravaTokens getTokens(final String authorizationCode, final boole
if (isRefreshToken) {
body.append("{\"" + OAuth2Constants.PARAM_REFRESH_TOKEN + "\" : \"" + refreshToken); //$NON-NLS-1$ //$NON-NLS-2$
grantType = OAuth2Constants.PARAM_REFRESH_TOKEN;
} else

{
} else {
body.append("{\"" + OAuth2Constants.PARAM_CODE + "\" : \"" + authorizationCode);//$NON-NLS-1$ //$NON-NLS-2$
grantType = OAuth2Constants.PARAM_AUTHORIZATION_CODE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (C) 2021 Frédéric Bard
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*******************************************************************************/

package net.tourbook.common.util;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

import net.tourbook.common.UI;

public final class FilesUtils {

public static String readFileContentString(final String filePath) {

String fileContent = UI.EMPTY_STRING;
try {
fileContent = Files.readString(Paths.get(filePath), StandardCharsets.US_ASCII);
} catch (final IOException e) {
StatusUtil.log(e);
}
return fileContent;
}
}
2 changes: 1 addition & 1 deletion bundles/net.tourbook.export/format-templates/gpx-1.0.vm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
<time>$dateformat.format($point.Date)</time>
#end
##
#if($point.hasValidExtention())
#if($point.hasValidExtension())
<extensions>
<gpxtpx:TrackPointExtension>
#if($point.hasValidTemperature())
Expand Down
79 changes: 61 additions & 18 deletions bundles/net.tourbook.export/format-templates/tcx-2.0.vm
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,48 @@
<TrainingCenterDatabase
xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 https://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd">
xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 https://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd http://www.garmin.com/xmlschemas/ActivityExtension/v2 https://www8.garmin.com/xmlschemas/ActivityExtensionv2.xsd">
#if($iscourses)
<Courses>
<Course>
<Name>$coursename</Name>
<Lap>
#else
<Activities>
<Activity Sport="$activityType">
#end
<Id>$dateformat.format($starttime)</Id>
<Lap StartTime="$dateformat.format($starttime)">
#end
<TotalTimeSeconds>$totaltime</TotalTimeSeconds>
<DistanceMeters>$nf3.format($totaldistance)</DistanceMeters>
#if(!$iscourses)
<Calories>$lap.getCalories()</Calories>
#end
#if($averageheartrate)
<AverageHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">
<AverageHeartRateBpm>
<Value>$averageheartrate</Value>
</AverageHeartRateBpm>
#end
#if($maximumheartrate)
<MaximumHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">
<MaximumHeartRateBpm>
<Value>$maximumheartrate</Value>
</MaximumHeartRateBpm>
#end
<Intensity>Active</Intensity>
#if($averagecadence)
<Cadence>$averagecadence</Cadence>
#end
#if(!$iscourses)
<TriggerMethod>Manual</TriggerMethod>
#end
#if(!$iscourses)
#foreach( $track in $tracks )
<Track>
#set ($points = $track.getWaypoints())
#foreach ($point in $points)
<Trackpoint>
#if($point.getDate())
<Time>$dateformat.format($point.getDate())</Time>
<Time>$dateformat.format($point.getDate())</Time>
#end
<Position>
<LatitudeDegrees>$nf8.format($point.Latitude)</LatitudeDegrees>
Expand All @@ -50,32 +56,69 @@
<DistanceMeters>$nf3.format($point.Distance)</DistanceMeters>
#end
#if($point.hasValidHeartrate())
<HeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">
<HeartRateBpm>
<Value>$point.Heartrate</Value>
</HeartRateBpm>
#end
#if($point.hasValidCadence())
<Cadence type="CadenceValue_t">$point.Cadence</Cadence>
<Cadence>$point.Cadence</Cadence>
#end
#if($point.hasValidPower() || $point.hasValidSpeed())
<Extensions>
<TPX xmlns="http://www.garmin.com/xmlschemas/ActivityExtension/v2">
#if($point.hasValidSpeed())
<Speed>$point.getSpeed()</Speed>
#end
#if($point.hasValidPower())
<Watts>$point.getPower()</Watts>
#end
</TPX>
</Extensions>
#end
</Trackpoint>
#end
</Track>
#end
</Lap>
#else
</Lap>
#foreach( $track in $tracks )
<Track>
#set ($points = $track.getWaypoints())
#foreach ($point in $points)
<Trackpoint>
#if($point.getDate())
<Time>$dateformat.format($point.getDate())</Time>
#end
<Position>
<LatitudeDegrees>$nf8.format($point.Latitude)</LatitudeDegrees>
<LongitudeDegrees>$nf8.format($point.Longitude)</LongitudeDegrees>
</Position>
#if($point.hasValidAltitude())
<AltitudeMeters>$nf3.format($point.Altitude)</AltitudeMeters>
#end
#if($point.hasValidDistance())
<DistanceMeters>$nf3.format($point.Distance)</DistanceMeters>
#end
</Trackpoint>
#end
</Track>
#end
#end
#if ($lap.hasNotes())
<Notes><![CDATA[$!lap.Notes]]></Notes>
#end
<Creator xsi:type="Device_t">
<Name>$creator</Name>
<UnitId>0</UnitId>
<ProductID>0</ProductID>
<Version>
<VersionMajor>$pluginMajorVersion</VersionMajor>
<VersionMinor>$pluginMinorVersion</VersionMinor>
<BuildMajor>$pluginMicroVersion</BuildMajor>
<BuildMinor>$pluginQualifierVersion</BuildMinor>
</Version>
</Creator>
<Creator xsi:type="Device_t">
<Name>$creator</Name>
<UnitId>0</UnitId>
<ProductID>0</ProductID>
<Version>
<VersionMajor>$pluginMajorVersion</VersionMajor>
<VersionMinor>$pluginMinorVersion</VersionMinor>
<BuildMajor>$pluginMicroVersion</BuildMajor>
<BuildMinor>$pluginQualifierVersion</BuildMinor>
</Version>
</Creator>
#if($iscourses)
</Course>
</Courses>
Expand Down