Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keyboardsurfer/Crouton
Context sensitive notifications for Android
https://github.com/keyboardsurfer/Crouton
Last synced: 3 months ago
JSON representation
Context sensitive notifications for Android
- Host: GitHub
- URL: https://github.com/keyboardsurfer/Crouton
- Owner: keyboardsurfer
- License: apache-2.0
- Created: 2012-08-03T11:04:36.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-09-28T15:29:58.000Z (over 9 years ago)
- Last Synced: 2024-10-14T08:42:39.774Z (3 months ago)
- Language: Java
- Size: 3.75 MB
- Stars: 3,010
- Watchers: 175
- Forks: 666
- Open Issues: 7
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- awesome-android-ui - https://github.com/keyboardsurfer/Crouton
- awesome-android-ui - https://github.com/keyboardsurfer/Crouton
README
# Crouton
![Crouton](https://raw.github.com/keyboardsurfer/Crouton/master/sample/src/main/res/drawable-xhdpi/ic_launcher.png "Crouton logo")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](http://android-developers.blogspot.co.uk/2015/05/android-design-support-library.html)
introducing [Snackbar](https://developer.android.com/reference/android/support/design/widget/Snackbar.html) 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](http://developer.android.com/reference/android/widget/Toast.html)**.
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.
If you're already using Crouton and just want to download the latest version of the library, follow [this link](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22de.keyboardsurfer.android.widget%22).
## [Releases / Changelog](https://github.com/keyboardsurfer/Crouton/releases)
### 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](https://speakerdeck.com/keyboardsurfer/crouton-devfest-berlin-2012).
##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](https://github.com/keyboardsurfer/Crouton/issues/24).
## Basic Examples
Currently you can use the three different Style attributes displayed below out of the box:![Alert](https://github.com/keyboardsurfer/Crouton/raw/master/res/Alert.png "Example of Style.ALERT")
![Confirm](https://github.com/keyboardsurfer/Crouton/raw/master/res/Confirm.png "Example of Style.CONFIRM")
![Info](https://github.com/keyboardsurfer/Crouton/raw/master/res/Info.png "Example of Style.INFO")
## Extension and Modification
The whole design of a Crouton is defined by [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java).
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 ImageSince [Style](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/main/java/de/keyboardsurfer/android/widget/crouton/Style.java) 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`:
```groovy
buildscript {
repositories {
mavenCentral()
}
}
repositories {
mavenCentral()
}
```Then declare Crouton within your dependencies:
```groovy
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
```xml
crouton
${crouton.version}
de.keyboardsurfer.android.widget```
to your pom.xml
If you also want the sources or javadoc add the respective classifier
```xml
sources
```or
```xml
javadoc
```
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:
```xml
crouton
${crouton.version}
de.keyboardsurfer.android.widget
com.android.support
support-v4
```
### DIY
The build requires Gradle. Operations are very simple:
* install [gradle](http://www.gradle.org/)
* `gradle assemble` builds all artifacts
* `gradle jar` builds the jarAfter putting Crouton in a repository you can add it as dependency.
```groovy
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](http://stackoverflow.com/questions/tagged/crouton).
### 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](https://github.com/keyboardsurfer/Crouton/issues/new).
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](https://github.com/keyboardsurfer/Crouton/tree/develop) as your base.
### Formatting
For contributors using Eclipse there's a formatter available at the [download section](https://github.com/downloads/keyboardsurfer/Crouton/Crouton_Eclipseformatter.xml).
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
* [Apache Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
## Attributions
The initial version was written by Benjamin Weiss.
The name and the idea of [Crouton](https://github.com/keyboardsurfer/Crouton/blob/master/library/src/de/keyboardsurfer/android/widget/crouton/Crouton.java) originates in a [blog article](http://android.cyrilmottier.com/?p=773) by Cyril Mottier.The Crouton logo has been created by [Marie Schweiz](http://marie-schweiz.de).