Skip to content
This repository was archived by the owner on Aug 20, 2018. It is now read-only.

Commit f6e5bc4

Browse files
committed
Changes to get the app approved :D
1 parent 1817fed commit f6e5bc4

File tree

14 files changed

+118
-40
lines changed

14 files changed

+118
-40
lines changed

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
1-
# G.O. Tracker
1+
# Building a Geo Tracker App in Titanium
22

3-
This app is an Open Source work in progress by [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). He plans to [cycle 400km](http://fokkezb.nl/rwanda) through Rwanda in June 2016 and raise €10.000 for the work of [Compassion](http://www.compassion.com/): *Releasing children from poverty in Jesus' name*.
3+
I have big plans this summer. I hope to cycle 400km through Rwanda (Africa) and raise €10,000 in funds for Compassion, a children aid charity. [Read more about these two challenges](http://fokkezb.nl/rwanda).
4+
5+
Obviously this means I'm on my bike a lot these days. I've been tracking all my rides using [Ride with GPS](https://ridewithgps.com) from the start, but a few weeks ago I wondered how easy it would be to build such a GPS tracker myself in Titanium.
6+
7+
So, I present to you...
8+
9+
## G.O. Tracker 4 Compassion
10+
11+
Pronounced *"geo" Tracker*, this initial version simply tracks your geolocation. You can view your previous routes on a map or browse through the individual data points. I plan to add more features in the next two months as I start to use the app for my own rides and hope to have it fairly complete by the time I go to Rwanda in June.
412

513
![Screenshots](docs/screenshots.png)
614

7-
## License
15+
<p align="center"><a href="https://play.google.com/store/apps/details?id=nl.fokkezb.tracker" target="_blank"><img alt="Get it on Google Play" src="https://play.google.com/intl/en_us/badges/images/apps/en-play-badge.png" width="150" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://itunes.apple.com/us/app/g.o.-tracker-4-compassion/id1100240821?ls=1&mt=8" target="_blank"><img src="https://devimages.apple.com.edgekey.net/app-store/marketing/guidelines/images/badge-download-on-the-app-store.svg" width="150" /></a></p>
16+
17+
## Learn from the source
18+
19+
As an Appcelerator Developer Evangelist I help developers to build Native Mobile Apps and APIs in JavaScript. One way I do this is by building and blogging about [sample apps](https://github.com/appcelerator-developer-relations).
20+
21+
In this spirit I [open sourced the app on GitHub](https://github.com/fokkezb/tracker) and as I continue to develop the app I will publish blog posts to guide you through the code and share some best practices.
22+
23+
## Contribute to the app...or to Compassion
24+
25+
I use [GitHub Issues](https://github.com/fokkezb/tracker/issues) to track planned features, enhancements and bugs. Feel free to contribute ideas there, or help me resolve them and send a PR. I will list the names of all contributors on the app's *Settings* screen.
26+
27+
Of course you are also more then welcome to [contribute to Compassion](http://fokkezb.nl/rwanda).
28+
29+
I'll follow up with the first blog post on the app source code soon.
30+
31+
Code Strong, Code with Compassion! 🚴
832

9-
This software is licensed under [MIT](http://choosealicense.com/licenses/mit/). Learn from it and use it in any way you want, as long as you include the copyright notice and permission notice in [LICENSE](LICENSE), including the link to [http://fokkezb.nl/rwanda](http://fokkezb.nl/rwanda). Also consider to [donate](https://www.muskathlon.com/en-us/athletes/1134/fokke-zandbergen.html) to Compassion.
33+
> This software is licensed under [MIT](http://choosealicense.com/licenses/mit/). Learn from it and use it in any way you want, as long as you include the copyright notice and permission notice in [LICENSE](LICENSE), including the link to [http://fokkezb.nl/rwanda](http://fokkezb.nl/rwanda). Also consider to [donate](https://www.muskathlon.com/en-us/athletes/1134/fokke-zandbergen.html) to Compassion.

app/controllers/settings.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var utils = require('utils');
1010
var system = properties.get('system');
1111
setIdHasCheck(system, true);
1212

13-
$.aboutBody.attributedString = utils.mdToAs(L('About_Body'));
13+
$.aboutBody.attributedString = utils.mdToAs(OS_ANDROID ? L('About_Body_Android') : L('About_Body'));
1414

1515
})();
1616

@@ -45,11 +45,10 @@ function onLink(e) {
4545
Ti.Platform.openURL(e.url);
4646
}
4747

48-
// Reuse the event listener for the button
4948
function openDonate() {
50-
onLink({
51-
url: 'http://fokkezb.nl/rwanda'
52-
});
49+
50+
// Not allowed to use Safari Dialog by Apple
51+
Ti.Platform.openURL(OS_ANDROID ? 'https://github.com/fokkezb/tracker' : 'http://fokkezb.nl/rwanda');
5352
}
5453

5554
// Helper to toggle the checkmark

app/i18n/en/strings.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<string name="Imperial">Imperial</string>
1919

2020
<string name="About">About</string>
21-
<string name="About_Body">This app is an [Open Source](https://github.com/fokkezb) work in progress by [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). He plans to [cycle 400km](http://fokkezb.nl/rwanda) through Rwanda in June 2016 and raise €10.000 for the work of [Compassion](http://www.compassion.com/): "Releasing children from poverty in Jesus name".</string>
22-
<string name="Donate">Info &amp; Donations</string>
21+
<string name="About_Body">This app is an [Open Source](https://github.com/fokkezb/tracker) work in progress by [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). He plans to [cycle 400km](http://fokkezb.nl/rwanda) through Rwanda in June 2016 and raise €10.000 for the work of [Compassion](http://www.compassion.com/): "Releasing children from poverty in Jesus name".</string>
22+
<string name="About_Body_Android">This app is an [Open Source](https://github.com/fokkezb/tracker) work in progress by [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). He plans to [cycle 400km](http://fokkezb.nl/rwanda) through Rwanda in June 2016 for the work of [Compassion](http://www.compassion.com/): "Releasing children from poverty in Jesus name".</string>
23+
<string name="Donate">Information &amp; Donations</string>
24+
<string name="Donate_Android">Learn More</string>
2325
</resources>

app/i18n/nl/strings.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<string name="Imperial">Engelse</string>
1919

2020
<string name="About">Informatie</string>
21-
<string name="About_Body">Deze app wordt [Open Source](https://github.com/fokkezb) ontwikkeld door [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). In juni 2016 hoopt hij [400km te fietsen](http://fokkezb.nl/rwanda) door Rwanda en €10.000 te werven voor het werk van [Compassion](https://www.compassion.nl/): "Kinderen bevrijden van armoede in Jezus' naam".</string>
22-
<string name="Donate">Info &amp; Donaties</string>
21+
<string name="About_Body">Deze app wordt [Open Source](https://github.com/fokkezb/tracker) ontwikkeld door [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). In juni 2016 hoopt hij [400km te fietsen](http://fokkezb.nl/rwanda) door Rwanda en €10.000 te werven voor het werk van [Compassion](https://www.compassion.nl/): "Kinderen bevrijden van armoede in Jezus' naam".</string>
22+
<string name="About_Body_Android">Deze app wordt [Open Source](https://github.com/fokkezb/tracker) ontwikkeld door [Appcelerator](http://www.appcelerator.com) Developer Evangelist [Fokke Zandbergen](http://fokkezb.nl). In juni 2016 hoopt hij [400km te fietsen](http://fokkezb.nl/rwanda) door Rwanda voor het werk van [Compassion](https://www.compassion.nl/): "Kinderen bevrijden van armoede in Jezus' naam".</string>
23+
<string name="Donate">Informatie &amp; Donaties</string>
24+
<string name="Donate_Android">Meer Informatie</string>
2325
</resources>

app/lib/crud.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
* Helpers to do CRUD operations on a large number of models, bypassing BB.
33
*/
44

5+
// PUBLIC INTERFACE
6+
//
57
exports.confirmToDeleteRide = confirmToDeleteRide;
68

9+
// PRIVATE FUNCTIONS
10+
711
function confirmToDeleteRide(rideId, onDelete) {
812

913
var dialog = Ti.UI.createAlertDialog({

app/lib/permissions.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
* Hepers for run-time permissions.
33
*/
44

5+
// PUBLIC INTERFACE
6+
57
exports.requestLocationPermissions = requestLocationPermissions;
68

9+
// PRIVATE FUNCTIONS
10+
711
function requestLocationPermissions(authorizationType, callback) {
812

913
// FIXME: Always returns false on Android 6

app/lib/properties.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ var $ = module.exports = _.extend({
1212

1313
}, Backbone.Events);
1414

15+
// PRIVATE VARIABLES
16+
1517
var _cache = [];
1618

19+
// PRIVATE FUNCTIONS
20+
1721
function set(key, val) {
1822

1923
if (!Alloy.CFG.settings[key]) {

app/lib/track.js

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,47 @@
22
* Library to do the actual tracking.
33
*/
44

5+
// DEPENDENCIES
6+
57
var dialogs = require('alloy/dialogs');
68
var permissions = require('permissions');
79
var utils = require('utils');
810

9-
var $ = module.exports = _.clone(Backbone.Events);
11+
// PUBLIC INTERFACE
12+
13+
var $ = module.exports = _.extend({
14+
15+
isTracking: isTracking,
16+
toggleTracking: toggleTracking,
17+
startTracking: startTracking,
18+
stopTracking: stopTracking
19+
20+
}, Backbone.Events);
21+
22+
// PRIVATE VARIABLES
1023

1124
var currentRide;
1225
var configuredMonitoring = false;
1326

14-
$.isTracking = function() {
27+
// PRIVATE FUNCTIONS
28+
29+
function isTracking() {
1530
return !!currentRide;
16-
};
31+
}
1732

18-
$.toggleTracking = function(cb) {
33+
function toggleTracking(cb) {
1934

20-
if ($.isTracking()) {
21-
$.stopTracking(cb);
35+
if (isTracking()) {
36+
stopTracking(cb);
2237
} else {
23-
$.startTracking(cb);
38+
startTracking(cb);
2439
}
2540

26-
};
41+
}
2742

28-
$.startTracking = function(cb) {
43+
function startTracking(cb) {
2944

30-
if ($.isTracking()) {
45+
if (isTracking()) {
3146
return cb({
3247
success: false,
3348
error: 'Already tracking'
@@ -55,11 +70,11 @@ $.startTracking = function(cb) {
5570
type: 'start'
5671
});
5772
});
58-
};
73+
}
5974

60-
$.stopTracking = function(cb) {
75+
function stopTracking(cb) {
6176

62-
if (!$.isTracking()) {
77+
if (!isTracking()) {
6378
return cb({
6479
success: false,
6580
error: 'Not tracking'
@@ -81,7 +96,7 @@ $.stopTracking = function(cb) {
8196
$.trigger('stop', {
8297
type: 'stop'
8398
});
84-
};
99+
}
85100

86101
function initMonitoring(cb) {
87102

app/lib/units.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
* Library to convert and localize units.
33
*/
44

5+
// DEPENDENCIES
6+
57
var properties = require('properties');
68

9+
// PUBLIC INTERFACE
10+
711
exports.formatFloat = formatFloat;
812
exports.formatSpeed = formatSpeed;
913
exports.formatHeading = formatHeading;
1014
exports.formatLength = formatLength;
1115

16+
// PRIVATE VARIABLES
17+
1218
// Trick to get the decimal separator
1319
var DECIMAL = String.formatDecimal(1.1, Ti.Locale.currentLocale, '0.0')[1];
1420

21+
// PRIVATE FUNCTIONS
22+
1523
function formatFloat(fl, dec) {
1624

1725
fl = round(fl, dec);

app/lib/utils.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
var $ = module.exports = {};
1+
// PUBLIC INTERFACE
22

3-
$.S4 = function() {
4-
return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
3+
var $ = module.exports = {
4+
guid: guid,
5+
mdToAs: mdToAs
56
};
67

7-
$.guid = function() {
8-
return $.S4() + $.S4() + "-" + $.S4() + "-" + $.S4() + "-" + $.S4() + "-" + $.S4() + $.S4() + $.S4();
9-
};
8+
// PRIVATE FUNCTIONS
9+
10+
function guid() {
11+
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
12+
}
1013

1114
// Helper to turn a string with Markdown-links into an Attributed String
12-
$.mdToAs = function(str) {
15+
function mdToAs(str) {
1316
var params = {
1417
attributes: []
1518
};
@@ -44,4 +47,8 @@ $.mdToAs = function(str) {
4447
});
4548

4649
return Ti.UI.createAttributedString(params);
47-
};
50+
}
51+
52+
function S4() {
53+
return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
54+
}

0 commit comments

Comments
 (0)