Skip to content

Commit

Permalink
Merge pull request #164 from openradiation/release/2.3.3
Browse files Browse the repository at this point in the history
2.3.3
  • Loading branch information
TomDemulierChevret authored Aug 4, 2020
2 parents 9822ce1 + 1436b29 commit b4cee4b
Show file tree
Hide file tree
Showing 36 changed files with 481 additions and 80 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="org.openradiation" version="2.3.2" xmlns="http://www.w3.org/ns/widgets">
<widget android-versionCode="2030301" id="org.openradiation" ios-CFBundleVersion="2.3.3.1" version="2.3.3" xmlns="http://www.w3.org/ns/widgets">
<name>OpenRadiation</name>
<description>Les citoyens mesurent la radioactivité.</description>
<author email="[email protected]" href="https://www.openradiation.org/">OpenRadiation</author>
Expand Down
3 changes: 2 additions & 1 deletion ios-native-translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"NSLocationAlwaysAndWhenInUseUsageDescription": "Phone location is needed to send measurements to the OpenRadiation data base. Please accept the permission.",
"NSLocationAlwaysUsageDescription": "Phone location is needed to send measurements to the OpenRadiation data base. Please accept the permission.",
"NSMotionUsageDescription": "Motion detection is needed to improve phone location accuracy. Please accept the permission.",
"NSBluetoothPeripheralUsageDescription": "Bluetooth activation is mandatory to connect to the sensors. Please accept the permission."
"NSBluetoothPeripheralUsageDescription": "Bluetooth activation is mandatory to connect to the sensors. Please accept the permission.",
"NSBluetoothAlwaysUsageDescription": "Bluetooth activation is mandatory to connect to the sensors. Please accept the permission."
}
}
3 changes: 2 additions & 1 deletion ios-native-translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"NSLocationAlwaysAndWhenInUseUsageDescription": "La position de l'appareil est nécessaire pour l'envoi des mesures à la base OpenRadiation. Merci d'accepter la permission.",
"NSLocationAlwaysUsageDescription": "La position de l'appareil est nécessaire pour l'envoi des mesures à la base OpenRadiation. Merci d'accepter la permission.",
"NSMotionUsageDescription": "La détection du déplacement de l'appareil est nécessaire pour améliorer la précision de la localisation des mesures. Merci d'accepter la permission.",
"NSBluetoothPeripheralUsageDescription": "L'activation du bluetooth est nécessaire pour se connecter aux capteurs. Merci d'accepter la permission."
"NSBluetoothPeripheralUsageDescription": "L'activation du bluetooth est nécessaire pour se connecter aux capteurs. Merci d'accepter la permission.",
"NSBluetoothAlwaysUsageDescription": "L'activation du bluetooth est nécessaire pour se connecter aux capteurs. Merci d'accepter la permission."
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "open-radiation",
"version": "2.3.2",
"version": "2.3.3",
"author": "OpenRadiation",
"homepage": "https://www.openradiation.org/",
"description": "Les citoyens mesurent la radioactivité.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export abstract class AbstractMeasureReportPage<T extends AbstractMeasure> exten
reportScan = true;
positionChangeSpeedOverLimit = false;
positionChangeAltitudeOverLimit = false;
fromHistory = false;

measurementEnvironmentOptions: SelectIconOption[];

Expand Down Expand Up @@ -106,6 +107,7 @@ export abstract class AbstractMeasureReportPage<T extends AbstractMeasure> exten
init() {
this.activatedRoute.queryParams.pipe(take(1)).subscribe(queryParams => {
if (queryParams.goBackHistory) {
this.fromHistory = true;
this.subscriptions.push(
this.actions$.pipe(ofActionSuccessful(StopMeasureSeries, CancelMeasure, StopMeasure)).subscribe(() => {
this.measureReportForm = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
import { Actions, ofActionSuccessful, Store } from '@ngxs/store';
import { AlertService } from '../../../../services/alert.service';
import { NavigationService } from '../../../../services/navigation.service';
import { MeasureEnvironment, MeasureSeries, MeasureSeriesParamsSelected } from '../../../../states/measures/measure';
import {
CancelMeasure,
StartMeasureSeriesReport,
StopMeasureSeries,
StopMeasureSeriesReport
Expand Down Expand Up @@ -35,7 +38,9 @@ export class MeasureSeriesReportPage extends AbstractMeasureReportPage<MeasureSe
protected navigationService: NavigationService,
protected actions$: Actions,
protected platform: Platform,
private formBuilder: FormBuilder
private formBuilder: FormBuilder,
private alertService: AlertService,
private translateService: TranslateService
) {
super(router, store, activatedRoute, navigationService, actions$, platform);
}
Expand Down Expand Up @@ -99,6 +104,27 @@ export class MeasureSeriesReportPage extends AbstractMeasureReportPage<MeasureSe
this.store.dispatch(new StopMeasureSeriesReport());
}

cancelMeasure() {
if (this.fromHistory) {
super.cancelMeasure();
} else {
this.alertService.show({
header: this.translateService.instant('GENERAL.CANCEL'),
message: this.translateService.instant('MEASURE_SERIES.REPORT.CANCEL_CONFIRMATION'),
backdropDismiss: false,
buttons: [
{
text: this.translateService.instant('GENERAL.NO')
},
{
text: this.translateService.instant('GENERAL.YES'),
handler: () => this.store.dispatch(new CancelMeasure())
}
]
});
}
}

protected initMeasurementEnvironmentOptions(measureSeries: MeasureSeries) {
this.positionChangeSpeedOverLimit = measureSeries.measures.some(measure =>
AbstractMeasureReportPage.hasPositionChanged(measure)
Expand Down
26 changes: 23 additions & 3 deletions src/app/pages/measure/measure-scan/measure-scan.page.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { _ } from '@biesbjerg/ngx-translate-extract/dist/utils/utils';
import { TranslateService } from '@ngx-translate/core';
import { Actions, ofActionSuccessful, Select, Store } from '@ngxs/store';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { AutoUnsubscribePage } from '../../../components/auto-unsubscribe/auto-unsubscribe.page';
import { AlertService } from '../../../services/alert.service';
import { NavigationService } from '../../../services/navigation.service';
import { AbstractDevice } from '../../../states/devices/abstract-device';
import { DevicesState } from '../../../states/devices/devices.state';
import {
HitsAccuracy,
Measure,
MeasureEnvironment,
MeasureSeries,
MeasureSeriesParamsSelected,
PositionAccuracyThreshold
Expand Down Expand Up @@ -78,7 +79,9 @@ export class MeasureScanPage extends AutoUnsubscribePage {
protected router: Router,
private store: Store,
private navigationService: NavigationService,
private actions$: Actions
private actions$: Actions,
private alertService: AlertService,
private translateService: TranslateService
) {
super(router);
}
Expand Down Expand Up @@ -130,6 +133,23 @@ export class MeasureScanPage extends AutoUnsubscribePage {
}

cancelMeasure() {
this.store.dispatch(new CancelMeasure());
if (this.isMeasureSeries) {
this.alertService.show({
header: this.translateService.instant('GENERAL.CANCEL'),
message: this.translateService.instant('MEASURE_SERIES.REPORT.CANCEL_CONFIRMATION'),
backdropDismiss: false,
buttons: [
{
text: this.translateService.instant('GENERAL.NO')
},
{
text: this.translateService.instant('GENERAL.YES'),
handler: () => this.store.dispatch(new CancelMeasure())
}
]
});
} else {
this.store.dispatch(new CancelMeasure());
}
}
}
4 changes: 2 additions & 2 deletions src/app/pages/tabs/settings/devices/devices.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<span class="state connected">
{{'GENERAL.CONNECTED' | translate}}
<div class="battery-icon" *ngIf="connectedDevice.batteryLevel !== undefined">
<ion-icon name="battery-full" mode="ios"></ion-icon>{{connectedDevice.batteryLevel}}%
<ion-icon name="battery-full" mode="ios"></ion-icon>{{connectedDevice.batteryLevel | number : '1.2-2'}}%
</div>
</span>
<ion-button
Expand All @@ -43,7 +43,7 @@
<span class="state" *ngIf="connectingDevice?.sensorUUID !== availableDevice.sensorUUID">
{{'GENERAL.AVAILABLE' | translate}}
<div class="battery-icon" *ngIf="availableDevice.batteryLevel">
<ion-icon name="battery-full" mode="ios"></ion-icon>{{availableDevice.batteryLevel}}%
<ion-icon name="battery-full" mode="ios"></ion-icon>{{availableDevice.batteryLevel | number : '1.2-2'}}%
</div>
</span>
<ion-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<ion-content>
<div class="notice" [innerHTML]="'MEASURES.PLANE_MODE_NOTICE.PART1' | translate | sanitizeHtml"></div>
<!-- TODO Voir avec le client pour le texte définitf-->
<div class="notice" [innerHTML]="'MEASURES.PLANE_MODE_NOTICE.PART2' | translate | sanitizeHtml"></div>
<div class="notice" [innerHTML]="'MEASURES.PLANE_MODE_NOTICE.PART3' | translate | sanitizeHtml"></div>

Expand Down
32 changes: 24 additions & 8 deletions src/app/services/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class StorageService {
private paramsKey = 'measures.params';
private measuresKey = 'measures.measures';
private recentTagsKey = 'measures.recentTags';
private currentSeriesKey = 'measures.currentSeries';

constructor(
private storage: Storage,
Expand All @@ -47,20 +48,24 @@ export class StorageService {
return knownDevices ? this.store.dispatch(new InitDevices(knownDevices)) : of(null);
})
),
forkJoin(this.getMeasures(), this.getParams(), this.getRecentTags()).pipe(
concatMap(([measures, params, recentTags]) => {
return measures && params && recentTags
? this.store.dispatch(new InitMeasures(measures, params, recentTags))
: of(null);
})
),
this.getUser().pipe(
concatMap(user => {
return user ? this.store.dispatch(new InitUser(user)) : of(null);
})
)
)
.pipe(concatMap(() => this.store.dispatch(new SetLanguage())))
.pipe(
concatMap(() => this.store.dispatch(new SetLanguage())),
concatMap(() =>
forkJoin(this.getMeasures(), this.getParams(), this.getRecentTags(), this.getCurrentSeries()).pipe(
concatMap(([measures, params, recentTags, currentSeries]) => {
return measures && params && recentTags
? this.store.dispatch(new InitMeasures(measures, params, recentTags, currentSeries || undefined))
: of(null);
})
)
)
)
.subscribe(() => {
this.store.select(({ user }: { user: UserStateModel }) => user).subscribe(user => this.saveUser(user));
this.store
Expand All @@ -75,6 +80,9 @@ export class StorageService {
this.store
.select(({ measures }: { measures: MeasuresStateModel }) => measures.recentTags)
.subscribe(recentTags => this.saveRecentTags(recentTags));
this.store
.select(({ measures }: { measures: MeasuresStateModel }) => measures.currentSeries)
.subscribe(currentSeries => this.saveCurrentSeries(currentSeries));
this.platform.ready().then(() => {
if (this.platform.is('cordova')) {
this.statusBar.overlaysWebView(true);
Expand Down Expand Up @@ -107,6 +115,10 @@ export class StorageService {
return this.getFromDB(this.recentTagsKey);
}

getCurrentSeries(): Observable<MeasureSeries | null> {
return this.getFromDB(this.currentSeriesKey);
}

private getFromDB(key: string): any {
return from(
this.storage.get(key).then(rawValue => {
Expand Down Expand Up @@ -144,6 +156,10 @@ export class StorageService {
this.storage.set(this.recentTagsKey, this.formatToDB(recentTags));
}

saveCurrentSeries(currentSeries?: MeasureSeries) {
this.storage.set(this.currentSeriesKey, currentSeries ? this.formatToDB(currentSeries) : null);
}

private parseFromDB(jsonString: string): any {
return JSON.parse(jsonString);
}
Expand Down
8 changes: 7 additions & 1 deletion src/app/states/devices/abstract-device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export abstract class AbstractDeviceService<T extends AbstractDevice> {
groundLevel: CalibrationFunctions;
};

constructor(protected store: Store) {}
protected constructor(protected store: Store) {}

abstract buildDevice(rawDevice?: RawDevice): T | null;

Expand Down Expand Up @@ -73,4 +73,10 @@ export abstract class AbstractDeviceService<T extends AbstractDevice> {
abstract disconnectDevice(device: T): Observable<any>;

protected abstract decodeDataPackage(buffer: ArrayBuffer | ArrayBuffer[]): Step | null;

protected arrayBufferToHex(buffer: ArrayBuffer): string {
return Array.from(new Uint8Array(buffer))
.map(n => n.toString(16).padStart(2, '0'))
.join('');
}
}
4 changes: 3 additions & 1 deletion src/app/states/devices/abstract-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export enum DeviceType {
AtomTag = 'AtomTag',
SafeCast = 'bGeigieBLE',
PocketGeiger = 'Pocket Geiger Type 6',
Rium = 'RiumGm'
Rium = 'RiumGm',
Rium2USB = 'RiumGM BLE -u',
Rium2BLE = 'RiumGM BLE -b'
}

// The key set the threshold and the value is the calibration function
Expand Down
2 changes: 1 addition & 1 deletion src/app/states/devices/ble/abstract-ble-device.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export abstract class AbstractBLEDeviceService<T extends AbstractBLEDevice> exte
protected abstract service: string;
protected abstract receiveCharacteristic: string;

constructor(protected store: Store, protected ble: BLE) {
protected constructor(protected store: Store, protected ble: BLE) {
super(store);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/states/devices/ble/abstract-ble-device.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AbstractDevice, RawDevice } from '../abstract-device';

export abstract class AbstractBLEDevice extends AbstractDevice {
constructor(rawDevice: RawBLEDevice) {
protected constructor(rawDevice: RawBLEDevice) {
super();
this.sensorUUID = rawDevice.id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/states/devices/ble/ble-devices.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AbstractBLEDevice, RawBLEDevice } from './abstract-ble-device';
providedIn: 'root'
})
export class BLEDevicesService {
private devices = [DeviceType.OGKit, DeviceType.AtomTag, DeviceType.SafeCast];
private devices = [DeviceType.OGKit, DeviceType.AtomTag, DeviceType.SafeCast, DeviceType.Rium2BLE];

private currentAlert?: any;
private scanDuration = 3;
Expand Down
7 changes: 5 additions & 2 deletions src/app/states/devices/ble/device-og-kit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Step } from '../../measures/measure';
import { ApparatusSensorType } from '../abstract-device';
import { RawBLEDevice } from './abstract-ble-device';
import { AbstractBLEDeviceService } from './abstract-ble-device.service';
import { DeviceOGKit } from './device-og-kit';
import { DeviceOGKit, DeviceOgKitType } from './device-og-kit';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -148,7 +148,10 @@ export class DeviceOGKitService extends AbstractBLEDeviceService<DeviceOGKit> {
}

buildDevice(rawBLEDevice: RawBLEDevice): DeviceOGKit | null {
if (rawBLEDevice.name.toUpperCase().startsWith('OG') || rawBLEDevice.name.toUpperCase().includes('OPENG')) {
if (
rawBLEDevice.name.toUpperCase().startsWith(DeviceOgKitType.OG) ||
rawBLEDevice.name.toUpperCase().includes(DeviceOgKitType.OPENG)
) {
return new DeviceOGKit(rawBLEDevice);
}
return null;
Expand Down
5 changes: 5 additions & 0 deletions src/app/states/devices/ble/device-og-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { DeviceType } from '../abstract-device';
import { DeviceParams, DeviceParamsModel, DeviceParamType } from '../device-params';
import { AbstractBLEDevice, RawBLEDevice } from './abstract-ble-device';

export enum DeviceOgKitType {
OG = 'OG',
OPENG = 'OPENG'
}

export class DeviceOGKit extends AbstractBLEDevice {
readonly deviceType = DeviceType.OGKit;
hitsPeriod = 1000;
Expand Down
Loading

0 comments on commit b4cee4b

Please sign in to comment.