Skip to content

Commit

Permalink
Merge pull request #14 from healthonnet/manage-permissions
Browse files Browse the repository at this point in the history
manage permissions android sdk 23+
  • Loading branch information
Adrion authored Aug 13, 2018
2 parents 76fd089 + 377da95 commit 1e5f8e1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 22 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"angular": true,
"inject": true,
"expect": true,
"cordova": true,
"spyOn": true,
"app": true,
"ons": true,
Expand Down
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<plugin name="cordova-android-support-gradle-release" spec="^1.4.4">
<variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<engine name="android" spec="^7.1.1" />
<engine name="ios" spec="^4.5.5" />
</widget>
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@
"cordova-plugin-statusbar": {},
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "27.+"
}
},
"cordova-plugin-android-permissions": {}
}
},
"dependencies": {
"cordova-android": "^7.1.1",
"cordova-android-support-gradle-release": "^1.4.4",
"cordova-ios": "^4.5.5",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-inappbrowser": "^3.0.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-tts": "^0.2.3",
"cordova-plugin-whitelist": "^1.3.3"
}
}
}
54 changes: 40 additions & 14 deletions www/scripts/controllers/colorPickerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ app.controller('colorPickerController', function($scope, $translate) {
console.log('ColorPickerController');
var that = this;

if (typeof cordova !== 'undefined') {
var permissions = cordova.plugins.permissions;
}

this.resizeVideo = function() {
$scope.canvas.height = window.innerHeight - 44;
$scope.canvas.width = window.innerWidth;
Expand Down Expand Up @@ -99,6 +103,24 @@ app.controller('colorPickerController', function($scope, $translate) {
$scope.currentColor = colorNames[1];
};

$scope.requestVideo = function() {
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({
video: {facingMode: {exact: 'environment'}},
})
.then(function(stream) {
successCallback(stream);
})
.catch(function(error) {
errorCallback(error);
});
} else {
// TODO onsenUI clean modal
alert('This browser does not support mediaDevices.\n\nTry Chrome.');
navigatorMain.popPage();
}
};

// Init
$scope.init = function() {
$scope.show = function() {
Expand Down Expand Up @@ -133,20 +155,24 @@ app.controller('colorPickerController', function($scope, $translate) {
navigatorMain.on('prepop', $scope.stopTalking);

// Load media stream
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({
video: { facingMode: { exact: 'environment' }},
})
.then(function(stream) {
successCallback(stream);
})
.catch(function(error) {
errorCallback(error);
});
} else {
// TODO onsenUI clean modal
alert('This browser does not support mediaDevices.\n\nTry Chrome.');
navigatorMain.popPage();
if (permissions) {
permissions.checkPermission(permissions.CAMERA, function(status) {
if (status.hasPermission) {
$scope.requestVideo();
} else {
permissions.requestPermission(permissions.CAMERA, function(status) {
if (status.hasPermission) {
$scope.requestVideo();
} else {
navigatorMain.popPage();
}
}, function() {
navigatorMain.popPage();
});
}
}, function() {
navigatorMain.popPage();
});
}
};
});
8 changes: 4 additions & 4 deletions www/scripts/controllers/simulatorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ app.controller('simulatorController', function($scope, $translate) {
};

$scope.imgLibrary = [
'./plates/plate-1.jpg',
'./plates/plate-2.jpg',
'./plates/plate-3.jpg',
'./plates/plate-4.jpg',
'./assets/images/1.jpg',
'./assets/images/2.jpg',
'./assets/images/3.jpg',
'./assets/images/4.jpg',
];

$scope.nextImg = function() {
Expand Down
3 changes: 3 additions & 0 deletions www/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ video.stereo {
right: 2%;
bottom: 2%;
}
#tts-btn.tts-bottom {
bottom: 50px;
}

#nextImg, #prevImg {
bottom: 50%;
Expand Down
2 changes: 1 addition & 1 deletion www/views/color-picker.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<canvas class="full"></canvas>
<div class="overlay">
<ons-row id="selected-color">{{currentShade | translate}}</ons-row>
<ons-button modifier="material" id="tts-btn"
<ons-button modifier="material" id="tts-btn" class="tts-bottom"
ng-show="TTS"
ng-click="readColor(currentShade)"><i class="fa fa-audio-description"></i></ons-button>
</div>
Expand Down

0 comments on commit 1e5f8e1

Please sign in to comment.