27
Crouton Context sensitive notifications for Android

Crouton

Embed Size (px)

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

Citation preview

Page 1: Crouton

CroutonContext sensitive notifications for Android

Page 2: Crouton

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

Page 3: Crouton

Agenda

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

Page 4: Crouton

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]

Page 5: Crouton

A Crouton is made of bread, like a Toast.

Now what has it to do with Android?

Page 6: Crouton

Context aware alternative to Android's Toast

Now what has it to do with Android?

Page 7: Crouton

Problems with Toast

● Toast is not context aware

Page 8: Crouton

Problems with Toast

● Toast is not context aware

Page 9: Crouton

Problems with Toast

● Toast is not context aware● Styling Toasts

Page 10: Crouton

Problems with Toast

● Toast is not context aware● Styling Toasts

Page 11: Crouton

What does a Crouton look like?

Any way you want

Page 12: Crouton

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

Style.ALERT

Page 13: Crouton

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Page 14: Crouton

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

Page 15: Crouton

What does a Crouton look like?

There are three predefined styles:

Style.INFO

Style.CONFIRM

Style.ALERT

Page 16: Crouton

What does a Crouton look like?

Page 17: Crouton

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

Page 18: Crouton

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();

Page 19: Crouton

Usage within your code

//Cancels all pending Croutons

Crouton.cancelAllCroutons();

//Clear all Croutons for an Activity

Crouton.clearCroutonsForActivity();

Page 20: Crouton

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>

Page 21: Crouton

Getting started

https://github.com/

keyboardsurfer/Crouton/downloads

https://github.com/downloads/

keyboardsurfer/Crouton/crouton-1.4.jar

Page 22: Crouton

Demo App

Page 23: Crouton
Page 24: Crouton

https://github.com/keyboardsurfer/Crouton

Page 25: 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

Page 26: Crouton

Thank you

Page 27: Crouton

Questions

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