From 1c6d1169198b74374a34ff8d6672dfb1d1a3c7ef Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 17 Nov 2017 12:38:28 +0200 Subject: [PATCH] Fix start audio/video streaming popup prompt The problem is that HMI creates new popup prompt every time when receives StartStreaming/StartAudioStreaming request from SDL and does not disappear until will be closed manually. This fix solves a problem by closing previous popup window if new StartStreaming request has come and closing active popup window if StopStreaming request has come. In this case HMI will display only one popup window at time during retry sequence and will close popup window if sequence is finished or user clicks OK. --- ffw/NavigationRPC.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ffw/NavigationRPC.js b/ffw/NavigationRPC.js index df166cd68..181b809e5 100644 --- a/ffw/NavigationRPC.js +++ b/ffw/NavigationRPC.js @@ -46,6 +46,16 @@ FFW.Navigation = FFW.RPCObserver.create( * Error codes will be injected into response. */ errorResponsePull: {}, + /** + * Contains pointer to currently active popup window with start Audio + * streaming in the model or null if does not exists + */ + startAudioStreamingPopup: null, + /** + * Contains pointer to currently active popup window with start Video + * streaming in the model or null if does not exists + */ + startVideoStreamingPopup: null, /** * access to basic RPC functionality */ @@ -280,7 +290,11 @@ FFW.Navigation = FFW.RPCObserver.create( case 'Navigation.StartAudioStream': { var text = 'Would you like to start Audio stream?'; - SDL.PopUp.create().appendTo('body').popupActivate( + if (this.startAudioStreamingPopup && this.startAudioStreamingPopup.active) { + this.startAudioStreamingPopup.deactivate(); + } + + this.startAudioStreamingPopup = SDL.PopUp.create().appendTo('body').popupActivate( text, function(result) { if (result) { FFW.Navigation.sendNavigationResult( @@ -308,6 +322,10 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationAudioStream = null; + if (this.startAudioStreamingPopup && this.startAudioStreamingPopup.active) { + this.startAudioStreamingPopup.deactivate(); + this.set('startAudioStreamingPopup', null); + } this.sendNavigationResult( SDL.SDLModel.data.resultCode.SUCCESS, request.id, @@ -355,7 +373,11 @@ FFW.Navigation = FFW.RPCObserver.create( case 'Navigation.StartStream': { var text = 'Would you like to start Video stream?'; - SDL.PopUp.create().appendTo('body').popupActivate( + if (this.startVideoStreamingPopup && this.startVideoStreamingPopup.active) { + this.startVideoStreamingPopup.deactivate(); + } + + this.startVideoStreamingPopup = SDL.PopUp.create().appendTo('body').popupActivate( text, function(result) { if (result) { SDL.SDLController.getApplicationModel(request.params.appID) @@ -378,6 +400,7 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationStream = request.params.url; + break; } case 'Navigation.StopStream': @@ -385,6 +408,10 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationStream = null; + if (this.startVideoStreamingPopup && this.startVideoStreamingPopup.active) { + this.startVideoStreamingPopup.deactivate(); + this.set('startVideoStreamingPopup', null); + } this.sendNavigationResult( SDL.SDLModel.data.resultCode.SUCCESS, request.id,