Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Crouton DevFest Berlin 2012

Crouton DevFest Berlin 2012

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

Benjamin Weiss

October 13, 2012
Tweet

More Decks by Benjamin Weiss

Other Decks in Technology

Transcript

  1. Crouton
    Context sensitive notifications for Android

    View Slide

  2. 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

    View Slide

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

    View Slide

  4. 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]

    View Slide

  5. A Crouton is made of bread,
    like a Toast.
    Now what has it to do with Android?

    View Slide

  6. Context aware alternative to
    Android's Toast
    Now what has it to do with Android?

    View Slide

  7. Problems with Toast
    ● Toast is not context aware

    View Slide

  8. Problems with Toast
    ● Toast is not context aware

    View Slide

  9. Problems with Toast
    ● Toast is not context aware
    ● Styling Toasts

    View Slide

  10. Problems with Toast
    ● Toast is not context aware
    ● Styling Toasts

    View Slide

  11. What does a Crouton look like?
    Any way you want

    View Slide

  12. What does a Crouton look like?
    There are three predefined styles:
    Style.INFO
    Style.CONFIRM
    Style.ALERT

    View Slide

  13. What does a Crouton look like?
    There are three predefined styles:
    Style.INFO

    View Slide

  14. What does a Crouton look like?
    There are three predefined styles:
    Style.INFO
    Style.CONFIRM

    View Slide

  15. What does a Crouton look like?
    There are three predefined styles:
    Style.INFO
    Style.CONFIRM
    Style.ALERT

    View Slide

  16. What does a Crouton look like?

    View Slide

  17. 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

    View Slide

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

    View Slide

  19. Usage within your code
    //Cancels all pending Croutons
    Crouton.cancelAllCroutons();
    //Clear all Croutons for an Activity
    Crouton.clearCroutonsForActivity();

    View Slide

  20. 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

    View Slide

  21. Getting started
    https://github.com/
    keyboardsurfer/Crouton/downloads
    https://github.com/downloads/
    keyboardsurfer/Crouton/crouton-1.4.jar

    View Slide

  22. Demo App

    View Slide

  23. View Slide

  24. https://github.com/keyboardsurfer/Crouton

    View Slide

  25. 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

    View Slide

  26. Thank you

    View Slide

  27. Questions
    Benjamin Weiss
    http://gplus.to/keyboardsurfer
    Twitter: @keyboardsurfer

    View Slide