fixed MM-139 MM-134 MM-123 MM-47

mekawy-issues
umasoodch 6 years ago
parent 6db87b6930
commit e7d476fc2e

@ -13,22 +13,25 @@ import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
providedIn: 'root'
})
export class DevicePermissionsService {
constructor(
public diagnostic: Diagnostic,
public cs: CommonService,
public nativeStorage: NativeStorage,
public ts: TranslatorService,
public nativeSettings: OpenNativeSettings) { }
public static GRANTED = 'GRANTED';
public static DENIED_ALWAYS = 'DENIED_ALWAYS';
public static CAMERA_MIC = 'camera_mic_permission';
public static LOCATION = 'location_permission';
public static APP_SETTINGS = 'application_details';
public onSucess;
public onerror;
constructor(
public diagnostic: Diagnostic,
public cs: CommonService,
public nativeStorage: NativeStorage,
public ts: TranslatorService,
public nativeSettings: OpenNativeSettings) { }
public requestCameraPermission(): Observable<boolean> {
return Observable.create(observer => {
@ -37,16 +40,17 @@ export class DevicePermissionsService {
}
private requestCamera(observer: any) {
//console.log("Camera permission????????")
this.hasCameraPermission().then((isAvailable) => {
if (isAvailable) {
// this.requestMicophonePermission(observer);
this.observerDone(observer, true);
} else {
this.diagnostic.requestCameraAuthorization(true).then((value) => {
// tslint:disable-next-line: triple-equals
if (value == DevicePermissionsService.GRANTED) {
//this.requestMicophonePermission(observer);
// this.requestMicophonePermission(observer);
this.observerDone(observer, true);
// tslint:disable-next-line: triple-equals
} else if (value == DevicePermissionsService.DENIED_ALWAYS) {
// this.setAlwaysDenied(DevicePermissionsService.CAMERA_MIC, true);
this.observerDone(observer, false);
@ -77,8 +81,10 @@ export class DevicePermissionsService {
this.observerDone(observer, true);
} else {
this.diagnostic.requestMicrophoneAuthorization().then((value) => {
// tslint:disable-next-line: triple-equals
if (value == DevicePermissionsService.GRANTED) {
this.observerDone(observer, true);
// tslint:disable-next-line: triple-equals
} else if (value == DevicePermissionsService.DENIED_ALWAYS) {
this.setAlwaysDenied(DevicePermissionsService.CAMERA_MIC, true);
this.observerDone(observer, false);
@ -112,8 +118,8 @@ export class DevicePermissionsService {
}
public async hasCameraAndMicPermissions(): Promise<boolean> {
let camera = await this.hasCameraPermission();
//let mic = await this.diagnostic.isMicrophoneAuthorized();
const camera = await this.hasCameraPermission();
// let mic = await this.diagnostic.isMicrophoneAuthorized();
if (camera) {
// await this.setAlwaysDenied(DevicePermissionsService.CAMERA_MIC, false);
return true;
@ -128,7 +134,7 @@ export class DevicePermissionsService {
resolve(true);
}, this.ts.trPK('general', 'accept'),
() => {
resolve(false)
resolve(false);
}, this.ts.trPK('general', 'not-now'), this.ts.trPK('general', 'confirm'), message
);
});
@ -140,15 +146,12 @@ export class DevicePermissionsService {
resolve(true);
}, this.ts.trPK('general', 'settings'),
() => {
resolve(false)
resolve(false);
}, this.ts.trPK('general', 'not-now'), this.ts.trPK('general', 'confirm'), message
);
});
}
public static APP_SETTINGS = 'application_details';
public async openApplicationSettings() {
// return new Promise((resolver, reject) => {
// this.nativeSettings.open(DevicePermissionsService.APP_SETTINGS).then(result => {
@ -208,13 +211,13 @@ export class DevicePermissionsService {
if (await this.hasCameraAndMicPermissions()) {
return true;
} else {
let message = this.ts.trPK('permissions', 'camera');
const message = this.ts.trPK('permissions', 'camera');
// if (await this.isPermissionAlwaysDenied(DevicePermissionsService.CAMERA_MIC)) {
// if (await this.permissionSettingsDialog(message)) {
// return this.openCameraAndMicSettings();
// }
// } else {
if (await this.permissionRequestDialog(message)) {
if (await this.permissionRequestDialog(message)) {
return this.requestCameraPermission().toPromise();
}
// }
@ -227,17 +230,16 @@ export class DevicePermissionsService {
public async requestLocationAutherization() {
if ( await this.isLocationEnabled()) {
if (await this.hasLocationPermissions()) {
return true;
} else {
let message = this.ts.trPK('permissions', 'location');
const message = this.ts.trPK('permissions', 'location');
// if (await this.isPermissionAlwaysDenied(DevicePermissionsService.LOCATION)) {
// if (await this.permissionSettingsDialog(message)) {
// return this.openLocationSettings();
// }
// } else {
if (await this.permissionRequestDialog(message)) {
if (await this.permissionRequestDialog(message)) {
return this.requestLocationPermission();
}
// }
@ -249,7 +251,7 @@ export class DevicePermissionsService {
}
private async isLocationEnabled() {
let isAvailable = await this.diagnostic.isLocationEnabled();
const isAvailable = await this.diagnostic.isLocationEnabled();
if (!isAvailable) {
this.cs.presentAlert(this.ts.trPK('permissions', 'enable-location'), () => {
});
@ -258,7 +260,7 @@ export class DevicePermissionsService {
}
public async hasLocationPermissions(): Promise<boolean> {
let location = await this.diagnostic.isLocationAvailable();
const location = await this.diagnostic.isLocationAvailable();
if (location) {
await this.setAlwaysDenied(DevicePermissionsService.LOCATION, false);
return true;
@ -280,12 +282,14 @@ export class DevicePermissionsService {
private async requestLocationPermission() {
let hasPermissions = await this.hasLocationPermissions();
const hasPermissions = await this.hasLocationPermissions();
if (!hasPermissions) {
let value = await this.diagnostic.requestLocationAuthorization();
const value = await this.diagnostic.requestLocationAuthorization();
// tslint:disable-next-line: triple-equals
if (value == DevicePermissionsService.GRANTED) {
return true;
// tslint:disable-next-line: triple-equals
} else if (value == DevicePermissionsService.DENIED_ALWAYS) {
this.setAlwaysDenied(DevicePermissionsService.LOCATION, true);
}

@ -85,7 +85,7 @@
</circle-progress>
</div>
<div class="fixed-shift-timer" *ngIf="isCheckedIn === false">
<fab-button (trigger)="attendance()"></fab-button>
<fab-button (trigger)="getDeviceLocation()"></fab-button>
<page-trailer [small] = "true"></page-trailer>
</div>
</ion-content>

@ -234,7 +234,7 @@ export class HomePage implements OnInit {
this.attendance();
})
.catch(error => {
console.log('Error getting location', error);
this.common.presentAlert(this.ts.trPK('home', 'position-error'));
});
} else {
return false;
@ -268,18 +268,6 @@ export class HomePage implements OnInit {
// });
// }
ionViewDidEnter() {
this.geolocation
.getCurrentPosition()
.then(resp => {
this.lat = resp.coords.latitude;
this.longt = resp.coords.longitude;
})
.catch(error => {
console.log('Error getting location', error);
});
}
private openMenu() {
this.menu.toggle();
}
@ -316,7 +304,6 @@ export class HomePage implements OnInit {
this.showOpenMissingSwipes();
this.showAttendanceTracking();
this.getAccrualBalance();
// this.common.stopLoading();
}
public Vacation_Rule() {
@ -472,9 +459,11 @@ export class HomePage implements OnInit {
this.barcodeScanner
.scan()
.then(barcodeData => {
this.scannedResult = barcodeData;
this.deviceID = this.device.uuid;
this.swipeAttendance();
if (!barcodeData.cancelled) {
this.scannedResult = barcodeData;
this.deviceID = this.device.uuid;
this.swipeAttendance();
}
})
.catch(err => {
console.log('Error', err);

@ -868,6 +868,10 @@
}
},
"home": {
"position-error": {
"en": "Error getting your location. Please try again!",
"ar": "Error getting your location. Please try again!"
},
"dashboard": {
"en": "My Dashboard",
"ar": "الرئيسية"

Loading…
Cancel
Save