In this assignment you will be constructing a mobile app that will help users identify invasive plant species and report the presence of these species in Wisconsin state parks.
I have constructed a server application that will serve up information about invasive plant species and state parks in Wisconsin. Users will be able to create accounts on the server and use their accounts to upload observations of invasive species in state parks.
The server application will allow users to download information about invasive plant species and state parks.
To download a list of invasive plant species you can do a GET with the URL
https://cmsc106.net/invasive/species
This will return a list of objects of the form
{
"idspecies": <integer species code>,
"name": <name>,
"image": <string containing an image URL>
}
To download a list of state parks you can do a GET with the URL
https://cmsc106.net/invasive/parks
This will return a list of objects of the form
{
"idpark": <integer park code>,
"name": <name of park>,
"county": <name of county>
}
To upload observations of invasive species in state parks users will first have to establish an account on the server. To set up an account your app will POST an object of the form
{
"username": "string",
"password": "string",
"realname": "string",
"phone": "string"
}
to the URL
https://cmsc106.net/invasive/users
The server will respond by sending back an object of the form
{
"iduser": <integer user id>,
"username": "string",
"password": "string",
"realname": "string",
"phone": "string"
}
that contains the user's user id number.
Users can also retrieve a user's id number by doing with a GET to the URL
https://cmsc106.net/invasive/users?user=<user name>&password=<password>
If the login is successful the server will send back an object of the form
{
"iduser": <integer user id>,
"username": "string",
"password": "string",
"realname": "string",
"phone": "string"
}
If the login is unsuccessful the server will send back an object with an iduser value of 0.
To upload an observation of an invasive species in a park your app will POST an object of the form
{
"user": <id of user>,
"park": <id of park>,
"species": <id of species>,
"comment": "string",
"date": <string containing the observation date>
}
to the URL
https://cmsc106.net/invasive/observations
The string in the date field should be in the yyyy-mm-dd format. The comment field will allow users to enter more detailed information about the observation, such as exactly where in the park the observation took place.
Your app will have to be able to show the user a list of different invasive plant species and a list of state parks. Since these lists will not change, it makes sense for your app to download these lists just once. You should set up your app so that when it starts up for the first time it will go to the server to fetch these lists. Once you have these lists you should store them in a local database on the user's device. Once those lists are stored in the local database you will not need to go back to fetch the lists each time your app starts up.
Another feature of your app is that it should allow users to enter observations when the user is not connected to the internet. Since users are going to be making these observations in state parks they may very often be making these observations in locations where they do not have reliable cell service. Your app should allow users to enter observations while they are offline and upload those observations to the server later when they have a more reliable internet connection. To enable this feature your app should store all user observations in a local database. Your app should provide an "Upload Observations" button: when the user presses that button your app should upload all of the observations you have stored in your local database to the server. Once the observations have been uploaded should remove them from the local database.
When you download a list of invasive plant species from the server each species object will contain an image URL that you can use to download a picture of that plant species. Your app should include a gallery feature that allows the user to see the images of the plants to help them with identifying the plants.
One aspect of the app that you should give some further thought to is the list of state parks. This list is pretty long, with 58 parks in total. Rather than showing the user a list of all 58 parks and asking them to choose the park where they made the observation you should give some thought to making it easier for users to find the right park. For example, you can try implementing a search feature where the user can enter all or part of the name of the park to filter the list of parks down to a short list of only those parks whose name contains the text the user has entered. Another approach is to allow the user to select a county from a shorter list of counties to filter the list of parks down to just those parks that are in that county.
For the Jetpack Compose solution you will need to add some additional code to
your main activity's onCreate() method:
val imageLoader = ImageLoader.Builder(this)
.okHttpClient {
OkHttpClient.Builder()
.addInterceptor { chain ->
val request = chain.request().newBuilder()
.header("User-Agent", "InvasiveAndroid/1.0")
.build()
chain.proceed(request)
}
.build()
}
.build()
Coil.setImageLoader(imageLoader)
along with some additional import statements:
import coil.Coil import coil.ImageLoader import okhttp3.OkHttpClient