Context sensitive notifications for Android

Related tags

Toast Crouton
Overview

Crouton

Crouton

Context sensitive notifications for Android

DEPRECATION NOTICE

This library has passed it's prime and is now considered deprecated.

With the Android Design Support Library introducing Snackbar developers get a well crafted pattern to use for context aware notification of users.

I won't do any active development for Crouton any more. But I still do accept pull requests that fix bugs.

So long, and thanks for all the forks.

Overview

Crouton is a class that can be used by Android developers that feel the need for an alternative to the Context insensitive Toast.

A Crouton will be displayed at the position the developer decides. Standard will be the top of an application window. You can line up multiple Croutons for display, that will be shown one after another.

You can check some features in the Crouton Demo.

Crouton Demo on Google Play

If you're already using Crouton and just want to download the latest version of the library, follow this link.

Releases / Changelog

Current version: 1.8.5

Usage

The API is kept as simple as the Toast API:

Create a Crouton for any CharSequence:

Crouton.makeText(Activity, CharSequence, Style).show();

Create a Crouton with a String from your application's resources:

Crouton.makeText(Activity, int, Style).show();

Further you can attach a Crouton to any ViewGroup like this:

Crouton.makeText(Activity, int, Style, int).show();

Crouton.makeText(Activity, int, Style, ViewGroup).show();

Also Crouton.show(...) methods are available for convenient fire and forget display of Croutons.

If you would like a more graphical introduction to Crouton check out this presentation.

##Important!

In your Activity.onDestroy() make sure to call

Crouton.cancelAllCroutons();

to cancel cancel all scheduled Croutons.

This is a workaround and further description is available in issue #24.

Basic Examples

Currently you can use the three different Style attributes displayed below out of the box:

Alert

Confirm

Info

Extension and Modification

The whole design of a Crouton is defined by Style.

You can use one of the styles Crouton ships with: Style.ALERT, Style.CONFIRM and Style.INFO. Or you can create your own Style.

In general you can modify

  • display duration
  • dimension settings
  • options for the text to display
  • custom Views
  • appearance & disappearance Animation
  • displayed Image

Since Style is the general entry point for tweaking Croutons, go and see for yourself what can be done with it.

Building

Gradle

From maven central

Add maven central to your build.gradle:

buildscript {
  repositories {
    mavenCentral()
  }
}
 
repositories {
  mavenCentral()
}

Then declare Crouton within your dependencies:

dependencies {
  ...
  compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
    // exclusion is not necessary, but generally a good idea.
    exclude group: 'com.google.android', module: 'support-v4'
  }
  ...
}

Maven

From maven central

To use crouton within your maven build simply add

<dependency>
  <artifactId>crouton</artifactId>
  <version>${crouton.version}</version>
  <groupId>de.keyboardsurfer.android.widget</groupId>
</dependency>

to your pom.xml

If you also want the sources or javadoc add the respective classifier

  <classifier>sources</classifier>

or

  <classifier>javadoc</classifier>

to the dependency.

If you are referencing a newer version of the Android Support Library in your application, you might want to exclude Crouton's dependency like this:

<dependency>
	<artifactId>crouton</artifactId>
	<version>${crouton.version}</version>
	<groupId>de.keyboardsurfer.android.widget</groupId>
	<exclusions>
	    <exclusion>
	        <groupId>com.android.support</groupId>
	        <artifactId>support-v4</artifactId>
	    </exclusion>
	</exclusions>
</dependency>

DIY

The build requires Gradle. Operations are very simple:

  • install gradle
  • gradle assemble builds all artifacts
  • gradle jar builds the jar

After putting Crouton in a repository you can add it as dependency.

compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
  exclude group: 'com.google.android', module: 'support-v4'
}

###Building and Signing

In order to build and sign Crouton locally you'll need to rename gradle.properties.sample to gradle.properties.

Contribution

###Questions

Questions regarding Crouton can be asked on StackOverflow, using the crouton tag.

Pull requests welcome

Feel free to contribute to Crouton.

Either you found a bug or have created a new and awesome feature, just create a pull request.

If you want to start to create a new feature or have any other questions regarding Crouton, file an issue. I'll try to answer as soon as I find the time.

Please note, if you're working on a pull request, make sure to use the develop branch as your base.

Formatting

For contributors using Eclipse there's a formatter available at the download section.

In order to reduce merging pains on my end, please use this formatter or format your commit in a way similar to it's example.

If you're using IDEA, the Eclipse Formatter plugin should allow you to use the formatter as well.

License

Attributions

The initial version was written by Benjamin Weiss. The name and the idea of Crouton originates in a blog article by Cyril Mottier.

The Crouton logo has been created by Marie Schweiz.

Comments
  • Problem with ListActivity and Crouton

    Problem with ListActivity and Crouton

    I'm actually working on an app and i want to use the Crouton library. So i decide to replace my Toast by this and all is right. Yet, i discover a problem with my ListActivity. I start an activity which needs internet connection so if it is not the case, i display a Crouton.

    And when i display a Crouton i can no longer click on listview items.

    ps : I use it with ActionBarSherlock

    bug 
    opened by aat-antoine 21
  • Action bar overlay?

    Action bar overlay?

    How do you handle repositioning of a crouton when action bar overlay is on?

    I have a weird case where the crouton goes below my action bar. My hacky solution for now is to add a custom view and add top padding when the action bar is visible?

    Is that something that this library doesn't handle automatically? or am I doing something wrong?

    Thanks

    question 
    opened by aryaxt 20
  • Crouton

    Crouton "destroys" PreferenceFragment

    This is how my PreferenceFragment looks like: https://picasaweb.google.com/lh/photo/QbpRCxQHqVATtMqhpP7OPhehlnpMhIUyAwoYnhPIGog?feat=directlink When showing a Crouton: https://picasaweb.google.com/lh/photo/MJwaGoIBiO7NNtpmprypnBehlnpMhIUyAwoYnhPIGog?feat=directlink

    bug 
    opened by gabrielittner 17
  • NoClassDefFoundError

    NoClassDefFoundError

    I'v some problems using your lib, i got a error

    NoClassDefFoundError: de.keyboardsurfer.android.widget.crouton.Style.
    

    I tried the lib with maven and with a jar combiled by gradle, the same error

    I' Downloaded the demo app on Google Play : Same Error on CroutonDemo Class (ICS 4.0.3 Device)

    bug 
    opened by adenaud 15
  • Orientation changes prevent the Crouton queue to be displayed correctly.

    Orientation changes prevent the Crouton queue to be displayed correctly.

    If there are a few Croutons within the queue and the device's orientation changes, all Croutons that have not yet been displayed will not be displayed.

    Also Croutons that get added to the queue will not be displayed until the pre-orientation change queue has been fully processed.

    This issue exists since the initial version of Crouton.

    bug 
    opened by keyboardsurfer 14
  • Gradle error with the latest build tools

    Gradle error with the latest build tools

    With today's update of the build tools, SDK and library-support, Crouton doesn't compile anymore from Maven:

    Error:Module version de.keyboardsurfer.android.widget:crouton:1.8.4 depends on libraries but is not a library itself
    

    I use in my build.gradle file the following:

    compile('de.keyboardsurfer.android.widget:crouton:1.8.4') {
         exclude group: 'com.google.android', module: 'support-v4'
    }
    
    opened by lynfogeek 13
  • Added Configuration - Seperating out duration from style

    Added Configuration - Seperating out duration from style

    Style is too limiting and the wrong name now. It contains aspects which should be available to none styled croutons.

    Configuration file is dependant to Style/CustomView meaning we can set a duration on the Custom views!! Yay!

    Please note, Only look at the last commit. I can cherry pick for you if you would like?

    This now allows Crouton.make(Activity,View,ViewGroup, Config) Or Crouton.make(Activity,View,ViewGroup).setConfiguration(Config.Builder().build()).show()

    And of course added to showText Method so users can define non default config.

    Feel free to ask questions. Or implement the concept slightly differently.

    Commit as follows: Separated out the Non Visual config from Style, Configuration is dependant of how the crouton is displayed.

    Issue being the duration (and potentially other items) should not be tied to the Visual aspect.

    Cherry Picked from upstream & master and merged.

    opened by chrisjenx 13
  • Crashes in L Preview

    Crashes in L Preview

    I know its a preview, but I'd like to make sure our app works in L. And Crouton doesn't seem to right now. Here's the stack trace on attempting to display a Crouton:

    java.lang.UnsupportedOperationException: addContentView does not support content transitions at com.android.internal.policy.impl.PhoneWindow.addContentView(PhoneWindow.java:394) at android.app.Activity.addContentView(Activity.java:2170) at de.keyboardsurfer.android.widget.crouton.Manager.addCroutonToView(Manager.java:216) at de.keyboardsurfer.android.widget.crouton.Manager.handleMessage(Manager.java:164) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5070) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)

    bug 
    opened by roms 12
  • Crouton vs HoloEverywhere

    Crouton vs HoloEverywhere

    When using HoloEverywhere Croutons are displayed on whole screen. This occurs even after changing all references to HoloEverywhere classes.

    My question is just if you haven't tried Croutons on HoloEverywhere. Thx

    opened by MartinRajniak 12
  • Crouton translucent status bar position.

    Crouton translucent status bar position.

    Hello i am using translucent statusbar in my app without using fitsSystemBar. I am using system tint bar lib for adding top padding to android.R.id.content, but Crouton place under actionbar + this padding. This is screenshot

    screenshot_2014-02-06-02-58-01

    opened by mecid 11
  • Does not compile with Gradle

    Does not compile with Gradle

    $ gradle assemble Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties. Deprecated dynamic property: "artifactId" on "project ':crouton-library'", value: "crouton".

    FAILURE: Build failed with an exception.

    • Where: Build file '/Users/code/studio/libraries/Crouton/library/build.gradle' line: 96

    • What went wrong: A problem occurred evaluating project ':crouton-library'.

      No such property: repositoryUrl for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer Possible solutions: repository

    • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

    Total time: 3.749 secs

    enhancement 
    opened by powder366 9
  • How to use Crouton.makeText in AsyncTask

    How to use Crouton.makeText in AsyncTask

    private class TestTask extends AsyncTask<Object, String, Boolean> {
            @Override
            protected Boolean doInBackground(Object... objects) {
                //....
                return true;
            }
    
            @Override
            protected void onPostExecute(Boolean aBoolean) {
                //....
                Crouton.makeText(??, "Some text", Style.ALERT).show();
        }
    
    opened by NMelis 0
  • Crouton Not work when app come background nearly after 2 mins

    Crouton Not work when app come background nearly after 2 mins

    Crouton Not work when app come background nearly after 2 mins. When remove from memory and start again it's work perfect.

    if user come background in 20 seconds it is not problem again work perfect.

    Do you have any idea how can i solve that ?

    opened by kaganbzkrt 2
  • SpannableString or Html tags ?

    SpannableString or Html tags ?

    Hi guys,

    I'm looking for a way to have a text that is mid bold mid italic. It seems impossible at the moment, because there is not method to do that and I can't touch the textview of crouton properly.

    Should I made a PR ?

    opened by adrienrx 2
  • Fixed memory leak in DefaultAnimationsBuilder

    Fixed memory leak in DefaultAnimationsBuilder

    When the animations get run there is a Handler that gets set on the Animation (Animation.mListenerHandler). This Handler holds a reference to the Activity. So caching the animations in a static field causes the Activity to be leaked. The fix was to remove the static fields that were caching the animation. Now the animations are created new each time.

    opened by jferlisi 2
  • memory leak in DefaultAnimationsBuilder.java

    memory leak in DefaultAnimationsBuilder.java

    final class DefaultAnimationsBuilder { private static final long DURATION = 400L; private static Animation slideInDownAnimation; // memory leak, hold on activity private static Animation slideOutUpAnimation; // memory leak, hold on activity ... }

    If you use leakcanary (https://github.com/square/leakcanary), you can detect this memory leak.

    Please check it. Thanks.

    opened by soxunyi 5
Releases(1.8.5)
  • 1.8.5(Jul 17, 2014)

  • 1.8.4(Mar 22, 2014)

  • 1.8.3(Feb 3, 2014)

    Back to Java 1.6 compatibility Allows usage of multiple Gravity attributes (@AngelDevil) Adds setTextColorValue to add colors directly (@AngelDevil)

    Source code(tar.gz)
    Source code(zip)
  • 1.8.2(Jan 13, 2014)

    Building with gradle Now Crouton is available as .jar and .aar file Gravity fixes Translucent ActionBar support Crouton.hide() allows hiding of a crouton directly Using Java 1.7 compatibility

    Source code(tar.gz)
    Source code(zip)
  • 1.8.1(Jul 2, 2013)

  • 1.8(Jul 2, 2013)

    Improves support for custom views Smoothing out animations for multiple line Croutons Cleans up Style Configuration is now available for non-UI information Style only holds UI-relevant information Introduces DURATION_SHORT and DURATION_LONG constants

    Source code(tar.gz)
    Source code(zip)
  • 1.7(Jul 2, 2013)

    Crouton.setOnClickListener(OnClickListener) has been introduced. Infinite display of Crouton is possible via Style.setDuration(Style.DURATION_INFINITE) Via Crouton.hide(Crouton) a Crouton can be hidden.

    Source code(tar.gz)
    Source code(zip)
  • 1.6(Jul 2, 2013)

    Crouton now can be used on any Android device with API level 4+. Changes the package name to de.keyboardsurfer.android.widget Adds possibility to set a custom width Can now be added to any ViewGroup (@coreform) Integration with TalkBack (@coreform) Adds Accessibility features (@coreform) Fixes bug that got Crouton out of sync with reality (@coreform) New LifecycleCallback (@coreform) initializeCroutonView was refactored, to make it easier on the eyes removes redundant initialization within Style.Builder documentation improvments

    Source code(tar.gz)
    Source code(zip)
Owner
Ben Weiss
#AndroidDev
Ben Weiss
An android library for easy implementation of Toasts in Android with easy customisation.

ToastTypeDecore ©️ A library for easy implementation of Toasts in Android with easy customisation. Latest Version : v2.1 Screenshots Success Toast1 Su

Aditya Bavadekar 1 Jul 7, 2022
Android : IamToast Another Toast library for Android

Android : IamToast Another Toast library for Android Warning. toast custom view is deprecated since android 11(R) Setup allprojects { repositories

null 2 Jun 12, 2022
A library that extends the Android toast framework.

SuperToasts Library The SuperToasts library enhances and builds upon the Android Toast class. This library includes support for context sensitive Supe

John Persano 2.7k Dec 29, 2022
An Android Toast replacement, similar to the one seen in the GMail app.

MessageBar An Android Toast replacement, similar to the one seen in the GMail app. Multiple messages can be posted in succession, and each message wil

Simon Vig Therkildsen 555 Nov 25, 2022
🍞 The missing toast library for Android.

Literally Toast ?? A toast library for Android. Usage: ?? Use the LitToast to get lit and show your users a proper toast. LitToast.create(context, "My

David Voiss 229 Nov 25, 2022
Custom toasts with color and icon for Android.

Dynamic Toasts A simple library to display themed toasts with icon and text on Android 2.3 (API 9) and above devices. Since v0.4.0, it uses 26.x.x sup

Pranav Pandey 156 Dec 20, 2022
Android library to create customizable floating animated toasts like in Clash Royale app

FloatingToast-Android An android library to make customisable floating animated toasts Getting Started In your build.gradle dependencies { impleme

Hariprasanth S 96 Dec 30, 2022
Toastie is a customizable Android toast library.

Toastie Getting Started Gradle Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories: Note

Burak Fidan 36 Apr 3, 2021
Android Custom Toast

Super Toast Library Written Purely in Kotlin ❤️ Usual Toast but with super powers!!! ?? A Fully Customised and Customisable Toast. ]( https://android-

null 26 Dec 27, 2022
Android Toast For RTL Applications

RTL-Toast Android library to show Toasts in a pretty RTL way Install Add it in your root build.gradle allprojects { repositories { ... ma

Arash Hatami 15 Nov 16, 2022
Attractive, stylish and customizable toast library for Android.

FabToast min SDK 16 (Jelly Bean 4.1) written in Java To download the demo app for this library from Google Playstore so you can see it in action, clic

Dean Spencer 11 Feb 14, 2022
A tooltip/showcase library for Android re-written in Kotlin.

UglyTooltip Based on another Showcase library. Being kotlinized, customized and refactored.

null 26 Dec 9, 2022
CuteToast is an Material Design Custom Toast for Android | Custom Material Design Toast

CuteToast is an Android Custom Toast library that could be used instead of Default Toast. It does everything as Toast but with some extra spice.

K M Rejowan Ahmmed 12 Dec 17, 2022
Customizable toast message library for Android

Android Custom Toast Message (SnToast) Customizable Toast Message Library For Android Add this in your root build.gradle file allprojects { reposito

null 9 Nov 15, 2021
BiometricAuth - A simple project to show biometric authenticaation in android

BiometricAuth a simple project to show biometric authenticaation in android link

richard ndemo 0 Feb 16, 2022
In-layout notifications. Based on Toast notifications and article by Cyril Mottier (http://android.cyrilmottier.com/?p=773).

Android AppMsg (Crouton) Library Implementation of in-layout notifications. Based on Toast notifications and article The making of Prixing #4: in-layo

Evgeny Shishkin 1.4k Nov 25, 2022
Service exposes sensitive administration APIs to initialize and set lower level of Slurpanize infrastructure

slurpanize-baker Project This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its

Slurpanize by Tetracube RED 0 Nov 25, 2021
Poc-sealed-secrets - An alternative to store sensitive data in the template Secrets Kubernetes an encrypted way

POC Sealed Secrets Overview Proof of concept with the objective of showing an al

Cainã Ferreira da Silva 2 Jan 28, 2022
A command line utility to help you investigate the sensitive data associated with Macie findings.

Macie Finding Data Reveal This project contains a command line utility to help you investigate the sensitive data associated with Macie findings.

AWS Samples 8 Nov 16, 2022
An elegant context-care loading placeholder for Android

FiftyShadesOf An elegant context-care loading placeholder for Android Usage FiftyShadesOf.with(context) .on(view1, view2, view3)

Florent CHAMPIGNY 1.1k Nov 21, 2022