2016-11-01 14:21:35 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2017-03-09 10:20:28 -03:00
|
|
|
angular.module('copayApp.controllers').controller('completeController', function($scope, $stateParams, $timeout, $log, $ionicHistory, $state, $ionicNavBarDelegate, $ionicConfig, platformInfo, configService, storageService, lodash, appConfigService, gettextCatalog) {
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.isCordova = platformInfo.isCordova;
|
2017-03-09 10:20:28 -03:00
|
|
|
$scope.title = gettextCatalog.getString("Share {{appName}}", {
|
|
|
|
|
appName: appConfigService.nameCase
|
|
|
|
|
});
|
|
|
|
|
|
2016-11-18 16:30:57 -03:00
|
|
|
var defaults = configService.getDefaults();
|
2017-03-09 16:48:38 -03:00
|
|
|
var downloadUrl = appConfigService.name == 'copay' ? defaults.download.copay.url : defaults.download.bitpay.url;
|
2016-11-02 15:30:14 -03:00
|
|
|
|
2016-11-18 16:30:57 -03:00
|
|
|
function quickFeedback(cb) {
|
2016-11-17 00:56:12 -05:00
|
|
|
window.plugins.spinnerDialog.show();
|
|
|
|
|
$timeout(window.plugins.spinnerDialog.hide, 300);
|
|
|
|
|
$timeout(cb, 20);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 15:30:14 -03:00
|
|
|
$scope.shareFacebook = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareFacebookVia, null, null, null, downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareTwitter = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareTwitterVia, null, null, null, downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareGooglePlus = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareVia($scope.shareGooglePlusVia, downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareEmail = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareViaEmail(downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareWhatsapp = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareViaWhatsApp(downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.shareMessage = function() {
|
2016-11-18 16:30:57 -03:00
|
|
|
quickFeedback(function() {
|
2017-03-09 16:48:38 -03:00
|
|
|
window.plugins.socialsharing.shareViaSMS(downloadUrl);
|
2016-11-17 00:56:12 -05:00
|
|
|
});
|
2016-11-02 15:30:14 -03:00
|
|
|
};
|
2016-11-01 15:35:52 -03:00
|
|
|
|
2017-02-23 14:26:05 -05:00
|
|
|
$scope.$on("$ionicView.beforeLeave", function() {
|
|
|
|
|
$ionicConfig.views.swipeBackEnabled(true);
|
|
|
|
|
});
|
|
|
|
|
|
2017-03-03 10:36:19 -03:00
|
|
|
$scope.$on("$ionicView.enter", function() {
|
|
|
|
|
if (!$scope.fromSettings)
|
|
|
|
|
$ionicConfig.views.swipeBackEnabled(false);
|
|
|
|
|
});
|
|
|
|
|
|
2016-11-17 11:06:22 -03:00
|
|
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
|
|
|
|
$scope.score = (data.stateParams && data.stateParams.score) ? parseInt(data.stateParams.score) : null;
|
|
|
|
|
$scope.skipped = (data.stateParams && data.stateParams.skipped) ? true : false;
|
|
|
|
|
$scope.rated = (data.stateParams && data.stateParams.rated) ? true : false;
|
|
|
|
|
$scope.fromSettings = (data.stateParams && data.stateParams.fromSettings) ? true : false;
|
|
|
|
|
|
2016-11-17 00:56:12 -05:00
|
|
|
if (!$scope.fromSettings) {
|
2017-01-25 10:41:32 -03:00
|
|
|
$ionicNavBarDelegate.showBackButton(false);
|
2016-11-17 00:56:12 -05:00
|
|
|
} else {
|
|
|
|
|
$ionicNavBarDelegate.showBackButton(true);
|
|
|
|
|
}
|
2016-11-16 18:32:12 -03: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;
|
2016-11-16 18:15:55 -05:00
|
|
|
$scope.animate = true;
|
2016-11-02 15:30:14 -03:00
|
|
|
|
|
|
|
|
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.nextViewOptions({
|
2016-11-16 16:57:36 -03:00
|
|
|
disableAnimate: false,
|
2016-11-16 11:16:20 -03:00
|
|
|
historyRoot: true
|
|
|
|
|
});
|
2016-11-16 18:32:12 -03:00
|
|
|
if ($scope.score == 5) $ionicHistory.goBack(-3);
|
|
|
|
|
else $ionicHistory.goBack(-2);
|
2016-11-16 11:16:20 -03:00
|
|
|
};
|
2016-11-01 14:21:35 -03:00
|
|
|
});
|