Assignment3
AndroidStudioSetting:
●APILevel>=33
●ABI=x86_64
●Target=Android(GooglePlay)
Database(15marks)
NotesonimplementingDataStorage(Entities)
●AspartofAssignment2,entitiesmustbeimplementedasRoomdatabase
entities(Event&EventCategory).
●LiveDataoftypeList
multipleevents&eventcategoriestodisplay.
●ThedatastoredforuserdetailsremainsSharedPreferences.Inotherwords,
youdonotneedtocreateanentitytostoreUserdetails.
1.DatabaseConfiguration(2marks)
1.1NewDatabaseClass
●Importrequireddependenciesfortheroomdatabaselibrary.
●CreateanewEMADatabaseclasstoensurethetwoentitiesarespecifiedand
theappropriatedatabasenames.
1.2DAO,Repository&ViewModel
●NewInterfaceDAOtoholdallCRUDoperationmethodslistedbelowunderother
tasks.
●ThenewRepository&ViewModelclassisusedtointeractwiththedatabase.
2.EventCategory(5marks)
2.1EventCategory-RoomEntity(1mark)
1.TransformpreviouslycreatedEventCategoryentitytoaroomdatabaseentity.
○Addanewuniquefield"id"(PrimaryKey),thiswillbeauto-generatedon
saveofthenewEventCategoryrecord.
○Addanotherfieldcalled"eventLocation"(String).Thiswillbereceived
fromtheuserenteringlocationofthecategoryintheAddCategoryform
(see2.2).
2.TheCategoryIdfieldpreviouslycreatedshouldstayasis(eg:CZX-1213)and
mustbestoredinthedatabase.It'sjustanothervaluesavedinthedatabase
tableasaString.
3.RequiredGetter&Settermethodsareusedinsteadtoaccesseventcategory
attributes.
Figure1:Modifying'NewCategoryForm'toaskuserforLocationwhencreatingnew
categories.Wewillusethisintheassignmenttosearchanddisplaythelocationona
mapusingGoogleMaps.
2.2EventCategory-Save(1mark)
●Modifythe"NewCategoryForm"UItoaddaEditTexttofetchlocationofnew
categories.SeeFigure1.
●UpdatethisEventCategoryFormtosavecategorydataintothedatabase.
●UsetheViewModelmethodtosaveanewrecord.
2.3EventCategory-ReadAll(2mark)
●UpdatetheFragmentListCategorytoreaddatafromthedatabaseand
remove/commentoutoldcodeofreadingdatafromSharedPreferences.Similar
toAssignment2,thisfragmentisloadedinsideDashboardActivity.
●UsetheViewModelmethodtoreaddatafromthedatabaseinto
FragmentListCategory.
2.4EventCategory-DeleteAll(1mark)
Updatethe"DeleteAllCategories"optionintheoptionsmenutodeleteallcategory
recordsfromtheEventCategorydatabasetable.
Youdonotneedtodeleteeventsofthedeletedcategories.Ifyou'dliketo,feelfreetocodethisforyour
ownknowledgebutthisisnotrequiredaspartoftheassessmentandtherearenomarksforthis
behaviour.
3.Event(8marks)
3.1Event-RoomEntity(1mark)
●TransformpreviouslycreatedEvententitytoaroomdatabaseentity.
●Addanewuniquefield"id"(PrimaryKey),thiswillbeauto-generatedonsaveof
thenewEventrecord.
●TheEventIdfieldpreviouslycreatedshouldstayasis(eg:EME-10776)andmust
bestoredinthedatabase.It'sjustanothervaluesavedinthedatabasetableasa
String.
●RequiredGetter&SettermethodsareusedinsteadtoaccessEventattributes.
3.2Event-Save(1mark)
●UpdatepreviouslyimplementedDashboardActivitywhereyouhadaNewEvent
Formtosaveeventdataintothedatabase.
●UsetheViewModelmethodtosaveanewrecord.
3.3Event-UpdateCategoryCount(3mark)
●BeforesavinganewEventrecordtothedatabase,updatethevalidationlogic
implementedaspartofA2("Categorydoesnotexist")tovalidateagainstthelist
ofcategoriessavedinthedatabase.Inotherwords,beforesavinganEventyou
shouldreadthelistofallcategoriesfromthedatabaseandmatchuser-provided
inputfortheCategoryIdfield.Iftheuserprovidedinputmatch,onlythenallowa
newEventrecordtobesavedinthedatabase.
●OnceanEventrecordissaved,incrementthevalueofEventCountbyoneofthe
specifiedcategoryrecord,identifiedbyCategoryIdinputprovidedbytheuser.
SimilartoA2,however,youneedtoupdatetheCategoryrecordsavedinthe
database.
3.4Event-ReadAll(2marks)
●UpdatetheFragmentListEventtoreaddatafromthedatabaseand
remove/commentoutoldcodeofreadingdatafromSharedPreferences.
●UsetheViewModelmethodtoreaddatafromthedatabaseinto
FragmentListEvent.
3.5Event-DeleteAll(1mark)
Updatethe"DeleteAllEvents"optionintheoptionsmenutodeletealleventrecords
fromtheEventdatabasetable.
Note:DonotupdatetheEventCountofdeletedevent'scategories,feelfreetotryfor
yourknowledgebutnotrequiredaspartoftheassessment.
C.GoogleMaps(7Marks)
4.1GoogleMapsActivity(2marks)
1.CreateanewActivitytodisplayGoogleMaps,youcancallitGoogleMapActivity
2.Onclickofeachcategoryrecord(eachcardintheRecyclerViewof
FragmentListCategory),launchGoogleMapActivitywiththelocationoftheclicked
categorypassedontoGoogleMapActivity.
4.2Geocoder(3marks)
●InsideGoogleMapActivity,findthecategorylocationusingGeocoderandmove
themaptothespecifiedlocation.
4.3UserExperience(2marks):
1.AddanewMarkertoidentifycategorylocationonthemapwithtitle=category
name.
2.Setthezoomlevelofthemapto10.
3.Iftheuserspecifiedlocationdoesnotyieldanyaddresses,keepthestateofthe
mapasdefaultandshowaToastmessage"Categoryaddressnotfound".
Figure:ClickingonaCategory(eachcardintheRecyclerViewof
FragmentListCategory)resultsintheCategorylocationbeingshownonaGoogleMap
embeddedwithintheapp.
D.WebResults
5.1EventGoogleResultActivity(6marks)
1.CreateanewActivityanduseaWebViewtodisplaytheGoogleresultsofthe
Event,youcancallitEventGoogleResult.Remembertoaddthenecessary
permissionstoaccesstheinternet.
2.Onclickofeacheventrecord(eachcardintheRecyclerViewof
FragmentListEvent),launchEventGoogleResultwiththenameoftheclicked
event'snamepassedontoEventGoogleResult.
3.OnceonEventGoogleResult,buildtheURLbyappendingtheEventnametothe
URLasshownbelow.
○
https://www.google.com/search?q=MelbourneCup
○Intheaboveexampleyourappwillputthethenameoftheeventbeing
clickedwhere'MelbourneCup'is.
4.MakesurewhenuserclicksonEventcard,itisopeningintheembedded
WebView(5.1.1)andnotinAndroid'sdefaultbrowser.
Figure:Clickingonaneventnamemakestheappopenanactivitywithgooglesearch
resultsforthatevent'sname.
E.Gestures
6.Gestures(4marks)
1.OntheDashboardactivityaddanewtouchpadtowardsthebottomofyour
screenforyourgestures,thistouchpadwillbeusedtoidentifyusergestures.
2.ImplementDoubleTapGesture:Whentheuserdoubletapsonthetouchpad
area,saveneweventrecord(i.e.dothesamebehaviourasFAB).
3.ImplementLongPressGesture:Whenuserlongpressesonthetouchpadarea,
ClearAllfields(justtheEditTexts&Switchresettofalse).
Fortroubleshootinganddebuggingpurposes,youcanalsodisplayTextViewcontainingthelastgesture
nameperformed(seeexpectedoutputvideoformoredetails).
Ensurenothinghappenswhenahorizontalscrollisperformed.
MarkingRubric:
Summary
AssignmentExpectedoutput:https://www.youtube.com/watch?v=Z8wPX2hb6rs