atick-faisal / Jetpack-Compose-Starter

Starter code for Android Kotlin Project with Jetpack Compose 🚀🚀🚀
https://atick.dev/Jetpack-Compose-Starter/
Apache License 2.0
54 stars 8 forks source link
android clean-architecture convention-plugin gradle-kotlin-dsl hilt-android jetpack-compose kotlin kotlin-coroutines multimodule mvvm okhttp3 retrofit2 template version-catalog

Jetpack Logo

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 app by Google. Check out the app from the latest Release.

Screenshots

[!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:

[!NOTE] Firebase auth needs setting up 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:

/**
 * 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<Unit>

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

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

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

/**
 * 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<String>): Boolean {
    return permissions.all { hasPermission(it) }
}

Technologies

Architecture

This template follows the official architecture guidance suggested by Google.

Modularization

Modularization

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. After that, run the following from the terminal.

$ ./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.

$ ./gradlew assembleRelease

Qatar University Machine Learning Group