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

Commit

Permalink
Changes to get the app approved :D
Browse files Browse the repository at this point in the history
  • Loading branch information
FokkeZB committed Apr 14, 2016
1 parent 1817fed commit f6e5bc4
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 40 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# G.O. Tracker
# Building a Geo Tracker App in Titanium

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*.
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).

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.

So, I present to you...

## G.O. Tracker 4 Compassion

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.

![Screenshots](docs/screenshots.png)

## License
<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>

## Learn from the source

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).

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.

## Contribute to the app...or to Compassion

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.

Of course you are also more then welcome to [contribute to Compassion](http://fokkezb.nl/rwanda).

I'll follow up with the first blog post on the app source code soon.

Code Strong, Code with Compassion! 🚴

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.
> 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.
9 changes: 4 additions & 5 deletions app/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var utils = require('utils');
var system = properties.get('system');
setIdHasCheck(system, true);

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

})();

Expand Down Expand Up @@ -45,11 +45,10 @@ function onLink(e) {
Ti.Platform.openURL(e.url);
}

// Reuse the event listener for the button
function openDonate() {
onLink({
url: 'http://fokkezb.nl/rwanda'
});

// Not allowed to use Safari Dialog by Apple
Ti.Platform.openURL(OS_ANDROID ? 'https://github.com/fokkezb/tracker' : 'http://fokkezb.nl/rwanda');
}

// Helper to toggle the checkmark
Expand Down
6 changes: 4 additions & 2 deletions app/i18n/en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<string name="Imperial">Imperial</string>

<string name="About">About</string>
<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>
<string name="Donate">Info &amp; Donations</string>
<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>
<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>
<string name="Donate">Information &amp; Donations</string>
<string name="Donate_Android">Learn More</string>
</resources>
6 changes: 4 additions & 2 deletions app/i18n/nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<string name="Imperial">Engelse</string>

<string name="About">Informatie</string>
<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>
<string name="Donate">Info &amp; Donaties</string>
<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>
<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>
<string name="Donate">Informatie &amp; Donaties</string>
<string name="Donate_Android">Meer Informatie</string>
</resources>
4 changes: 4 additions & 0 deletions app/lib/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
* Helpers to do CRUD operations on a large number of models, bypassing BB.
*/

// PUBLIC INTERFACE
//
exports.confirmToDeleteRide = confirmToDeleteRide;

// PRIVATE FUNCTIONS

function confirmToDeleteRide(rideId, onDelete) {

var dialog = Ti.UI.createAlertDialog({
Expand Down
4 changes: 4 additions & 0 deletions app/lib/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
* Hepers for run-time permissions.
*/

// PUBLIC INTERFACE

exports.requestLocationPermissions = requestLocationPermissions;

// PRIVATE FUNCTIONS

function requestLocationPermissions(authorizationType, callback) {

// FIXME: Always returns false on Android 6
Expand Down
4 changes: 4 additions & 0 deletions app/lib/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ var $ = module.exports = _.extend({

}, Backbone.Events);

// PRIVATE VARIABLES

var _cache = [];

// PRIVATE FUNCTIONS

function set(key, val) {

if (!Alloy.CFG.settings[key]) {
Expand Down
43 changes: 29 additions & 14 deletions app/lib/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,47 @@
* Library to do the actual tracking.
*/

// DEPENDENCIES

var dialogs = require('alloy/dialogs');
var permissions = require('permissions');
var utils = require('utils');

var $ = module.exports = _.clone(Backbone.Events);
// PUBLIC INTERFACE

var $ = module.exports = _.extend({

isTracking: isTracking,
toggleTracking: toggleTracking,
startTracking: startTracking,
stopTracking: stopTracking

}, Backbone.Events);

// PRIVATE VARIABLES

var currentRide;
var configuredMonitoring = false;

$.isTracking = function() {
// PRIVATE FUNCTIONS

function isTracking() {
return !!currentRide;
};
}

$.toggleTracking = function(cb) {
function toggleTracking(cb) {

if ($.isTracking()) {
$.stopTracking(cb);
if (isTracking()) {
stopTracking(cb);
} else {
$.startTracking(cb);
startTracking(cb);
}

};
}

$.startTracking = function(cb) {
function startTracking(cb) {

if ($.isTracking()) {
if (isTracking()) {
return cb({
success: false,
error: 'Already tracking'
Expand Down Expand Up @@ -55,11 +70,11 @@ $.startTracking = function(cb) {
type: 'start'
});
});
};
}

$.stopTracking = function(cb) {
function stopTracking(cb) {

if (!$.isTracking()) {
if (!isTracking()) {
return cb({
success: false,
error: 'Not tracking'
Expand All @@ -81,7 +96,7 @@ $.stopTracking = function(cb) {
$.trigger('stop', {
type: 'stop'
});
};
}

function initMonitoring(cb) {

Expand Down
8 changes: 8 additions & 0 deletions app/lib/units.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
* Library to convert and localize units.
*/

// DEPENDENCIES

var properties = require('properties');

// PUBLIC INTERFACE

exports.formatFloat = formatFloat;
exports.formatSpeed = formatSpeed;
exports.formatHeading = formatHeading;
exports.formatLength = formatLength;

// PRIVATE VARIABLES

// Trick to get the decimal separator
var DECIMAL = String.formatDecimal(1.1, Ti.Locale.currentLocale, '0.0')[1];

// PRIVATE FUNCTIONS

function formatFloat(fl, dec) {

fl = round(fl, dec);
Expand Down
23 changes: 15 additions & 8 deletions app/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
var $ = module.exports = {};
// PUBLIC INTERFACE

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

$.guid = function() {
return $.S4() + $.S4() + "-" + $.S4() + "-" + $.S4() + "-" + $.S4() + "-" + $.S4() + $.S4() + $.S4();
};
// PRIVATE FUNCTIONS

function guid() {
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
}

// Helper to turn a string with Markdown-links into an Attributed String
$.mdToAs = function(str) {
function mdToAs(str) {
var params = {
attributes: []
};
Expand Down Expand Up @@ -44,4 +47,8 @@ $.mdToAs = function(str) {
});

return Ti.UI.createAttributedString(params);
};
}

function S4() {
return (65536 * (1 + Math.random()) | 0).toString(16).substring(1);
}
2 changes: 1 addition & 1 deletion app/styles/app.tss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"Window": {
backgroundColor: "#FFF",
backgroundColor: "#FFF"
}

"Window[platform=ios]": {
Expand Down
7 changes: 6 additions & 1 deletion app/styles/settings.tss
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@
font: {
fontSize: 20,
fontWeight: "bold"
}
},
titleid: "Donate"
}

".donateBtn[platform=android]": {
titleid: "Donate_Android"
}
2 changes: 1 addition & 1 deletion app/views/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Label id="aboutBody" class="rowPadding" onLink="onLink" />
</TableViewRow>
<TableViewRow>
<Button class="donateBtn rowPadding" titleid="Donate" onClick="openDonate" />
<Button class="donateBtn rowPadding" onClick="openDonate" />
</TableViewRow>
</TableViewSection>

Expand Down
8 changes: 6 additions & 2 deletions tiapp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<guid>9edae89e-a1ef-42c8-9b54-1344805042a9</guid>
<property name="ti.ui.defaultunit" type="string">dp</property>
<ios>

<!-- Minimum of iOS 8 so we don't need fallback Launch Images for older iPhones -->
<min-ios-ver>8.0</min-ios-ver>

<!-- Use the builtin Storyboard Launch File with DefaultIcon.png on a blue background -->
Expand Down Expand Up @@ -58,11 +60,13 @@
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>2</string>
</dict>
</plist>
</ios>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<manifest android:versionCode="3">
<application android:theme="@style/tracker">

<!-- API key for nl.fokkezb.tracker and the Titanium development keystore -->
Expand All @@ -83,7 +87,7 @@
<target device="mobileweb">false</target>
<target device="windows">false</target>
</deployment-targets>
<sdk-version>5.2.2.GA</sdk-version>
<sdk-version>5.4.0.v20160405023842</sdk-version>
<plugins>
<plugin version="1.0">ti.alloy</plugin>
</plugins>
Expand Down

0 comments on commit f6e5bc4

Please sign in to comment.