Arvutiteaduse instituut
  1. Kursused
  2. 2021/22 sügis
  3. Mobiiliarvutus ja asjade internet (LTAT.06.009)
EN
Logi sisse

Mobiiliarvutus ja asjade internet 2021/22 sügis

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

Homework 1: Plant Care App

Let's start building an app for browsing & tracking plants (in a greenhouse, in an apartment etc). In this homework, we will focus on a single sub-part of the app - the detailed view of a single plant. Here, the user can see the plant's essential information and write entries about how the plant has been taken care of. This homework has 2 parts:

  1. Implementing an Android app
  2. Conducting experiments with the app and answering questions

You can choose any plant for your solution to fill the content!

Part 1: Plant Care App

  • Create a new project and design a graphical interface with some interactive behavior according to the below requirements.
    • use minSDK API v21
    • Locate your project in a sub-folder within your GitLab repo called homework1

The UI has 2 sections: Plant Information and Plant Care Log

Plant Information Section

  • An ImageView and TextView should be used to show a picture of the plant and it's name
    • ImageView should show a drawable image resource
    • Plant name TextView should have a fontsize larger than the default
  • A "Tips" Button next to the Plant name should open a pop-up Dialog showing additional background information about it, e.g. how to care for it.
    • See Tips below for a hint how to do this

Plant Care Log Section

The user can enter their plant-care activities into an activity log:

  • An EditText should allow user to enter text
  • A LinearLayout will show the text entries the user has entered
    • Make the LinearLayout scrollable by placing it inside a ScrollView!
  • A "Save" Button is used to take the user input and add it to the LinearLayout
    • Hitting Save should add a new TextView to the children of the LinearLayout
  • A Checkbox allows the user enable automatic date prefixes to their plant log entries
    • If enabled, a formatted date (DD/MM/YYYY) is prepended to whatever the user's input was when they hit "Save"
  • A TextView displays the no. of entries currently in the activity log.
  • All of the described Widgets should be laid out using a ConstraintLayout.
  • The Plant Information section should vertically appear above the Plant Care Log part of the UI.
  • Use Margins to create some space between the widgets, elements for a neater look.

Landscape Mode

The Application should define a 2nd resource file of the Activity, for landscape mode.

  • In the landscape version, the Plant Information and Care Log should appear side-by-side (see sample screenshot)
    • Use a vertical Guideline, with a value of 50% to split the layout into two exactly at the middle.
    • Set some constraints to the Guideline to achieve the side-by-side placement

'' When you run your application and rotate the device, the App should switch between the 2 activity layout files!''

Non-Functional Requirements

  • Don't use hardcoded Strings in your XML, instead use String Resources, including String resources with variables ( see tips below). Same goes for UI content in Kotlin (e.g. the plant care tips pop-up text).
  • Update the colors of your application in styles.xml to something non-default.
  • Please note we are not requesting for the data to be saved permanently (i.e. if the log entries are lost after closing the app, this is OK!)

Tips

  • setText() and getText() methods of EditText and TextView are helpful
  • You can add child Views to a LinearLayout programmatically with the .addView( .. ) method
  • To show the Plant Care Tips Pop-up Dialog, you can programmatically display an AlertDialog using AlertDialog.Builder, see here for an example
  • String resources with variables:
    • If you have a string resource such as <string name="greeting">Hello, %1s!</string> , where %1s represents a placeholder for a variable, you can use it in kotlin with: getString(R.strings.greeting, "John") , this will pass the 2nd argument to the placeholder of the sting resource.
  • Optional: You may try using Elevation to adjust how Androids Material Design shows shadows for different UI elements

Part 2 - Observing lifecycle methods

Override the onPause(), onResume(), onStop(), onDestroy() methods as discussed in lecture 2. Write some log statements in them and answer these questions:

  • Which of the methods are called & in which order when:
    • Changing device orientation
    • Hitting the home button and returning to the application
    • Hitting the back button and re-opening the application
  • What happens to the EditText and TextView elements in each of these 3 cases (assuming the user has previously already entered some text into the log, plus something new has been written into the EditText and "Save" has not yet been clicked. )

Write your answers into the Readme.MD of subfolder for this homework on your GitLab.

Submission

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

  • Create a new Git TAG named homework1 for the last commit related to this homework. You can do it with the command-line git utility or from the GitLab web interface.
  • Also, please update the .MD file at the root of your repository, so it contains a link to the subfolder of this homework.
  • Note: Android Studio projects include a .gitignore by default, this should already take care the it, but just in case we are mentioning it - make sure you don't commit cached files or binaries, just the source code. This can happen if for some reason you have deleted the .gitignore.
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused