forked from MapComplete/MapComplete
		
	WIP: Some changes to make the android wrapper
This commit is contained in:
		
							parent
							
								
									3adeb7b130
								
							
						
					
					
						commit
						3d2db00548
					
				
					 6 changed files with 1617 additions and 34 deletions
				
			
		
							
								
								
									
										9
									
								
								capacitor.config.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								capacitor.config.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,9 @@ | ||||||
|  | import type { CapacitorConfig } from '@capacitor/cli'; | ||||||
|  | 
 | ||||||
|  | const config: CapacitorConfig = { | ||||||
|  |   appId: 'org.mapcomplete', | ||||||
|  |   appName: 'MapComplete', | ||||||
|  |   webDir: 'dist' | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default config; | ||||||
							
								
								
									
										1554
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										1554
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -156,6 +156,9 @@ | ||||||
|     "not op_mini all" |     "not op_mini all" | ||||||
|   ], |   ], | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|  |     "@capacitor/android": "^6.1.2", | ||||||
|  |     "@capacitor/core": "^6.1.2", | ||||||
|  |     "@capacitor/geolocation": "^6.0.1", | ||||||
|     "@comunica/core": "^3.0.1", |     "@comunica/core": "^3.0.1", | ||||||
|     "@comunica/query-sparql": "^3.0.1", |     "@comunica/query-sparql": "^3.0.1", | ||||||
|     "@comunica/query-sparql-link-traversal": "^0.3.0", |     "@comunica/query-sparql-link-traversal": "^0.3.0", | ||||||
|  | @ -235,6 +238,7 @@ | ||||||
|     "@babeard/svelte-heroicons": "^2.0.0-rc.0", |     "@babeard/svelte-heroicons": "^2.0.0-rc.0", | ||||||
|     "@babel/polyfill": "^7.10.4", |     "@babel/polyfill": "^7.10.4", | ||||||
|     "@babel/preset-env": "7.13.8", |     "@babel/preset-env": "7.13.8", | ||||||
|  |     "@capacitor/cli": "^6.1.2", | ||||||
|     "@monaco-editor/loader": "^1.4.0", |     "@monaco-editor/loader": "^1.4.0", | ||||||
|     "@parcel/service-worker": "^2.6.0", |     "@parcel/service-worker": "^2.6.0", | ||||||
|     "@rollup/plugin-json": "^6.0.0", |     "@rollup/plugin-json": "^6.0.0", | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ else | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| export NODE_OPTIONS=--max-old-space-size=16000 | export NODE_OPTIONS=--max-old-space-size=20000 | ||||||
| which vite | which vite | ||||||
| vite --version | vite --version | ||||||
| vite build --sourcemap || { echo 'Vite build failed' ; exit 1; } | vite build --sourcemap || { echo 'Vite build failed' ; exit 1; } | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import { LocalStorageSource } from "../Web/LocalStorageSource" | ||||||
| import { QueryParameters } from "../Web/QueryParameters" | import { QueryParameters } from "../Web/QueryParameters" | ||||||
| import { Translation } from "../../UI/i18n/Translation" | import { Translation } from "../../UI/i18n/Translation" | ||||||
| import Translations from "../../UI/i18n/Translations" | import Translations from "../../UI/i18n/Translations" | ||||||
|  | import { Geolocation } from "@capacitor/geolocation" | ||||||
| 
 | 
 | ||||||
| export type GeolocationPermissionState = "prompt" | "requested" | "granted" | "denied" | export type GeolocationPermissionState = "prompt" | "requested" | "granted" | "denied" | ||||||
| 
 | 
 | ||||||
|  | @ -24,7 +25,7 @@ export class GeoLocationState { | ||||||
|      * 'denied' means that we don't have access |      * 'denied' means that we don't have access | ||||||
|      */ |      */ | ||||||
|     public readonly permission: UIEventSource<GeolocationPermissionState> = new UIEventSource( |     public readonly permission: UIEventSource<GeolocationPermissionState> = new UIEventSource( | ||||||
|         "prompt" |         "prompt", | ||||||
|     ) |     ) | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -69,6 +70,7 @@ export class GeoLocationState { | ||||||
|      * A human explanation of the current gps state, to be shown on the home screen or as tooltip |      * A human explanation of the current gps state, to be shown on the home screen or as tooltip | ||||||
|      */ |      */ | ||||||
|     public readonly gpsStateExplanation: Store<Translation> |     public readonly gpsStateExplanation: Store<Translation> | ||||||
|  | 
 | ||||||
|     constructor() { |     constructor() { | ||||||
|         const self = this |         const self = this | ||||||
| 
 | 
 | ||||||
|  | @ -128,7 +130,7 @@ export class GeoLocationState { | ||||||
|                 } |                 } | ||||||
|                 return Translations.t.general.waitingForLocation |                 return Translations.t.general.waitingForLocation | ||||||
|             }, |             }, | ||||||
|             [this.allowMoving, this.permission, this.currentGPSLocation] |             [this.allowMoving, this.permission, this.currentGPSLocation], | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -201,29 +203,46 @@ export class GeoLocationState { | ||||||
|      * @private |      * @private | ||||||
|      */ |      */ | ||||||
|     private async startWatching() { |     private async startWatching() { | ||||||
|  |         console.log("Starts watching", navigator.geolocation, Geolocation) | ||||||
|         const self = this |         const self = this | ||||||
|         navigator.geolocation.watchPosition( |         try { | ||||||
|             function (position) { |             await Geolocation.requestPermissions({ permissions: ["location"] }) | ||||||
|                 self._gpsAvailable.set(true) |             console.log("Requested permission") | ||||||
|                 self.currentGPSLocation.setData(position.coords) |         } catch (e) { | ||||||
|                 self._previousLocationGrant.setData(true) |             // pass
 | ||||||
|  |         } | ||||||
|  |         try { | ||||||
|  |             await Geolocation.watchPosition( | ||||||
|  |                 { | ||||||
|  |                     enableHighAccuracy: true, | ||||||
|  |                     maximumAge: 120000, | ||||||
|                 }, |                 }, | ||||||
|             function (e) { |                 (position: GeolocationPosition, error: GeolocationPositionError) => { | ||||||
|                 if (e.code === 2 || e.code === 3) { |                     if (error) { | ||||||
|  |                         if (error.code === 2 || error.code === 3) { | ||||||
|                             self._gpsAvailable.set(false) |                             self._gpsAvailable.set(false) | ||||||
|                             return |                             return | ||||||
|                         } |                         } | ||||||
|                         self._gpsAvailable.set(true) // We go back to the default assumption that the location is physically available
 |                         self._gpsAvailable.set(true) // We go back to the default assumption that the location is physically available
 | ||||||
|                 if (e.code === 1) { |                         if (error.code === 1) { | ||||||
|                             self.permission.set("denied") |                             self.permission.set("denied") | ||||||
|                             self._grantedThisSession.setData(false) |                             self._grantedThisSession.setData(false) | ||||||
|                             return |                             return | ||||||
|                         } |                         } | ||||||
|                 console.warn("Could not get location with navigator.geolocation due to", e) |                         console.warn("Could not get location with navigator.geolocation due to", error) | ||||||
|             }, |                     } | ||||||
|             { | 
 | ||||||
|                 enableHighAccuracy: true, | 
 | ||||||
|  |                     console.log("Got position:", position, JSON.stringify(position)) | ||||||
|  |                     if (!position) { | ||||||
|  |                         return | ||||||
|  |                     } | ||||||
|  |                     this._gpsAvailable.set(true) | ||||||
|  |                     this.currentGPSLocation.setData(position.coords) | ||||||
|  |                     this._previousLocationGrant.setData(true) | ||||||
|  |                 }) | ||||||
|  |         } catch (e) { | ||||||
|  |             console.error("Could not get geolocation due to", e) | ||||||
|         } |         } | ||||||
|         ) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,13 +1,20 @@ | ||||||
| { | { | ||||||
|   "name": "MapComplete", |   "name": "MapComplete", | ||||||
|   "short_name": "MapComplete", |   "short_name": "MapComplete", | ||||||
|  |   "id":"mapcomplete", | ||||||
|   "start_url": "index.html", |   "start_url": "index.html", | ||||||
|   "lang": "en", |   "lang": "en", | ||||||
|   "display": "standalone", |   "display": "standalone", | ||||||
|   "background_color": "#fff", |   "background_color": "#ffffff", | ||||||
|   "theme_color": "#fff", |   "theme_color": "#ffffff", | ||||||
|   "description": "A thematic map viewer and editor based on OpenStreetMap", |   "description": "A thematic map viewer and editor based on OpenStreetMap", | ||||||
|   "orientation": "portrait-primary, landscape-primary", |   "orientation": "portrait-primary", | ||||||
|  |     "display_override": [ | ||||||
|  |       "standalone", | ||||||
|  |       "minimal-ui", | ||||||
|  |       "browser", | ||||||
|  |       "window-controls-overlay" | ||||||
|  |     ], | ||||||
|   "icons": [ |   "icons": [ | ||||||
|     { |     { | ||||||
|       "src": "assets/generated/images/assets_svg_mapcomplete_logo72.png", |       "src": "assets/generated/images/assets_svg_mapcomplete_logo72.png", | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue