updated and additions
[webos-internals:djcin7s-modifications.git] / google-maps / google-maps-auto-enable-and-disable-gps-for-maps.patch
1 diff --git a/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js b/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
2 index f5c81a6..4b8e353 100644
3 --- a/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.maps/app/assistants/app-assistant.js
5 @@ -3,6 +3,7 @@ AppAssistant.webViewWidget = undefined;
6  AppAssistant.googleMapsURL = "http://maps.google.com/maps/m";
7  //AppAssistant.googleMapsURL = "http://gjm.google.com/mwm?sky=tfb";
8  AppAssistant.urlClientParam = "client=ms-mwm-palm";
9 +AppAssistant.gpsWasEnabled = false;
10  
11  function AppAssistant(appController) {
12         Mojo.Log.info("MAPS App: AppAssistant");
13 @@ -22,6 +23,21 @@ function AppAssistant(appController) {
14         window.document.addEventListener(Mojo.Event.activate, this.onAppActivate.bind(this));
15         window.document.addEventListener(Mojo.Event.deactivate, this.onAppDeactivate.bind(this));
16         
17 +    AppAssistant.gpsWasEnabled = false;
18 +    new Mojo.Service.Request('palm://com.palm.location', {
19 +        method: 'getUseGps',
20 +               parameters: {},
21 +               onSuccess: function(response){
22 +            AppAssistant.gpsWasEnabled = response.useGps;
23 +            if (AppAssistant.gpsWasEnabled==false){
24 +                new Mojo.Service.Request('palm://com.palm.location', {
25 +                    method: 'setUseGps',
26 +                    parameters: {useGps: true}
27 +                });
28 +            }
29 +        }      
30 +    });
31 +    
32         // subscribe for notifications from connection manager
33         this._startConnectionWatch();
34         
35 @@ -102,6 +118,16 @@ AppAssistant.prototype.handleLaunch = function(appLaunchParams) {
36  
37  AppAssistant.prototype.cleanup = function() {
38         Mojo.Log.info("Maps: AppAssistant cleanup");
39 +    
40 +    if (AppAssistant.gpsWasEnabled==false){
41 +        new Mojo.Service.Request('palm://com.palm.location', {
42 +                       method: 'setUseGps',
43 +                       parameters: {
44 +                               useGps: false
45 +                       }
46 +               });
47 +    }   
48 +    
49         this._cleanupConnectionWatch(); 
50         this.storageNotificationSession.cancel();
51  };
52 diff --git a/usr/palm/applications/com.palm.app.maps/app/assistants/mapshell-assistant.js b/usr/palm/applications/com.palm.app.maps/app/assistants/mapshell-assistant.js
53 index 75c81aa..7451f16 100644
54 --- a/usr/palm/applications/com.palm.app.maps/app/assistants/mapshell-assistant.js
55 +++ b/usr/palm/applications/com.palm.app.maps/app/assistants/mapshell-assistant.js
56 @@ -5,6 +5,8 @@ var MapshellAssistant = Class.create({
57                 // when true, card the app else instruct webview to go back
58                 this.goBack = false;
59                 this.spinnerModel = {spinning: false};
60 +               // fs mode parameter
61 +               this.paramFS = true
62                 
63                 // event handlers
64                 this._onWebViewCreatePageH = this._onWebViewCreatePage.bind(this);
65 @@ -16,6 +18,7 @@ var MapshellAssistant = Class.create({
66                 this._onWebViewTitleUrlChangedH = this._onWebViewTitleUrlChanged.bind(this);
67                 this._onAdapterConnectH = this._onAdapterConnect.bind(this);
68                 this._onAdapterDisconnectH = this._onAdapterDisconnect.bind(this);
69 +               this._holdHandlerH = this._holdHandler.bind(this);
70                 
71                 /*
72                 var curr = new Date();
73 @@ -42,6 +45,8 @@ var MapshellAssistant = Class.create({
74                 };      
75                 this.controller.setupWidget(Mojo.Menu.appMenu, appMenuAttrs, this.appMenuModel);        
76                 
77 +               //set fs mode
78 +               this.controller.enableFullScreenMode(this.paramFS);
79                 // setup spinner
80                 this.controller.setupWidget('disconnected_spinner', 
81                         {spinnerSize: Mojo.Widget.spinnerLarge}, this.spinnerModel);
82 @@ -66,6 +71,7 @@ var MapshellAssistant = Class.create({
83                 this.controller.listen('webview', Mojo.Event.webViewTitleUrlChanged, this._onWebViewTitleUrlChangedH);
84                 this.controller.listen('webview', Mojo.Event.webViewServerConnect, this._onAdapterConnectH);
85                 this.controller.listen('webview', Mojo.Event.webViewServerDisconnect, this._onAdapterDisconnectH);
86 +               this.controller.listen('webview', Mojo.Event.hold, this._holdHandlerH);
87         },
88         
89         cleanup: function() {
90 @@ -79,6 +85,7 @@ var MapshellAssistant = Class.create({
91                 this.controller.stopListening('webview', Mojo.Event.webViewTitleUrlChanged, this._onWebViewTitleUrlChangedH);
92                 this.controller.stopListening('webview', Mojo.Event.webViewServerConnect, this._onAdapterConnectH);     
93                 this.controller.stopListening('webview', Mojo.Event.webViewServerDisconnect, this._onAdapterDisconnectH);
94 +               this.controller.stopListening('webview', Mojo.Event.hold, this._holdHandlerH);
95         },
96         
97         activate: function() {
98 @@ -272,6 +279,16 @@ var MapshellAssistant = Class.create({
99                 this.controller.modelChanged(this.spinnerModel);
100         },
101         
102 +       _holdHandler: function(event) {
103 +               if (this.paramFS) {
104 +                       this.paramFS = false
105 +                       this.controller.enableFullScreenMode(this.paramFS);
106 +               } 
107 +               else {
108 +                       this.paramFS = true
109 +                       this.controller.enableFullScreenMode(this.paramFS);
110 +               }
111 +       },
112  
113         handleCommand: function(event) {
114                 if (event.type == Mojo.Event.back) {