Skip to content

Commit

Permalink
Merge pull request #1450 from RADAR-base/release-2.5.0-alpha
Browse files Browse the repository at this point in the history
Release 2.5.0-alpha
  • Loading branch information
mpgxvii authored Apr 27, 2022
2 parents 914f60e + 4e467b0 commit 45d751e
Show file tree
Hide file tree
Showing 14 changed files with 214 additions and 116 deletions.
3 changes: 2 additions & 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="565" id="org.phidatalab.radar_armt" ios-CFBundleIdentifier="org.phidatalab.radar-armt" ios-CFBundleVersion="1" version="2.4.0-alpha" xmlns:android="http://schemas.android.com/apk/res/android">
<widget android-versionCode="566" id="org.phidatalab.radar_armt" ios-CFBundleIdentifier="org.phidatalab.radar-armt" ios-CFBundleVersion="1" version="2.5.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 All @@ -21,6 +21,7 @@
<allow-intent href="market:*" />
<preference name="AndroidLaunchMode" value="singleTop" />
<preference name="AndroidXEnabled" value="true" />
<preference name="android-targetSdkVersion" value="30" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
Expand Down
5 changes: 3 additions & 2 deletions publishing_script.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ionic cordova build --release android

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/Downloads/radar-armt-release-key.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk alias_name
~/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk ~/Downloads/radar-armt-app-zipaligned.apk

~/Library/Android/sdk/build-tools/28.0.3/apksigner sign -v --out ~/Downloads/radar-armt-app-$1.apk --ks ~/Downloads/radar-armt-release-key.keystore --ks-key-alias alias_name ~/Downloads/radar-armt-app-zipaligned.apk

~/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk ~/Downloads/radar-armt-app-$1.apk
4 changes: 2 additions & 2 deletions src/app/core/services/config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DefaultSettingsWeeklyReport
} from '../../../../assets/data/defaultConfig'
import { StorageKeys } from '../../../shared/enums/storage'
import { setDateTimeToMidnight } from '../../../shared/utilities/time'
import { setDateTimeToMidnightEpoch } from '../../../shared/utilities/time'
import { StorageService } from '../storage/storage.service'

@Injectable()
Expand Down Expand Up @@ -103,7 +103,7 @@ export class AppConfigService {
setReferenceDate(enrolmentDate) {
return this.storage.set(
this.CONFIG_STORE.REFERENCEDATE,
setDateTimeToMidnight(new Date(enrolmentDate)).getTime()
setDateTimeToMidnightEpoch(new Date(enrolmentDate))
)
}

Expand Down
32 changes: 20 additions & 12 deletions src/app/core/services/config/questionnaire.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ export class QuestionnaireService {
// NOTE: Update assessment list from protocol
return Promise.all(
this.util.deepCopy(assessments).map(a => {
const type = this.getAssessmentTypeFromAssessment(a)
return this.pullDefinitionForSingleQuestionnaire(a)
.then(res =>
this.addToAssessments(type, Object.assign(res, { type }))
.then(assessment =>
this.addToAssessments(assessment.type, assessment)
)
.catch(e => {
throw this.logger.error(
'Failed to update ' + type + ' assessments',
'Failed to update ' + a.name + ' assessment',
e
)
})
Expand All @@ -64,6 +63,9 @@ export class QuestionnaireService {
})
const language = this.localization.getLanguage().value
let uri = this.formatQuestionnaireUri(assessment.questionnaire, language)
assessment.type = assessment.type
? assessment.type
: this.getAssessmentTypeFromAssessment(assessment)
return this.githubClient
.getContent(uri)
.catch(e => {
Expand All @@ -87,17 +89,22 @@ export class QuestionnaireService {
const organization = urlParts[1],
repo = urlParts[2],
branch = urlParts[3],
directory = urlParts[4] + '/' + questionnaireName
directory = urlParts.slice(4).join('/')
const suffix = lang.length ? `_${lang}` : ''
const fileName =
questionnaireName + metadata.type + suffix + metadata.format
return urljoin(
GIT_API_URI,
organization,
repo,
'contents',
directory,
fileName
return (
urljoin(
GIT_API_URI,
organization,
repo,
'contents',
directory,
questionnaireName,
fileName
) +
'?ref=' +
branch
)
}

Expand Down Expand Up @@ -159,6 +166,7 @@ export class QuestionnaireService {
}

addToAssessments(type, assessment) {
// NOTE: If an assessment does not exist, it is added, otherwise it is updated
return this.getAssessments(type).then(assessments => {
if (!assessments) assessments = []
const index = assessments.findIndex(a => a.name == assessment.name)
Expand Down
68 changes: 48 additions & 20 deletions src/app/core/services/notifications/message-handler.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'
import { Injectable, OnDestroy } from '@angular/core'
import { FirebaseX } from '@ionic-native/firebase-x/ngx'
import { Subscription } from 'rxjs'

import { UsageEventType } from '../../../shared/enums/events'
import { Assessment, AssessmentType } from '../../../shared/models/assessment'
Expand All @@ -11,37 +12,55 @@ import { ScheduleService } from '../schedule/schedule.service'
import { UsageService } from '../usage/usage.service'

@Injectable()
export class MessageHandlerService {
export class MessageHandlerService implements OnDestroy {
messageListener: Subscription = new Subscription()

constructor(
public firebase: FirebaseX,
public logger: LogService,
public schedule: ScheduleService,
public questionnaire: QuestionnaireService,
public questionnaireService: QuestionnaireService,
public usage: UsageService,
public appConfig: AppConfigService
) {
this.firebase
.onMessageReceived()
.subscribe(data => this.onMessageReceived(new Map(Object.entries(data))))
this.messageListener = this.firebase.onMessageReceived().subscribe(data => {
this.usage.sendGeneralEvent(UsageEventType.FCM_MESSAGE_RECEIVED)
return this.onMessageReceived(new Map(Object.entries(data)))
})
}

ngOnDestroy() {
this.messageListener.unsubscribe()
}

onMessageReceived(data: Map<string, string>) {
const action = data.get('action')
switch (action) {
case MessagingAction.QUESTIONNAIRE_TRIGGER:
this.usage.sendGeneralEvent(
UsageEventType.QUESTIONNAIRE_TRIGGER_MESSAGE_RECEIVED
)
this.logger.log('A questionnaire was triggered!')
const questionnaire = <Assessment>JSON.parse(data.get('questionnaire'))
const metadata = new Map<string, string>(
Object.entries(JSON.parse(data.get('metadata')))
)
return this.triggerQuestionnaire(questionnaire).then(() =>
this.usage.sendQuestionnaireEvent(
UsageEventType.QUESTIONNAIRE_TRIGGERED,
questionnaire.name,
Date.now(),
metadata
return this.triggerQuestionnaire(questionnaire)
.then(() =>
this.usage.sendQuestionnaireEvent(
UsageEventType.QUESTIONNAIRE_TRIGGERED,
questionnaire.name,
Date.now(),
metadata
)
)
.catch(e =>
this.usage.sendGeneralEvent(
UsageEventType.QUESTIONNAIRE_TRIGGER_ERROR,
false,
e.message
)
)
)
default:
this.logger.log('Cannot process message.')
}
Expand All @@ -50,13 +69,22 @@ export class MessageHandlerService {
triggerQuestionnaire(questionnaire: Assessment) {
return Promise.all([
this.appConfig.getReferenceDate(),
this.questionnaire.pullDefinitionForSingleQuestionnaire(questionnaire)
]).then(([refTimestamp, questionnaire]) =>
this.schedule.generateSingleAssessmentTask(
questionnaire,
AssessmentType.SCHEDULED,
refTimestamp
this.questionnaireService.pullDefinitionForSingleQuestionnaire(
questionnaire
)
]).then(([refTimestamp, questionnaireWithDef]) => {
this.usage.sendGeneralEvent(
UsageEventType.QUESTIONNAIRE_TRIGGER_DEFINITION_PULL_SUCCESS
)
)
return this.questionnaireService
.addToAssessments(AssessmentType.SCHEDULED, questionnaireWithDef)
.then(() =>
this.schedule.generateSingleAssessmentTask(
questionnaireWithDef,
AssessmentType.SCHEDULED,
refTimestamp
)
)
})
}
}
Loading

0 comments on commit 45d751e

Please sign in to comment.