Skip to content
Application Development II
GitLabGitHub

Module 3: Android Development (Version 2)

In this assignment we continue learning techniques in application architecture for the Android stack, in particular navigation and advanced state management. We will also document our progress through codelabs using git/GitHub best practises to keep track of the techiques learned and to practise useful repository management skills.
Overview
A3Overview
Worth:8%
Due:Nov 1
Hand-in:A link to a private GitHub repository, with yourself and me (@michaelhaaf) as collaborators
Notes:Course late penalty applies.

For this assignment, you will pick up two important Jetpack Compose / Android Architecture techniques (Navigation and State/Side-effect management with ViewModel) from the Android compose labs. You will also practise maintaining legible development history using git and GitHub.

Your main deliverable will be a repository containing two Pull Requests documenting your progress on each codelabs. See Requirements.

The actual coding part of this assignment is explained in each codelab, so there are no other instructions as such. Many of the git and GitHub techniques needed for this lab are review for you, but some are not: the Tips section clarifies some of the requirements and gives more detailed instructions.

A previous version of these instructions focused on git submodules — that turned out to be more complicated than worthwhile, sorry about that. Depending on whether you already followed that instruction or not, there are a couple possible ways to easily use your existing progress in the codelabs rather than starting from scratch — see Getting Started for more details about that.

  1. Build on Jetpack Compose knowledge

    • Learn Navigation
    • Learn the View Model and advanced state management in Android Architecture
  2. Practise git/GitHub skills

    • Identify and separate functional commits in development history
    • Manage and manipulate git history to generate pull requests with precise, intentional changes

In essense: the main goals are to learn the technical things about Navigation/ViewModel in Jetpack Compose the labs are trying to teach you, and in documenting that you’ve done so, to learn & practise repo management habits useful for your project milestones— that is, to learn to stop worrying and love git (if you don’t already).

Your submission will be a private GitHub repository, with @michaelhaaf invited as a collaborator, called Assignment 3 (or similar, the name isn’t that important). The rest of the requirements in the marking scheme below are things that should be in that repository by the deadline.

Tentative Marking Scheme

The exact weights may change slightly, but should serve as a guide for the rough proportions for each part of the assignment.

  • (8) A main branch containing your initial code (the two codelab starting points)
  • (18) A development branch called nav-codelab (or similar) tracking your progress through the Navigation Codelab
  • (18) A development branch called advstate-codelab (or similar) tracking your progress through the Advanced State Codelab
  • (18) An open pull request from the nav-codelab branch to main
  • (18) An open pull request from the advstate-codelab branch to main

There are a total of 80 marks available. The rubric details for each requirement follow in the sections below.

  • (2) Repository requirements met (private, @michaelhaaf collaborator, begins as bare repository with only default Initial commit)
  • (2) Android template .gitignore, either included in Initial commit, or added in a subsequent commit immediately after. Don’t forget this step — your subsequent commits will be affected by the presence of this file in an important way.
  • (2) One commit with message title “init NavigationCodelab” containing ONLY the the addition of the NavigationCodelab stater code directory
  • (2) One commit with message title “init AdvancedStateAndSideEffectsCodelab” containing ONLY the the addition of the AdvancedStateAndSideEffectsCodelab starter code directory

Suggestion: This repo should begin as a bare repository with nothing and only yourself and me (@michaelhaaf) as collaborators. Do not fork another branch to begin this repository. See Getting Started for more details, whether you are starting from scratch or you have progress from the previous version of this assignment you want to adapt.

The following requirements apply to both development branches (15 marks for each codelab)

  • (8) Marks for progress on the codelab itself
    • If you finish the whole codelab, you get full marks — partial marks for partial progress.
    • Feel free to make use of the guided solutions provided in the tutorial — make sure you try the steps yourself and understand the accompanying tutorial. Most of the marks are for your commit messages explaining the changes made, as you’ll see below.
  • (10) Marks for quality of commit messages tracking your progress
    • Your commit history should document each functional change required by the labs into separate commits.
    • Commit messages should demonstrate best practises outlined in the git/github lecture notes.

You can see more details/examples of what I’m looking for in the Making precise commits section below.

NOTE: The idea isn’t to get it perfect the first time! One of the goals of this lab is to practise Tailoring commit history so that you can Update Pull Requests with confidence (links go to Tips section below). That is, learning how to use git to rewrite/tweak/edit/squash/create local branch commits before pushing/updating a pull request.

The following requirements apply to both development branches (18 marks for each codelab)

  • (8) Marks for pull request management
    • should be a linear set of commits from the appropriate branch
    • updates to the pull request done directly, rather than creating new pull requests
    • pull request template used for entering codelab progress / answering codelab questions. This should be pushed to main branch after the previous initial commits. Link to sample template
  • (10) Marks for progress on codelab documented/answers to questions about each codelab. See questions below.

The questions are short and aren’t intended to take you too much time — they are there simply to make sure you noticed/understood some foundational concepts from each codelab.

The Pull Request template you are using/adapting is explained in more detail in the Creating a Pull Request template section.

The tips provide below aren’t comprehensive (e.g. there’s no step-by-step instructions for creating the repository) or all strictly necessary (i.e. there’s more than one way to meet the requirements of the assignment stated above) but should serve as a useful guideline for the main tasks.

One of the requirements for the main repository is to create two initial commits adding just the starter code for each project. Both the Navigation and Advanced State starter code comes from the same repository: android codelabs.

There’s a couple ways to go about adding this code to your assignment — one way to do that is shown below.

Terminal window
## Acquire codelab code, either by downloading/extracting the .zip or cloning
git clone https://github.com/android/codelab-android-compose.git
## Copy codelab code to your Assignment3 repository
cp -R codelab-android-compose/NavigationCodelab /path/to/your/a3repository
cp -R codelab-android-compose/AdvancedStateAndSideEffectsCodelab /path/to/your/a3repository
## Initialize your repository history.
## Double check that your repository has a .gitignore committed already before proceeding!
cd /path/to/your/a3repository/
git add NavigationCodelab
## See "Making precise commits" for more detail about the use of two "-m" arguments
git commit -m "init NavigationCodelab" -m "Starter code for NavigationCodeLab from android/codelab-android-compose"
git add AdvancedStateAndSideEffectsCodelab
git commit -m "init AdvancedStateAndSideEffectsCodelab" -m "Starter code for AdvancedStateAndSideEffectsCodelab from android/codelab-android-compose"
## Creating development branches after the starter code is present
git switch -c nav-codelab
## ... navigation codelab commits ready to push
git push --set-upstream origin nav-codelab
Terminal window
## Acquire codelab code, either by downloading/extracting the .zip or cloning
git clone https://github.com/android/codelab-android-compose.git
## Copy codelab code to your Assignment3 repository
cp -R codelab-android-compose/NavigationCodelab /path/to/your/a3repository
cp -R codelab-android-compose/AdvancedStateAndSideEffectsCodelab /path/to/your/a3repository
## Initialize your repository history.
## Double check that your repository has a .gitignore committed already before proceeding!
cd /path/to/your/a3repository/
git add NavigationCodelab
## See "Making precise commits" for more detail about the use of two "-m" arguments
git commit -m "init NavigationCodelab" -m "Starter code for NavigationCodeLab from android/codelab-android-compose"
git add AdvancedStateAndSideEffectsCodelab
git commit -m "init AdvancedStateAndSideEffectsCodelab" -m "Starter code for AdvancedStateAndSideEffectsCodelab from android/codelab-android-compose"
## Creating development branches after the starter code is present
git switch -c nav-codelab
## ... navigation codelab commits ready to push
git push --set-upstream origin nav-codelab

At this point, you’re ready to begin working on your labs! Remember to use your development branches to track your progress. If you accidentally commit to main instead, it’s fixable — as long as you don’t push.

Depending on how much progress you made on the codelabs before Version 2 of the instructions was published, you may also have existing progress on the codelabs you want to use.

The two workflows below were covered in class on Wednesday, Oct 25. They assume you already have the initial repository set up with init commits on main.

The most straightforward way to preserve your existing changes is to simply copy them, overwriting the starter code. The interesting part is then creating discrete commits from the big blob of changes, depending on how much progress you made.

The main tools used:

  • git status / git diff
  • git add --patch / git add -p
  • git rebase --interactive / git rebase -i
Terminal window
## Ensure you are on the correct branch, nav-codelab for example
## (same steps apply for other codelab)
cd /path/to/your/a3repository
git switch nav-codelab
## Copy your codelab code progress, overwriting starter code
cp -R /path/to/your/codelabprogress/NavigationCodelab ./NavigationCodelab
## Double check changes: ensure that ONLY your codelab progress is "unstaged"
## I.e. you should not see a bunch of new files in the diff, just the modifications you made to the starter code
git status
git diff
## *** Begin interactive add workflow: stage one "change" at a time ***
## see "Making precise commits" for more detail
git add /path/to/unstaged/file # if all changes to file are needed
git add -p /path/to/unstaged/file # if only some changes to file are needed
## Double check that only desired changes are staged
git status
git diff --staged
## Commit staged changes. "-m" not recommended, see "Making precise commits" for more detail
git commit
## *** Repeat interactive add workflow until all commits are made ***
## At any time: modify commits using interactive rebase workflow
git rebase -i HEAD~3 # interactive rewrite last 3 commits (4 including HEAD)
Terminal window
## Ensure you are on the correct branch, nav-codelab for example
## (same steps apply for other codelab)
cd /path/to/your/a3repository
git switch nav-codelab
## Copy your codelab code progress, overwriting starter code
cp -R /path/to/your/codelabprogress/NavigationCodelab ./NavigationCodelab
## Double check changes: ensure that ONLY your codelab progress is "unstaged"
## I.e. you should not see a bunch of new files in the diff, just the modifications you made to the starter code
git status
git diff
## *** Begin interactive add workflow: stage one "change" at a time ***
## see "Making precise commits" for more detail
git add /path/to/unstaged/file # if all changes to file are needed
git add -p /path/to/unstaged/file # if only some changes to file are needed
## Double check that only desired changes are staged
git status
git diff --staged
## Commit staged changes. "-m" not recommended, see "Making precise commits" for more detail
git commit
## *** Repeat interactive add workflow until all commits are made ***
## At any time: modify commits using interactive rebase workflow
git rebase -i HEAD~3 # interactive rewrite last 3 commits (4 including HEAD)