A group of exercise projects implementing different areas of native Android development with Kotlin and Jetpack Compose.

Overview

Jetpack Compose Exercises

A group of exercise projects implementing different areas of native Android development with Kotlin and Jetpack Compose. Can help anyone who is just starting to learn Android development with Kotlin.

#1. Basic Navigation

  • Simple navigation between two screens with passing values using Jetpack Compose.
  • Allow entering only letters on the TextField.


#2. Viewmodel Sharing

  • Sharing a View Model between composables inside Jetpack Compose Navigation.
  • Providing a numeric keyboard for number input.
  • Showing number format conditionally based on the floating point digits (0.0 or 0).


#3. Lazy Column Scrolling

  • Display a simple scrollable list using Lazy Column.
  • Loading images from internet using the Coil library.
  • Applying text and background color.


#4. LazyColumn Sync

  • Sync list on a LazyColumn after adding and deleting items.

  • Using TopAppBar, Button with an icon, built-in icons.

  • Filling up the whole remaining space by an UI element.

  • Hiding keyboard on enter press and on button click.

  • Case insensitive check for a word on a list.

  • Make a word sentence case.

  • Allow entering only letters on the TextField.

  • TopAppBar icon change on click (ascending/descending order).

  • Delete items from LazyColumn on click.

  • Show leading icon on TextField.

  • Show trailing icon on TextField based on error.

  • Show separate error message with TextField based on error.

  • FIXME: Strange sorting bug. Keeps the new words separate while sorting.



#5. State Hoisting

  • Implementing state hoisting to manage a list of people and their age.
  • Row click handling by removing the item from a LazyColumn.
  • Input validation (name & age).
  • Replace multiple spaces from an input.
  • Capitalize first character of each word in a sentence.
  • Hiding keyboard on enter press and on button click.
  • Generating unique ID as model field.


#6. LazyVerticalGrid

  • Making a grid layout using the experimental LazyVerticalGrid composable.
  • Column vertical scroll.
  • Using Scaffold with TopAppBar and NavHost.
  • Navigation back button on TopAppBar.
  • Change TopAppBar title dynamically in different screens (using a shared view model).


#7. Image Sources

  • Show user-selected image from the gallery.

  • Show user-entered image from a web URL.

  • TODO: Verify image exists on provided URL before showing.

  • TODO: Show the previous image in case of an non-existing image on the URL.

  • TODO: Display image from the camera when the Camera API from Compose arrives.



#8. Room Basics

  • Add, show, edit, and delete data from a Room database using Jetpack Compose.
  • TextField background color change.
  • Keep only one edit form open at a time.


#9. Room CRUD

  • Scaffold with TopAppBar and FAB.
  • Set title dynamically from different screens by raising event.
  • Turn on/off FAB in different screens by raising event.
  • Show alert dialog to confirm an action.


#10. Retrofit Basics

  • Call an external API using the Retrofit library and get the returned JSON.
  • Handle loading/error/done status of the API call.
  • Use query to filter the results of the API call.
  • Convert JSON to Kotlin object using the Moshi library.
  • Display images from remote URLs using the Coil library.
  • Replace part of a string with a new value.
  • Custom property on a data class.
  • Currency format from number.
  • Get color from hex code.
  • Dropdown menu on TopAppBar (options menu).


#11. Offline Caching

This project demonstrates the offline caching of REST API data in the local database. It fetches earthquake data from the United States Geological Survey department's server using REST API, stores it on the local database, and displays it.

Data is filtered to show only the earthquakes of 4 magnitudes or higher, with a 400 km radius from the Bangladeshi capital Dhaka, in the past 12 months.

Every time the app is opened, it checks for any new earthquake data on the server that is more recent than locally stored. If any new data is found, it fetches all the data, deletes everything from the database, and stores the latest data for displaying. Also sync data once in a day by running a background work using WorkManager.

Takeaways

  • Fetch data from API using the Retrofit library.
  • Convert JSON data to Kotlin objects using the Moshi library.
  • Cache all data from API to local database and display from there.
  • Sync data once in a day by running background work using WorkManager.
  • Date/Time formatting from Unix Epoch (Util.kt).
  • Support java.time API (26+) in legacy projects (21).
  • Splitting string to a list of different parts (Util.kt).
  • Generating background color conditionally (Util.kt).
  • Subtract 1 year from today.
  • Window background (avoid showing the white screen flickering during app loading).
  • Splash screen.


#12. Ad Network

Display AdMob ads on Android apps using Jetpack Compose.

Takeaways

  • Show AdMob traditional banner, adaptive banner, and inline adaptive banner.
  • Show AdMob interstitial ad on button click from a composable.
  • Extension function to get the current activity from any composable.


#13. Notifications

Show different types of notifications using Jetpack Compose.

You might also like...
A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose
A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose

Authentication A simple authentication application using Jetpack compose to illustrate signin and sign up using Mvvm, Kotlin and jetpack compose Scree

Android UI Development with Jetpack Compose, published by Packt
Android UI Development with Jetpack Compose, published by Packt

Android UI Development with Jetpack Compose This is the code repository for Android UI Development with Jetpack Compose, published by Packt. Bring dec

Compose-navigation - Set of utils to help with integrating Jetpack Compose and Jetpack's Navigation

Jetpack Compose Navigation Set of utils to help with integrating Jetpack Compose

Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop 🚀, using Canvas API 🎨
Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop 🚀, using Canvas API 🎨

🐜 🐜 🐜 Compose flocking Ants(boids) 🐜 🐜 🐜 Jetpack compose Boids | Flocking Insect. bird or Fish simulation using Jetpack Compose Desktop 🚀 , usi

A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!
A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

Why Not Compose! A collection of animations, compositions, UIs using Jetpack Compose. You can say Jetpack Compose cookbook or play-ground if you want!

This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.
This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.

JetBMICalculator This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Co

Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose
Jetpack-Compose-Demo - Instagram Profile UI using Jetpack Compose

Jetpack-Compose-Demo Instagram Profile UI using Jetpack Compose

Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose
Jetpack-compose-animations-examples - Cool animations implemented with Jetpack compose

Jetpack-compose-animations-examples This repository consists of 4 animations: St

Jetpack-compose-uis - A collection of some UIs using Jetpack Compose. built using Katalog

Jetpack Compose UIs This is a collection of some UIs using Jetpack Compose. It i

Owner
Raw Hasan
Android Developer | Kotlin | Compose
Raw Hasan
Pinocchio is a group of libraries for various common UI components. It could contain Composable, View, and everything related to UI.

Pinocchio Pinocchio is a group of libraries for various common UI components. It could contain Composable, View, and everything related to UI. All UI

NAVER Z 24 Nov 30, 2022
OTPView is a view made in Jetpack compose. It is highly customisable and can be used to show OTP view with different length and shapes.

OTPView OTPView is a highly costumizable OTP view made in the Jetpack compose UI. Usage: CircleOtpView is a sample composable that calls the OtpView w

kunalsale 17 Aug 4, 2022
PexWallpapers is one of my current projects in Jetpack Compose.

Welcome to PexWallpapers! Hi! PexWallpapers is one of my current projects in Jetpack Compose. The app use Pexels.com image library to showpictures/wal

Adrian Witaszak 89 Dec 6, 2022
📱 WhatsApp clone project demonstrates modern Android development built with Jetpack Compose and Stream Chat SDK for Compose.

This is a WhatsApp clone app built with Jetpack Compose and Stream Chat SDK for Compose. The purpose of this repository is to demonstrate below: Imple

Stream 689 Dec 25, 2022
An android library to highlight different features of the app built using Jetpack Compose.

An android library to highlight different features of the app built using Jetpack Compose.

Canopas Software 230 Dec 23, 2022
A library that you can use in 4 different types toast written with Jetpack Compose

Composable Sweet Toast A library that you can use in 4 different types(Success, Error, Warning, Info) written with Jetpack Compose. You can use this t

Talha Fakıoğlu 67 Dec 19, 2022
A library that you can use in 4 different types(Success, Error, Warning, Info) written with Jetpack Compose.

Composable Sweet Toast A library that you can use in 4 different types(Success, Error, Warning, Info) written with Jetpack Compose. You can use this t

Talha Fakıoğlu 67 Dec 19, 2022
Forget about bunch of XML files for maintaining UIs. Jetpack Compose is Android’s modern toolkit for building native UI. Here is a small example to get started.

Jetpack Compose Sample Description This repository is to get started with new Jetpack Compose Toolkit for Android. By using Jetpack Compose you no nee

Simform Solutions 39 Nov 10, 2022
From Swedish "Öppettider", an app to quickly access your favorite places' opening times. Built to practice Android development and try out Jetpack Compose.

Appettider From Swedish "Öppettider", an app to quickly access your favorite places' opening times. Built to practice Android development and try out

Arianna Masciolini 0 Dec 6, 2021
A Native Andorid App developed in Jetpack Compose MVVM architecture

Astronomy Picture of the Day This is a Native Andorid App developed in Jetpack Compose MVVM architecture, To view the Astronomy Picture of the day fro

Santhosh J 0 Jul 3, 2022