Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/atick-faisal/Jetpack-Compose-Starter

Starter code for Android Kotlin Project with Jetpack Compose 🚀🚀🚀
https://github.com/atick-faisal/Jetpack-Compose-Starter

android clean-architecture convention-plugin gradle-kotlin-dsl hilt-android jetpack-compose kotlin kotlin-coroutines multimodule mvvm okhttp3 retrofit2 template version-catalog

Last synced: 9 days ago
JSON representation

Starter code for Android Kotlin Project with Jetpack Compose 🚀🚀🚀

Awesome Lists containing this project

README

        

![Jetpack Logo](https://github.com/atick-faisal/Jetpack-Compose-Starter/assets/38709932/6d8f68ad-3045-4736-99ed-86c1593f1241)






## What is it

It's a starting template that I use for all my Android apps. It is based on the architecture of the [Now In Android](https://github.com/android/nowinandroid) app by Google. Check out the app from the latest [Release](https://github.com/atick-faisal/Jetpack-Compose-Starter/releases).

![Screenshots](https://github.com/atick-faisal/Jetpack-Compose-Starter/blob/main/assets/ss.png)

> [!WARNING]
> Firebase authentication and crashlytics requires Firebase console setup and the `google-services.json` file. I have provided a template to ensure a successful build. However, you need to provide your own in order to use all the functionalities.

## Documentation







Read The Documentation Here

## Features

This template offers Modern Android Development principles and Architecture guidelines. It provides an out-of-the-box template for:

- Connecting to a remote API using Retrofit and OKHttp
- Persistent database solution using Room and Datastore
- Sign In Authentication using Firebase i.e. Google ID and Email
- Bluetooth communication using classic and low-energy (upcoming) protocols

> [!NOTE]
> Firebase auth needs [setting up](https://developers.google.com/android/guides/client-auth?sjid=11391664450238405928-EU) first using the SHA fingerprint. Get the SHA fingerprint of the app and add it to firebase console.

It contains easy-to-use Interfaces for common tasks. For example, the following provides utilities for Bluetooth communication:

```kotlin
/**
* BluetoothManager interface provides methods to manage Bluetooth connections.
*/
interface BluetoothManager {
/**
* Attempts to establish a Bluetooth connection with the specified device address.
*
* @param address The address of the Bluetooth device to connect to.
* @return A [Result] indicating the success or failure of the connection attempt.
*/
suspend fun connect(address: String): Result

/**
* Returns the state of the connected Bluetooth device.
*
* @return A [StateFlow] emitting the current state of the connected Bluetooth device.
*/
fun getConnectedDeviceState(): StateFlow

/**
* Closes the existing Bluetooth connection.
*
* @return A [Result] indicating the success or failure of closing the connection.
*/
suspend fun closeConnection(): Result
}
```

It also contains several utilities and extension functions to make repetitive tasks easier. For example:

```kotlin
/**
* Displays a short toast message.
*
* @param message The message to be displayed in the toast.
*/
fun Context.showToast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}

/**
* Checks if the app has a given permission.
*
* @param permission The permission to check.
* @return `true` if the permission is granted, `false` otherwise.
*/
fun Context.hasPermission(permission: String): Boolean {
return ContextCompat.checkSelfPermission(this, permission) ==
PackageManager.PERMISSION_GRANTED
}

/**
* Checks if all the given permissions are granted.
*
* @param permissions List of permissions to check.
* @return `true` if all permissions are granted, `false` otherwise.
*/
fun Context.isAllPermissionsGranted(permissions: List): Boolean {
return permissions.all { hasPermission(it) }
}
```

## Technologies

- Kotlin 2.0
- Jetpack Compose
- Kotlin Coroutines
- Kotlin Flow for Reactive Data
- Retrofit and OkHttp
- Firebase Auth
- Firebase Crashlytics
- Room Database
- Preferences Datastore
- Dependency Injection with Hilt
- Gradle Kotlin DSL
- Gradle Version Catalog
- Convention Plugin

## Architecture

This template follows the [official architecture guidance](https://developer.android.com/topic/architecture) suggested by Google.

## Modularization

![Modularization](https://github.com/atick-faisal/Jetpack-Compose-Starter/blob/main/assets/modularization.svg)

## Building

### Debug

This project requires Firebase for analytics. Building the app requires `google-services.json` to be present inside the `app` dir. This file can be generated from the [Firebase Console](https://firebase.google.com/docs/android/setup). After that, run the following from the terminal.

```sh
$ ./gradlew assembleDebug
```

Or, use `Build > Rebuild Project`.

### Release

Building the `release` version requires a `Keystore` file in the `app` dir. Also, a `keystore.properties` file needs to be created in the `rootDir`.

```
storePassword=****
keyPassword=*****
keyAlias=****
storeFile=keystore file name (e.g., key.jks)
```

After that, run the following from the terminal.

```sh
$ ./gradlew assembleRelease
```


Qatar University Machine Learning Group