Skip to content
Snippets Groups Projects
Commit f23b62d3 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

Profile: open external links in external browser (Android) - fix #292

parent 63fb0ca0
Branches
Tags
No related merge requests found
......@@ -86,7 +86,8 @@
{
"locator": "https://github.com/phonegap/phonegap-plugin-barcodescanner.git",
"id": "phonegap-plugin-barcodescanner"
}
},
"cordova-plugin-inappbrowser"
],
"cordovaPlatforms": [
"ios",
......
......@@ -545,6 +545,7 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, U
$scope.alreadyCertified = true;
UIUtils.alert.info('INFO.CERTIFICATION_DONE');
$scope.formData.received_cert_pending.unshift(cert);
$scope.formData.requirements.pendingCertificationCount++;
$scope.doMotion();
}
})
......
......@@ -25,26 +25,6 @@ angular.module('cesium.device.services', ['ngResource', 'cesium.utils.services']
exports.enable = false;
// endRemoveIf(device)
// Replace the '$ionicPlatform.ready()', to enable multiple calls
function ready() {
if (!readyPromise) {
readyPromise = $ionicPlatform.ready().then(function(){
var enableCamera = !!navigator.camera;
exports.enable = enableCamera;
if (exports.enable){
var enableBarcodeScanner = cordova && cordova.plugins && !!cordova.plugins.barcodeScanner;
console.debug('[device] Ionic platform ready, with [barcodescanner={0}] [camera={1}]'.format(enableBarcodeScanner, enableCamera));
}
else {
console.debug('[device] Ionic platform ready - no device detected.');
}
});
}
return readyPromise;
}
function getPicture(options) {
if (!exports.enable) {
return $q.reject("Camera not enable. Please call 'Device.ready()' once before use (e.g in app.js).");
......@@ -138,7 +118,34 @@ angular.module('cesium.device.services', ['ngResource', 'cesium.utils.services']
return deferred.promise;
}
exports.ready = ready;
// Replace the '$ionicPlatform.ready()', to enable multiple calls
readyPromise = $ionicPlatform.ready();
function ready() {
return readyPromise;
}
readyPromise.then(function(){
var enableCamera = !!navigator.camera;
exports.enable = enableCamera;
if (exports.enable){
var enableBarcodeScanner = cordova && cordova.plugins && !!cordova.plugins.barcodeScanner;
console.debug('[device] Ionic platform ready, with [barcodescanner={0}] [camera={1}]'.format(enableBarcodeScanner, enableCamera));
if (cordova.InAppBrowser) {
console.debug('[device] Enabling InAppBrowser');
}
}
else {
console.debug('[device] Ionic platform ready - no device detected.');
}
});
exports.ready = function() {
return readyPromise;
};
exports.clipboard = {copy: copy};
exports.camera = {
getPicture : getPicture,
......
......@@ -165,6 +165,7 @@ angular.module('cesium.modal.services', [])
parameters);
}
return {
showTransfer: showTransfer,
showLogin: showLogin,
......
......@@ -380,6 +380,18 @@ angular.module('cesium.utils.services', ['ngResource'])
return deferred.promise;
}
function showCopyPopover(event, value) {
var rows = value && value.indexOf('\n') >= 0 ? value.split('\n').length : 1;
showPopover(event, {
templateUrl: 'templates/common/popover_copy.html',
bindings: {
value: value,
rows: rows
},
autoselect: '.popover-copy ' + (rows <= 1 ? 'input' : 'textarea')
});
}
function showSharePopover(event, options) {
options = options || {};
options.templateUrl = options.templateUrl ? options.templateUrl : 'templates/common/popover_share.html';
......@@ -645,6 +657,7 @@ angular.module('cesium.utils.services', ['ngResource'])
},
popover: {
show: showPopover,
copy: showCopyPopover,
share: showSharePopover,
helptip: showHelptip
},
......
......@@ -6,6 +6,8 @@ angular.module('cesium.es.common.controllers', ['ngResource', 'cesium.es.service
.controller('ESSocialsEditCtrl', ESSocialsEditController)
.controller('ESSocialsViewCtrl', ESSocialsViewController)
.controller('ESCommentsCtrl', ESCommentsController)
.controller('ESCategoryModalCtrl', ESCategoryModalController)
......@@ -282,7 +284,7 @@ function ESCommentsController($scope, $timeout, $filter, $state, $focus, UIUtils
};
}
function ESSocialsEditController($scope, $focus, $timeout, $filter, UIUtils, SocialUtils) {
function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils) {
'ngInject';
$scope.socialData = {
......@@ -327,3 +329,23 @@ function ESSocialsEditController($scope, $focus, $timeout, $filter, UIUtils, Soc
$focus('socialUrl');
};
}
function ESSocialsViewController($scope, $window, Device, UIUtils) {
'ngInject';
$scope.open = function(event, social) {
if (!social) return;
var url = (social.type == 'email') ? ('mailto:' + social.url) : social.url;
// If email, do not try to open, but copy value
if (!Device.enable && social.type == 'email') {
UIUtils.popover.copy(event, social.url);
return;
}
// Open the url
// Note: If device is enable, this will use InAppBrowser cordova plugin
$window.open(url, '_system', 'location=yes');
};
}
......@@ -205,8 +205,10 @@ angular.module('cesium.es.notification.services', ['cesium.services', 'cesium.es
var userEventWs = that.raw.ws.getUserEvent();
listeners.push(userEventWs.close);
return userEventWs.on(
function(){
$rootScope.$apply(onNewNotification);
function(event){
$rootScope.$apply(function() {
onNewNotification(event);
});
},
{pubkey: data.pubkey, locale: csSettings.data.locale.id}
)
......
......@@ -25,19 +25,19 @@
</div>
<!-- Socials networks -->
<div class="item" ng-if="formData.profile.socials && formData.profile.socials.length">
<div class="item" ng-if="formData.profile.socials && formData.profile.socials.length" ng-controller="ESSocialsViewCtrl">
<span class="gray" translate>PROFILE.SOCIAL_NETWORKS_DIVIDER</span>
<div class="list no-padding">
<ion-item class="item-icon-left item-text-wrap no-padding-bottom"
ng-repeat="social in formData.profile.socials track by social.url"
id="social-{{::social.url|formatSlug}}">
<ion-item ng-repeat="social in formData.profile.socials track by social.url"
id="social-{{::social.url|formatSlug}}"
class="item-icon-left item-text-wrap no-padding-bottom ink"
ng-click="open($event, social)">
<i class="icon ion-social-{{social.type}}"
ng-class="{'ion-bookmark': social.type == 'other', 'ion-link': social.type == 'web', 'ion-email': social.type == 'email'}"></i>
<p ng-if="social.type && social.type != 'web'">{{social.type}}</p>
<h2>
<a href="{{social.url}}" ng-if="social.type != 'email'" target="_blank">{{::social.url}}</a>
<a href="mailto:{{social.url}}" ng-if="social.type == 'email'">{{::social.url}}</a>
</h2>
<h4>
<a>{{::social.url}}</a>
</h4>
</ion-item>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment