Crouton

Post on 22-May-2015

561 views 0 download

Tags:

description

Slides for the talk on Crouton at the 2012 Berlin DevFest. The whole talk also is available as a video here: http://vimeo.com/51356663

Transcript of Crouton

CroutonContext sensitive notifications for Android

Benjamin Weisshttp://gplus.to/keyboardsurferTwitter: @keyboardsurfer

Senior Software Developerat ImmobilienScout24

Organizer: GDG Android in Berlin

Co-Organizer:● Global Android Dev Camp● GTUG Community Weekend● Google I/O Extended Berlin 2012● DevFest Berlin 2012

Agenda

● What is a Crouton?● Problems with Toast● What does a Crouton look like?● Usage● Getting started● Sources

What is a Crouton

"A crouton is a piece of sautéed or rebaked bread, often cubed and seasoned, that is used to add texture and flavor to salads [...] as an accompaniment to soups, or eaten as a snack food.

The word crouton is derived from the French [...] meaning "crust"." [1]

A Crouton is made of bread, like a Toast.

Now what has it to do with Android?

Context aware alternative to Android's Toast

Now what has it to do with Android?

Problems with Toast

● Toast is not context aware

Problems with Toast

● Toast is not context aware

Problems with Toast

● Toast is not context aware● Styling Toasts

Problems with Toast

● Toast is not context aware● Styling Toasts

What does a Crouton look like?

Any way you want

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

Style.ALERT

What does a Crouton look like?

There are three predefined styles:

Style.INFO

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

Style.ALERT

What does a Crouton look like?

What does a Crouton look like?

Any way you want

new Style.Builder()

.setDuration(int) //in milliseconds

.setTextColor(int) //resId

.setBackgroundDrawable(Drawable) //background drawable

.setBackgroundColor(int) //resource id

.setTileEnabled(boolean) //whether the image should be tiled

.setHeight(int) // WRAP_CONTENT or MATCH_PARENT

.setImageResource(int) //resId

.setTextShadowRadius(float) //shadow radius

.setGravity(int) //one of the Gravity constants

.setTextAppearance(int) //resId

.setInAnimation(Animation) //in animation

// more options

.build(); //creates the Style

Usage within your code

//Crouton with String

Crouton.

makeText(this, "Hello Crouton", Style.INFO).

show();

//Crouton with text resource

Crouton.

makeText(this, R.string.hello, Style.INFO).

show();

Usage within your code

//Cancels all pending Croutons

Crouton.cancelAllCroutons();

//Clear all Croutons for an Activity

Crouton.clearCroutonsForActivity();

Getting started

# clones Crouton to your machine

git clone git://github.com/keyboardsurfer/Crouton.git

# will install Crouton to your local maven repository

cd library && mvn install

<!--include this in your pom.xml's dependency section-->

<dependency>

<artifactId>crouton</artifactId>

<version>1.4</version>

<groupId>de.keyboardsurfer.android.widget</groupId>

</dependency>

Getting started

https://github.com/

keyboardsurfer/Crouton/downloads

https://github.com/downloads/

keyboardsurfer/Crouton/crouton-1.4.jar

Demo App

https://github.com/keyboardsurfer/Crouton

Sources

[1] https://en.wikipedia.org/wiki/Crouton

[2] http://android.cyrilmottier.com/?p=773

[3] https://github.com/keyboardsurfer/Crouton

[4] http://marie-schweiz.de

Thank you

Questions

Benjamin Weisshttp://gplus.to/keyboardsurferTwitter: @keyboardsurfer