[TIMOB-27741] Android: Allow requestPermissions to succeed if already granted
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-04-10T21:47:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.0.1 |
Components | Android |
Labels | n/a |
Reporter | Gary Mathews |
Assignee | Gary Mathews |
Created | 2020-01-28T17:57:55.000+0000 |
Updated | 2020-06-18T12:16:18.000+0000 |
Description
Allow
requestPermissions
to succeed when when permissions have already been granted. This prevents the need for calling hasPermissions
and simplified code.
*EXAMPLE*
const overlay = Ti.UI.createView({});
const takePicture = Ti.UI.createButton({ title: 'Take Picture' });
takePicture.addEventListener('click', _ => {
Ti.Media.takePicture();
});
overlay.add(takePicture);
// Should not need to call 'hasCameraPermissions', 'requestCameraPermissions' should succeed.
Ti.Media.requestCameraPermissions(e => {
if (e.success) {
Ti.Media.showCamera({
success: e => {
if (e.success) {
console.log('Taken picture successfully!');
} else {
console.error(JSON.stringify(e, null, 2));
}
},
saveToPhotoGallery: true,
autohide: false,
overlay: overlay,
mediaTypes: [ Ti.Media.MEDIA_TYPE_PHOTO ]
});
}
});
master: https://github.com/appcelerator/titanium_mobile/pull/11496
*FR: Pass* *Test Environment* SDK Ver: 8.3.1.GA & 9.0.0.GA & 9.1.0(this PR) OS Ver: 10.14.6 Appc NPM: 5.0.0 Appc CLI: 8.0.0 Daemon Ver: 3.2.0 Ti CLI Ver: 5.2.2 Node Ver: 10.17.0 Java Ver: 1.8.0_162 Devices: ⇨ Google Pixel 3a (Android 10) Emulators: Android 9 (API 28) and Android 10 (API 29) *Notes* * Permissions: WRITE_CALENDAR and WRITE_CONTACTS are required for Ti.Calendar and Ti.Contacts to execute correctly. * I also get these unnecessary warnings in the console as soon as the requests appear on-device (first-time launch):
Apart from these notes, the test case passes successfully with this PR.
9_0_X: https://github.com/appcelerator/titanium_mobile/pull/11563
Reopening so 9_0_X back port can be tested.
FR Passed, Waiting on Jenkins build
merged to master and 9_0_X
Verified on: Mac OS: 10.15.4 SDK: 9.0.1.v20200409100807, 9.1.0.v20200409073825 Appc CLI: 8.0.0 JDK: 11.0.4 Node: 10.17.0 Studio: 6.0.0.202003132109 Device: Nexus4(v5.1.1) device, Pixel3(v10.0) emulator,