Skip to content

Home

Jetpack Logo

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 * Bluetooth communication using classic and low-energy (upcoming) protocols

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

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

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 Google Cloud 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