Skip to content

Commit cf2fc87

Browse files
author
Patrick FINKELSTEIN
committed
Upload activity tested and fix in Oauth
1 parent b9ee005 commit cf2fc87

17 files changed

Lines changed: 577 additions & 578 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ https://github.com/BirdyF/strava_flutter/blob/master/lib/main.dart
3131

3232

3333
Tested on:
34-
- Android 4.4.2
34+
- Android 4.4.2 , 4.4.23
3535
- iOS 12.1.2
3636

3737

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11+
1CDFFED3BF7DE5F1A595B52B /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C40FD4FCF8B6BA955620D96 /* libPods-Runner.a */; };
1112
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
1213
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1314
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
@@ -43,6 +44,7 @@
4344
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
4445
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4546
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
47+
6C40FD4FCF8B6BA955620D96 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4648
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
4749
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
4850
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@@ -64,6 +66,7 @@
6466
files = (
6567
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
6668
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
69+
1CDFFED3BF7DE5F1A595B52B /* libPods-Runner.a in Frameworks */,
6770
);
6871
runOnlyForDeploymentPostprocessing = 0;
6972
};
@@ -90,7 +93,8 @@
9093
9740EEB11CF90186004384FC /* Flutter */,
9194
97C146F01CF9000F007C117D /* Runner */,
9295
97C146EF1CF9000F007C117D /* Products */,
93-
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
96+
AE575367F9D9CDE8C91FEF88 /* Pods */,
97+
A07FEDBF3F08864A43BA0CEA /* Frameworks */,
9498
);
9599
sourceTree = "<group>";
96100
};
@@ -126,19 +130,36 @@
126130
name = "Supporting Files";
127131
sourceTree = "<group>";
128132
};
133+
A07FEDBF3F08864A43BA0CEA /* Frameworks */ = {
134+
isa = PBXGroup;
135+
children = (
136+
6C40FD4FCF8B6BA955620D96 /* libPods-Runner.a */,
137+
);
138+
name = Frameworks;
139+
sourceTree = "<group>";
140+
};
141+
AE575367F9D9CDE8C91FEF88 /* Pods */ = {
142+
isa = PBXGroup;
143+
children = (
144+
);
145+
name = Pods;
146+
sourceTree = "<group>";
147+
};
129148
/* End PBXGroup section */
130149

131150
/* Begin PBXNativeTarget section */
132151
97C146ED1CF9000F007C117D /* Runner */ = {
133152
isa = PBXNativeTarget;
134153
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
135154
buildPhases = (
155+
78E915BC6000267E3E0DD1A2 /* [CP] Check Pods Manifest.lock */,
136156
9740EEB61CF901F6004384FC /* Run Script */,
137157
97C146EA1CF9000F007C117D /* Sources */,
138158
97C146EB1CF9000F007C117D /* Frameworks */,
139159
97C146EC1CF9000F007C117D /* Resources */,
140160
9705A1C41CF9048500538489 /* Embed Frameworks */,
141161
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
162+
FC271CEED52330ADD8135322 /* [CP] Embed Pods Frameworks */,
142163
);
143164
buildRules = (
144165
);
@@ -212,6 +233,28 @@
212233
shellPath = /bin/sh;
213234
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
214235
};
236+
78E915BC6000267E3E0DD1A2 /* [CP] Check Pods Manifest.lock */ = {
237+
isa = PBXShellScriptBuildPhase;
238+
buildActionMask = 2147483647;
239+
files = (
240+
);
241+
inputFileListPaths = (
242+
);
243+
inputPaths = (
244+
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
245+
"${PODS_ROOT}/Manifest.lock",
246+
);
247+
name = "[CP] Check Pods Manifest.lock";
248+
outputFileListPaths = (
249+
);
250+
outputPaths = (
251+
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
252+
);
253+
runOnlyForDeploymentPostprocessing = 0;
254+
shellPath = /bin/sh;
255+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
256+
showEnvVarsInLog = 0;
257+
};
215258
9740EEB61CF901F6004384FC /* Run Script */ = {
216259
isa = PBXShellScriptBuildPhase;
217260
buildActionMask = 2147483647;
@@ -226,6 +269,28 @@
226269
shellPath = /bin/sh;
227270
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
228271
};
272+
FC271CEED52330ADD8135322 /* [CP] Embed Pods Frameworks */ = {
273+
isa = PBXShellScriptBuildPhase;
274+
buildActionMask = 2147483647;
275+
files = (
276+
);
277+
inputFileListPaths = (
278+
);
279+
inputPaths = (
280+
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
281+
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
282+
);
283+
name = "[CP] Embed Pods Frameworks";
284+
outputFileListPaths = (
285+
);
286+
outputPaths = (
287+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
288+
);
289+
runOnlyForDeploymentPostprocessing = 0;
290+
shellPath = /bin/sh;
291+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
292+
showEnvVarsInLog = 0;
293+
};
229294
/* End PBXShellScriptBuildPhase section */
230295

231296
/* Begin PBXSourcesBuildPhase section */

example/ios/Runner.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>BuildSystemType</key>
6+
<string>Original</string>
7+
</dict>
8+
</plist>

example/lib/examples.dart

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// examples to use strava_flutter
2+
import 'dart:async';
3+
import 'dart:io';
4+
import 'package:flutter/services.dart' show rootBundle;
5+
import 'package:path_provider/path_provider.dart';
6+
import 'dart:typed_data'; // Needed when declaring ByteData
7+
8+
9+
import 'package:strava_flutter/API/constants.dart';
10+
11+
// Used by uploadExample
12+
import 'package:strava_flutter/API/strava.dart';
13+
import 'package:strava_flutter/Models/fault.dart';
14+
import 'package:strava_flutter/API/token.dart';
15+
16+
17+
// Used by example
18+
import 'package:strava_flutter/Models/detailedActivity.dart';
19+
import 'package:strava_flutter/Models/club.dart';
20+
import 'package:strava_flutter/Models/detailedAthlete.dart';
21+
import 'package:strava_flutter/Models/gear.dart';
22+
import 'package:strava_flutter/Models/runningRace.dart';
23+
import 'package:strava_flutter/Models/stats.dart';
24+
import 'package:strava_flutter/Models/summaryAthlete.dart';
25+
import 'package:strava_flutter/Models/summaryActivity.dart';
26+
27+
28+
29+
30+
/// Example showing how to upload an activity on Strava
31+
/// Use file Bormes.gpx in assets
32+
/// Should appear on your activities 6 Feb. 2018
33+
/// Under the title Bormes3
34+
Future<Fault> exampleUpload(String secret) async {
35+
36+
Future<void> writeToFile(ByteData data, String path) {
37+
final buffer = data.buffer;
38+
return File(path).writeAsBytes(
39+
buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
40+
}
41+
42+
43+
// Do authentication with the right scope
44+
final strava = Strava(
45+
secret, 'auto');
46+
47+
bool isAuthOk = false;
48+
49+
isAuthOk = await strava.OAuth(clientID, "http://localhost:8080", 'activity:write', secret);
50+
51+
print('---> thats it!!, $isAuthOk');
52+
53+
Token tokenStored = await strava.getStoredToken();
54+
55+
56+
// Use the asset file to test without having to create internally a ride
57+
//----------------------------------------------------------------------
58+
String dir = (await getApplicationDocumentsDirectory()).path;
59+
var data = await rootBundle.load('assets/Bormes.gpx');
60+
// Save the data loaded from the assert into a file
61+
// Transfer the data into a real file
62+
await writeToFile(data, '$dir/myActivity.gpx');
63+
64+
Fault fault = await strava.uploadActivity('Bormes3', 'It is working!', '$dir/myActivity.gpx',
65+
'gpx', tokenStored.accessToken);
66+
67+
return fault;
68+
}
69+
70+
71+
72+
73+
void example(String secret) async {
74+
75+
bool isAuthOk = false;
76+
77+
final strava = Strava(
78+
secret, 'auto');
79+
80+
isAuthOk = await strava.OAuth(clientID, "http://localhost:8080", 'activity:write', secret);
81+
82+
if (isAuthOk) {
83+
84+
DetailedAthlete athlete = await strava.getLoggedInAthlete();
85+
86+
List<RunningRace> listRunningRaces = await strava.getRunningRaces("2019");
87+
88+
RunningRace race = await strava.getRunningRaceById('2724');
89+
90+
// Change of the loggedAthlete in profile
91+
DetailedAthlete athlete2 = await strava.updateLoggedInAthlete(84);
92+
93+
94+
Gear gear = await strava.getGearById("b4366285");
95+
// print('error code getGearById ${gear.errorCode}');
96+
97+
Stats stats = await strava.getStats(athlete.id);
98+
99+
// List<Zone> list = await strava.getLoggedInAthleteZones();
100+
101+
final clubStravaMarseille =
102+
'226910'; // You have to join this club to do the test
103+
104+
Club club = await strava.getClubById(clubStravaMarseille);
105+
106+
// Test getActivityById
107+
DetailedActivity _activity = await strava.getActivityById('2131889191');
108+
109+
List<SummaryAthlete> listMembers = await strava.getClubMembersById('1');
110+
111+
List<SummaryActivity> listSumm =
112+
await strava.getClubActivitiesById(clubStravaMarseille);
113+
}
114+
}
115+

0 commit comments

Comments
 (0)