Adds scan tab. Fix grunt ios

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-17 15:23:17 -03:00
parent 752fa1e432
commit 70ba150e60
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
14 changed files with 141 additions and 132 deletions

View File

@ -259,8 +259,9 @@ module.exports = function(grunt) {
grunt.registerTask('chrome', ['exec:chrome']);
grunt.registerTask('wp', ['prod', 'exec:wp']);
grunt.registerTask('wp-debug', ['default', 'exec:wp']);
grunt.registerTask('ios', ['prod', 'exec:ios', 'exec:xcode']);
grunt.registerTask('ios-debug', ['default', 'exec:ios', 'exec:xcode']);
grunt.registerTask('ios', ['prod', 'exec:ios']);
grunt.registerTask('ios-debug', ['default', 'exec:ios']);
grunt.registerTask('ios-run', ['exec:xcode']);
grunt.registerTask('cordovaclean', ['exec:cordovaclean']);
grunt.registerTask('android-debug', ['default', 'exec:android', 'exec:androidrun']);
grunt.registerTask('android', ['prod', 'exec:android']);

View File

@ -1,32 +1,31 @@
.PHONY: ios android wp
.PHONY: ios android wp
WORKDIR=project-
all:
clean:
rm -Rf $(WORKDIR)*
clean:
rm -Rf $(WORKDIR)*
$(WORKDIR)android $(WORKDIR)ios $(WORKDIR)wp: config.xml
cordova create $@ com.bitpay.*NAMENOSPACE* *NAMECASENOSPACE* || echo "Project Path Existed"
cp ProjectMakefile $@/Makefile
cp -af ../public/** $@/www
sed "s/<\!-- PLACEHOLDER: CORDOVA SRIPT -->/<script type='text\/javascript' charset='utf-8' src='cordova.js'><\/script>/g" ../public/index.html > $@/www/index.html
rm -r $@/www && ln -sF ../../public $@/www
cp config.xml $@/config.xml
make -C $@ $(subst $(WORKDIR),, $@)
make -C $@ $(subst $(WORKDIR),, $@)
ios: $(WORKDIR)ios
ios: $(WORKDIR)ios
make -C $(WORKDIR)ios build-ios
android: project-android
android: project-android
mkdir -p android/platforms/android/res/xml/
cp android/build-extras.gradle $(WORKDIR)android/platforms/android/build-extras.gradle
cp android/project.properties $(WORKDIR)android/platforms/android/project.properties
cp -R android/res/* $(WORKDIR)android/platforms/android/res
make -C $(WORKDIR)android build-android
wp: build-wp
cp -vf wp/Properties/* $</platforms/wp8/Properties/
cp -vf wp/MainPage.xaml $</platforms/wp8/

0
public/cordova.js vendored Normal file
View File

View File

@ -8,19 +8,17 @@
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="css/ionic.min.css">
<link rel="stylesheet" type="text/css" href="css/copay.css">
<title>{{index.appConfig.name}} - {{index.appConfig.description}}</title>
<title>{{index.appConfig.nameCase}} - {{index.appConfig.description}}</title>
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<!-- <body ng&#45;cloak class="ng&#45;cloak"> -->
<body >
<body>
<ion-nav-view name="main"></ion-nav-view>
<script src="lib/ionic.bundle.min.js"></script>
<script src="lib/angular.js"></script>
<!-- DO NOT DELETE THIS COMMET -->
<!-- PLACEHOLDER: CORDOVA SRIPT -->
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script src="js/copay.js"></script>

View File

@ -1,34 +1,21 @@
<div class="splash extra-padding-bottom p20t content text-center"
ng-controller="disclaimerController as disclaimer" ng-init="disclaimer.init()">
<div class="row">
<div class="medium-centered small-centered large-centered columns size-14">
<span class="text-bold text-white" translate>WELCOME TO COPAY</span>
<p class="text-gray m0 text-light" translate>A multisignature bitcoin wallet</p>
</div>
</div>
<div class="row">
<div class="scrollArea">
<p class="enable_text_select m0">
<div class="size-14 text-gray" translate>Terms of Use</div>
<div ng-include="'views/includes/terms.html'"></div>
</p>
</div>
</div>
<ion-view>
<ion-content class="padding" ng-controller="disclaimerController" ng-init="init()">
<h1 translate>WELCOME TO COPAY</h1>
<h3 translate>A multisignature bitcoin wallet</h3>
<div class="row">
<p ng-show="disclaimer.lang != 'en'">
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
</p>
</div>
<div>
<p class="text-gray columns size-12" translate>I affirm that I have read, understood, and agree with these terms.</p>
</div>
<div class="row">
<h4 translate>Terms of Use</h4>
<p ng-include="'views/includes/terms.html'"></p>
<div class="start-button columns button-box">
<button ng-click="disclaimer.accept()" class="button black expand round size-12 text-spacing m0" translate>
<div class="padding-vertical" ng-show="lang != 'en'">
<a ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
</div>
<p translate>I affirm that I have read, understood, and agree with these terms.</p>
<button ng-click="accept()" class="button button-block button-positive" translate>
I AGREE. GET STARTED
</button>
</div>
</div>
</div>
</ion-content>
</ion-view>

View File

@ -1,4 +1,4 @@
<ion-modal-view ng-controller="scannerController">
<ion-modal-view>
<ion-header-bar align-title="center" class="tab-bar">
<div class="left-small">
<a ng-click="cancel()" class="p10">
@ -7,7 +7,7 @@
</div>
<h1 class="title ellipsis" translate>QR-Scanner</h1>
</ion-header-bar>
<ion-content class="modal-content text-center fix-modals-touch" ng-init="init()">
<ion-content ng-controller="tabScanController" ng-init="init()">
<canvas id="qr-canvas" width="200" height="150"></canvas>
<video id="qrcode-scanner-video" width="300" height="225"></video>
</ion-content>

View File

@ -0,0 +1,11 @@
<ion-view view-title="Scan" cache-view="false">
<ion-nav-bar class="bar-stable">
<ion-nav-title>Scan</ion-nav-title>
</ion-nav-bar>
<ion-content ng-controller="tabScanController" ng-init="init()">
<canvas id="qr-canvas" width="200" height="150"></canvas>
<video id="qrcode-scanner-video" width="300" height="225"></video>
</ion-content>
</ion-view>

View File

@ -14,7 +14,7 @@ navigation history that also transitions its views in and out.
</ion-tab>
<ion-tab title="Scan" icon-off="ion-ios-chatboxes-outline" icon-on="ion-ios-chatboxes" href="#/scan">
<ion-tab title="Scan" icon-off="ion-ios-camera-outline" icon-on="ion-ios-camera" href="#/tabs/scan">
<ion-nav-view name="tab-scan"></ion-nav-view>
</ion-tab>
@ -26,4 +26,4 @@ navigation history that also transitions its views in and out.
<ion-tab title="Settings" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tabs/settings">
<ion-nav-view name="tab-settings"></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-tabs>

View File

@ -2,8 +2,7 @@
angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $rootScope, $timeout, $log, $ionicSideMenuDelegate, profileService, applicationService, gettextCatalog, uxLanguage, go, storageService, gettext, platformInfo, ongoingProcess) {
var self = this;
self.tries = 0;
var tries = 0;
var isCordova = platformInfo.isCordova;
ongoingProcess.set('creatingWallet', true);
@ -20,13 +19,13 @@ angular.module('copayApp.controllers').controller('disclaimerController',
return $timeout(function() {
$log.warn('Retrying to create profile......');
if (self.tries == 3) {
self.tries == 0;
if (tries == 3) {
tries == 0;
return create({
noWallet: true
});
} else {
self.tries += 1;
tries += 1;
return create();
}
}, 3000);
@ -36,9 +35,9 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
};
this.init = function(opts) {
$scope.init = function(opts) {
$ionicSideMenuDelegate.canDragContent(false);
self.lang = uxLanguage.currentLanguage;
$scope.lang = uxLanguage.currentLanguage;
storageService.getProfile(function(err, profile) {
if (!profile) {
@ -57,7 +56,7 @@ angular.module('copayApp.controllers').controller('disclaimerController',
});
};
this.accept = function() {
$scope.accept = function() {
profileService.setDisclaimerAccepted(function(err) {
if (err) $log.error(err);
else {

View File

@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('tabHomeController',
self.setWallets();
});
self.setWallets = function() {
self.setWallets = function() {
$scope.wallets = profileService.getWallets();
};
@ -36,5 +36,5 @@ angular.module('copayApp.controllers').controller('tabHomeController',
$scope.bitpayCardEnabled = true; // TODO
$state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
// $state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
});

View File

@ -1,6 +1,63 @@
'use strict';
angular.module('copayApp.controllers').controller('scannerController', function($scope, $timeout) {
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, gettextCatalog, platformInfo) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
var onSuccess = function(result) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
if (isWP && result.cancelled) return;
$timeout(function() {
var data = isIOS ? result : result.text;
$scope.onScan({
data: data
});
}, 1000);
};
var onError = function(error) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
};
$scope.cordovaOpenScanner = function() {
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
if (isIOS) {
cloudSky.zBar.scan({}, onSuccess, onError);
} else {
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
}
if ($scope.beforeScan) {
$scope.beforeScan();
}
}, 100);
};
$scope.modalOpenScanner = function() {
$ionicModal.fromTemplateUrl('views/modals/scanner.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.scannerModal = modal;
$scope.scannerModal.show();
});
};
$scope.openScanner = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
} else {
$scope.modalOpenScanner();
}
};
// QR code Scanner
var video;
@ -73,6 +130,10 @@ angular.module('copayApp.controllers').controller('scannerController', function(
};
$scope.init = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
return;
}
setScanner();
$timeout(function() {
if ($scope.beforeScan) {
@ -99,4 +160,8 @@ angular.module('copayApp.controllers').controller('scannerController', function(
$scope.scannerModal.remove();
};
$scope.$on("$destroy", function(){
_scanStop();
});
});

View File

@ -1,66 +1,7 @@
'use strict';
angular.module('copayApp.directives')
.directive('qrScanner', function($rootScope, $timeout, $ionicModal, gettextCatalog, platformInfo) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
var controller = function($scope) {
var onSuccess = function(result) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
if (isWP && result.cancelled) return;
$timeout(function() {
var data = isIOS ? result : result.text;
$scope.onScan({
data: data
});
}, 1000);
};
var onError = function(error) {
$timeout(function() {
window.plugins.spinnerDialog.hide();
}, 100);
};
$scope.cordovaOpenScanner = function() {
window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true);
$timeout(function() {
if (isIOS) {
cloudSky.zBar.scan({}, onSuccess, onError);
} else {
cordova.plugins.barcodeScanner.scan(onSuccess, onError);
}
if ($scope.beforeScan) {
$scope.beforeScan();
}
}, 100);
};
$scope.modalOpenScanner = function() {
$ionicModal.fromTemplateUrl('views/modals/scanner.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.scannerModal = modal;
$scope.scannerModal.show();
});
};
$scope.openScanner = function() {
if (isCordova) {
$scope.cordovaOpenScanner();
} else {
$scope.modalOpenScanner();
}
};
};
.directive('qrScanner', function() {
return {
restrict: 'E',
@ -68,7 +9,7 @@ angular.module('copayApp.directives')
onScan: "&",
beforeScan: "&"
},
controller: controller,
controller: 'tabScanController',
replace: true,
template: '<a ng-click="openScanner()"><i class="icon ion-qr-scanner"></i></a>'
}

View File

@ -161,6 +161,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
}
})
.state('tabs.scan', {
url: '/scan',
needProfile: true,
views: {
'tab-scan': {
templateUrl: 'views/tab-scan.html',
},
}
})
.state('tabs.send', {
url: '/send',
cache: false,
@ -200,7 +209,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
},
},
})
.state('unsupported', {
url: '/unsupported',
needProfile: false,
@ -652,9 +661,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}, 300);
});
if (window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
cordova.plugins.Keyboard.disableScroll(false);
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleLightContent();
}
$ionicPlatform.registerBackButtonAction(function(event) {

View File

@ -35,16 +35,12 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe
$log.debug("Wallet not complete at startup... redirecting")
root.path('copayers');
} else {
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome', true);
});
root.path('tabs.home');
}
};
root.send = function() {
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'send');
});
root.path('tabs.send');
};
root.addWallet = function() {