Git Product home page Git Product logo

crouton's Introduction

Crouton

Crouton

Context sensitive notifications for Android

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.

Current version: 1.8.3

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.3') {
    // exclusion is not neccessary, 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.google.android</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.3') {
  exclude group: 'com.google.android', module: 'support-v4'
}

###Signing

To sign your artifacts, create a file at the repository root, called gradle.properties that contains:

# makes building faster
org.gradle.daemon true

# only requried for the demo
keyStore=theKeyStoreFileName
storePassword=theStorePassword
keyAlias=theKeyAlias
keyPassword=theKeyPassword

# for uploading to a repository
repositoryUrl=yourRepositoryUrl
sonatypeUser=yourSonatypeUser
sonatypePass=yourSonatypePassword

# if you want to sign the built artifacts
signing.keyId=yourKeyId
signing.password=yourGPGPassword
signing.secretKeyRingFile=/path/to/your/secring

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.

crouton's People

Contributors

keyboardsurfer avatar arturdryomov avatar mattkranzler5 avatar coreform avatar chrisjenx avatar hameno avatar angeldevil avatar ataulm avatar scleriot avatar damianflannery avatar imminent avatar flavioarfaria avatar izzyleung avatar jtietema avatar intrications avatar theelfismike avatar niqo01 avatar writtmeyer avatar gabrielittner avatar morphine9 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.