Crouton


Source link: https://github.com/keyboardsurfer/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.

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:

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.

Resources

A library mimics the circles used in optic forms.

A Circle Progress View with a rotate animation.

Indeterminate Progress is a lightweight custom view with pretty animation.

A support library for VectorDrawable and AnimatedVectorDrawable classes introduced in Lollipop.

A simple SegmentControl Widget.

This library provides an elegant form for credit card entry that can be easily added to a activity or fragment. Regex is used to validate credit card types and a Luhn check is performed on the card numbers.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes