Skip to content

Commit

Permalink
Merge pull request #1366 from RADAR-base/release-2.2.0-alpha
Browse files Browse the repository at this point in the history
Release 2.2.0-alpha
  • Loading branch information
mpgxvii authored Oct 13, 2021
2 parents 74091b3 + e18f374 commit 230af8a
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 78 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 android-versionCode="561" id="org.phidatalab.radar_armt" ios-CFBundleIdentifier="org.phidatalab.radar-armt" ios-CFBundleVersion="1" version="2.0.3-alpha" xmlns:android="http://schemas.android.com/apk/res/android">
<widget android-versionCode="563" id="org.phidatalab.radar_armt" ios-CFBundleIdentifier="org.phidatalab.radar-armt" ios-CFBundleVersion="1" version="2.2.0-alpha" xmlns:android="http://schemas.android.com/apk/res/android">
<name>RADAR Questionnaire</name>
<description>An application that collects active data for research.</description>
<author email="[email protected]" href="http://radar-base.org/">RADAR-Base</author>
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"@ionic-native/android-permissions": "^5.26.0",
"@ionic-native/app-version": "^5.28.0",
"@ionic-native/background-mode": "^5.32.0",
"@ionic-native/barcode-scanner": "^5.27.0",
"@ionic-native/barcode-scanner": "^5.33.1",
"@ionic-native/core": "^5.32.0",
"@ionic-native/device": "^5.26.0",
"@ionic-native/dialogs": "^5.26.0",
"@ionic-native/file": "^5.26.0",
"@ionic-native/file": "^5.32.1",
"@ionic-native/firebase": "^5.31.1",
"@ionic-native/firebase-x": "^5.29.0",
"@ionic-native/globalization": "^5.26.0",
Expand All @@ -79,11 +79,11 @@
"cordova-custom-config": "^5.1.0",
"cordova-lib": "^9.0.1",
"cordova-media-with-compression": "^2.1.2",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-android-permissions": "^1.1.2",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-app-version": "^0.1.12",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "^4.0.3",
"cordova-plugin-camera": "^5.0.2",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-enable-multidex": "git+https://github.com/adriano-di-giovanni/cordova-plugin-enable-multidex.git",
Expand All @@ -92,7 +92,7 @@
"cordova-plugin-insomnia": "^4.3.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-local-notification": "^0.9.0-beta.3",
"cordova-plugin-splashscreen": "^5.0.4",
"cordova-plugin-splashscreen": "^6.0.0",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-vibration": "^3.1.1",
"cordova-plugin-whitelist": "^1.3.4",
Expand Down Expand Up @@ -175,7 +175,7 @@
"prettier": "^2.1.2",
"reflect-metadata": "^0.1.13",
"requirejs": "^2.3.6",
"rxjs-compat": "^6.5.5",
"rxjs-compat": "^6.6.7",
"rxjs-tslint": "0.1.5",
"stylefmt": "^6.0.3",
"stylelint": "^13.6.1",
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/services/config/questionnaire.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class QuestionnaireService {

updateAssessment(type: AssessmentType, assessment: Assessment) {
return this.getAssessments(type).then(assessments => {
if (!assessments) assessments = []
const index = assessments.findIndex(a => a.name == assessment.name)
if (index != -1) {
assessments[index] = this.util.deepCopy(assessment)
Expand All @@ -159,6 +160,7 @@ export class QuestionnaireService {

addToAssessments(type, assessment) {
return this.getAssessments(type).then(assessments => {
if (!assessments) assessments = []
const index = assessments.findIndex(a => a.name == assessment.name)
if (index > -1) assessments[index] = assessment
else assessments.push(assessment)
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/services/config/remote-config.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ describe('FirebaseRemoteConfig', () => {
TestBed.configureTestingModule({
providers: [
FirebaseRemoteConfigService,
Platform,
{ provide: StorageService, useClass: StorageServiceMock },
{ provide: LogService, useClass: LogServiceMock },
{ provide: Platform, useClass: PlatformMock },
{ provide: FirebaseX, useClass: FirebaseMock }
]
})
)

beforeEach(() => {
service = TestBed.get(FirebaseRemoteConfigService)
const platform = TestBed.get(Platform)
spyOn(platform, 'ready').and.callFake(() => Promise.resolve(''))
})

it('should create', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/services/config/remote-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class FirebaseRemoteConfig implements RemoteConfig {
@Injectable()
export class FirebaseRemoteConfigService extends RemoteConfigService {
private readonly configSubject: BehaviorSubject<RemoteConfig>
private FETCH_TIMEOUT_SECONDS = 20

constructor(
private firebase: FirebaseX,
Expand All @@ -114,7 +115,9 @@ export class FirebaseRemoteConfigService extends RemoteConfigService {
) {
super(storage)
this.configSubject = new BehaviorSubject(new EmptyRemoteConfig())
this.firebase.setConfigSettings({ fetchTimeout: 10 })
this.platform.ready().then(() => {
FirebasePlugin.setConfigSettings(this.FETCH_TIMEOUT_SECONDS, null)
})
}

forceFetch(): Promise<RemoteConfig> {
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/services/token/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export class TokenService {
}

isValid(): Promise<boolean> {
return this.storage.get(StorageKeys.OAUTH_TOKENS).then(tokens => {
return !this.jwtHelper.isTokenExpired(tokens.refresh_token)
})
return this.storage
.get(StorageKeys.OAUTH_TOKENS)
.then(tokens => !this.jwtHelper.isTokenExpired(tokens.refresh_token))
}

reset() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
{{ settings.enrolmentDate | amCalendar }}
</span>
</ion-item>
<ion-item no-lines>
{{ 'SETTINGS_DAYS_SINCE_ENROL' | translate }}
<span item-right class="info-value">
{{ daysSinceEnrolment }}
</span>
</ion-item>
</ion-item-group>

<ion-item-group>
Expand Down
17 changes: 14 additions & 3 deletions src/app/pages/settings/containers/settings-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class SettingsPageComponent {
notificationSettings = DefaultSettingsNotifications
weeklyReport = DefaultSettingsWeeklyReport
showLoading = false
daysSinceEnrolment = 0

RESET_OPTION_MESSAGES = {
[ResetOption.ENROLMENT]: LocKeys.SETTINGS_RESET_ALERT_ENROLMENT_DESC,
Expand Down Expand Up @@ -56,9 +57,19 @@ export class SettingsPageComponent {
}

loadSettings() {
Object.entries(this.settingsService.getSettings()).map(([k, v]) =>
v.then(val => (this.settings[k] = val))
)
Promise.all(
Object.entries(this.settingsService.getSettings()).map(([k, v]) =>
v.then(val => (this.settings[k] = val))
)
).then(() => {
this.daysSinceEnrolment = this.getDaysSinceEnrolment()
})
}

getDaysSinceEnrolment() {
const now = this.localization.moment(Date.now())
const enrolment = this.localization.moment(this.settings.enrolmentDate)
return now.diff(enrolment, 'days')
}

reloadConfig() {
Expand Down
14 changes: 13 additions & 1 deletion src/app/pages/splash/services/splash.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { UsageService } from '../../../core/services/usage/usage.service'

@Injectable()
export class SplashService {
INVALID_USER_ERROR = 'was not found in the database'
constructor(
private config: ConfigService,
private token: TokenService,
Expand All @@ -18,7 +19,18 @@ export class SplashService {
) {}

evalEnrolment() {
return this.token.isValid().catch(() => false)
return this.token
.refresh()
.catch(e => {
if (e.status == 401) {
if (
e.error.error_description &&
e.error.error_description.includes(this.INVALID_USER_ERROR)
)
return this.token.setTokens(null)
} else return
})
.then(() => this.token.isValid().catch(() => false))
}

isEnrolled() {
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/enums/localisations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class LocKeys {
static SETTINGS_PROJECTNAME = new LocKeys('SETTINGS_PROJECTNAME')
static SETTINGS_USER_INFO = new LocKeys('SETTINGS_USER_INFO')
static SETTINGS_ENROL_DATE = new LocKeys('SETTINGS_ENROL_DATE')
static SETTINGS_DAYS_SINCE_ENROL = new LocKeys('SETTINGS_DAYS_SINCE_ENROL')
static SETTINGS_LANGUAGE = new LocKeys('SETTINGS_LANGUAGE')
static SETTINGS_LANGUAGE_ALERT = new LocKeys('SETTINGS_LANGUAGE_ALERT')
static SETTINGS_NOTIFICATIONS = new LocKeys('SETTINGS_NOTIFICATIONS')
Expand Down
2 changes: 1 addition & 1 deletion src/assets/data/defaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Localisations } from './localisations'
export const DefaultPlatformInstance = 'RADAR-CNS'

// *Default app version
export const DefaultAppVersion = '2.0.3-alpha'
export const DefaultAppVersion = '2.1.0'

// *Default Android package name
export const DefaultPackageName = 'org.phidatalab.radar_armt'
Expand Down
10 changes: 10 additions & 0 deletions src/assets/data/localisations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ export const Localisations = {
pl: 'Data rejestracji',
hb: 'תאריך הרשמה'
},
SETTINGS_DAYS_SINCE_ENROL: {
da: 'Dage siden registrering',
de: 'Tage seit der Registrierung',
en: 'Days Since Enrolment',
es: 'Días desde el registro',
it: 'Giorni dalla registrazione',
nl: 'Dagen sinds registratie',
pl: 'Dni od rejestracji',
hb: 'ימים מרגע ההרשמה'
},
SETTINGS_LANGUAGE: {
da: 'Sprog',
de: 'Sprache',
Expand Down
Loading

0 comments on commit 230af8a

Please sign in to comment.