From cdc07a3858d86337cf8ff6c46a5ad554fad8ba6d Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Thu, 6 Jun 2019 14:49:22 +0200
Subject: [PATCH] [fix] Avoid fullscreen mode on desktop release [enh] Ask
 confirmation before switching to fullscreen, on mobile web browser

---
 www/i18n/locale-en-GB.json            |  1 +
 www/i18n/locale-en.json               |  1 +
 www/i18n/locale-fr-FR.json            |  1 +
 www/index.html                        |  8 +-----
 www/js/app.js                         |  5 ----
 www/js/controllers/app-controllers.js | 39 ++++++++++++++++++++-------
 www/templates/menu.html               | 16 ++++++-----
 7 files changed, 43 insertions(+), 28 deletions(-)

diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json
index cd34aadd..6749473f 100644
--- a/www/i18n/locale-en-GB.json
+++ b/www/i18n/locale-en-GB.json
@@ -798,6 +798,7 @@
     "POPUP_SECURITY_WARNING_TITLE": "<i class=\"icon ion-alert-circled\"></i> <b>Security warning</b>",
     "CERTIFY_RULES_TITLE_UID": "Certify {{uid}}",
     "CERTIFY_RULES": "<b class=\"assertive\">Don't certify an account</b> if you believe that: <ul><li>1.) the issuers identity might be faked.<li>2.) the issuer already has another certified account.<li>3.) the issuer purposely or carelessly violates rule 1 or 2 (he certifies faked or double accounts).</ul></small><br/>Are you sure you want to certify this identity?",
+    "FULLSCREEN": "View the application in full screen?",
     "EXIT_APP": "Close the application ?",
     "TRANSFER": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li></ul><br/><b>Are-you sure you want to do this transfer?</b>",
     "TRANSFER_ALL": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li><br/><li> - Rest : <b>{{restAmount}} {{unit}}</b> to <b>{{restTo}}</b></li></ul><br/><b>Are-you sure you want to do this transfer?</b>",
diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json
index 54ed594d..378db495 100644
--- a/www/i18n/locale-en.json
+++ b/www/i18n/locale-en.json
@@ -798,6 +798,7 @@
     "POPUP_SECURITY_WARNING_TITLE": "<i class=\"icon ion-alert-circled\"></i> <b>Security warning</b>",
     "CERTIFY_RULES_TITLE_UID": "Certify {{uid}}",
     "CERTIFY_RULES": "<b class=\"assertive\">Don't certify an account</b> if you believe that: <ul><li>1.) the issuers identity might be faked.<li>2.) the issuer already has another certified account.<li>3.) the issuer purposely or carelessly violates rule 1 or 2 (he certifies faked or double accounts).</ul></small><br/>Are you sure you want to certify this identity?",
+    "FULLSCREEN": "View the application in full screen?",
     "EXIT_APP": "Close the application ?",
     "TRANSFER": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li></ul><br/><b>Are-you sure you want to do this transfer?</b>",
     "TRANSFER_ALL": "<b>Transfer summary:</b><br/><br/><ul><li> - From: <b>{{from}}</b></li><li> - To: <b>{{to}}</b></li><li> - Amount: <b>{{amount}} {{unit}}</b></li><li> - Comment: <i>{{comment}}</i></li><br/><li> - Rest : <b>{{restAmount}} {{unit}}</b> to <b>{{restTo}}</b></li></ul><br/><b>Are-you sure you want to do this transfer?</b>",
diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json
index e05fd87f..6b08675f 100644
--- a/www/i18n/locale-fr-FR.json
+++ b/www/i18n/locale-fr-FR.json
@@ -798,6 +798,7 @@
     "POPUP_SECURITY_WARNING_TITLE": "<i class=\"icon ion-alert-circled\"></i> <b>Avertissement de sécurité</b>",
     "CERTIFY_RULES_TITLE_UID": "Certifier {{uid}}",
     "CERTIFY_RULES": "<b class=\"assertive\">Ne PAS certifier</b> un compte si vous pensez que :<br/><br/><ul><li>1.) il ne correspond pas à une personne <b>physique et vivante</b>.<li>2.) son propriétaire <b>possède un autre compte</b> déjà certifié.<li>3.) son propriétaire viole (volontairement ou non) la règle 1 ou 2 (par exemple en certifiant des comptes factices ou en double).</ul><br/><b>Êtes-vous sûr</b> de vouloir néanmoins certifier cette identité ?",
+    "FULLSCREEN": "Afficher l'application en plein écran ?",
     "EXIT_APP": "Fermer l'application ?",
     "TRANSFER": "<b>Récapitulatif du virement</b> :<br/><br/><ul><li> - De : {{from}}</li><li> - A : <b>{{to}}</b></li><li> - Montant : <b>{{amount}} {{unit}}</b></li><li> - Commentaire : <i>{{comment}}</i></li></ul><br/><b>Êtes-vous sûr de vouloir effectuer ce virement ?</b>",
     "TRANSFER_ALL": "<b>Récapitulatif du virement</b> :<br/><br/><ul><li> - De : {{from}}</li><li> - A : <b>{{to}}</b></li><li> - Montant : <b>{{amount}} {{unit}}</b></li><li> - Commentaire : <i>{{comment}}</i></li><br/><li> - Reste : <b>{{restAmount}} {{unit}}</b> à <b>{{restTo}}</b></li></ul><br/><b>Êtes-vous sûr de vouloir effectuer ce virement ?</b>",
diff --git a/www/index.html b/www/index.html
index 6d3c668e..40016956 100644
--- a/www/index.html
+++ b/www/index.html
@@ -54,13 +54,7 @@
   <body ng-app="cesium" id="cesium" ng-strict-di="true" window-exit-unauth="true"
         ng-class="{'nobackdrop': $root.tour, 'expert-mode': $root.settings.expertMode}">
 
-    <!-- Enable fullscreen mode on small device (on a web browser) -->
-    <!--removeIf(device)-->
-    <div class="popover-backdrop visible-xs visible-sm"
-         ng-click="enableFullscreen($event)"
-         ng-if="forceFullscreen">
-    </div>
-    <!--endRemoveIf(device)-->
+
 
     <ion-nav-view>
       <div class="loader">
diff --git a/www/js/app.js b/www/js/app.js
index a250e46a..b16ac852 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -138,10 +138,5 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'pascalprecht
     // Start plugins eager services
     PluginService.start();
 
-    $rootScope.forceFullscreen = UIUtils.screen.isSmall();
-    $rootScope.enableFullscreen = function() {
-      delete $rootScope.forceFullscreen;
-      UIUtils.screen.fullscreen.all();
-    };
   })
 ;
diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js
index e56f0997..df0a751d 100644
--- a/www/js/controllers/app-controllers.js
+++ b/www/js/controllers/app-controllers.js
@@ -74,6 +74,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
   $scope.login = csWallet.isLogin();
   $scope.auth = csWallet.isAuth();
   $scope.motion = UIUtils.motion.default;
+  $scope.fullscreen = UIUtils.screen.fullscreen.isEnabled();
 
   $scope.showHome = function() {
     $ionicHistory.nextViewOptions({
@@ -348,13 +349,6 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
       })
       .catch(UIUtils.onError());
   };
-
-  // Full screen
-  $scope.toggleFullscreen = function() {
-    UIUtils.screen.fullscreen.toggleAll();
-    $scope.fullscreen = UIUtils.screen.fullscreen.isEnabled();
-  };
-
   // Do authentification
   $scope.doAuth = function(options) {
     var wallet = options && options.wallet || csWallet;
@@ -410,7 +404,6 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
     return Modals.showHelp(parameters);
   };
 
-
   ////////////////////////////////////////
   // Useful popovers
   ////////////////////////////////////////
@@ -444,7 +437,7 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
   };
 
   ////////////////////////////////////////
-  // Link managment (fix issue #)
+  // Link management (fix issue #)
   ////////////////////////////////////////
 
   $scope.openLink = function($event, uri, options) {
@@ -479,6 +472,34 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
     return $scope.motion.show(options);
   };
 
+
+  ////////////////////////////////////////
+  // Fullscreen mode
+  ////////////////////////////////////////
+
+  $scope.askFullscreen = function() {
+    var skip = $scope.fullscreen || !UIUtils.screen.isSmall() || !Device.isWeb();
+    if (skip) return;
+
+    return UIUtils.alert.confirm('CONFIRM.FULLSCREEN', null, {
+      cancelText: 'COMMON.BTN_NO',
+      okText: 'COMMON.BTN_YES'
+    })
+      .then(function(confirm) {
+         if (!confirm) return;
+        $scope.toggleFullscreen();
+      });
+  };
+
+  $scope.toggleFullscreen = function() {
+    $scope.fullscreen = !UIUtils.screen.fullscreen.isEnabled();
+    UIUtils.screen.fullscreen.toggleAll();
+  };
+
+  // removeIf(device)
+  // Ask switching fullscreen
+  $scope.askFullscreen();
+  // endRemoveIf(device)
 }
 
 
diff --git a/www/templates/menu.html b/www/templates/menu.html
index 67c67baf..daf1999c 100644
--- a/www/templates/menu.html
+++ b/www/templates/menu.html
@@ -81,14 +81,16 @@
         <a ng-if="login" class="button-icon" ng-click="logout({askConfirm: true})" style="position: absolute; top: 5px; left: 5px; z-index: 999;">
           <i class="icon light ion-android-exit"></i>
         </a>
-        <!-- fullscreen -->
-        <a class="button-icon visible-xs visible-sm"
-           ng-if="!forceFullscreen"
-           ng-click="toggleFullscreen()" style="position: absolute; top: 5px; right: 5px; z-index: 999;">
-          <i class="icon ion-arrow-expand dark"
-             ng-class="{'ion-arrow-shrink': !fullscreen}"
-             ></i>
+
+        <!-- Fullscreen button -->
+        <!-- removeIf(device) -->
+        <a ng-if="::$root.device.isWeb()"
+           ng-click="toggleFullscreen()"
+           class="button-icon"
+           style="position: absolute; top: 5px; right: 5px; z-index: 999;">
+          <i class="icon ion-arrow-expand dark" ng-class="{'ion-arrow-shrink': fullscreen}"></i>
         </a>
+        <!-- endRemoveIf(device) -->
       </div>
     </ion-header-bar>
 
-- 
GitLab