Skip to content

Commit

Permalink
Adding the ability to upload manual tours to Strava (#285)
Browse files Browse the repository at this point in the history
* Changes per code review

* Removing the harmless ResourceNotFoundException

* Putting it back

* We clear the browser session so that a user can log in with different
accounts

* Misc

* Useless

* Making the Strava upload asynchronous to speed up the upload

* Renaming the field per Wolfgang suggestion

* Putting fields, which belong together, into { ... }, for better
readability

* displaying the account user name in the upload dialog

* Misc

* Export Unit tests update and successful

* Unit tests

* Unit tests update after this fix
20bb310

* XML Unit 2.8.2

* Using OauthConstants

* Typo

* Unit tests update

* Dropbox Authentication modifications (Using external browser and PKCE implementation) (#38)

* Readme update

* Misc

* Adding the number of tours in the progress bar message

* Translation typos

* Trying to renew the token right before uploading the tours

* Default button is now at the bottom of the page

* Putting constructLocalExpireAtDateTime in TimeTools for reuse

* the icon is at the beginning of the line and the dots are removed

* removing the prefstore listener when closed

* 2021

* Removing the colons from the labels

* Misc

* Use a more random number for the port (4917) and displyaing an error
message if it's not available.

* Misc

* Changing the Dropbox Url

* Using the external browser for Strava as well

* Misc

* Misc

* Upper case for public fields

* Protected

* Misc improvements

* English typos

* Removing the code that is too context specific

* Expires At is now at the bottom

* V2 ?

* [SRTM] test connection to server failed with old default value, however the srtm data retrieval worked

Connection test failed for https://dds.cr.usgs.gov/srtm/version2_1
Returncode: 301  <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://dds.cr.usgs.gov/srtm/version2_1/">here</a>.</p>
</body></html>

Only the last / in the url was missing

* Per code review

* Removing slf4j warnings

* Adding the ability to upload manual tours to Strava (#40)

* Renaming

* No dot

Co-authored-by: wolfgang-ch <wolfgang-ch@users.sourceforge.net>
  • Loading branch information
FJBDev and wolfgang-ch committed Jan 11, 2021
1 parent a7ae098 commit 53b9fe7
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@

public class PrefPageDropbox extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {

public static final String ID = "net.tourbook.cloud.PrefPageDropbox"; //$NON-NLS-1$
private static final String PREF_CLOUD_CONNECTIVITY_CLOUD_ACCOUNT_GROUP =
net.tourbook.cloud.Messages.Pref_CloudConnectivity_CloudAccount_Group;

public static final String ClientId = "vye6ci8xzzsuiao"; //$NON-NLS-1$
public static final String ID = "net.tourbook.cloud.PrefPageDropbox"; //$NON-NLS-1$

public static final int CALLBACK_PORT = 4917;
public static final String ClientId = "vye6ci8xzzsuiao"; //$NON-NLS-1$

private IPreferenceStore _prefStore = Activator.getDefault().getPreferenceStore();
public static final int CALLBACK_PORT = 4917;

private IPreferenceStore _prefStore = Activator.getDefault().getPreferenceStore();
private IPropertyChangeListener _prefChangeListener;
private LocalHostServer _server;
/*
Expand All @@ -76,7 +79,7 @@ private String computeAccessTokenExpirationDate() {
Preferences.DROPBOX_ACCESSTOKEN_ISSUE_DATETIME) + _prefStore.getInt(
Preferences.DROPBOX_ACCESSTOKEN_EXPIRES_IN);

return (expireAt == 0) ? UI.EMPTY_STRING : TimeTools.constructLocalExpireAtDateTime(expireAt);
return (expireAt == 0) ? UI.EMPTY_STRING : TimeTools.getUTCISODateTime(expireAt);
}

@Override
Expand Down Expand Up @@ -148,7 +151,7 @@ private void createUI_20_TokensInformation(final Composite parent) {

_group = new Group(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(_group);
_group.setText(net.tourbook.cloud.Messages.Pref_CloudConnectivity_CloudAccount_Group);
_group.setText(PREF_CLOUD_CONNECTIVITY_CLOUD_ACCOUNT_GROUP);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(_group);
{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

public class OAuth2Constants {

public static final String CONTENT_TYPE = "Content-Type"; //$NON-NLS-1$

public static final String PARAM_AUTHORIZATION_CODE = "authorization_code"; //$NON-NLS-1$

public static final String PARAM_REFRESH_TOKEN = "refresh_token"; //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2020 Frédéric Bard
* 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
Expand All @@ -16,33 +16,31 @@
package net.tourbook.cloud.strava;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ActivityUpload {

private String id;
private String error;
private String name;
private String status;
private String activityId;

private String tourDate;

ActivityUpload() {}

@JsonProperty("activity_id")
public String getActivityId() {
return activityId;
}

public String getError() {
return error;
}

@JsonProperty("id_str")
public String getId() {
return id;
}

public String getName() {
return name;
}

public String getStatus() {
return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class Messages extends NLS {
public static String Image__Connect_With_Strava;

public static String Log_UploadToursToStrava_001_Start;
public static String Log_UploadToursToStrava_002_NoTimeDataSeries;
public static String Log_UploadToursToStrava_002_NoTourTitle;
public static String Log_UploadToursToStrava_003_ActivityLink;
public static String Log_UploadToursToStrava_003_UploadStatus;
public static String Log_UploadToursToStrava_004_UploadError;
public static String Log_UploadToursToStrava_005_End;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void widgetSelected(final SelectionEvent e) {
}

private String getLocalExpireAtDateTime() {
return (_accessTokenExpiresAt == 0) ? UI.EMPTY_STRING : TimeTools.constructLocalExpireAtDateTime(
return (_accessTokenExpiresAt == 0) ? UI.EMPTY_STRING : TimeTools.getUTCISODateTime(
_accessTokenExpiresAt);
}

Expand Down

0 comments on commit 53b9fe7

Please sign in to comment.