Multiple fixes for chrome app

This commit is contained in:
Matias Pando 2014-12-02 10:40:24 -03:00
commit 834c57a51a
12 changed files with 88 additions and 10 deletions

View file

@ -13,3 +13,4 @@ popup.html
lib/angular/angular-csp.css lib/angular/angular-csp.css
lib/angular/angular.min.js.map lib/angular/angular.min.js.map
lib/angular-route/angular-route.min.js.map lib/angular-route/angular-route.min.js.map
lib/angular-touch/angular-touch.min.js.map

View file

@ -22,6 +22,7 @@
color: #B7C2CD; color: #B7C2CD;
} }
#qr-canvas { display: none; } #qr-canvas { display: none; }
#qrcode-scanner-video { #qrcode-scanner-video {
display: block; display: block;
@ -60,6 +61,7 @@ body, html{
height:100%; height:100%;
width:100%; width:100%;
color: #2C3E50; color: #2C3E50;
-webkit-user-select: text;
} }
header { header {

View file

@ -21,6 +21,7 @@
<link rel="shortcut icon" href="img/favicon.ico"> <link rel="shortcut icon" href="img/favicon.ico">
</head> </head>
<body> <body>
<div id="loading" class="loadingpage"> <div id="loading" class="loadingpage">
<img src="img/ajax-loader.gif" alt="Loading..."> <img src="img/ajax-loader.gif" alt="Loading...">
</div> </div>

12
init.js
View file

@ -20,6 +20,18 @@ function init() {
ld.visibility = "hidden"; ld.visibility = "hidden";
} else if (ns6 || ie4) { } else if (ns6 || ie4) {
ld.display = "none"; ld.display = "none";
} else {
console.log('Warning!! is a chrome app!');
console.log('ns4', ns4);
console.log('ns6', ns6);
console.log('ie4', ie4);
ld = document.loading;
ld = document.getElementById("loading").style;
ld.visibility = "hidden";
ld.display = "none";
} }
} }
init(); init();

View file

@ -1,8 +1,8 @@
chrome.app.runtime.onLaunched.addListener(function() { chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('index.html', { chrome.app.window.create('index.html', {
'bounds': { 'bounds': {
'width': 1024, 'width': 1200,
'height': 768 'height': 800
} }
}); });
}); });

View file

@ -4,19 +4,67 @@ var copay = require('copay');
var _ = require('lodash'); var _ = require('lodash');
var config = defaultConfig; var config = defaultConfig;
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
var localStorage; var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) { if (isChromeApp) {
console.log('Is a chrome app!'); var storage = chrome.storage.local;
var myAccess = 'myAccess';
var obj = {};
obj[myAccess] = Math.floor((Math.random() * 1000) + 1);;
storage.get(myAccess, function(result) {
console.log('Last access 1', JSON.stringify(myAccess), JSON.stringify(result));
});
storage.set(obj);
storage.get(myAccess, function(result) {
console.log('Last access 2', JSON.stringify(myAccess), JSON.stringify(result));
});
console.log('Is a chrome app!...app.js');
console.log('chrome.storage', chrome.storage);
chrome.storage.local.set({
'MiNombre': 'Matias'
}, function(done) {
console.log('Saving to local storage', done);
});
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
console.log('localStorage', localStorage); console.log('localStorage', localStorage);
} else { } else {
console.log('Is web!'); console.log('Is web!');
localStorage = window.localStorage; localStorage = window.localStorage;
} }
console.log('access to localStorage');
var localConfig; var localConfig;
if (localStorage) { if (localStorage) {
localConfig = JSON.parse(localStorage.getItem('config'));
if (isChromeApp) {
var result;
localStorage.getItem('config', function(data) {
result = data;
});
console.log('retrieving data from local storage', result);
localConfig = JSON.parse(result);
} else {
localConfig = JSON.parse(localStorage.getItem('config'));
console.log('localStorage', localConfig);
}
} else {
console.log('localStorage is null ');
} }

View file

@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id; var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
if (isChromeApp) { if (isChromeApp) {
console.log('Is a chrome app!'); console.log('Is a chrome app!...settings.js');
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
} else { } else {
console.log('Is web!'); console.log('Is web!');
@ -92,6 +92,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
plugins[$scope.selectedStorage.pluginName] = true; plugins[$scope.selectedStorage.pluginName] = true;
copay.logger.setLevel($scope.selectedLogLevel.name); copay.logger.setLevel($scope.selectedLogLevel.name);
localstorageService.setItem('config', JSON.stringify({ localstorageService.setItem('config', JSON.stringify({
network: insightSettings, network: insightSettings,
version: copay.version, version: copay.version,
@ -107,6 +108,7 @@ angular.module('copayApp.controllers').controller('SettingsController', function
}), function() { }), function() {
applicationService.restart(); applicationService.restart();
}); });
}; };

View file

@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('UnsupportedController',
var localStorage; var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) { if (window.chrome && chrome.runtime && chrome.runtime.id) {
console.log('Is a chrome app!'); console.log('Is a chrome app!..unssoported.js');
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
} else { } else {
console.log('Is web!'); console.log('Is web!');

View file

@ -76,6 +76,15 @@ Compatibility._decrypt = function(base64, passphrase) {
Compatibility._read = function(k, passphrase, cb) { Compatibility._read = function(k, passphrase, cb) {
preconditions.checkArgument(cb); preconditions.checkArgument(cb);
var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) {
console.log('Is a chrome app!..Compatibility.js');
localStorage = chrome.storage.local;
} else {
console.log('Is web!');
localStorage = window.localStorage;
}
var ret = localStorage.getItem(k); var ret = localStorage.getItem(k);
if (!ret) return cb(null); if (!ret) return cb(null);
var ret = self._decrypt(ret, passphrase); var ret = self._decrypt(ret, passphrase);

View file

@ -7,6 +7,7 @@ var isChromeApp = window.chrome && chrome.runtime && chrome.runtime.id;
function LocalStorage() { function LocalStorage() {
this.type = 'DB'; this.type = 'DB';
if (isChromeApp) { if (isChromeApp) {
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
window.localStorage = chrome.storage.local; window.localStorage = chrome.storage.local;

View file

@ -119,12 +119,14 @@ angular
} }
$rootScope.$on('$routeChangeStart', function(event, next, current) { $rootScope.$on('$routeChangeStart', function(event, next, current) {
var localStorage; var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) { if (window.chrome && chrome.runtime && chrome.runtime.id) {
console.log('Is a chrome app!'); console.log('Is a chrome app!...routes.js');
console.log('chrome.storage', chrome.storage);
console.log('chrome.storage.local', chrome.storage.local);
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
console.log('chrome.storage', chrome.storage);
console.log('localStorage', localStorage); console.log('localStorage', localStorage);
} else { } else {
console.log('Is web!'); console.log('Is web!');

View file

@ -6,7 +6,7 @@ factory('notification', ['$timeout',
var localStorage; var localStorage;
if (window.chrome && chrome.runtime && chrome.runtime.id) { if (window.chrome && chrome.runtime && chrome.runtime.id) {
console.log('Is a chrome app!'); console.log('Is a chrome app!...notification.js');
localStorage = chrome.storage.local; localStorage = chrome.storage.local;
} else { } else {
console.log('Is web!'); console.log('Is web!');