Institute of Computer Science
  1. Courses
  2. 2021/22 fall
  3. Mobile Computing and Internet of Things (LTAT.06.009)
ET
Log in

Mobile Computing and Internet of Things 2021/22 fall

  • Main
  • Lectures
  • Labs
  • Homeworks & Assignments
  • Results
  • Task submission
  • Extra Materials
  • Best Practices
  • Projects
    • Teams & Topics
    • Presentations & Report

Homework 2

Let's build an application that allows browsing between a set of plants in a greenhouse.

The app has 2 views:

  1. A List of all plants
  2. A Detailed view of one plant.

Implementing UI & Navigation

The UI should be implemented using 1 Activity and 2 Fragments.

  • One Fragment for List of plants
    • The list should be implemented using RecyclerView
    • Each list item layout should have a TextView and an ImageView
      • By default, the ImageView should not be visible
    • The user should be able to select one plant in the List, which navigates them to the details View of the selected Plant.
      • The movement between the list and detailed view should be implemented using a Navigation Graph (Recall Lab 2)
      • Use Fragment Arguments to pass data to the Details view
  • Second Fragment for the Detailed view of one plant. It should include at minimum
    • A TextView for the name of the plant,
    • A TextView for Description of the Plant
    • An ImageView, which will have a default image or be hidden by default (up to you).
    • A Button with the text "Take picture" (see below)

Base project

Use [ this base project ] as a starting point for the app. It provides a Plant data class and a PlantRepository and PlantDataset classes. Use PlantDataset to get the list of plants or fetch a single one by ID / Name or to assign a thumbnail to a plant.

  • Use PlantRepository.instance(context) to get an instance of a PlantDataset object.
    • PlantRepository uses the Singleton pattern to ensure that only 1 instance of PlantDataset exists, even if the above is called multiple times, from different Activities, Fragments, etc.
  • Use methods of PlantDataset to get a list of all plants from the json. You should use setPlantThumbnail(..) to update the thumbnail
  • NB! make sure you test your to ensure the recycling of views during scrolling does not introduce unexpected bugs!
  • Your RecyclerView custom Adapter should manage a dataset of the Plant class/type (instead of String as we did in Lab 4).

"Take picture" button

  • Clicking the "Take Picture" button brings the user to the Camera app for taking a picture.
  • After the picture is taken, the user is returned to the Detail view, and the image is shown in the DetailsView with an ImageView
  • Recall how we started new Activities in Lab 2, use Intents, refer to this material to get started
    • You can use the simpler version of image capture that only returns the thumbnail in Intent Extras, handling the full-size image requires some more work, not needed for this homework. See here

Distinguishing plants that have a Pictures in the list

  • After a picture has been taken and returning back to the list, listed plants that have a picture taken should have a little Icon next to their name, distinguishing whether or not a picture was taken.
    • Hint: achieve this with View Binding of RecyclerViews, and use the thumbnail attribute of the Plant data class. Use the PlantRepository.instance(context).setPlantThumbnail( .. ) helper method to update the in-memory object.

Note: If the app is closed, the state is lost, we are not requiring storing any long-term state.

Submission

Create a sub-folder particularly for this homework (call it homework2), it should contain the source code of your Android Studio project.

  • Create a new Git TAG named homework2 for the last commit related to this homework.
  • Update the .MD file at the root of your repository, so it contains a link to the subfolder of this homework.
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment