tigeraware android: an improved mobile survey and...

72
TigerAware Android: An Improved Mobile Survey and Notification System A Project Presented to The Faculty of the Graduate School At the University of Missouri In Partial Fulfillment Of the Requirements for the Degree Master of Science Implemented and Defended by: Weiliang Xia Prof. Yi Shang, Advisor May 2019

Upload: others

Post on 25-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

TigerAwareAndroid:AnImprovedMobileSurveyandNotificationSystem

AProject

Presentedto

TheFacultyoftheGraduateSchool

AttheUniversityofMissouri

InPartialFulfillment

OftheRequirementsfortheDegree

MasterofScience

ImplementedandDefendedby:

WeiliangXiaProf.YiShang,Advisor

May2019

Page 2: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

i

TABLEOFCONTENTS

ListofFigures.........................................................................................................................iii

ListofTables...........................................................................................................................v

Acknowledgements................................................................................................................vi

Abstract...............................................................................................................................viii

1.Introduction........................................................................................................................1

1.1ProblemDescription.............................................................................................................1

1.2ProposedSolution................................................................................................................4

2.RelatedWorks.....................................................................................................................8

2.1Firebaseandstoragestructure.............................................................................................8

2.2ResearchStack.....................................................................................................................12

2.2.1ResearchStackBackbone..........................................................................................................13

2.2.2ResearchStackSkin...................................................................................................................17

2.3ResearchKit.........................................................................................................................19

2.3.1ResearchKitActivetasks...........................................................................................................19

2.4RelationshipsbetweenResearchStackandResearchKit....................................................25

3.TigerAwareAndroidDesign...............................................................................................27

3.1TigerAwareSystemarchitecture........................................................................................27

3.2TigerAwareAndroidarchitecture.......................................................................................28

3.2.1Flowcharts................................................................................................................................28

3.2.2Authentication..........................................................................................................................29

3.2.3ParseSurvey.............................................................................................................................31

3.2.4LaunchSurvey...........................................................................................................................35

3.2.5Uploadresults...........................................................................................................................36

Page 3: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

ii

3.3Sitemaps............................................................................................................................37

3.4Functionsandalgorithms...................................................................................................42

3.4.1Questiontypes..........................................................................................................................42

3.4.2Notifications.............................................................................................................................48

3.4.3Suspension................................................................................................................................53

4.Systemperformanceevaluation........................................................................................57

4.1Differentframeworkforquestiontypes............................................................................58

4.2Notificationsperformanceevaluation................................................................................59

4.3Suspensionperformanceevaluation..................................................................................59

5.ConclusionandFutureWork.............................................................................................61

6.References........................................................................................................................63

Page 4: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

iii

LISTOFFIGURES

Figure1MainframeworksaboutTigerAwareAndroid..................................................................8

Figure2Progressionofsurveystepsstoredindatabase...............................................................9

Figure3ThestructureofsurveysinFirebase...............................................................................10

Figure4ThestructureofanswersinFirebase.............................................................................11

Figure5ThestructureofusersinFirebase..................................................................................12

Figure6Thebackbone1.1.1API..................................................................................................14

Figure7Theprogrammingstructureoftasks..............................................................................15

Figure8Task,steps,resultsstructure..........................................................................................15

Figure9Asampleinstructionstep...............................................................................................16

Figure10Theprogrammingstructureofstep.............................................................................16

Figure11ThestructureofonActivityResult.................................................................................17

Figure12ThestructureofResearchStackSkin............................................................................18

Figure13ThestructureofResearchKit(citedfromhttp://researchkit.org)................................19

Figure14Agaitandbalancetask.................................................................................................24

Figure15RelationshipsbetweenResearchStackandResearchKit..............................................26

Figure16TigerAwaresystemarchitectureandcomponents.......................................................27

Figure17TigerAwareAndroidarchitectureflowcharts...............................................................28

Figure18Firebase........................................................................................................................29

Figure19ProcessaboutsignInWithEmailAndPassword..............................................................30

Figure20ProcessaboutsignInWithEmailAndPassword..............................................................30

Figure21Firebaseauthentication................................................................................................31

Figure22Usersinfirebase...........................................................................................................31

Figure23Blueprintsinfirebase....................................................................................................31

Page 5: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

iv

Figure24ProgrammingofgetinstanceofFirebaseDatabase......................................................32

Figure25Parsesurveysection1..................................................................................................32

Figure26Parsesurveysection2..................................................................................................33

Figure27ERDforthestoragestructure.......................................................................................34

Figure28Flowchartsforthestoragestructure............................................................................34

Figure29Flowchartsforlaunchingsurvey...................................................................................35

Figure30OnActivityResult.........................................................................................................36

Figurer31Flowchartsforuploadingresults................................................................................37

Figure32Firstactivity..................................................................................................................37

Figure33Registrationpage..........................................................................................................38

Figure34Mainactivity.................................................................................................................39

Figure35Surveypage..................................................................................................................40

Figure36Suspendwindowpage..................................................................................................41

Figure37Sitemap........................................................................................................................41

Page 6: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

v

LISTOFTABLES

Table1ThelistoffunctionsplannedtobeimplementedinTigerAwareAndroid.........................4

Table2ThelistoffunctionsandalgorithmsplannedinTigerAwareAndroid...............................7

Table3ActivetasksinResearchKit(citedfromhttp://researchkit.org)......................................20

Table4ResearchStackSupportedAnwersformat........................................................................43

Table5ThelistoffunctionsandalgorithmsaboutSystemperformance....................................57

Table6TheperformancecomparisonalongtheframeworkchangesofTigerAware.................58

Table7Theperformancecomparisonaboutdifferentalgorithmsfornotifications...................59

Table8Theperformancecomparisonaboutdifferentalgorithmsforsuspension......................60

Table9Thelistofmycontributions.............................................................................................62

Page 7: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

vi

ACKNOWLEDGEMENTS

Firstly,Iwouldthankmyparentsforthesupportofmystudy,andtheextendmysinceregratitude

tomysupervisorYiShang, forhiskindguidance,notonly to thisproject,butalso thoughmywhole

overseastudy,andmylife.Twoyearsgoesreallyfast,Iwanttosay,asthefirsttimeItalkedtoprofessor

Shang,“talkingwithyouforonemomentismuchbetterthanreadingbooksfortenyears.”

Second,Iwanttosaythankyoutomygirlfriend,JiachenJi,shemusthavenoawarenessabout

mygraduationpaper.SoIwanttosayhere,“Iwillreturn.Iwillfindyou.Loveyou.Marryyou.Andlive

withoutshame.”

I want to thank Nickolas Wergeles, Dr. Tim Trull, Luke Guerdan, Connor Rowland, William

Morrison,HandriantoYohanesPatrikandeveryoneImissedinthelab.Icannotforgetthehappiness

whenIshowLukearoundtheChina,IcannotforgetthesummerIworkedtogetherwithPatrik,Peng,

Yang,JunlinandZhaoyuandourstudentsinthesummercamp.Icannotforgetthepatientanddetailed

explanationfromWillandConnorandtheirpowerfulhelp,andthankNickforleadingmetothe“Hello

world” in JAVA and thank Tim, Denis, and Hannah for the great opportunity and happiness for

collaboration.

IwanttothankSiyangLiu,inthefirstsemesterforthisproject,itishimwhoguidedmetoandroid

developmentandhelpedmealot.Icannotforgetthehappinesswhenwesolvedthefirstbugtogether

rightbeforethemeetinganditwasanullpointererror.

IwanttothankJoshua,Lewis,inthesecondsemesterforthisproject,weworkedeverySaturday

onthefirst languagelearningapplicationandwenttokindsofrestaurantsforcelebration,andmeet

Page 8: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

vii

professorRoxanaformoredetailaboutthatapplicationanditdidhelpusbuildagreatfoundationabout

thebasicframeworkforTigerAware.

IwanttothankMohanLi,ShiqiWang,andRunnanDonginthethirdsemesterforthisproject,

westaytogetheratFridayandIworkwithMohanonSaturdayforsomuchfunandjoy.

Finally,Iwanttothankeveryoneinthelabforeverythingyoubringtome.

Page 9: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

viii

ABSTRACT

Fromhealthcaretocommunityassessment,mobilephoneshavebecomeanimportanttoolin

manyresearchareasbycollectingavarietyofdata,suchasdailysteps,walkingdistanceandGPSdata.

TigerAware is a new cross platform systemdeveloped for conductingmobile surveys and collecting

sensordataviasmartphones.TigerAware iOS implementation isbasedonResearchKit fromApple,a

softwareframeworkformedicalresearchstudyapps,whereasitsAndroidimplementationisbasedon

ResearchStack,aResearchKit-likeSDKandUXframeworkforappsonAndroid.ResearchStackisdesigned

tohelpdevelopersandresearcherswithexistingappsoniOSmoreeasilyadaptthoseappsforAndroid.

ThegoalofthisprojectistoadaptTigerAwareiOSappstoAndroidwiththesamefunctionality,

andpilotsomenewfeaturesonAndroid.BasedonResearchStackBackBoneandSkin,severalcustom

questiontypes,suchasanimagequestiontype,havebeenimplementedtosupportavarietyofquestion

typesandactivetasksforvariousresearchstudies.Aconditionalrandomselectionalgorithmhasbeen

developedtohandlesurveynotificationswithmoreflexibility,suchasschedulingrandomnotification

withbreaks.Anewalgorithmhasbeendevelopedtohandlesuspensionwindowsindifferentsituations,

suchassuspendingovermidnight.Finally,anewdatedetectionalgorithmhasbeendevelopedtohandle

thestarttimeandendtimecorrectly.

Page 10: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

1

1.INTRODUCTION

First,letusbrieflyintroduceTigerAwarebeforewemoveontoTigerAwareAndroid.Inthisbig

dataera,scientistsaretryingtogatherasmanydataastheycan,especiallyinsightfulnewdatatodraw

more clear conclusions. The old way is, handing out paper surveys, asking participants to answer

questionsinacertaintimeandcertainplace.However,thiswayishardforfollowingupsurveys,while

requiringa lotofbudget, though it is good foraone timequestionnaire. Thus,over thepast years,

researchersstarttorelymoreandmoreonsmartphones,websitesandthesekindofnewwaytogather

noveldata.Smartphonesarecheapandconvenientsourceforpeopletocommunicate,forinformation

exchangingandgathering.Moreover,thiskindofmoderndeviceusuallyequippedwithawiderangeof

sensortogetthe informationoutsidestheworld,suchasmotoractivities, fitness,cognition,speech,

hearing,handdexterity,andvision.ResearcherscanuseAccelerometer

Gyroscopesensortodetectthemotionofparticipantwhiletheyarefinishingaspecifictask,they

canalsouseGPSdatatojudgetheuserbehavior,filterouttheunreliableinformationandsoon.Ina

word,researcherscanusesmartphonesurveystoapproachdifferentkindsofspecificresearchquestions.

Thus, survey based on smartphone applications become more and more popular, From health to

community assessment, from science to engineering, they have become a cornerstone in many research

areas.

1.1ProblemDescription

Smartphone applications can collectavarietyofnewdata,suchasdailysteps,walkingdistance

andGPSdatacomparedwitholdpaper surveys.However, smartphone-basedstudiesaredifficult to

develop and deploy, because they usually require on-sites teamswith the researchers tomeet the

Page 11: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

2

specificstudypurpose,whichmaycauseamajorportionofresearchbudgets.Currentplatformsfordata

collection,areeither limiting researchersby justprovidinga fixedplatformand lack the flexibilityof

develop, modify and integrate with the new data collected or requiring on-sites teams with the

researchers[2][3].Forexample,ahealthrelatedresearchteammayneedasurveyaboutbloodalcohol

level,usingexternalsensorsuchasBluetoothbreathalyzer.Upondataarrival,researchersmayalsoneed

tovisualizeandinteractwithdataindifferentways.Thesoftwaredevelopmenttoaccommodatethese

needsistimeconsumingandexpensive,takingalargeportionofresearchbudget.Tosolvethisproblem,

aninnovativesystemcalledTigerAwareisdeveloped.TigerAwareisacrossplatformsystemwhichallows

researcherstocreateavarietyofsurveys,questiontypesbythemselves,collectingawiderangeofdata

includingbutnotlimitedtoquestionresponses,ondevicesensordata,suchasGPSdata,andexternal

sensordata,suchasbloodalcohollevelfromaBluetoothbreathalyzer.

However,themainSDKResearchKitusedinTigerAwarecanonlysupportIOSSystem,thusan

Androidbasedonapplicationisneeded.

EvenusingasimilarSDKforAndroid,therearestillfewchallengestowardsachievingthesame

functionalityasIOSsystemorreachingsomespecificresearchstudygoals.Thefollowingisthelistabout

theproblemswehavetosolvecomparingtothecurrentmostsimilarsurveyframework,ResearchStack

basedonthreeaspects:questiontypes,notificationsandsuspension.

Page 12: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

3

(1)Questiontypes:

Staticvsdynamic:asforbasicquestions,therearetwomainproblems,oneproblemis,most

question types supported in Research Stack are static, but in TigerAware Android, we need more

dynamicquestions,whichmeansresearchers

Can change the question settings to achieve their study use. For example, amultiple choice

questioninResearchStackisaquestionusercanselectoneormorethanonechoices,butinTigerAware

Android,thisquestionmaybeastrictsinglechoicequestionoramoreflexiblemultiplechoicequestion

basedonhowresearchersetthisquestionfortheirstudyuse.

Basicquestionsvscustomquestions:

ThereareonlyfewlimitedquestiontypesinResearchStackwhicharenotenoughforsomestudy

use.Thensomenewquestiontypesareneeded.However,therearefewexamplesorexplanationsabout

howtocreateanewquestiontypebasedonResearchStackframework.

(2)Notifications:

TheoriginResearchStackBackboneframelacktheabilitytoreceiveandcreatenotificationson

thedevice.However, in order to tell participants to take surveyson time, each surveyneeds a few

notifications scheduled before it. They can be random notifications and schedule notifications. To

achievethegoalofresearchstudy,randomnotificationneedtobescheduledduringaperiodoftime

and scheduled notification need to be scheduled at a certain time.However, both of them are not

supportinResearchStackBackbone.

Moreover,evenforthecurrentTigerAwareandroidsystem,whichhastheabilityofschedule

notifications, forthepurposeofsomespecificstudyuse,morefunctionsneedtobeadded.Random

Page 13: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

4

notifications need to be scheduled with fifteen minutes break, scheduled notifications need to be

scheduledbasedonnumberofdaysinsteadofschedulebasedontheendday.

(3)Suspension:

Accordingtonotificationsystem,anadvancedsuspensionsystemisneededtoblocknotifications

forparticipantswhentheydonotwanttobebothered.Duringthesuspendwindow,thereshouldnot

beanynotificationsshowingtotheparticipantsevenrandomnotificationsandschedulednotifications

arescheduledatthattime.

Moreover,even for thecurrentTigerAwareandroid system,whichhas theabilityof suspend

notificationsbasedontwotimestampsduringoneday, it still lack theabilityofschedulingonetime

suspensioninsteadofschedulingitoverandoveragain.

Table1ThelistoffunctionsplannedtobeimplementedinTigerAwareAndroid

Functions Requirements

Questions Dynamicandcustomquestions

Notifications Schedulenotificationswith15minutesbreak

Suspension Scheduleonetimesuspension

1.2ProposedSolution

Likewejustmentionedabove,themainSDKResearchKitusedinTigerAwarecanonlysupport

IOSSystem,thusanAndroidbasedonapplicationisneeded.TheoverallgoalofthisAndroidapplication

Page 14: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

5

istomakeiteasiertoadapttheexistingfunctionsoniOSintoandroidwiththesamefunctionality,and

developthenewfeaturestogetherwithTigerAwareIOStohelpsomestudyspecifics. Inmoredetail,

TigerAwareAndroid isusingasimilar frameworkcalledResearchStack(whileTigerAware IOS isusing

ResearchKit)toaccommodatestheseneedswementionedabove.Toreachthesamefunctionalityas

TigerAware IOS, we implement ResearchStack Backbone, and to achieve the same structure as

TigerAwareIOS,weimplementResearchStackSkininandroidapplication.Asforsomefunctionswhich

arenotsupportedbyResearchStackbutResearchKit,whichisstillcommon,becausethesetwoSDKs’

functionsarenotonetoone,weimplementit intoTigerAwareAndroidbydefiningandaddingextra

modules intoResearchStack. InChapter threeand four,wewill talkabouthowwe implement these

functionsinmoredetail.

TigerAwareAndroidcanalsobeeasily incorporated into theexistingTigerAwareSystemwith

minordesignandchangesbyusingthesimilarSDKwementionedabove.Furthermore,theplatformis

highlyconfigurable,allowresearcherstodesign,developanddeploytheirownquestiontypesusingthe

existingmodules.

ByusingthesimilarSDKResearchStack,mostquestionscanbeimplementeddirectlywithminor

changes and the following is the table towards the solutions in three aspects: question types,

notificationsandsuspensions.

(1)questiontypes:

a) ThefirstproblemisTigerAwareneedsdynamicsurveydesignandhandlingsystem,tosolve

this problem, TigerAware Android uses two ways: one way is to rewrite the question

framework to make the question itself dynamic by adding more parameters. These

Page 15: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

6

parametersallcomefromTigerAwareDashboard,afterresearchcreatetheirownsurveys,

theseparameterswillgoalongwithquestionsintoFirebasethenbereceivedbyTigerAware

Android.Forexample,atextslidequestionwhichcanonlyshowtext,afterwechangedthe

framework,anoptioncalled“showimage”canbeaddedintothisquestion.Ifatextslide

questioncontains“showimage”option,itmayshowimagesgoingalongwiththissurvey.In

thisway,wemakethequestionitselfdynamic.

Anotherwayistokeepthequestionstaticbutcreateanewdynamicquestionwhichcan

selectstaticquestionsdynamically.Forexample,inResearchStack,therearetwomultiple

choice questions. One is single answer question, another is single or multiple answer

question. Then in order to dynamically make multiple questions based on study use.

TigerAwareAndroidcreateanewmultiplequestiontypewhichcontainaparametercalled

“allowmultiple”.Ifallowmultipleissettobetrue,TigerAwareAndroidwillchoosesingleor

multipleanswerquestion,otherwiseitwillswitchtosingleanswerquestion.

b) Thesecondproblemissomequestionsresearcherneedfortheirstudyusearenotsupported

byResearchStack.Tosolvethisproblem,TigerAwareAndroidtakestwoactionsbasedon

different situations. If a new question type is similar to an existing question type, then

modifyingthatexistingquestiontypeisbetter,ifanewquestiontypeistotallydifferentwith

those existing question types supported by Research Stack, then creating a new custom

questiontypeisbetteralthoughitwillcostmoretimeandworkthanjustmodifying.

(2)notifications:

Toensureatleastfifteenminsbreakbetweennotifications,therearetwoalgorithmsplannedto

beimplementedforthissituation:thelateststarttimealgorithmandtheconditionalrandomselection

Page 16: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

7

algorithm.Bothofthemcansolvetheproblemofschedulingrandomnotificationswithatleastfifteen

minutes break problem andwewill talk about them later in the chapter three, System design and

implementation.

(3)suspension:

Toachievetheabilityofschedulingonetimesuspensioninsteadofschedulingitoverandover

again.Weneedtoimportasmartalgorithmtocalculatethestartdateandenddatebasedonthestart

timeandendtimeandcomparethesuspenddateandtimetogetherwithcurrentdateandtimeinstead

of only compare timewithout date to tell if the time is in suspendwindow or not. There are two

algorithmsplannedtosolvethisproblembydetectingdateandblindingdateandtimewhilecomparing.

Oneisaddingonedatetowardssuspendwindow,anotherisanIntelligentdatedetectionalgorithmfor

bothstarttimeandendtime.Wewilltalkabouttheminmoredetailinsuspensionsection.

Table2ThelistoffunctionsandalgorithmsplannedinTigerAwareAndroid

Functions Requirements algorithms

Questions Dynamicandcustomquestions Noalgorithmsneeded, frameworkchangeonly

Notifications Schedule notifications with 15minutesbreak

Thelateststarttimealgorithm

The conditional random selectionalgorithm

Suspension Scheduleonetimesuspension A Intelligent date detectionalgorithm for both start time andendtime

Adding suspend window datebasedontheenddate

Page 17: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

8

2.RELATEDWORKS

TigeraAware Android is designed to work together with the TigerAware Dashboard and

TigerAware IOS. TigerAware Dashboard is connected with Firebase and TigerAware IOS is using

ResearchKit.Moreover, forTigerAware system,all dataare saved in Firebase, Firebase is the center

databaseinTigerAware.

Inthischapter,wearegoingtointroducethesethreemainframeworksweusedinTigerAware

Android:Firebase,ResearchStackandResearchKit.

Figure1MainframeworksaboutTigerAwareAndroid

2.1Firebaseandstoragestructure

Firebaseisarealtimedatabasesupportedbygoogle.Infirebase,dataarestoredintable,orin

moredetail,dataarestoredinJSONfile.Justlikeasocket,usercaninputakeyandgettheassociated

valuewiththatkey.Inthenewversionoffirebase,thereisadatabasecalledFirestore,inFirestore,data

arenotnecessarystored intablebutpageofdata.TherearetworeasonswechooseFirebase:First,

Page 18: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

9

FirebaseisaNoSQLdatabaseanditcangreatlyreducethedeveloptime.Theprocessofsettingupanew

Firebasedatabasemayeventakeonly fewminutes.Second,Firebasecansupporta largenumberof

diverseplatforms,includingmobileandtheweb.Thefollowingfeaturewilltellhowsurveysarestored

inFirebase,theirstructureandthenamingformat.

Figure2Progressionofsurveystepsstoredindatabase

Eachsurveyismadeofasetofquestionsorstepswhosegrammararedefinedbyextendingthe

JSONformatformally.Eachstepcouldbeapointofinputlikemultiplechoicequestion,oratextslide,

which describes a section of a survey. Each stepmay include its own configurationmetadata, title,

conditionalandsteptype,butallstepsmustincludeitsownuniqueid.Andoverall,allthesestepsare

leftgenerictoenabledifferentinterpretationsofquestions.Forexample,ayesornomaybecombined

withanimagetypequestionandifuserchooseyes,itmayjumptoamultiplechoicequestionaboutthat

Page 19: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

10

image.Inotherword,researcherscanaddtheirnewquestiontypesbyslightlyformattingtheexisting

questionsteps,andthefollowingfeatureshowshowthesurveysareactuallystoredinfirebase.

Figure3ThestructureofsurveysinFirebase

Thesecondmaincomponentofthedatabaseistheanswersdatamadebyuser.Alluserresponse

dataarestoredinaplacecalleddata,whichisatthesamelevelwithblueprints.Undereachsurvey,

thereareanswersmadebyeachuser.Andeachanswercontainsfourmainparts:whichplatformthe

answers generated from, (particularly in TigerAware Android,We will only upload android with its

versionnumber),theactuallyanswers,timestampanduserID.

Page 20: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

11

Figure4ThestructureofanswersinFirebase

Thethirdpartistheuserinformation,includingtheemail,theusernameandthesurveysthey

aretaking.

Page 21: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

12

Figure5ThestructureofusersinFirebase

Inaword,TigerAwareAndroidwilluseFirebase,pullingsurveys fromFirebaseanduploading

answersintoFirebase,andalloperationsarebasedonthestoragestructurewementionedabove.

2.2ResearchStack

ResearchStack isanSDK(SoftwareDevelopmentKit)andUX(UserExperience)frameworkfor

buildingresearchstudyappsonAndroidtohelpscientistsandresearchersbuildtheirresearchsurveys

andcollectavarietyofdatatheyneedinordertomeettherequirementofthemostscientificresearch.[4]

ResearchersanddeveloperscanuseResearchStacktobuildbasicAndroidapplicationswithout

havingalargeextensionofAndroidProgrammingskills,whichmeansmostoftheobjectsarepre-defined

Page 22: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

13

withtheirownfieldsandmethodsinResearchStack.Soresearchersanddeveloperscaneasilybuilda

simpleapplicationbydoingminorextensionsorchangesandUsingJSONandHTMLfiles.Inaddition,In

TigerAware Android, we use Firebase to store the JSON files and import data from Firebase. This

application can share information with users by showing the onboarding process (study

overview/consent/registration)andcollectdatafromusersbyshowingamainactivityscreenwithpre-

scheduledtaskssuchassurveyswithkindsofquestions.

TherearetwomainmodulesforbuildingaResearchStackapplication:BackboneandSkin.

Backbone:ThecoreResearchStackAPI.Thisincludestasks,steps,results,consent,file/database

storageandencryption.

Skin:Above thestructureofBackbone,Skin isbuilt,which isbasedonBackbonebutbeyond

Backbone.ComparedtoBackbone,Skinrequirelessandroidknowledgetobuildaresearchapp.Skinpull

everycomponentofbackbonetogetherandbuildtheapp inamoreefficientway.Moreover,Skin is

morecompatiblewithResearchKit'sAppCoreengineandskinisdesignedtoworkwithminorchangesto

anexistingResearchKit™iOSapp'sresources.

2.2.1ResearchStackBackbone

ResearchStack Backbone is a API (Application Programming Interface) supported by

ResearchStack,BackboneisthecorebuildingblocksofResearchStackwhichincludesthesurveyengine,

visualconsentflowandactivetasks[5].

Page 23: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

14

Figure6Thebackbone1.1.1API

(1)Tasks:

Atask inResearchStackcontainsasetofstepstopresenttousers.Everythingwementioned

aboveisinResearchStackisrepresentedasataskssuchassurveys,consentflowsandactivestasks.By

usingResearchStackBackbone,researcherscanbuildsurveysformodalpresentationonandroiddevice,

buildconsentpagetoinformusersthedetailofthestudyandobtainthesignaturefromtheparticipants

andbuild active tasks page to lead a activity under semi-controlled conditions, gathering data from

Androidphone.

ResearchStackusestheclassOrderedTaskclasstotrackalistoforderedstepsfordisplayingthe

questionsorcontentstousers.InResearchKit,ithasaaccordingclasscalledORKOrderedTask.

Page 24: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

15

Figure7Theprogrammingstructureoftasks

Figure8Task,steps,resultsstructure

(2)Steps:

Astepisasinglecomponentoftasktocompleteacertainfunction.Differenttypesofstepsgive

differentkindsoffunctions.

Forexample,aninstructionstepcaninformtheuserthegoalofthisstudyorthispage.Aquestion

stepcanaskusersomequestionsandgatherdatafromtheuser.Moreover,ifwewanttoshowuseran

audio_instruction_page,togiveusermoreinformationaboutourstudy,hereishowitworks.Similarly,

ifwewanttoaddaquestion,tolettheuserchoosea,b,candd,wecouldSimilarlyaddaQuestionStep

whichincludeaspecificquestionandaddthatsteptothelist.

Page 25: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

16

Figure9Asampleinstructionstep

Figure10Theprogrammingstructureofstep

(3)Results

InResearchStack,thereisnodatabaseassociatedwithit.Thus,allresultsarestoredinaclass.

calledTaskResult.

AnTaskResultobjectisaresultthatcontainsallthestepresultsgeneratedfromtask.Afterone

runof a task or ordered task (that is, classTask or classOrderedTask), itwill generate its own

TaskResult.Inotherwords,ataskresultistypicallygeneratedbytheframeworkasthetaskproceeds.

Whenthetaskcompletes,itmaybeappropriatetosavethedatabyourselves,uploadthemtoserveror

database,ortoimmediatelyperformanalysisonthedata.

Page 26: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

17

Figure11ThestructureofonActivityResult

2.2.2ResearchStackSkin

Skin:Above thestructureofBackbone,Skin isbuilt,which isbasedonBackbonebutbeyond

Backbone.ComparedtoBackbone,Skinrequirelessandroidknowledgetobuildaresearchapp.Skinpull

everycomponentofbackbonetogetherandbuildtheapp inamoreefficientway.Moreover,Skin is

morecompatiblewithResearchKit'sAppCoreengineandskinisdesignedtoworkwithminorchangesto

anexistingResearchKit™iOSapp'sresources.[6]

Page 27: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

18

Figure12ThestructureofResearchStackSkin

Aswecanseeinthisstructuregraph,SkinusesSmartSurveyTaskwhileBackboneusesTask,and

SmartSurveyTask is extended from Task. And Skin uses the same type StepModel with different

constraints while Backbone uses different Step. Here is how it works. First, TaskModel get all the

informationsfromlocaldatabaseorserverandgeneratedifferentStepModelbasedonwhatkindof

questionstheyare.Inotherwords,differentStepModelsaregeneratedwithdifferentConstrainModels.

Inthisway,surveyisgenerated.Whilethesurveyisinprocessing,differentviewsareswitchedbetween

eachother.WhiletheSmartSurveyTaskisinprocessing,allthedataaresavedinTaskResults.Whenthe

taskcompletes,itmaybeappropriatetosavethedatabyresearchersthemselves,uploaddatatoserver

ordatabase,ortoimmediatelyperformanalysisonthedata.

Page 28: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

19

2.3ResearchKit

AccordingtoAppleResearchKit,ResearchKitisanopensourceframeworkreleasedbyApple.It

allowsresearchersanddeveloperstodesignpowerfulapplicationsinmedicinearea.UsingResearchKit,

researcherscanbuildcustomblockstocreatethevisualconsentflows,surveysandreal-timedynamic

activetasks.Moreover,ResearchKitcanworkperfectlywithHealthKit,whichtheycansharedatawith

eachother[7].Inthatway,researcherscanvisitmorerelatedresearchdata,suchasdailysteps,calorie

useandheartrate.

Figure13ThestructureofResearchKit(citedfromhttp://researchkit.org)

2.3.1ResearchKitActivetasks

ResearchKit also has some active tasks, guiding users to do someperformancewhich are

undersemi-controlledconditions,anddataarecollectedbytheiPhone.Herearethemainseven

Page 29: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

20

categories of active tasks based onwhat kind of sensor they use [8]. The seven categories are:

motoractivities,fitness,cognition,speech,hearing,handdexterity,andvision.

Table3ActivetasksinResearchKit(citedfromhttp://researchkit.org)

CATEGORY TASK SENSOR DATACOLLECTED

Motor

Activities

RangeofMotion Accelerometer

Gyroscope

Devicemotion

GaitandBalance Accelerometer

Gyroscope

Devicemotion

Pedometer

TappingSpeed Multi-Touch

display

Accelerometer

(optional)

Touchactivity

Fitness Fitness GPS

Gyroscope

Devicemotion

Pedometer

Location

Heartrate

Page 30: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

21

TimedWalk GPS

Gyroscope

Devicemotion

Pedometer

Location

Cognition SpatialMemory Multi-Touch

display

Accelerometer

(optional)

Touchactivity

Correctanswer

Actualsequences

StroopTest Multi-Touch

display

Actualcolor

Actualtext

Userselection

Completiontime

TrailMakingTest Multi-Touch

display

Completiontime

Touchactivity

Paced Serial

Addition Test

(PSAT)

Multi-Touch

display

Additionresultsfromuser

Page 31: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

22

TowerofHanoi Multi-Touch

display

Everymovetakenbytheuser

ReactionTime Accelerometer

Gyroscope

Devicemotion

Speech Sustained

Phonation

Microphone Uncompressedaudio

Speech

Recognition

Microphone Rawaudiorecording

TranscriptionintheformofanSFTranscription

object.

Editedtranscript(ifany,bytheuser)

Speech-in-Noise Microphone Rawaudiorecording

TranscriptionintheformofanSFTranscription

object

Editedtranscript(ifany,bytheuser).Thiscan

be used to calculate the Speech Reception

Threshold(SRT)forauser.

Page 32: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

23

Hearing EnvironmentSPL Microphone EnvironmentsoundpressurelevelindBA

ToneAudiometry AirPods

Headphones

Minimumamplitude for theuser to recognize

thesound

dBHL Tone

Audiometry

AirPods

Headphones

HearingthresholdindBHLscale

Userresponsetimestamps

Hand

Dexterity

9-HolePeg Multi-Touch

display

Completiontime

Movedistance

Vision AmslerGrid Multi-Touch

display

Touchactivity

Eyeside

Areasofdistortionsasannotatedbytheuser

For example, a gait and balance task, can ask user to perform awalking task, user follow a

movementinstructionandtheirmovementdataiscollectedbytheaccelerometerandgyroscopesensor

fromtheirdevice.Thefollowingshowshowgaitandbalancetaskisperformedinmoredetail.

Page 33: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

24

Figure14Agaitandbalancetask

AndHerearethethreemaindatawegatheredfromthephonesensor:

(1)Accelerometerdata:

Most smartphone device has three accelerometers, one along each accelerometer axis. The

direction of the first accelerometer is along the sort side of the phone, the direction of the second

Page 34: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

25

accelerometerisalongthelongsideofthephone,whilethethirdaccelerometerisverticaltotheplane

formedbythefirsttwoaccelerometers’axes.

All thesedata are represented in threedimensions andmeasured in theunit of “g”,while g

represents the force of gravity. If a device is dropping verticallywithout any force fromoutside, its

accelerometerdatashouldbe[0,0,0],whileadeviceisputhorizontallyonaflattable,itsaccelerometer

datashouldbecloseto[0,0,-1].Developerscandefinethespeedofcollectingrateandthenumberof

samplestocollectaccelerometerdatatoachieveaninstructiontask.

(2)Gyroscopedata:

Similarlytoaccelerometer,adevicehasGyroscopesensorstomeasuretherotationofthedevice.

The rotation vector represents the orientation of the device as a combination of an angle and an axis, in

other words, a device has rotated through an angle θ around an axis (x, y, or z).

(3)Stepdata:

AdevicecanuseStepdetectorsensortocounthowmanystepsuserwalkedeachtimethestep

sensoristriggered.Particularlyinandroiddevice,therearetwostepmotionsensors:stepdetectorand

stepcounter.Bothcancountstepswhilestepcounterhasmorelatency(upto10seconds)butmore

accuracy.

2.4RelationshipsbetweenResearchStackandResearchKit

FirstResearchKitisbuiltbyapple,anopensourceframeworkfordeveloperstomakeresearch

apps.Accordingly,ResearchStackisbuilt,theoverallgoalofresearchStackistomakeiteasiertoadapt

theexistingappsoniOSintoandroidwiththesamefunctionality.ThusResearchStackBackboneisbuilt.

However,thoughBackbonesharealmostthesamefunctionalitywithResearchKit,theyhavedifferent

Page 35: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

26

structures.ThenSkinisbuilt,basedonBackbonebutaboveBackbone,wrappedBackboneintosome

classes,thatsharethesamestructurewithResearchKit.

Inaword,thoughthecorrespondenceoffeaturesbetweenthetwoSDKsisn’tone-to-one,they

willofferenoughstandardfunctionality(Backbone)andcommonframeworks(Skin).InTigerAware,both

backboneandskinareusedinordertoreachthesamefunctionalitywithIOSResearchKit.

Figure15RelationshipsbetweenResearchStackandResearchKit

Page 36: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

27

3.TIGERAWAREANDROIDDESIGN

TigerAware Android is part of the whole TigerAware System, playing a significant role in

TigerAware.Inthischapter,wearegoingtointroducehowthewholeSystemworks,whatisthedata

flowinsideTigerAwareandgoinmoredetailaboutTigerAwareAndroiddesign.

3.1TigerAwareSystemarchitecture

TigerAwareconsistsoffourmainpart:TigerAwareDashBoard,TigerAwaredatabase(Firebase),

TigerAwareIOSandTigerAwareAndroid.

Figure16TigerAwaresystemarchitectureandcomponents

First, researchers can create a survey on TigerAware DashBoard, schedule surveys for

participants.ThenthesurveyswillbesentintoFirebase,whichisarealtimedatabase,aswellasthe

Page 37: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

28

notificationsandremindersaboutthatsurvey.ThenTigerAwareAndroidwillpullthatdatafromFirebase,

whenever it changes, TigerAware Android will update its data accordingly. Moreover, TigerAware

Androidwillsavethatinformationandschedulesurveysandnotificationsonitsdevice.Whenitbecomes

therighttimeforparticipantstotakethesurvey,surveyswillpopup.Afteruserstakingthatsurvey,

TigerAwareAndroidwillsendtheresultsbackintoFirebaseforlateranalysisandresearchstudy.

3.2TigerAwareAndroidarchitecture

3.2.1Flowcharts

Figure17TigerAwareAndroidarchitectureflowcharts

Page 38: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

29

Thefirstpagetheuserwillencounterwillbealoginpage,tochecktheuserhasanaccountor

not,iftheuserdoesnothaveanaccount,TigerAwarewillaskthemtocreateone.Iftheuserhasone,

TigerAwarewilluseFirebaseforauthentication.Afterauthentication,userwillbepromptedtothemain

surveypage.Inthispage,TigerAwarewillshowusersalistofactivepublicandprivatesurveys.Once

user click one of the surveys, kinds of questionswill pop up. After user finishing taking the survey,

TigerAwareAndroidwillsendtheresultsbackintoFirebaseforlateranalysisandresearchstudy.

3.2.2Authentication

Sothefirststepcomestoauseristheregistrationandtheauthenticationstep.InTigerAware,

we use Firebase Authentication because Firebase supports an easy back end service for user

authentication.Thatservicecanalsosupportauthenticationbypasscode,phonenumber,andGoogle,

Facebook,Twitter,andsoon.ParticularlyinTigerAwareAndroid,weuseauthenticationwithFirebase

usingPassword-BasedAccounts.

Figure18Firebase

Page 39: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

30

Worktheory:

FirebaseAPIprovidesaclasscalledFirebaseAuth,everytimeuserswanttocreateanaccountor

signin,TigerAwareAndroidwillgettheirusernameandpasswordasstring,andbyusingauthentication

functionsfromthatAPI,Firebasewillcheckorcreateaaccountforusers.

Figure19ProcessaboutsignInWithEmailAndPassword

Figure20ProcessaboutsignInWithEmailAndPassword

Inthefiguresabove,mAuthisanobjectfromclassFirebaseAuth.Onceuserssuccessfullycreate

theiraccounts,theiruserinformationwillbestoredinFirebaseunderauthenticationsection.Research

canalsomanuallyadd,deleteandsearchusersbytheiremailaddressoruserUID.

Page 40: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

31

Figure21Firebaseauthentication

3.2.3ParseSurvey

Afteruserssuccessfully login in,thesecondpagecomestotheirminds isthemainsurvey list

page.Wetalkedabouttheflowchartsabove,basicallyTigerAwarewillsendsurveystousersandusers

willsendtheiranswersbacktoTigerAware,buthowdoesithappeninmoredetail?Aswementioned

before,allsurveysarestoredinFirebaseinthefollowingformat.

Figure22UsersinfirebaseFigure23Blueprintsinfirebase

Figure22UsersinfirebaseFigure23Blueprintsinfirebase

Page 41: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

32

Developer can input a key and get the associated value with that key by some certain

programminglanguage.InTigerAware,weuseJAVAandbyusingTigerAwareAPI,wecansimplygetthe

associatedvaluewiththekeyweinput,thefollowingistheprogrammingtheoryinmoredetail.

Figure24ProgrammingofgetinstanceofFirebaseDatabase

First,byusingFirebaseDatabase,researcherscangetusers,UID,aswellasthesurveystheyare

taking.Everyuserissupposedtohaveitsownuniqueuseridandeverysurveyisalsodesignedtohave

itsownuniquesurveyid.

ThenaftergettingtheuniquesurveyID,whichusersarecurrentlytakinginusersection,thenext

stepistogoblueprintssectionandgetthesurveysbasedonthesurveyidwegot.

Finally,wecanparsethatsurveyaswellasupdatetheUIorthesurveylist.Everytimeifthereis

anewsurveycomingtotheuser,ortherearenewdataunderuser-taking,itwillparsethatsurveyas

wellasupdatetheUIorthesurveylistagain.

Figure25Parsesurveysection1

Page 42: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

33

Thisistheparsesurveysection,inthissection,itcallsafunctioncalledparseQuestiontohelp

dividethewholeparsingprocessinmoredetail.TigerAwareAndroidwillparsealltheinformationfor

thatsurveyandstoretheinformationinStringorList,dependingonwhatkindofinformationitis.Then

useanotherfunctiontoparsequestionstosuitResearchStackFormat.

switch(type)

Figure26Parsesurveysection2

Withinparsingsurveyfunction,TigerAwareAndroidusesparsingquestionfunction.Aboveisthe

parsingquestionsection.Foreachquestioninthatlistorinthatsurvey,wegettheirquestionid,title,

type and so on. Then based on what kind of information it contains, we encapsulate them into

ResearchStackquestionformattogenerateactualquestions.Forexample,ifaquestioncontainsitstype

asDATE_TIME_QUESTION,TigerAwareAndroidwillgenerateadataandtimequestionaccordingly.

Page 43: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

34

Afterweaddingall questions into List<Question>, the last step is to launch surveys, and the

followingaretheERDandtheworkflowchartforthestoragestructurewementionedabove.

Figure27ERDforthestoragestructure

Figure28Flowchartsforthestoragestructure

Page 44: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

35

3.2.4LaunchSurvey

Aswementioned in3.2.3, afterparsing surveys, all questionare stored in surveys in certain

formatandwaitingforlaunching,andthefollowingistheflowchartwementionedabove.

Figure29Flowchartsforlaunchingsurvey

First,afterparsingprocess,allquestionsarestoredinsurveysincertainformat.Thenassoonas

welaunchorauserclickoneofthesurveyinthesurveylist,thelaunchingsurveyfunctionwillstart.The

firststepofthefunctionistojudgewhatkindofquestionitis,letustakeyesornoquestionasexample,

if a question is regarded as a yes or no question, the launching survey function will set the

constrainsModel.typeasbooleanConstraints,whichisonlyacustomnameofthattype,inotherwords,

wecanjusttakeitasanametag.ThelaststepoflaunchingsurveyfunctionistouseReserchStackAPI

andtheSmartSurveyTask,amainfunctionsupportedbyoneofitsmaincore,ResearchStackSkin,and

thebooleanConstraintswesetwillbeusedinthisSmartSurveyTask.InSmartSurveyTask,similarly,itwill

first divide different questions into different types based on their constraints. Then for different

questions,SmartSurveyTaskwilldefinedifferentanswerformataccordingtothattypeofquestion.The

answer format and the question step are both defined and supported by the other core api of

Page 45: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

36

ResearchStack,which is not inResearchStack Skinbut inResearchStackBackBone. In thisway,both

ResearchStackBackBoneandResearchStackSkinarefullyimplementedandcooperatedwitheachother.

3.2.5Uploadresults

Afterauserfinishonequestion,hisanswerwillbeuploadedintoFirebase.InTigerAwareAndroid,

itusesTaskResult,whichissupportedbyBackBoneinResearchStack,tocollectalltheanswers.

Figure30OnActivityResult

AswementionedinBackBoneintroductionsection,aTaskResultobjectisaresultthatcontains

allthestepresultsgeneratedfromtask.Afteronerunofataskororderedtask(thatis,classTaskor

classOrderedTask), it will generate its own TaskResult. In other words, a task result is typically

generatedbytheframeworkasthetaskproceeds.Whenthetaskcompletes,theanswerwillberecorded

intaskresult,whichhasafunctioncalledgetResults.Bycallingthatfunction,ahashmapwillbegenerated.

Hashmapwillmapthekeywhichisastring,toanobject,whichisaStepResultclass.Thenwecanparse

theStepResultbasedonwhatkindofquestionitis.Afterparsing

Page 46: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

37

Thefollowingistheflowchartsforuploadingresults.

Figurer31Flowchartsforuploadingresults

3.3Sitemaps

Figure32Firstactivity

Page 47: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

38

Thisisthefirstactivitycomesintouser,theloginpage.Inthispage,usercaneitherloginwith

existingaccountandpasswordorcreateanaccount.

Figure33Registrationpage

Aboveistheregistrationpage,ifusedonothaveanaccount,TigerAwarewillleadusertothis

pagetohelpthemcreateanaccountwithemail,username,andaccordingpassword.

Page 48: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

39

Figure34Mainactivity

Thisisthemainactivity,whenpeoplesuccessfullyloginin,themainpagewithshowupwiththe

surveylist,andtwootherbuttons.Oneisthesignoutbutton,whichwillleaduserbacktothefirstpage

forthesecuritypurpose.Anotheristhesuspendwindow,insuspendwindow,userwillnotreceiveany

notification.

Page 49: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

40

Figure35Surveypage

This is the survey page, including different kinds of questions, which is the core function of

TigerAwareAndroid.Inthenextchapter,wewilltalkabouttheexactquestiontypes,theanswerformat

andhowitimplemented.

Page 50: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

41

Figure36Suspendwindowpage

Thisisthesuspendwindowpage,usercanchooseatimewindowtosuspendnotifications.Inthis

suspendwindow,userwillnotreceiveanynotification.

Figure37Sitemap

Page 51: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

42

3.4Functionsandalgorithms

Inthischapter,wearegoingtointroducethreemainfunctionsinTigerAwareAndroid:questions,

suspension,andnotifications.Then,wewilldiscusshowsuspensionandnotificationareimplemented

andthealgorithmsbehindthem.

3.4.1Questiontypes

InTigerAwareAndroid,mostquestiontypesaresupportedbyResearchStackinordertohavethe

similarfunctionalitywithTigerAwareIOS,whichisusingResearchKit.Forthosequestionsthatarenot

supported by ResearchStack but are implemented in ResearchKit, ResearchStack offers a custom

interfaceforusertodesignanewquestiontypebasedontheresearchstudypurpose.

Inthetablebelow,wecanseetherearesevenquestiontypesorquestionanswerssupportedby

ResearchStack,andtheUnknownAnswerFormatisthecustominterfacefordeveloperstodesigntheir

ownquestions.

AsforTigerAware,intotal,TigerAwareAndroidsuppportstwelvequestiontypessofar,theyare:

yes or no question,multiple choice question, date and time question, text slide question, text field

question, time of day question, time interval question, scale question, continuous scale question,

BACTrackAlcoholSensorquestion,numbertypequestion,activelocationquestion,activegaitquestion

andactivePSATquestion.

Page 52: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

43

Table4ResearchStackSupportedAnwersformat

(1)Yesornoquestion

Definition:Ayesornoquestionisaquestionwhoseexpectedansweris“yes”or“no”.Formally,

theypresentanexclusivedisjunction,apairofalternativesofwhichonlyoneisacceptable.Forexample,

ayesornoquestioncouldbelikethat“Didyoudrinkalcoholtoday?”

Implementation: Yes or no question is predefined in ResearchStack, as a basic question,

TigerAwareAndroidusesitdirectlywithminorchanges.

(2)Multiplechoicequestion

Definition:Amultiplechoicequestionisaquestionwhoseexpectedanswercouldbeonlyone

choice,oroneormorechoices,definedbytheresearcherbasedondifferentstudy.

Implementation:Formultiplechoicequestion,TigerAwareAndroidmakessomeslightchanges.

InResearchStack, ithas twodifferentquestiontypesoranswer formats,one issinglechoiceanswer

format,whichcanonlyallowusertochooseoneandonlyonechoice.Anotherismultiplechoiceanswer

format, which can allow user to choose one or more than one choices. However, for better

Page 53: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

44

implementation,oramoreconvenientway,TigerAwareAndroidcombinesthesetwoquestionsintoone.

Thisishowitworks,whenresearchersareschedulingsurveysontheTigerAwaredashboardformultiple

choicequestion,theycanalsochooseallowmultiplechoiceornot,iftheyclickyes,abooleanvariable

calledallowMultiwillbepassedtoTigerAwarealongwithquestions.Thuswedefinedanewconstraint

typecalledallowMulti,ifallowMultiequalstrue,itwillselectmultiplechoiceanswerformatotherwise

itwillselectsinglechoiceanswerformat.

(3)DateandTimequestion

Definition:Adateandtimequestionisaquestionwhoseexpectedansweris“yes”or“no”.For

example,analcoholbasedonstudycouldaskparticipantswhatwasthelasttimetheydrinkalcohol,and

theyneedtospecifywhatdayassociatedwiththetimeaswell.Theanswershouldbeacalendarinwhich

theusercanselectaday,thenTigerAwarewilldisplayaclockforusertoselectatimeaswell

Implementation:DateandtimeanswerformatispredefinedinResearchStack,whichmeansthe

clockandthecalendararesupported.However,Fordateandtimequestion,TigerAwareAndroidmakes

someslightchanges.First,TigerAwareAndroidchangedthetimeformatfrom24hoursinto12hours

withAM/PM.

Second,TigerAwareAndroidoffersthreemoreoptionsforthisquestion,justlikehowitworksin

multiplechoicequestionwementionedabove,theresearchercandisableorenablethesethreeoptions

inthedashboard,thenthreeparameterswillbepassedtoTigerAwareAndroidwiththequestionitself.

Oneis“selectbothdateandtime”,ifresearcherenablethisoption,theanswerwouldbedateandtime,

otherwisetheanswerwillonlybeacertainday.Anotheris“selectpastdays”,ifresearcherenablethis

option,theparticipantscouldselectpastdaysinsteadofselectthefuturedays.Thelastoneis“select

Page 54: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

45

multipledays”,ifresearcherenablethisoption,whenparticipantsfinishonedateandtime,theycould

chooseanotherdateandtimeaswell.

Futurework:Forcurrentstudies, inordertonotconfuseusersandresearchers,wemanually

disabled“selectmultipledays”,andenabled“selectbothdateandtime”and“selectpastdays”.Inorder

tofullyusethisquestionandmakeitconsistentwithwhatresearchersselectedandscheduledinthe

dashboard,weshouldnotfixtheseoptionswhenwearereadytouse.

(4)Textslidequestion

Definition:Atextslidequestionisaquestionoraninformativepagetogiveuserinformation,

thereisnoanswerrequiredforusertoinputortypebacktothisquestion.Usually,thetextslidequestion

will only contain text content, but in TigerAware Android, we modified this question and made it

compatiblewithimagecontent.

Implementation: text slide question is predefined in ResearchStack, as a basic question,

TigerAwareAndroidusesitwhileaddingimagetypecontentwithtextslidecontenttomakethisquestion

moreflexibleandcontainmoreinformation.Forcurrentstudy,wesaveimageatlocalspaceandwhen

thereisatextslidequestioncoming,aswementionedabove,therewillbea“enableimage”option.If

userenablethisoptionandscheduleanimagecontentaswellastestslide,theywillshowtogetherin

thetextslidequestion.

Futurework:Ifwewanttouseimagecontentinmoregeneralspace,notlikeusingfewcertain

imagesforcertainstudies,wehavetostoreallimagesindatabaseandreadtheseimageswithquestions.

AgoodwayistostoreimagesinFirebasestorageandstoretheassociatedURLintheFirebasedatabase.

Page 55: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

46

(5)Textfieldquestion

Definition:Atextfieldquestionisaquestionwhoseexpectedanswerisatextfield,whichmeans

usersneedtotypetheiranswerforthesequestion.Usuallytheanswerwillbemoregeneralandnot

easytopredefine,oritishardtobelimitedintoA,B,CandDfouroptions.Forexample,aquestioncan

belike“Whatdidyouhavethismorning?”

Implementation: Text field question is predefined in ResearchStack, as a basic question,

TigerAwareAndroidusesitdirectlywithminorchanges.

(6)Timeofdayquestion

Definition:A timeof day question is a questionwhose expected answer is a timestamp. For

example,atimeofdayquestioncouldbelike“Whenwasthelasttimeyouhadalcoholtoday?”Similarly,

todayandtimequestion,oneisaskingfordayandthisquestionisaskingfortime.

Implementation: timeof day is predefined inResearchStack, as abasic question, TigerAware

Androidusesitdirectlywithminorchanges.

(7)Timeintervalquestion

Definition:Atimeintervalquestionisaquestionwhoseexpectedanswerisaperiodoftime.The

purposeofthisquestion isaskforatime intervalbetweentwoactivity.Forexample,atime interval

questioncouldbelike“Howlongdoyourelaxbetweenquestions?”.Asfortheanswer,theusercan

selecthoursfrom0-23andselectminutesfrom0-59,andtheanswerwillcombinethemtogether.

Implementation:timeinterval ispredefinedinResearchStack,asabasicquestion,TigerAware

Androidusesitdirectlywithminorchanges.

Page 56: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

47

(8)Scalequestion

Definition:Ascalequestion isaquestionwhoseexpectedanswer isadegree.Toachievethis

questiontype,researcherwilldefineascalebarwithnumbers,forexample,ifaquestionistodetermine

whetherusersarehappyornot,ascalebarcanbedefinedfromonetofive,andonestandsfornot

happy,fivestandsforveryhappy,andtheusercandragthescalebartothedegreeassociatedwiththeir

truesituations.

Implementation:scalequestionisnotsupportinResearchStackBackbone,butitissupportedin

ResearchStackSkin.Beforethisquestiontype,TigerAwareAndroidwasusingResearchStackBackbone,

wecancallitTigerAwareAndroid1.0.Theninordertoaddthisquestiontype,wechangedTigerAware

Android from1.0 to 2.0 by refining the system structure andusingResearchStack Skin instead, and

ResearchStackBackbone is still inuseas themajorcomponent,whichoffering theanswer format in

ResearchStackSkin.

(9)Continuousscalequestion

Definition:A continuous scalequestion is aquestionwhoseexpectedanswer is adegree. To

achieve this question type, researcher will define a scale bar with numbers. Differently with scale

question,ascalequestioncanonlystartfromonetouptoeightdegrees,anddisplayallnameswiththat

degree.Forexample,ifaquestionistodeterminewhetherusersarehappyornot,ascalebarcanbe

definedfromonetothree,andonestandsfornothappy,twomeansnotsureyet,andonestandsfor

veryhappy,andtheusercandragthescalebartothedegreeassociatedwiththeirtruesituations.While

incontinuousquestion,theresearcherscanonlydefinetheminimumstringandthemaximumstring,

which is “not happy” and “very happy”. In addition, the continuous scale questions can holdmore

Page 57: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

48

degreesstartingnotonlyfromone.Forexample,acontinuousquestioncanbefrom100to300anda

minimumstringwithamaximumstring.

Implementation:AcontinuousscalequestionispredefinedinResearchStackwhichsharingthe

same framework with scale question.We added themaximum string andminimum string and the

maximumvalueandminimumvaluebyreadingthemfromfirebase.Wealsochangedthedisplaystring

byaddingtheminimumvaluenumberintothedisplaystringnumberwhichstartsfromzero.Forexample,

ifweusescalequestion,andthequestionisfrom11to15,thedisplaynumberwillbe1-5,butifweuse

continuousscalequestion,thedisplaynumberwillbe11-15instead.

(10)Numbertypequestion

Definition:Anumbertypequestionisaquestionwhoseexpectedanswerisanumber.Toachieve

thisquestiontype,researcherwilldefineanumberpadwithnumbers.Therangeofnumberisfromzero

tonine.Thepurposeofthisquestionistoaskuserstheirinformationwhichhasalargerange,andalso,

whenresearchersareschedulingthisquestiontype,theycanalsodefineaunittypeassociatedwiththe

numberanswer.Forexample,aquestioncouldbedefinedlikethis,whatisyourage,andtheunittype

couldbeyears.

Implementation:anumber typequestion ispredefined inResearchStack,asabasicquestion,

TigerAwareAndroidusesitdirectlywithminorchanges.

3.4.2Notifications

InTigerAwareAndroid,onemajorfunctionisnotification.Researchstudiesusuallywanttomake

surveysscheduledatrandomtimeinordertogetageneralunderstandingofparticipantsgenerallives,

and theyalsowant to schedulenotificationsat certain time to remind theparticipates to take their

Page 58: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

49

survey in time.When researchers are scheduling surveys, they can also schedule both notifications

associated with that survey, so that it makes the survey taking process more efficient, or some

participantsmaymisssomesurveyswithoutnotifications,andaswementionedabove,therearetwo

kinds of notifications mechanisms in TigerAware Android, random notifications and scheduled

notifications.

(1)Randomnotifications

Definition:

Randomnotificationplays a significant role in TigerAwareAndroid notification system,when

researchersareschedulingsurveys,theycanalsoschedulerandomnotificationwithrandomnotification

starttime,randomnotificationendtime,howmanydaysitwilllastandhowmanyrandomnotification

willbesentoutduringthattime.

Mechanism:

Randomnotificationsarealsotreatasquestions, toseehow itworks,pleaserefer tosection

3.2.3 Parse Survey and section 3.2.4 Launch Survey in questions. Then after the question data is

processed, if the question type equals random notification, it will generate a random timestamp

betweenthestarttimeandtheendtime.

In addition, in order to save memory and improve the working efficiency, every time the

applicationisopened,itwillonlyschedulenotificationsinthenexttwodaysinadvance.Toachievethis

function,afewcomparisonisaddedintothemakenotificationfunction.

Page 59: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

50

Above all, in order to schedulenotification everyday till the last day, itwill start scheduling

notificationsfromthenextdayandincreasethedatebyonetillthelastday.Thenafterthedatedatais

received in themake notification function aswell as the start time, end time and the last day, the

followingcomparisonmechanismwillhappentokeepeveryaspectsinnotificationsworkingasexpected.

(1)First,itwilljudgewhetherrightnowisbeforenotificationdate,toensurethenotificationis

scheduledinthefuture.

(2)Second,itwilljudgewhetherthenumberofnotificationscheduledislessthanfivehundred,

tomakesurethenotificationsarenotoverloadedforthememorystorage.

(3)Thenitwillmakesurenotificationdateisbeforetwodaysaftertoday,whichmeansevery

timeaparticipantopentheapplication,TigerAwareAndroidwillonlyscheduletwodaysnotificationin

advanceinsteadofschedulingallthenotificationstillthelastdayatonetime.Inthisway,itwillsave

spaceforthememorystorageandimprovetheworkingefficiencyforthenotificationsystem.

(4)Lastbutnotleast, itwillalsocheckwhetherthenotificationdateandtimeareinsuspend

window. Suspend window is a window during which the notifications cannot be received, we will

introducesuspendwindowinmoredetailinthefollowingchapter.

Algorithms:

Toensureeach randomnotificationsare scheduledat least fifteenminutes fromeachother,

therearetwoalgorithmstosolvethisproblem:

Page 60: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

51

(1)Thelateststarttimealgorithm:

Thisthealgorithmalwayscalculatesthelateststarttimeforthefirstfollowingnotification.For

example,ifresearcherwanttoschedule5randomnotificationsfrom8:15amto10:15am,whichmeans

there are 4 times breaks of 15mins. So the latest start time for the first notification is 10:15am -

4*15mins=9:15am,otherwisetherewouldnotbeenoughtimeforthe leftnotifications.nowwejust

random choose a time between start time 8:15am and the latest start time 9:15am as the first

notificationtime.Forexample,ifwechoose8:35amasthefirstnotification,toguarantee15minsbreak,

thenewstarttimeshouldbe8:35am+15mins=8:50am.Nowwehavenewstarttime8:50am,endtime

10:15amand4timesnotificationsleft.Thenlooptillallnotificationsarescheduled.

(2)Theconditionalrandomselectionalgorithm:

Similartoreservoirsampling,thisalgorithmlistsallthepossibletimestampstoselectinanarray,

thenremovea15minuteradiusfromthatarray.Forexample,thereare120minutesfrom8:15amto

10:15am,thenitcreatesanarrayorlistofsortsofall120digitsandrandomlyselectanindexinthat

array.Afterthat itwouldremovea15-minuteradiusfromthatarray.So if itchose97then itwould

remove97andall thenumbersfrom82-112.Thenselectanotherrandomindex inthatarray,which

wouldexclusivelybefullofvalidnumbers.Totransferitbacktotimestamp,itwouldthenaddthatvalue

tothestartvaluetoformtimeinhoursandminutesformat.

Toensurethe15minutes’break,randomnotificationsshouldbescheduledwitha14-minute

radius(soselectthenumber,thenremoveit+and-14minutes).The14-minuteradiusissoselectedto

enableanexclusiveradialselectionof15minutes.

Page 61: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

52

Thealgorithmwillalsochecktoseeiftheamountofnotificationsrequestedcanbeschedule(so

2notificationsfora30minsperiod,4notificationsfora60minutes’period…)

Processandexample:

a) Create an array of numbers from the lowest specified bound of minute to the highest

specifiedboundinminutes

b) Selectarandomindexinthatarray,thevalueofthespecifiednumberwhichtheindexpoints

toisthevalueoftheselectednumber

c) removethe14-minuteradiusandtheselectedvalue.Theseremovalsmustbemadebyvalue

notindex

d) appendtherandomnumbertothelowbound

Example:

RandomWindow:12:00-12:45

1.arraygenerated: 0,1,2,3….,45

2.selectrandomindex: i=31(30selected)

…28,29,30,31,32…

3.remove14minuteradius: 16-44removedfromarray

4.appendnumbertolowbound 12:00+30minutes=12:30

5.repeatuntilallnumbersselected

Page 62: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

53

(2)Schedulednotifications

Definition:

SchedulednotificationplaysasignificantroleinTigerAwareAndroidnotificationsystem,when

researchersareschedulingsurveys,theycanalsoscheduleschedulednotificationwithcertaintimeand

whatdayitwillend.

Mechanism:

Schedulednotificationsarethesimplifiedversionofrandomnotifications.Thedifferenceis, it

wouldnotusetherandomselectionalgorithmandusethestarttimefromtheschedulednotification

itselfinstead.

3.4.3Suspension

Definition:

Suspensionmeans,duringsuspendwindow,userwillnotreceiveanynotificationeventhough

thereisanotificationscheduledatthattime.

Mechanism:

First,usersneedtosetuptheirownsuspendwindowinTigerAwareAndroid,whichcontainsa

start time and an end time, then when a new notification come in, it will compare weather the

notificationdateis insuspendwindowthenpostthatnotification,whichmeansthenotificationtime

should be after suspend window start time and before suspend window end time. Users are not

supported to get any notification during the suspend window even though there is a notification

scheduledatthattime.

Page 63: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

54

Theproblem is, for thesituationabove, thesuspendwindowwill repeatoverandoveragain

becauseitonlycomparesthetimebutignorethedate.Tomakeitworkforonetime,dateneedtobe

addedfromthebackendandboundwithtime,whichistheuserinput.

So thepointof thenewsuspend is toonly suspend1 time.Currently suspendsuspendsata

specifictimeeveryday.SocurrentlyyouwouldsayIdonotwanttogetanotificationbetween1PMand

3PMandyouwouldthenneverreceiveanotificationthenforever.Wewanttohaveitsoyoudonot

receivethenotificationjustbetween1PM-3PMonthedayyoususpended(1time).

Thefollowingishowtheimprovedsuspendwindowworkforonlyonetimesuspension.

Algorithms:

(1)Addingsuspendwindowdatebasedontheenddate

Themainpointofthechangesistomakeitsuchthateachsuspendwindowappliesonlyonetime

beforebeingautomaticallyremoved.Thewaythatthisshouldbeimplementedisbyusingthecurrent

datewhentheusersetsthewindowinadditiontothetime.Itshouldnotneedtoaddanyadditional

inputfieldsfortheusertofillout;simplygrabthedateonthebackend.Then,usethatincombination

withtheuser-inputtimestoapplythetimewindowtotheearliestpossibleopportunity.Thereshould

betwocases:

a) Thetimesenteredbytheuserarebothinthefuture.Forexample,saythetimeis1pmandIsetthesuspendwindowstartat3pmandendat5pm.Inthisscenario,Itissupposedtodosuspensiononthecurrentdatebetween3pmand5pm.However,mysuspendshouldapplyonlytodayfrom3pmto5pm,andnottomorrow.

b) Themorecomplexcaseisiftheuserprovidestimessuchthatonlytheendtimeisinthefuture.Forexample,considerthesamescenarioasaboveexceptIsetthewindowtimesfrom10amto5pm.Although10amhasalreadypassed,since5pmisinthefuturewecanstillapplythewindow.Thisscenarioshouldsuspendfromthecurrenttimeuntil5pm.

Page 64: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

55

To achieve the scenariosabove,themainpointistocomparetheendtimewithnow,ifendtime

isbeforenow,suspenddate is tomorrowotherwisesuspenddate is thesamedaywhenusersetup

suspendwindow.

It would add the date when user finish the suspend survey from the backend and store it

separatelylike"starttime","endtime".Andwhenitisgeneratingnotification,itwillnotonlycompare

thewhetherthenotificationtimeis insuspendwindow(previousversion)butalsocomparethesuspend

date.

(2)Adatedetectionalgorithmforbothstarttimeandendtime

Tomake suspensionhappenonlyone time,dateneed tobeadded.Thedifferencewith first

algorithmis,thisalgorithmaddedtwodatesinsteadofone.InFirebase,underuser/suspendWindow

thereisawindowStartandwindowEndthatbothstoretimes.Toexecutesuspendonceandonlyonce

weused2newfieldswindowEndDateandwindowStartDate.Theystorethedateandtimeatwhichare

supposedtosuspend.Theresearcherswantedjustthetimeinput,soitstillhavetogetonlythetime

fromthequestionandapplythedatestoit.Theapplyingthedatesistheonlytoughparttherestisjust

readingandwritingdatesfromthefirebaseandputtingthemintherightplace.

Thisishowitworks:whenuserinputbothstarttimeandendtime,grabdateatthatmomentand

storeitaswindowEndDateandwindowStartDate.Thencomparethestarttimeandendtime,ifendtime

isbeforestarttime,windowEndDateequalswindowEndDateplusone.Otherwisetheyarebothtoday.

Anditshouldstillsuitthefollowingscenarios.

(1)Thetimesenteredbytheuserarebothinthefuture.Forexample,saythetimeis1pmandI

setthesuspendwindowstartat3pmandendat5pm.Inthisscenario,Itissupposedtodosuspension

Page 65: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

56

onthecurrentdatebetween3pmand5pm.However,mysuspendshouldapplyonlytodayfrom3pmto

5pm,andnottomorrow.

(2)Themorecomplexcaseisiftheuserprovidestimessuchthatonlytheendtimeisinthefuture.

Forexample,considerthesamescenarioasaboveexceptIsetthewindowtimesfrom10amto5pm.

Although10amhasalreadypassed,since5pmisinthefuturewecanstillapplythewindow.Thisscenario

shouldsuspendfromthecurrenttimeuntil5pm.

Intheperformancechapterwewillcomparebothalgorithmsinmoredetailformorescenarios.

Page 66: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

57

4.SYSTEMPERFORMANCEEVALUATION

Systemperformanceisevaluatedinthefollowingthreeaspects:questiontypes,notificationand

suspension.

Table5ThelistoffunctionsandalgorithmsaboutSystemperformance

Functions Requirements methods results

Questions Dynamicand

customquestions

Dynamicandcustom

questions

Vsoriginal

ReseachStack

Dynamicandcustomquestionsdesign

isbetterthanjustusingResearchStack

anditsfixedquestiontypesbecauseit

hasmoreflexibility

Notifications Schedule

notificationswith

15minutesbreak

(1)thelateststart

timealgorithm

(2)theconditional

randomselection

algorithm

Weselectedtheconditionalrandom

selectionalgorithmwhichismore

compatiblewithTigerAware

dashboarddesign(strictly15minutes

break)

Suspension Scheduleonetime

suspension

(1)datedetection

algorithmforboth

starttimeandend

time

(2)Addingsuspend

windowdatebased

ontheenddate

AIntelligentdatedetectionalgorithm

forbothstarttimeandendtimeis

betterbecauseitcanavoidsuspend

overmidnightproblem

Page 67: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

58

4.1Differentframeworkforquestiontypes

Forquestiontypes,theimprovedtigerawareAndroidsystemhasmoreflexibilitythanoriginal

researchStack.TheoriginalTigerAwareandroiddirectlyResearchStackBackBoneanditsquestiontypes

and countered a few problems. Such as slider bar question type is not supported in ResearchStack

BackBoneandwecannotmodifyquestions.However, it issupported inResearchStackSkin, thenwe

downloadbothResearchStackBackboneandResearchStackSkintolocalandmodifythemtohavemore

flexibility. In this way, the questions can dynamically change based on question design from the

dashboardside.WealsoaddedcustomquestionssuchasBacTrackAlcoholSensorquestion.

Table6TheperformancecomparisonalongtheframeworkchangesofTigerAware

framework Dynamicquestions Customquestions Sliderquestion

importOriginal

ResearchStack

Backboneand

no no no

importOriginal

ResearchStackboth

SkinandBackbone

no no yes

download

ResearchStackskin

andbackbonetolocal

importandmodify

both

yes yes yes

Page 68: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

59

4.2Notificationsperformanceevaluation

Fornotifications,therearetwoalgorithmsforSchedulingnotificationswith15minutesbreak.

Thefollowingisthetableabouttheperformanceaboutthem.

Table7Theperformancecomparisonaboutdifferentalgorithmsfornotifications

algorithms Advantages Disadvantages

thelateststart

timealgorithm

moreefficientinitsuseofmemory Lessrandom:afterfirstnotificationis

scheduled,thesecondnotification

cannotbescheduledbeforefirst

notification.

theconditional

randomselection

algorithm

Morerandom:afterfirstnotificationis

scheduled,thesecondnotification

stillcanbescheduledbeforefirst

notification

Usemorememory

4.3Suspensionperformanceevaluation

Forsuspension,therearetwoalgorithmstodesignasuspendwindow.Thefollowingisthetable

abouttheperformanceaboutthetwoalgorithms.

Page 69: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

60

Table8Theperformancecomparisonaboutdifferentalgorithmsforsuspension

algorithms Advantages Disadvantages

date detection algorithm for

bothstarttimeandendtime

Solveanysuspendproblem UseMorememory

Addingsuspendwindowdate

basedontheenddate

Lessmemory

Easytoachieve

It cannot solve the suspend

overmidnightproblem

Page 70: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

61

5.CONCLUSIONANDFUTUREWORK

AccordingtoResearchKit,asimilarSDKcalledResearchStack isusedtodevelopafunctionally

equalapplicationsupportedbyAndroid,includingkindsofquestions,activetasks,suspendwindowand

notifications.

Forkindsofquestions,TigerAwarehasexperiencedthreestages:directlyimportResearchStack

Backbone,importResearchStackBackboneandSkin,anddownloadResearchStackBackboneandskin

thenmodify.Thefirststagecanonlysupportafewquestionswhilethesecondcansupportmore,such

assliderquestions.ThefinalstageworksthebestbecausebothResearchStackBackBoneandSkinare

modified,andcustomquestiontypeiscreatedtosupportavarietyofquestiontypesandactivetasksfor

studyuse.

Forrandomnotifications,twoconditionalrandomselectionalgorithmareproposedtohandle

notifications with more flexibility, they are the latest start time algorithm, the conditional random

selectionalgorithm.Eventuallywechosetheconditionalrandomselectionalgorithmbecauseitismore

randombasedonthetimesequence.

Forsuspendwindow,onetimesuspensionisnecessarytoavoidrepeatingissue,andthereare

twoalgorithmstohandlesuspendwindowindifferentsituations,suchassuspendovermidnight.Oneis

basedonendtimeandaddingonedate,anotheristodetectbothstartdateandenddateandthesecond

algorithmisfinallyimplementedbecauseithasmorecompatibility.

In conclusion, by modifying both ResearchStack BackBone and Skin and adding random

notificationwith15minutesbreakandsuspension,theimprovedTigerAwareAndroidSystemhasthe

abilitytoadapttheexistingfunctionsoniOSintoandroidwiththesamefunctionality,anddevelopthe

Page 71: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

62

newfeaturestogetherwithTigerAwareSystemtohelpsomeresearchstudyspecifics,andallofthese

features and functions developed aremarkedwith themature development of TigerAwareAndroid

version2.0.

Inthefuture,asthechangingofthedatabasestructure,thewaytoreadthesurveysfromthe

FirebaseneedtobechangedandtheeraofTigerAwareAndroidversion3.0iscoming!

Table9Thelistofmycontributions

Mycontributions

Survey

Questions

Multiplechoicequestion,dateandtimequestion,pictureintextslidequestion,time

ofdayquestion,scalequestion,continuousscalequestionandsoon

Notifications Randomnotificationinfifteenminutesbreak

Suspension Onetimesuspension

Others UIimprovements:textcolor,icon,barcolor.Testing:debugandsoon

Page 72: TigerAware Android: An Improved Mobile Survey and ...dslsrv1.rnet.missouri.edu/~shangy/Thesis/WeiliangXia2019.pdfResearchStack, a ResearchKit-like SDK and UX framework for apps on

63

6.REFERENCES

[1]PewResearchCenter,"MobileFactSheet,"Jan2018.[Online].Available:http://www.pewinternet.org/fact-sheet/mobile/.[Accessed2018February2018].

[2]JayanthKanugo,“TigerAwareDashboard:AnImprovedSurveyGenerationandResponseVisualizationDashboard,”May2018.[Online].Avaliable:http://dslsrv1.rnet.missouri.edu/~shangy/[accessed2019april2019]

[3]WilliamMorrison;LukeGuerdan;JayanthKanugo;TimothyTrull;YiShang,“TigerAware:AnInnovativeMobileSurveyandSensorDataCollectionandAnalyticsSystem,”June2018[Online].in2018IEEEThirdInternationalConferenceonDataScienceinCyberspace(DSC),2018

[4]JasonLong.“ResearchStack,”[Online].available:http://researchstack.org[accessed2019april2019]

[5]ResearchStack“backbonedocumentation,”[online].Avaliable:“http://researchstack.org/documentation/backbone/[accessed2019april2019]

[6]ResearchStack“backbonedocumentation[online].Avaliable:“http://researchstack.org/documentation/skin/”[accessed2019april2019]

[7]ResearchKit“ResearchKit”[online].Avaliable:“http://researchkit.org/”[accessed2019april2019][8]ResearchKit“ActiveTasks”[online].Avaliable:

“http://researchkit.org/docs/docs/ActiveTasks/ActiveTasks.html”[accessed2019april2019]