From 65700846257c99cee71272ad06876861893337e6 Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Thu, 5 Oct 2023 22:11:53 -0700 Subject: [PATCH 1/4] another approach on detect device magnometer --- .../report-of-fire/compass-page/rof-compass-page.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts index 39e07ef4d1..dd248223e1 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts @@ -39,10 +39,12 @@ initialize (data: any, index: number, reportOfFire: ReportOfFire) { } ngOnInit(): void { - if ( typeof( DeviceMotionEvent ) !== "undefined") { + if ('AbsoluteOrientationSensor' in window && 'ontouchstart' in window) { + // setup real compass thing this.getOrientation(); this.useMyCurrentLocation(); } else { + // skip compass this.skip() } } From 5da99babed053bc6eb483901b6b59956a9984a7a Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Wed, 11 Oct 2023 13:20:47 -0700 Subject: [PATCH 2/4] revert compass availablity check --- .../compass-page/rof-compass-page.component.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts index dd248223e1..0e71d6edb8 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts @@ -39,14 +39,14 @@ initialize (data: any, index: number, reportOfFire: ReportOfFire) { } ngOnInit(): void { - if ('AbsoluteOrientationSensor' in window && 'ontouchstart' in window) { - // setup real compass thing + // if ('AbsoluteOrientationSensor' in window && 'ontouchstart' in window) { + // // setup real compass thing this.getOrientation(); this.useMyCurrentLocation(); - } else { - // skip compass - this.skip() - } + // } else { + // // skip compass + // this.skip() + // } } async getOrientation() { From 10fc586ada4f8761eba8f4d00e6a85ce7e4e3981 Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Wed, 11 Oct 2023 13:46:25 -0700 Subject: [PATCH 3/4] compass supposed to be undefined without motion detector --- .../compass-page/rof-compass-page.component.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts index 0e71d6edb8..027317b975 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts @@ -39,14 +39,8 @@ initialize (data: any, index: number, reportOfFire: ReportOfFire) { } ngOnInit(): void { - // if ('AbsoluteOrientationSensor' in window && 'ontouchstart' in window) { - // // setup real compass thing this.getOrientation(); this.useMyCurrentLocation(); - // } else { - // // skip compass - // this.skip() - // } } async getOrientation() { @@ -86,6 +80,10 @@ async getOrientation() { handler(e, self) { if (self.reportOfFire?.headingDetectionActive){ + if (!e.alpha && !e.webkitCompassHeading){ + this.skip() + } + try { let compassHeading = e.webkitCompassHeading || Math.abs(e.alpha - 360); compassHeading = Math.trunc(compassHeading) From 8670208e6c44550c71876bacb9fedfa1e1c80b11 Mon Sep 17 00:00:00 2001 From: Lucas Li Date: Wed, 11 Oct 2023 17:40:57 -0700 Subject: [PATCH 4/4] more updates for skipping compass --- .../rof-compass-page.component.html | 2 +- .../rof-compass-page.component.ts | 4 ++++ .../rof-complex-question-page.component.ts | 12 +++++++++-- .../app/components/report-of-fire/rofPage.ts | 2 ++ .../rof-simple-question-page.component.ts | 20 +++++++++++++++---- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.html b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.html index b84aae7b37..8a8b504723 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.html +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.html @@ -1,4 +1,4 @@ -
+
{{ title }}
{{ message }}
diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts index 027317b975..866a70ec46 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/compass-page/rof-compass-page.component.ts @@ -81,8 +81,12 @@ async getOrientation() { handler(e, self) { if (self.reportOfFire?.headingDetectionActive){ if (!e.alpha && !e.webkitCompassHeading){ + this.motionSensor = false; this.skip() } + else { + this.motionSensor = true; + } try { let compassHeading = e.webkitCompassHeading || Math.abs(e.alpha - 360); diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/complex-question-page/rof-complex-question-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/complex-question-page/rof-complex-question-page.component.ts index d809efabc5..fe76eb08aa 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/complex-question-page/rof-complex-question-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/complex-question-page/rof-complex-question-page.component.ts @@ -115,8 +115,16 @@ export class RoFComplexQuestionPage extends RoFPage { } previousPage() { - if (this.id === 'distance-page') this.reportOfFire.headingDetectionActive = true; - this.previous(); + if (this.id === 'distance-page'){ + this.reportOfFire.headingDetectionActive = true; + if (this.motionSensor) { + this.previous(); + } else{ + this.reportOfFirePage.selectPage('callback-page',null,false) + } + } else { + this.previous(); + } } } diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/rofPage.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/rofPage.ts index 1fdf78161d..3cdf63483c 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/rofPage.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/rofPage.ts @@ -30,6 +30,7 @@ export class RoFPage { public updateAttribute: string; public showProgress: boolean; public allowMultiSelect: boolean; + public motionSensor: boolean; initialize (data: any, index: number, reportOfFire: ReportOfFire) { this.allowExit = data.allowExit; @@ -48,6 +49,7 @@ export class RoFPage { this.previousId = data.previousId || null; this.nextId = data.nextId || null; this.skipId = data.skipId || null; + this.motionSensor = false; } previous () { diff --git a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/simple-question-page/rof-simple-question-page.component.ts b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/simple-question-page/rof-simple-question-page.component.ts index a4aa747745..125c483c5f 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/simple-question-page/rof-simple-question-page.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/report-of-fire/simple-question-page/rof-simple-question-page.component.ts @@ -87,12 +87,24 @@ export class RoFSimpleQuestionPage extends RoFPage { } nextPage(){ - if (this.id === 'callback-page') this.reportOfFire.headingDetectionActive = true; - this.next(); + if (this.id === 'callback-page') { + this.reportOfFire.headingDetectionActive = true; + this.next(); + } } skipPage(){ - if (this.id === 'callback-page') this.reportOfFire.headingDetectionActive = true; - this.skip(); + if (this.id === 'callback-page') { + this.reportOfFire.headingDetectionActive = true; + if (this.motionSensor) { + this.skip(); + } else { + this.reportOfFirePage.selectPage('distance-page',null,false); + } + } + else{ + this.skip(); + + } } }