Crouton
Context sensitive notifications for Android
Slide 2
Slide 2 text
Benjamin Weiss
http://gplus.to/keyboardsurfer
Twitter: @keyboardsurfer
Senior Software Developer
at ImmobilienScout24
Organizer: GDG Android in Berlin
Co-Organizer:
●
Global Android Dev Camp
●
GTUG Community Weekend
●
Google I/O Extended Berlin 2012
●
DevFest Berlin 2012
Slide 3
Slide 3 text
Agenda
● What is a Crouton?
● Problems with Toast
● What does a Crouton look like?
● Usage
● Getting started
● Sources
Slide 4
Slide 4 text
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]
Slide 5
Slide 5 text
A Crouton is made of bread,
like a Toast.
Now what has it to do with Android?
Slide 6
Slide 6 text
Context aware alternative to
Android's Toast
Now what has it to do with Android?
Slide 7
Slide 7 text
Problems with Toast
● Toast is not context aware
Slide 8
Slide 8 text
Problems with Toast
● Toast is not context aware
Slide 9
Slide 9 text
Problems with Toast
● Toast is not context aware
● Styling Toasts
Slide 10
Slide 10 text
Problems with Toast
● Toast is not context aware
● Styling Toasts
Slide 11
Slide 11 text
What does a Crouton look like?
Any way you want
Slide 12
Slide 12 text
What does a Crouton look like?
There are three predefined styles:
Style.INFO
Style.CONFIRM
Style.ALERT
Slide 13
Slide 13 text
What does a Crouton look like?
There are three predefined styles:
Style.INFO
Slide 14
Slide 14 text
What does a Crouton look like?
There are three predefined styles:
Style.INFO
Style.CONFIRM
Slide 15
Slide 15 text
What does a Crouton look like?
There are three predefined styles:
Style.INFO
Style.CONFIRM
Style.ALERT
Slide 16
Slide 16 text
What does a Crouton look like?
Slide 17
Slide 17 text
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
Slide 18
Slide 18 text
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();
Slide 19
Slide 19 text
Usage within your code
//Cancels all pending Croutons
Crouton.cancelAllCroutons();
//Clear all Croutons for an Activity
Crouton.clearCroutonsForActivity();
Slide 20
Slide 20 text
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
crouton
1.4
de.keyboardsurfer.android.widget
Slide 21
Slide 21 text
Getting started
https://github.com/
keyboardsurfer/Crouton/downloads
https://github.com/downloads/
keyboardsurfer/Crouton/crouton-1.4.jar