Convert Figma logo to code with AI

Tapadoo logoAlerter

An Android Alerting Library

5,520
632
5,520
48

Top Related Projects

[Moved to MavenCentral] An Android library that takes the standard toast to the next level with many styling options. Works on all Android versions.

6,570

The usual Toast, but with steroids 💪

Make your native android Toasts Fancy. A library that takes the standard Android toast to the next level with a variety of styling options. Style your toast from code.

Quick Overview

Alerter is an Android library for creating customizable alert views that appear from the top of the screen. It provides a more flexible and visually appealing alternative to traditional Toast messages or Snackbars, allowing developers to easily add eye-catching notifications to their Android applications.

Pros

  • Highly customizable appearance and behavior
  • Easy to implement with a fluent API
  • Supports custom layouts and animations
  • Lightweight and doesn't require many dependencies

Cons

  • Limited to top-of-screen alerts by default
  • May not fit well with Material Design guidelines in some cases
  • Requires additional setup compared to built-in Android notifications
  • Limited documentation for advanced use cases

Code Examples

Creating a basic alert:

Alerter.create(this)
    .setTitle("Alert Title")
    .setText("This is the alert message")
    .show()

Customizing the alert appearance:

Alerter.create(this)
    .setTitle("Customized Alert")
    .setText("This alert has custom colors")
    .setBackgroundColorRes(R.color.colorAccent)
    .setIcon(R.drawable.ic_custom_icon)
    .setDuration(5000)
    .enableSwipeToDismiss()
    .show()

Adding a click listener to the alert:

Alerter.create(this)
    .setTitle("Clickable Alert")
    .setText("Click me to perform an action")
    .setOnClickListener { view ->
        Toast.makeText(this, "Alert clicked!", Toast.LENGTH_SHORT).show()
    }
    .show()

Getting Started

  1. Add the JitPack repository to your project's build.gradle file:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle file:
dependencies {
    implementation 'com.github.Tapadoo:Alerter:7.2.4'
}
  1. Sync your project, and you're ready to use Alerter in your Android app!

Competitor Comparisons

[Moved to MavenCentral] An Android library that takes the standard toast to the next level with many styling options. Works on all Android versions.

Pros of StyleableToast

  • Lightweight and focused specifically on customizable toast messages
  • Offers extensive styling options for toasts, including icons, fonts, and animations
  • Easy to implement with a simple, fluent API

Cons of StyleableToast

  • Limited to toast notifications, lacking the versatility of Alerter's various alert types
  • Does not support action buttons or callbacks, which Alerter provides
  • May require more custom styling work to achieve complex designs

Code Comparison

StyleableToast:

StyleableToast.makeText(context, "Hello World!", R.style.myToast).show()

Alerter:

Alerter.create(this)
    .setTitle("Alert Title")
    .setText("Alert text...")
    .show()

Summary

StyleableToast excels in creating highly customizable toast notifications with a simple API, making it ideal for projects that require unique toast designs. However, it lacks the versatility and advanced features of Alerter, such as action buttons and different alert types. Alerter provides a more comprehensive solution for in-app notifications but may be overkill for projects only needing toast-style messages. The choice between the two depends on the specific requirements of the project and the desired level of customization for notifications.

6,570

The usual Toast, but with steroids 💪

Pros of Toasty

  • Lightweight and simple to implement
  • Offers customizable icons and colors
  • Supports chained methods for easy configuration

Cons of Toasty

  • Limited to toast-style notifications
  • Less flexible in terms of positioning and animation options
  • Fewer customization options for overall appearance

Code Comparison

Toasty:

Toasty.success(context, "Success!", Toast.LENGTH_SHORT, true).show()

Alerter:

Alerter.create(this)
    .setTitle("Alert Title")
    .setText("Alert text...")
    .show()

Summary

Toasty is a lightweight library focused on enhancing Android's built-in toast notifications with additional styling options. It's easy to implement and offers quick customization for icons and colors. However, it's limited to toast-style notifications and doesn't provide as much flexibility in terms of positioning and animations as Alerter.

Alerter, on the other hand, provides more comprehensive alert functionality with a wider range of customization options. It allows for in-app alerts that can be positioned at the top of the screen and offers more advanced features like swipe-to-dismiss and custom layouts. While it may require more setup, Alerter provides greater flexibility for creating visually appealing and interactive alerts.

Make your native android Toasts Fancy. A library that takes the standard Android toast to the next level with a variety of styling options. Style your toast from code.

Pros of FancyToast-Android

  • Offers a wider variety of pre-defined toast styles (success, error, warning, etc.)
  • Simpler implementation for basic use cases
  • Allows for custom icons in toasts

Cons of FancyToast-Android

  • Less customizable in terms of layout and animation
  • Limited to toast-style notifications, not as versatile for different types of alerts
  • Fewer options for controlling duration and positioning

Code Comparison

FancyToast-Android:

FancyToast.makeText(this, "Hello World!", FancyToast.LENGTH_LONG, FancyToast.SUCCESS, true).show();

Alerter:

Alerter.create(this)
    .setTitle("Alert Title")
    .setText("Alert text...")
    .setDuration(5000)
    .setBackgroundColorRes(R.color.colorAccent)
    .show();

FancyToast-Android provides a more concise way to create and show toasts with predefined styles, while Alerter offers more customization options but requires a slightly more verbose implementation.

Both libraries serve different purposes: FancyToast-Android focuses on enhancing the standard Android toast, while Alerter provides a more comprehensive alert system with additional features like progress bars and custom layouts.

Choose FancyToast-Android for quick, stylish toasts with minimal setup. Opt for Alerter when you need more complex, customizable alerts that can persist on screen and offer interactive elements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Alerter - An Android Alerter Library, now in Kotlin!

This library aims to overcome the limitations of Toasts and Snackbars, while reducing the complexity of your layouts.

API Android Arsenal Android Weekly

Header

General

With simplicity in mind, the Alerter employs the builder pattern to facilitate easy integration into any app. A customisable Alert View is dynamically added to the Decor View of the Window, overlaying all content.

Install

Include the JitPack.io Maven repo in your project's build.gradle file

allprojects {
 repositories {
    maven { url "https://jitpack.io" }
 }
}

Then add this dependency to your app's build.gradle file

dependencies {
    implementation 'com.github.tapadoo:alerter:$current-version'
}

Usage

Default Alert

From an Activity -

Alerter.create(this@DemoActivity)
       .setTitle("Alert Title")
       .setText("Alert text...")
       .show()

Or from a Fragment -

Alerter.create(activity)
       .setTitle("Alert Title")
       .setText("Alert text...")
       .show()

To check if an alert is showing -

Alerter.isShowing()

To hide a currently showing Alert -

Alerter.hide()

Customisation

Background Colour

Alerter.create(this@DemoActivity)
       .setTitle("Alert Title")
       .setText("Alert text...")
       .setBackgroundColorRes(R.color.colorAccent) // or setBackgroundColorInt(Color.CYAN)
       .show()

Coloured Alert

Icon

Alerter.create(this@DemoActivity)
       .setText("Alert text...")
       .setIcon(R.drawable.alerter_ic_mail_outline)
       .setIconColorFilter(0) // Optional - Removes white tint
       .setIconSize(R.dimen.custom_icon_size) // Optional - default is 38dp
       .show()

Custom Icon Alert

On screen duration, in milliseconds

Alerter.create(this@DemoActivity)
       .setTitle("Alert Title")
       .setText("Alert text...")
       .setDuration(10000)
       .show()

Without title

Alerter.create(this@DemoActivity)
       .setText("Alert text...")
       .show()

Text Only Alert

Adding an On Click Listener

 Alerter.create(this@DemoActivity)
        .setTitle("Alert Title")
        .setText("Alert text...")
        .setDuration(10000)
        .setOnClickListener(View.OnClickListener {
            Toast.makeText(this@DemoActivity, "OnClick Called", Toast.LENGTH_LONG).show();
        })
        .show()

On Click Alert

Verbose text

 Alerter.create(this@DemoActivity)
        .setTitle("Alert Title")
        .setText("The alert scales to accommodate larger bodies of text. " +
                 "The alert scales to accommodate larger bodies of text. " +
                 "The alert scales to accommodate larger bodies of text.")
        .show()

Verbose Alert

Custom Enter/Exit Animations

  Alerter.create(this@KotlinDemoActivity)
         .setTitle("Alert Title")
         .setText("Alert text...")
         .setEnterAnimation(R.anim.alerter_slide_in_from_left)
         .setExitAnimation(R.anim.alerter_slide_out_to_right)
         .show()

Visibility Callbacks

 Alerter.create(this@KotlinDemoActivity)
        .setTitle("Alert Title")
        .setText("Alert text...")
        .setDuration(10000)
        .setOnShowListener(OnShowAlertListener {
            Toast.makeText(this@KotlinDemoActivity, "Show Alert", Toast.LENGTH_LONG).show()
        })
        .setOnHideListener(OnHideAlertListener {
            Toast.makeText(this@KotlinDemoActivity, "Hide Alert", Toast.LENGTH_LONG).show()
        })
        .show()

Custom Fonts and Text Appearance

 Alerter.create(this@DemoActivity)
        .setTitle("Alert Title")
        .setTitleAppearance(R.style.AlertTextAppearance_Title)
        .setTitleTypeface(Typeface.createFromAsset(getAssets(), "Pacifico-Regular.ttf"))
        .setText("Alert text...")
        .setTextAppearance(R.style.AlertTextAppearance_Text)
        .setTextTypeface(Typeface.createFromAsset(getAssets(), "ScopeOne-Regular.ttf"))
        .show()

Verbose Alert

Swipe to Dismiss

 Alerter.create(this@DemoActivity)
        .setTitle("Alert Title")
        .setText("Alert text...")
        .enableSwipeToDismiss()
        .show()

Verbose Alert

Progress Bar

 Alerter.create(this@DemoActivity)
        .setTitle("Alert Title")
        .setText("Alert text...")
        .enableProgress(true)
        .setProgressColorRes(R.color.colorAccent)
        .show()

Verbose Alert

With Buttons

 Alerter.create(this@KotlinDemoActivity)
        .setTitle(R.string.title_activity_example)
        .setText("Alert text...")
        .addButton("Okay", R.style.AlertButton, View.OnClickListener {
            Toast.makeText(this@KotlinDemoActivity, "Okay Clicked", Toast.LENGTH_LONG).show()
        })
        .addButton("No", R.style.AlertButton, View.OnClickListener {
            Toast.makeText(this@KotlinDemoActivity, "No Clicked", Toast.LENGTH_LONG).show()
        })
        .show()

Verbose Alert

With Custom Layout

 Alerter.create(this@KotlinDemoActivity, R.layout.custom_layout)
        .setBackgroundColorRes(R.color.colorAccent)
        .also { alerter ->
            val tvCustomView = alerter.getLayoutContainer()?.tvCustomLayout
            tvCustomView?.setText(R.string.with_custom_layout)
        }
        .show()

Verbose Alert

Contributing & Reporting Issues

Please read this if you're reporting an issue, or thinking of contributing!

Licence

See the LICENSE file for license rights and limitations (MIT).

Copyright 2017 Tapadoo, Dublin.