2016-11-01 14:21:35 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-11-16 11:16:20 -03:00
|
|
|
angular.module('copayApp.controllers').controller('completeController', function($scope, $stateParams, $timeout, $log, $ionicHistory, $state, platformInfo, configService, storageService, lodash) {
|
2016-11-01 14:21:35 -03:00
|
|
|
$scope.score = parseInt($stateParams.score);
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.skipped = $stateParams.skipped == 'false' ? false : true;
|
|
|
|
|
$scope.isCordova = platformInfo.isCordova;
|
|
|
|
|
var config = configService.getSync();
|
|
|
|
|
|
|
|
|
|
$scope.shareFacebook = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareFacebookVia, null, null, null, config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareTwitter = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareTwitterVia, null, null, null, config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareGooglePlus = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareGooglePlusVia, config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareEmail = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareViaEmail(config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareWhatsapp = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareViaWhatsApp(config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareMessage = function() {
|
2016-11-16 13:56:46 -05:00
|
|
|
window.plugins.socialsharing.shareViaSMS(config.download.url);
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
2016-11-01 15:35:52 -03:00
|
|
|
|
|
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
2016-11-15 16:35:30 -05:00
|
|
|
|
2016-11-11 17:04:53 -03:00
|
|
|
storageService.getFeedbackInfo(function(error, info) {
|
2016-11-16 11:16:20 -03:00
|
|
|
var feedbackInfo = lodash.isString(info) ? JSON.parse(info) : null;
|
2016-11-11 17:04:53 -03:00
|
|
|
feedbackInfo.sent = true;
|
|
|
|
|
storageService.setFeedbackInfo(JSON.stringify(feedbackInfo), function() {});
|
|
|
|
|
});
|
|
|
|
|
|
2016-11-02 15:30:14 -03:00
|
|
|
if (!$scope.isCordova) return;
|
|
|
|
|
|
|
|
|
|
window.plugins.socialsharing.available(function(isAvailable) {
|
|
|
|
|
// the boolean is only false on iOS < 6
|
|
|
|
|
$scope.socialsharing = isAvailable;
|
|
|
|
|
if (isAvailable) {
|
|
|
|
|
window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null, function(e) {
|
2016-11-16 12:58:55 -03:00
|
|
|
$scope.shareFacebookVia = 'com.apple.social.facebook';
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.facebook = true;
|
|
|
|
|
}, function(e) {
|
2016-11-16 12:58:55 -03:00
|
|
|
window.plugins.socialsharing.canShareVia('com.facebook.katana', 'msg', null, null, null, function(e) {
|
|
|
|
|
$scope.shareFacebookVia = 'com.facebook.katana';
|
|
|
|
|
$scope.facebook = true;
|
|
|
|
|
}, function(e) {
|
|
|
|
|
$log.debug('facebook error: ' + e);
|
|
|
|
|
$scope.facebook = false;
|
|
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
});
|
2016-11-16 12:58:55 -03:00
|
|
|
window.plugins.socialsharing.canShareVia('com.apple.social.twitter', 'msg', null, null, null, function(e) {
|
|
|
|
|
$scope.shareTwitterVia = 'com.apple.social.twitter';
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.twitter = true;
|
|
|
|
|
}, function(e) {
|
2016-11-16 12:58:55 -03:00
|
|
|
window.plugins.socialsharing.canShareVia('com.twitter.android', 'msg', null, null, null, function(e) {
|
|
|
|
|
$scope.shareTwitterVia = 'com.twitter.android';
|
|
|
|
|
$scope.twitter = true;
|
|
|
|
|
}, function(e) {
|
|
|
|
|
$log.debug('twitter error: ' + e);
|
|
|
|
|
$scope.twitter = false;
|
|
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
});
|
|
|
|
|
window.plugins.socialsharing.canShareVia('com.google.android.apps.plus', 'msg', null, null, null, function(e) {
|
2016-11-03 11:43:34 -03:00
|
|
|
$scope.shareGooglePlusVia = 'com.google.android.apps.plus';
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.googleplus = true;
|
|
|
|
|
}, function(e) {
|
2016-11-03 11:43:34 -03:00
|
|
|
$log.debug('googlePlus error: ' + e);
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.googleplus = false;
|
2016-11-03 11:43:34 -03:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
window.plugins.socialsharing.canShareViaEmail(function(e) {
|
|
|
|
|
$scope.email = true;
|
|
|
|
|
}, function(e) {
|
2016-11-03 11:43:34 -03:00
|
|
|
$log.debug('email error: ' + e);
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.email = false;
|
2016-11-03 11:43:34 -03:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
window.plugins.socialsharing.canShareVia('whatsapp', 'msg', null, null, null, function(e) {
|
|
|
|
|
$scope.whatsapp = true;
|
|
|
|
|
}, function(e) {
|
2016-11-03 11:43:34 -03:00
|
|
|
$log.debug('whatsapp error: ' + e);
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.whatsapp = false;
|
2016-11-03 11:43:34 -03:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
}
|
2016-11-03 11:43:34 -03:00
|
|
|
}, 100);
|
2016-11-01 15:35:52 -03:00
|
|
|
});
|
2016-11-15 16:35:30 -05:00
|
|
|
|
2016-11-16 11:16:20 -03:00
|
|
|
$scope.close = function() {
|
|
|
|
|
$ionicHistory.clearHistory();
|
|
|
|
|
$ionicHistory.nextViewOptions({
|
|
|
|
|
disableAnimate: true,
|
|
|
|
|
historyRoot: true
|
|
|
|
|
});
|
|
|
|
|
$timeout(function() {
|
|
|
|
|
$state.go('tabs.home');
|
|
|
|
|
}, 100);
|
|
|
|
|
};
|
2016-11-01 14:21:35 -03:00
|
|
|
});
|