Alerts & Toasts for Android, done right.

Android's native Toast API is rigid, unstylable, and constrained by modern OS restrictions. Flare is a lightweight, zero-XML notification library engineered to provide beautiful, responsive banners across both Jetpack Compose and traditional Android Views.

πŸ’‘ Zero-XML Footprint: Flare draws vector icons and progress countdown indicators programmatically, keeping your app binary size extremely lean (< 2KB core size).

Features

🎯

Unified Platform Core

Write your configurations once. UI integrations are completely decoupled, sharing one core state engine.

πŸ”„

Thread-Safe Queue

Queue notifications sequentially or replace active banners instantly with lock-free notification threads.

πŸ–οΈ

Swipe to Dismiss

Fluid, physics-based dragging mechanics. Fling to dismiss or snap back with organic spring bounds.

πŸŒ“

Dynamic Theme Engine

Real-time dark/light mode detection corresponding with system UI modes or user configuration overlays.

Installation

Add the JitPack maven URL inside your root settings.gradle.kts file:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Include the native target dependency inside your module level build.gradle.kts:

dependencies {
    // For Traditional Android XML / View Layouts
    implementation("com.github.RoxyBasicNeedBot.Flare:flare-android:v1.0.7")

    // For Jetpack Compose UI
    implementation("com.github.RoxyBasicNeedBot.Flare:flare-compose:v1.0.7")
}

Quick Start

Launch banners directly from any Activity context using a fluent builder syntax:

import com.roxy.flare.android.Flare
import com.roxy.flare.FlareType
import com.roxy.flare.FlarePosition
import com.roxy.flare.FlareDuration

Flare.with(activity)
    .type(FlareType.SUCCESS)
    .message("Transaction Completed!")
    .position(FlarePosition.TOP)
    .duration(FlareDuration.LONG)
    .showProgressBar(true)
    .action("Undo") {
        performUndo()
    }
    .show()

Wrap your container inside FlareHost and trigger alerts cleanly from coroutine scopes:

import com.roxy.flare.compose.FlareHost
import com.roxy.flare.compose.rememberFlareHostState
import com.roxy.flare.FlareType
import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.launch

@Composable
fun MainScreen() {
    val flareState = rememberFlareHostState()
    val scope = rememberCoroutineScope()

    FlareHost(state = flareState) {
        Button(onClick = {
            scope.launch {
                flareState.show {
                    type = FlareType.ERROR
                    message = "Connection Lost!"
                    action("Retry") {
                        reconnect()
                    }
                }
            }
        }) {
            Text("Show Alert")
        }
    }
}

How It Works

Flare is structured to optimize responsiveness, thread-safety, and UI separation. The lifecycle of a banner flows through three distinct layers:

1. Thread-Safe State Machine

Calling .show() constructs a immutable FlareMessage model and submits it to the global FlareQueue singleton. Operations are guarded internally using a synchronized lock object (stateLock). To prevent callbacks from causing deadlocks in re-entrant threads (such as calling a new show request immediately on dismiss), all callbacks are gathered and dispatched outside the synchronized lock context.

2. DecorView Window Overlay

Rather than dealing with Toast restrictions, flare-android hooks into the active Activity's window DecorView. It applies compensating spacing calculations dynamically utilizing WindowInsetsCompat to wrap around status notches and navigation bars. Activity lifecycle hooks are registered automatically to dismiss active overlays during destruction, guaranteeing zero memory leaks.

3. Compose Pointer Gestures

In Compose layouts, gestures are processed using Modifier.pointerInput velocity trackers. Alert containers adjust horizontal and vertical visual translations relative to touch drag metrics. Dragging beyond 50% width triggers an exit transition, while smaller drags snap the banner back into resting bounds using Compose physics-spring specs.

Configuration Reference

Customize banner layouts using parameters supported in both Views and Jetpack Compose configurations:

Parameter Type Default Behavior
type FlareType INFO Alert presets: SUCCESS, ERROR, WARNING, INFO, LOADING, or CUSTOM.
message String "" Display text contents. Auto-ellipsized after 4 lines.
position FlarePosition BOTTOM Location: TOP (notch offset), BOTTOM (nav offset), CENTER.
duration FlareDuration SHORT Auto-dismiss timer: SHORT (2s), LONG (3.5s), INDEFINITE, or CUSTOM(ms).
showProgressBar Boolean false Enables visual, draining countdown indicator synced to timer.
haptic Boolean true Triggers haptic feedback upon presentation.
animationType FlareAnimationType SLIDE Transitions: SLIDE (spring translation), FADE, BOUNCE.

Deploying to Render via Docker

This documentation portal is containerized for simple one-click deployment on platforms like Render.

Render Setup Instructions

  1. Create a new Web Service on Render.
  2. Connect your GitHub repository containing this project.
  3. Set Environment to Docker.
  4. Set the Docker Context and Dockerfile Path to:
    • Docker Context: . (Root)
    • Dockerfile Path: documentation/Dockerfile
  5. Render will build and deploy the container automatically, serving it on port 5000.

Copyright © 2026, π•½π•Ίπ•π•β€’π”Ήπ•’π•€π•šπ•”β„•π•–π•–π••π”Ήπ• π•₯ ⚑️. Licensed under BSD 3-Clause License.