Skip to content

Commit 5f4209c

Browse files
authored
Merge pull request #518 from Bitcoin-com/wallet/hotfix/852
852 - Bugfix for Android camera.
2 parents b3de7d0 + a401649 commit 5f4209c

5 files changed

Lines changed: 13 additions & 49 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ module.exports = function(grunt) {
201201
'src/js/trezor-url.js',
202202
'bower_components/trezor-connect/connect.js',
203203
'node_modules/bezier-easing/dist/bezier-easing.min.js',
204-
'node_modules/cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min.js',
204+
'node_modules/cordova-plugin-qrscanner-no-android/dist/cordova-plugin-qrscanner-lib.min.js',
205205
'node_modules/cordova-plugin-camera-preview/www/CameraPreview.js'
206206
],
207207
dest: 'www/js/app.js'

app-template/config-template.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
6565
<plugin name="cordova-plugin-whitelist" spec="~1.3.0" />
6666
<plugin name="cordova-plugin-ionic-webview" spec="~3.0.0" />
67-
<plugin name="cordova-plugin-qrscanner" spec="~2.5.0" />
67+
<plugin name="cordova-plugin-qrscanner-no-android" spec="https://github.com/Bitcoin-com/cordova-plugin-qrscanner-no-android.git" commit="cbb6910d245a60899d33d933c9fa369c960e90f7" />
6868
<plugin name="cordova-plugin-camera-preview" spec="~0.10.0" />
6969
<plugin name="cordova-plugin-customurlscheme" spec="https://github.com/cmgustavo/Custom-URL-scheme.git">
7070
<variable name="URL_SCHEME" value="bitcoin" />
@@ -79,7 +79,7 @@
7979
<variable name="KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE" value="NO" />
8080
</plugin>
8181
<plugin name="cordova-plugin-geolocation" spec="~4.0.1" />
82-
<plugin name="cordova-plugin-qrreader" spec="https://github.com/Bitcoin-com/cordova-plugin-qrreader.git"/>
82+
<plugin name="cordova-plugin-qrreader" spec="https://github.com/Bitcoin-com/cordova-plugin-qrreader.git" commit="bdeb2f1afb28e9f5a845ea46a681b6a2b0b5691c"/>
8383
<!-- Supported Platforms -->
8484
<engine name="ios" spec="~4.5.3" />
8585
<engine name="android" spec="~6.4.0" />

app-template/package-template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"bitcore-wallet-client": "https://github.com/Bitcoin-com/bitcore-wallet-client.git",
6363
"bower": "^1.7.9",
6464
"cordova-custom-config": "^3.0.5",
65-
"cordova-plugin-qrscanner": "^2.5.0",
65+
"cordova-plugin-qrscanner-no-android": "https://github.com/Bitcoin-com/cordova-plugin-qrscanner-no-android.git",
6666
"cordova-plugin-vibration": "^3.0.1",
6767
"cordova-plugin-camera-preview": "^0.10.0",
6868
"coveralls": "^2.11.9",

src/js/controllers/tab-scan.controller.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,49 +54,12 @@ angular
5454

5555
$scope.$on("$ionicView.afterEnter", function() {
5656
_checkPermissionThenStartReading();
57-
document.addEventListener("resume", _onResume, true);
5857
});
5958

6059
$scope.$on("$ionicView.beforeLeave", function() {
61-
document.removeEventListener("resume", _onResume, true);
6260
qrService.stopReading();
6361
});
6462

65-
66-
function _onResume() {
67-
console.log('onResume()');
68-
69-
// Give everything time to settle since onResume gets call after the app resumes,
70-
// and some things are already happening, such as:
71-
// - Permission check has returned and reading was started.o
72-
73-
$timeout(function onResumeTimeout() {
74-
75-
if (isCheckingPermissions) {
76-
console.log('onResume(), was checking permissions, so don\'t do anything.');
77-
// Resume is called after using the permissions dialog
78-
// Let's hope they are not switching back to this app from another app
79-
return;
80-
}
81-
82-
if (isReading && platformInfo.isAndroid) { // Don't need to do this on iOS, in fact it breaks if you do
83-
console.log('onResume(), was reading, so restart reading.');
84-
qrService.stopReading().then(
85-
function onStoppedReadingSuccess() {
86-
console.log('onResume(), Starting reading after stopping.');
87-
_startReading();
88-
},
89-
function onStoppedReadingFailed(err) {
90-
$log.error('Failed to restart reading', err);
91-
$scope.currentState = scannerStates.unavailable;
92-
}
93-
);
94-
}
95-
96-
}, 200);
97-
98-
}
99-
10063
function _handleSuccessfulScan(contents){
10164

10265
$log.debug('Scan returned: "' + contents + '"');

src/js/services/qr-reader.service.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@
5656

5757
qrReader.openSettings(
5858
function onSuccess(result) {
59-
console.log('qrreader openSettings() result:', result);
59+
// Concatenate with + so that it shows up well in Android Logcat
60+
console.log('qrreader openSettings() result: ' + result);
6061

6162
deferred.resolve(result);
6263
},
6364
function onError(error) {
64-
console.error('qrreader openSettings() error:', error);
65+
console.error('qrreader openSettings() error: ' + error);
6566

6667
var errorMessage = errors[error] || error;
6768
var translatedErrorMessage = gettextCatalog.getString(errorMessage);
@@ -76,12 +77,12 @@
7677

7778
qrReader.startReading(
7879
function onSuccess(result) {
79-
console.log('qrreader startReading() result:', result);
80+
console.log('qrreader startReading() result: ' + result);
8081

8182
deferred.resolve(result);
8283
},
8384
function onError(error) {
84-
console.error('qrreader startReading() error:', error);
85+
console.error('qrreader startReading() error: ' + error);
8586

8687
var errorMessage = errors[error] || error;
8788
var translatedErrorMessage = gettextCatalog.getString(errorMessage);
@@ -98,12 +99,12 @@
9899

99100
qrReader.stopReading(
100101
function onSuccess(result) {
101-
console.log('qrReader stopReading() result:', result);
102+
console.log('qrReader stopReading() result: ' + result);
102103

103104
deferred.resolve(result);
104105
},
105106
function onError(error) {
106-
$log.error('qrReader stopReading() error:', error);
107+
$log.error('qrReader stopReading() error: ' + error);
107108

108109
var errorMessage = errors[error] || error;
109110
var translatedErrorMessage = gettextCatalog.getString(errorMessage);
@@ -118,12 +119,12 @@
118119

119120
qrReader.checkPermission(
120121
function onSuccess(result) {
121-
console.log('qrReader checkPermission() result:', result);
122+
console.log('qrReader checkPermission() result: ' + result);
122123

123124
deferred.resolve(result);
124125
},
125126
function onError(error) {
126-
$log.error('qrReader checkPermission() error:', error);
127+
$log.error('qrReader checkPermission() error: ' + error);
127128

128129
var errorMessage = errors[error] || error;
129130
var translatedErrorMessage = gettextCatalog.getString(errorMessage);

0 commit comments

Comments
 (0)