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

[TIMOB-14806] #7

Merged
merged 1 commit into from
Nov 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
tmp
.DS_Store
build/iphone/*
!build/iphone/.gitignore
build/android/*
!build/android/.gitignore
build/mobileweb/*
!build/mobileweb/.gitignore
build
.settings
build.log
.fastdev.lock
Empty file modified CHANGELOG.txt
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion LICENSE
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2009 Appcelerator, Inc.
Copyright 2013 Appcelerator, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Empty file modified LICENSE.txt
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified Resources/android/appicon.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/android/default.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions Resources/app.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This is a single context, single window application
// There is only one master window to which sub views will be added
(function() {
if (Ti.version < 1.8 ) {
if (Ti.version < 1.8) {
alert('Sorry - this application requires Titanium Mobile SDK 1.8 or later');
}
else {
} else {
var ApplicationWindow = require('ui/ApplicationWindow').ApplicationWindow;
new ApplicationWindow().open();
}
Expand Down
54 changes: 28 additions & 26 deletions Resources/geo.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ exports.forwardGeocode = function(address, callback) {
};

var forwardGeocodeNative = function(address, callback) {
var url = GOOGLE_BASE_URL + address.replace(' ', '+') ;
url += "&sensor=" + (Titanium.Geolocation.locationServicesEnabled == true);
var url = GOOGLE_BASE_URL + address.replace(' ', '+');
url += "&sensor=" + (Titanium.Geolocation.locationServicesEnabled == true);
var xhr = Titanium.Network.createHTTPClient();
xhr.open('GET', url);
xhr.onload = function() {
var json = JSON.parse(this.responseText);
if (json.status != 'OK') {
alert('Unable to geocode the address');
return;
}
callback(new GeoData(
address,
json.results[0].geometry.location.lat,
json.results[0].geometry.location.lng
));
var json = JSON.parse(this.responseText);
if (json.status != 'OK') {
alert('Unable to geocode the address');
return;
}

callback(new GeoData(
address,
json.results[0].geometry.location.lat,
json.results[0].geometry.location.lng
));
};
xhr.onerror = function(e) {
Ti.API.error(e.error);
Expand All @@ -47,19 +47,21 @@ var forwardGeocodeNative = function(address, callback) {
var forwardGeocodeWeb = function(address, callback) {
var geocoder = new google.maps.Geocoder();
if (geocoder) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
callback(new GeoData(
address,
results[0].geometry.location.lat(),
results[0].geometry.location.lng()
));
} else {
Ti.API.error(status);
alert(ERROR_MESSAGE);
}
});
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
callback(new GeoData(
address,
results[0].geometry.location.lat(),
results[0].geometry.location.lng()
));
} else {
Ti.API.error(status);
alert(ERROR_MESSAGE);
}
});
} else {
alert('Google Maps Geocoder not supported');
alert('Google Maps Geocoder not supported');
}
};
Empty file modified Resources/images/delete.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/Default-568h@2x.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/Default-Landscape.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/Default-Portrait.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/Default.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/Default@2x.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/iphone/appicon.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/appicon.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default-Landscape.jpg
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default-Landscape.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default-Portrait.jpg
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default-Portrait.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default.jpg
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/Default.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/apple_startup_images/README
100644 → 100755
Empty file.
Empty file modified Resources/mobileweb/splash/README
100644 → 100755
Empty file.
Empty file modified Resources/mobileweb/splash/appc.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified Resources/mobileweb/splash/splash.css
100644 → 100755
Empty file.
Empty file modified Resources/mobileweb/splash/splash.html
100644 → 100755
Empty file.
Empty file modified Resources/mobileweb/splash/titanium.png
100644 → 100755
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 61 additions & 44 deletions Resources/ui/ApplicationWindow.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
//Application Window Component Constructor
exports.ApplicationWindow = function() {
function isiOS7Plus()
{
// iOS-specific test
if (Titanium.Platform.name == 'iPhone OS')
{
var version = Titanium.Platform.version.split(".");
var major = parseInt(version[0],10);

// Can only test this support on a 3.2+ device
if (major >= 7)
{
return true;
}
}
return false;
}

var iOS7 = isiOS7Plus();
var theTop = iOS7 ? 20 : 0;

var geo = require('geo');

//create object instance
var self = Ti.UI.createWindow({
backgroundColor:'#fff',
fullscreen: false,
exitOnClose: true
backgroundColor: '#800'
});

// create UI components
var view = Ti.UI.createView({
backgroundColor: '#800',
height: '50dp',
top: 0
top: theTop
});
var textfield = Ti.UI.createTextField({
height: '40dp',
Expand All @@ -29,36 +46,36 @@ exports.ApplicationWindow = function() {
title: '+',
font: {
fontSize: '20dp',
fontWeight: 'bold'
fontWeight: 'bold'
},
top: '5dp',
height: '40dp',
width: '40dp',
right: '5dp'
});
var mapview;

// add map after window opens
self.addEventListener('open', function() {
// Make sure we only add the map once
if (mapview !== undefined) {
return;
return;
}

mapview = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region: {
latitude: geo.LATITUDE_BASE,
longitude: geo.LONGITUDE_BASE,
latitudeDelta: 0.1,
longitudeDelta: 0.1
},
animate:true,
regionFit:true,
userLocation:false,
top: '50dp'
mapType: Titanium.Map.STANDARD_TYPE,
region: {
latitude: geo.LATITUDE_BASE,
longitude: geo.LONGITUDE_BASE,
latitudeDelta: 0.1,
longitudeDelta: 0.1
},
animate: true,
regionFit: true,
userLocation: false,
top: '70dp'
});

// Add initial annotation
mapview.addAnnotation(Ti.Map.createAnnotation({
animate: true,
Expand All @@ -68,42 +85,42 @@ exports.ApplicationWindow = function() {
longitude: geo.LONGITUDE_BASE,
leftButton: '/images/delete.png'
}));

// Handle all map annotation clicks
mapview.addEventListener('click', function(e) {
if (e.annotation && (e.clicksource === 'leftButton' || e.clicksource == 'leftPane')) {
if (e.annotation && (e.clicksource === 'leftButton' || e.clicksource == 'leftPane')) {
mapview.removeAnnotation(e.annotation);
}
}
});
self.add(mapview);
});


// Execute forward geocode on button click
button.addEventListener('click', function() {
button.addEventListener('click', function() {
textfield.blur();
geo.forwardGeocode(textfield.value, function(geodata) {
mapview.addAnnotation(Ti.Map.createAnnotation({
animate: true,
pincolor: Titanium.Map.ANNOTATION_RED,
title: geodata.title,
latitude: geodata.coords.latitude,
longitude: geodata.coords.longitude,
leftButton: '/images/delete.png'
}));
mapview.setLocation({
latitude: geodata.coords.latitude,
longitude: geodata.coords.longitude,
latitudeDelta: 1,
longitudeDelta: 1
});
animate: true,
pincolor: Titanium.Map.ANNOTATION_RED,
title: geodata.title,
latitude: geodata.coords.latitude,
longitude: geodata.coords.longitude,
leftButton: '/images/delete.png'
}));
mapview.setLocation({
latitude: geodata.coords.latitude,
longitude: geodata.coords.longitude,
latitudeDelta: 1,
longitudeDelta: 1
});
});
});

// assemble view hierarchy
view.add(textfield);
view.add(button);
self.add(view);

return self;
};
};
Empty file removed build/android/.gitignore
Empty file.
Empty file removed build/iphone/.gitignore
Empty file.
Empty file removed build/mobileweb/.gitignore
Empty file.
Empty file modified manifest
100644 → 100755
Empty file.
5 changes: 3 additions & 2 deletions tiapp.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<sdk-version>2.0.0</sdk-version>
<sdk-version>3.1.3.GA</sdk-version>
<deployment-targets>
<target device="tizen">false</target>
<target device="mobileweb">true</target>
<target device="iphone">true</target>
<target device="ipad">true</target>
Expand All @@ -21,7 +22,7 @@
<statusbar-style>default</statusbar-style>
<statusbar-hidden>false</statusbar-hidden>
<fullscreen>false</fullscreen>
<navbar-hidden>false</navbar-hidden>
<navbar-hidden>true</navbar-hidden>
<analytics>true</analytics>
<guid>359aba67-83fb-48bf-96fe-c07fa972648f</guid>
<iphone>
Expand Down