Permalink
Browse files

phonegap structure

  • Loading branch information...
1 parent 569fea3 commit 80c21e0cb154325a2439a2a53a11c73b6601348f @andrewtrusty andrewtrusty committed Jun 1, 2013
Showing with 236 additions and 68 deletions.
  1. +0 −14 app/main.css
  2. +0 −50 app/map.js
  3. +103 −0 config.xml
  4. +55 −0 csv2json.py
  5. BIN icon.png
  6. +7 −4 {app → }/index.html
  7. +68 −0 map.js
  8. BIN res/icon/android/icon-36-ldpi.png
  9. BIN res/icon/android/icon-48-mdpi.png
  10. BIN res/icon/android/icon-72-hdpi.png
  11. BIN res/icon/android/icon-96-xhdpi.png
  12. BIN res/icon/bada-wac/icon-48-type5.png
  13. BIN res/icon/bada-wac/icon-50-type3.png
  14. BIN res/icon/bada-wac/icon-80-type4.png
  15. BIN res/icon/bada/icon-128.png
  16. BIN res/icon/blackberry/icon-80.png
  17. BIN res/icon/ios/icon-57-2x.png
  18. BIN res/icon/ios/icon-57.png
  19. BIN res/icon/ios/icon-72-2x.png
  20. BIN res/icon/ios/icon-72.png
  21. BIN res/icon/tizen/icon-128.png
  22. BIN res/icon/webos/icon-64.png
  23. BIN res/icon/windows-phone/icon-173-tile.png
  24. BIN res/icon/windows-phone/icon-48.png
  25. BIN res/icon/windows-phone/icon-62-tile.png
  26. BIN res/screen/android/screen-hdpi-landscape.png
  27. BIN res/screen/android/screen-hdpi-portrait.png
  28. BIN res/screen/android/screen-ldpi-landscape.png
  29. BIN res/screen/android/screen-ldpi-portrait.png
  30. BIN res/screen/android/screen-mdpi-landscape.png
  31. BIN res/screen/android/screen-mdpi-portrait.png
  32. BIN res/screen/android/screen-xhdpi-landscape.png
  33. BIN res/screen/android/screen-xhdpi-portrait.png
  34. BIN res/screen/bada-wac/screen-type3.png
  35. BIN res/screen/bada-wac/screen-type4.png
  36. BIN res/screen/bada-wac/screen-type5.png
  37. BIN res/screen/bada/screen-portrait.png
  38. BIN res/screen/blackberry/screen-225.png
  39. BIN res/screen/ios/screen-ipad-landscape-2x.png
  40. BIN res/screen/ios/screen-ipad-landscape.png
  41. BIN res/screen/ios/screen-ipad-portrait-2x.png
  42. BIN res/screen/ios/screen-ipad-portrait.png
  43. BIN res/screen/ios/screen-iphone-landscape-2x.png
  44. BIN res/screen/ios/screen-iphone-landscape.png
  45. BIN res/screen/ios/screen-iphone-portrait-2x.png
  46. BIN res/screen/ios/screen-iphone-portrait-568h-2x.png
  47. BIN res/screen/ios/screen-iphone-portrait.png
  48. +3 −0 res/screen/tizen/README.md
  49. BIN res/screen/webos/screen-64.png
  50. BIN res/screen/windows-phone/screen-portrait.jpg
View
@@ -1,14 +0,0 @@
-html {
- height: 100%
-}
-
-body {
- height: 100%;
- margin: 0;
- padding: 0
-}
-
-#map-canvas {
- height: 100%;
- width: 100%;
-}
View
@@ -1,50 +0,0 @@
-
-function placeMarker(map, location, title, markerColor) {
- console.log(location);
-
- var lineSymbol = {
- path: google.maps.SymbolPath.CIRCLE,
- scale: 3,
- strokeColor: markerColor ? markerColor : '#F00'
- };
-
- var marker = new google.maps.Marker({
- position: location,
- map: map,
- title: title,
- icon: lineSymbol
- });
-}
-
-function initialize() {
- if (navigator.geolocation)
- navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
- else
- noLocation();
-}
-
-function foundLocation(position) {
- setupMap(position.coords.latitude, position.coords.longitude);
-}
-
-function noLocation() {
- setupMap(40.0195625603, -105.279270661);
-}
-
-function setupMap(centerLat, centerLng) {
- var mapOptions = {
- center: new google.maps.LatLng(centerLat, centerLng),
- zoom: 17,
- mapTypeId: google.maps.MapTypeId.HYBRID
- };
-
- var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
-
- placeMarker(map, mapOptions.center, 'You are here', '#00F')
-
- var dataLength = data.length > 100 ? 100 : data.length;
- for (var i = 0; i < dataLength; i++)
- placeMarker(map, new google.maps.LatLng(data[i].lat, data[i].lng), data[i].description);
-}
-
-google.maps.event.addDomListener(window, 'load', initialize);
View
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- config.xml reference: https://build.phonegap.com/docs/config-xml -->
+<widget xmlns = "http://www.w3.org/ns/widgets"
+ xmlns:gap = "http://phonegap.com/ns/1.0"
+ id = "com.phonegap.hello-world"
+ version = "1.0.0">
+
+ <name>Fruitdrop</name>
+
+ <description>
+ Mapping the urban harvest!
+ </description>
+
+ <!--
+ <author href="http://phonegap.com" email="support@phonegap.com">
+ PhoneGap Team
+ </author>
+-->
+
+ <!--
+ Enable individual API permissions by defining each here.
+ The 'device' permission is required for the 'deviceready' event.
+ -->
+ <feature name="http://api.phonegap.com/1.0/device" />
+ <feature name="http://api.phonegap.com/1.0/geolocation" />
+
+ <!--
+ If you do not want any permissions to be added to your app, add the
+ following tag to your config.xml; you will still have the INTERNET
+ permission on your app, which PhoneGap requires.
+ -->
+ <preference name="permissions" value="none"/>
+
+ <!-- Customize your app and platform with the preference element. -->
+ <preference name="phonegap-version" value="2.7.0" /> <!-- all: current version of PhoneGap -->
+ <preference name="orientation" value="default" /> <!-- all: default means both landscape and portrait are enabled -->
+ <preference name="target-device" value="universal" /> <!-- all: possible values handset, tablet, or universal -->
+ <preference name="fullscreen" value="true" /> <!-- all: hides the status bar at the top of the screen -->
+ <preference name="webviewbounce" value="true" /> <!-- ios: control whether the screen 'bounces' when scrolled beyond the top -->
+ <preference name="prerendered-icon" value="true" /> <!-- ios: if icon is prerendered, iOS will not apply it's gloss to the app's icon on the user's home screen -->
+ <preference name="stay-in-webview" value="false" /> <!-- ios: external links should open in the default browser, 'true' would use the webview the app lives in -->
+ <preference name="ios-statusbarstyle" value="black-opaque" /> <!-- ios: black-translucent will appear black because the PhoneGap webview doesn't go beneath the status bar -->
+ <preference name="detect-data-types" value="true" /> <!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->
+ <preference name="exit-on-suspend" value="false" /> <!-- ios: if set to true, app will terminate when home button is pressed -->
+ <preference name="show-splash-screen-spinner" value="true" /> <!-- ios: if set to false, the spinner won't appear on the splash screen during app loading -->
+ <preference name="auto-hide-splash-screen" value="true" /> <!-- ios: if set to false, the splash screen must be hidden using a JavaScript API -->
+ <preference name="disable-cursor" value="false" /> <!-- blackberry: prevents a mouse-icon/cursor from being displayed on the app -->
+ <preference name="android-minSdkVersion" value="7" /> <!-- android: MIN SDK version supported on the target device. MAX version is blank by default. -->
+ <preference name="android-installLocation" value="auto" /> <!-- android: app install location. 'auto' will choose. 'internalOnly' is device memory. 'preferExternal' is SDCard. -->
+
+ <!-- Plugins can also be added here. -->
+ <!--
+ <gap:plugin name="Example" />
+ A list of available plugins are available at https://build.phonegap.com/docs/plugins
+ -->
+
+ <!-- Define app icon for each platform. -->
+ <icon src="icon.png" />
+ <icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:density="ldpi" />
+ <icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:density="mdpi" />
+ <icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:density="hdpi" />
+ <icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:density="xhdpi" />
+ <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" />
+ <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" gap:state="hover"/>
+ <icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57" />
+ <icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72" />
+ <icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114" />
+ <icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144" />
+ <icon src="res/icon/webos/icon-64.png" gap:platform="webos" />
+ <icon src="res/icon/windows-phone/icon-48.png" gap:platform="winphone" />
+ <icon src="res/icon/windows-phone/icon-173.png" gap:platform="winphone" gap:role="background" />
+
+ <!-- Define app splash screen for each platform. -->
+ <gap:splash src="res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:density="ldpi" />
+ <gap:splash src="res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:density="mdpi" />
+ <gap:splash src="res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:density="hdpi" />
+ <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:density="xhdpi" />
+ <gap:splash src="res/screen/blackberry/screen-225.png" gap:platform="blackberry" />
+ <gap:splash src="res/screen/ios/screen-iphone-portrait.png" gap:platform="ios" width="320" height="480" />
+ <gap:splash src="res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios" width="640" height="960" />
+ <gap:splash src="res/screen/ios/screen-ipad-portrait.png" gap:platform="ios" width="768" height="1024" />
+ <gap:splash src="res/screen/ios/screen-ipad-landscape.png" gap:platform="ios" width="1024" height="768" />
+ <gap:splash src="res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone" />
+
+ <!--
+ Define access to external domains.
+
+ <access /> - a blank access tag denies access to all external resources.
+ <access origin="*" /> - a wildcard access tag allows access to all external resource.
+
+ Otherwise, you can specify specific domains:
+ -->
+ <!--
+ <access origin="http://127.0.0.1*"/> --> <!-- allow local pages -->
+ <access origin="*" />
+ <!--
+ <access origin="http://phonegap.com" /> - allow any secure requests to http://phonegap.com/
+ <access origin="http://phonegap.com" subdomains="true" /> - same as above, but including subdomains, such as http://build.phonegap.com/
+ <access origin="http://phonegap.com" browserOnly="true" /> - only allows http://phonegap.com to be opened by the child browser.
+ -->
+
+</widget>
View
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+
+import csv
+import sys
+import json
+
+
+def run(fn, outfn):
+ ints = ['id', 'yield_rating', 'quality_rating', 'access', 'season_start']
+ floats = ['lat', 'lng']
+ bools = ['unverified']
+
+ data = []
+
+ with open(outfn, 'w') as out:
+ out.write("data = [\n")
+
+ i = 0
+
+ with open(fn, 'r') as fp:
+ reader = csv.DictReader(fp)
+
+ for row in reader:
+ for k, v in row.iteritems():
+ if not v.strip():
+ # assume empty strings represent null/no data
+ v = None
+ elif k in ints:
+ row[k] = int(v)
+ elif k in floats:
+ row[k] = float(v)
+ elif k in bools:
+ assert v in ['f', 't']
+ row[k] = (v == 't')
+
+ out.write(json.dumps(row) + ",\n")
+
+ i += 1
+
+ if i % 10000 == 0:
+ print i
+
+ out.write("]")
+
+ print 'fin'
+
+
+if __name__ == '__main__':
+ if len(sys.argv) < 3:
+ print 'Usage: ' + __file__ + ' /path/to/data.csv /path/to/output/json_data.js'
+ sys.exit(0)
+
+ run(sys.argv[1], sys.argv[2])
+
+
View
BIN icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -3,11 +3,14 @@
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" type="text/css" href="main.css" />
- </head>
- <body>
- <div id="map-canvas"></div>
+
+ <script type="text/javascript" src="phonegap.js"></script>
+
+ <script type="text/javascript" src="data/boulder.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.12&key=AIzaSyDPq9h3wwq3U6xzBeVQPPA7h2CJamlU82s&sensor=true"></script>
- <script type="text/javascript" src="../data/boulder.js"></script>
<script type="text/javascript" src="map.js"></script>
+ </head>
+ <body>
+ <div id="map-canvas"></div>
</body>
</html>
View
68 map.js
@@ -0,0 +1,68 @@
+
+var map,
+ native_app = (window.location.href.indexOf('/Users/') !== -1 &&
+ window.location.href.indexOf('/workspace/') !== -1);
+
+function geo_success(pos) {
+ var lat = pos.coords.latitude,
+ lng = pos.coords.longitude;
+
+ map.setCenter(new google.maps.LatLng(lat, lng));
+ placeMarker(map, map.getCenter(), 'You are here', '#00F');
+ placeDataMarkers();
+}
+
+function geo_fail() {
+ //alert('Unable to find your location!');
+ placeMarker(map, map.getCenter(), 'You are here', '#00F');
+ placeDataMarkers();
+}
+
+function placeMarker(map, location, title, markerColor) {
+ var lineSymbol = {
+ path: google.maps.SymbolPath.CIRCLE,
+ scale: 3,
+ strokeColor: markerColor ? markerColor : '#F00'
+ };
+
+ var marker = new google.maps.Marker({
+ position: location,
+ map: map,
+ title: title,
+ icon: lineSymbol
+ });
+}
+
+function placeDataMarkers() {
+ var dataLength = data.length > 100 ? 100 : data.length;
+ for (var i = 0; i < dataLength; i++)
+ placeMarker(map, new google.maps.LatLng(data[i].lat, data[i].lng), data[i].description);
+}
+
+function initialize2() {
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(geo_success, geo_fail, {enableHighAccuracy:true});
+ } else {
+ geo_fail();
+ }
+}
+
+function initialize() {
+ var mapOptions = {
+ center: new google.maps.LatLng(40.0195625603, -105.279270661),
+ zoom: 17,
+ mapTypeId: google.maps.MapTypeId.HYBRID
+ };
+
+ map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
+
+ // phonegap specific deviceready event
+ // can't use phonegap API's (eg. geolocation) until this fires
+ if (native_app) {
+ document.addEventListener('deviceready', initialize2, false);
+ } else {
+ initialize2();
+ }
+}
+
+google.maps.event.addDomListener(window, 'load', initialize);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
@@ -0,0 +1,3 @@
+# Tizen Splash Screen
+
+Splash screens are unsupported on the Tizen platform.
Diff not rendered.
Diff not rendered.

0 comments on commit 80c21e0

Please sign in to comment.