Build Copay for OSX, Linux and Windows

This commit is contained in:
Gustavo Maximiliano Cortez 2015-05-28 10:52:33 -03:00
commit c0b496c7e7
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
15 changed files with 759 additions and 101 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog) {
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit) {
var self = this;
$rootScope.hideMenuBar = false;
@ -381,6 +381,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (isCordova) {
window.cordova.plugins.clipboard.copy('bitcoin:' + addr);
window.plugins.toast.showShortCenter('Copied to clipboard');
} else if (nodeWebkit.isDefined()) {
nodeWebkit.writeToClipboard(addr);
}
};

View file

@ -370,7 +370,7 @@ angular
needProfile: false
});
})
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService, $timeout) {
.run(function($rootScope, $state, $log, gettextCatalog, uriHandler, isCordova, amMoment, profileService, $timeout, nodeWebkit) {
FastClick.attach(document.body);
// Auto-detect browser language
@ -392,6 +392,14 @@ angular
uriHandler.register();
}
if (nodeWebkit.isDefined()) {
var gui = require('nw.gui');
var win = gui.Window.get();
var nativeMenuBar = new gui.Menu({ type: "menubar" });
nativeMenuBar.createMacBuiltin("Copay");
win.menu = nativeMenuBar;
}
var pageWeight = {
walletHome: 0,
copayers: -1,

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, profileService) {
angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, profileService, nodeWebkit) {
var root = {};
var hideSidebars = function() {
@ -30,7 +30,12 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
};
root.openExternalLink = function(url) {
var ref = window.open(url, '_blank', 'location=no');
if (nodeWebkit.isDefined()) {
nodeWebkit.openExternalLink(url);
}
else {
var ref = window.open(url, '_blank', 'location=no');
}
};
root.path = function(path, cb) {

View file

@ -1,17 +0,0 @@
'use strict';
// Detect node-webkit
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
var isNodeWebkit = false;
//Is this Node.js?
if(isNode) {
//If so, test for Node-Webkit
try {
isNodeWebkit = (typeof require('nw.gui') !== "undefined");
} catch(e) {
isNodeWebkit = false;
}
}
angular.module('copayApp.services').value('isNodeWebkit', isNodeWebkit);

View file

@ -1,11 +1,11 @@
'use strict';
angular.module('copayApp.services')
.factory('localStorageService', function(isChromeApp, isNodeWebkit, $timeout) {
.factory('localStorageService', function(isChromeApp, nodeWebkit, $timeout) {
var root = {};
var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null);
if (isChromeApp && !isNodeWebkit && !ls) {
if (isChromeApp && !nodeWebkit.isDefined() && !ls) {
ls = localStorage = chrome.storage.local;
window.localStorage = chrome.storage.local;
}
@ -14,7 +14,7 @@ angular.module('copayApp.services')
throw new Error('localstorage not available');
root.get = function(k, cb) {
if (isChromeApp && !isNodeWebkit) {
if (isChromeApp && !nodeWebkit.isDefined()) {
chrome.storage.local.get(k,
function(data) {
//TODO check for errors
@ -40,7 +40,7 @@ angular.module('copayApp.services')
};
root.set = function(k, v, cb) {
if (isChromeApp && !isNodeWebkit) {
if (isChromeApp && !nodeWebkit.isDefined()) {
var obj = {};
obj[k] = v;
@ -53,7 +53,7 @@ angular.module('copayApp.services')
};
root.remove = function(k, cb) {
if (isChromeApp && !isNodeWebkit) {
if (isChromeApp && !nodeWebkit.isDefined()) {
chrome.storage.local.remove(k, cb);
} else {
ls.removeItem(k);

View file

@ -1,8 +1,8 @@
'use strict';
angular.module('copayApp.services')
.factory('logHeader', function($log, isChromeApp, isCordova, isNodeWebkit) {
.factory('logHeader', function($log, isChromeApp, isCordova, nodeWebkit) {
$log.info('Starting Copay v' + window.version + ' #' + window.commitHash);
$log.info('Client: isCordova:', isCordova, 'isChromeApp:', isChromeApp, 'isNodeWebkit:', isNodeWebkit);
$log.info('Client: isCordova:', isCordova, 'isChromeApp:', isChromeApp, 'isNodeWebkit:', nodeWebkit.isDefined());
$log.info('Navigator:', navigator.userAgent);
return {};
});

View file

@ -0,0 +1,42 @@
'use strict';
angular.module('copayApp.services').factory('nodeWebkit', function nodeWebkitFactory() {
var root = {};
var isNodeWebkit = function() {
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
if(isNode) {
try {
return (typeof require('nw.gui') !== "undefined");
} catch(e) {
return false;
}
}
};
root.isDefined = function() {
return isNodeWebkit();
};
root.readFromClipboard = function() {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.get();
};
root.writeToClipboard = function(text) {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.set(text);
};
root.openExternalLink = function(url) {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
return gui.Shell.openExternal(url);
};
return root;
});