├── .gitignore ├── README.md ├── app ├── build.gradle ├── libs │ └── crouton-1.8.3.jar └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── codepath │ │ └── example │ │ └── croutondemo │ │ └── CroutonMessageActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── drawable │ └── ic_info.png │ ├── layout │ ├── activity_crouton_message.xml │ └── custom_crouton_layout.xml │ ├── menu │ └── crouton_message.xml │ ├── values-sw600dp │ └── dimens.xml │ ├── values-sw720dp-land │ └── dimens.xml │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Source: https://gist.github.com/nesquena/5617544/raw/53710b374e7df3302df43b552488d876040ada3d/.gitignore 2 | 3 | # built application files 4 | *.apk 5 | *.ap_ 6 | 7 | # files for the dex VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # generated files 14 | bin/ 15 | gen/ 16 | 17 | # Local configuration file (sdk path, etc) 18 | local.properties 19 | 20 | # Eclipse project files 21 | .classpath 22 | .project 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | proguard-project.txt 27 | 28 | # Intellij project files 29 | *.iml 30 | *.ipr 31 | *.iws 32 | .idea/ 33 | 34 | *.pydevproject 35 | .project 36 | .metadata 37 | bin/** 38 | tmp/** 39 | tmp/**/* 40 | *.tmp 41 | *.bak 42 | *.swp 43 | *~.nib 44 | local.properties 45 | .classpath 46 | .settings/ 47 | .loadpath 48 | 49 | # External tool builders 50 | .externalToolBuilders/ 51 | 52 | # Locally stored "Eclipse launch configurations" 53 | *.launch 54 | 55 | # CDT-specific 56 | .cproject 57 | 58 | # PDT-specific 59 | .buildpath 60 | 61 | # Android Studio project files 62 | *.iml 63 | .gradle 64 | .idea 65 | build 66 | import-summary.txt 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Crouton Sample Code 2 | 3 | Displays the use of the [Crouton](https://github.com/keyboardsurfer/Crouton) library with three use cases: 4 | 5 | * Basic preset crouton 6 | * Styled crouton 7 | * Custom view crouton 8 | 9 | Demo: 10 | 11 | 12 | 13 | Screens: 14 | 15 |   16 | 17 | 18 | See [this tutorial](http://www.grokkingandroid.com/useful-android-libraries-crouton/) for more details. 19 | 20 | ## Quick Usage 21 | 22 | Show simple text crouton alert based on string resource: 23 | 24 | ```java 25 | Crouton.showText(this, R.string.simple_text_message, Style.INFO); 26 | ``` 27 | 28 | Show styled text crouton alert: 29 | 30 | ```java 31 | // Define configuration options 32 | Configuration croutonConfiguration = new Configuration.Builder() 33 | .setDuration(2500).build(); 34 | // Define custom styles for crouton 35 | Style style = new Style.Builder() 36 | .setBackgroundColorValue(Color.parseColor("#daffc0")) 37 | .setGravity(Gravity.CENTER_HORIZONTAL) 38 | .setConfiguration(croutonConfiguration) 39 | .setHeight(150) 40 | .setTextColorValue(Color.parseColor("#323a2c")).build(); 41 | // Display notice with custom style and configuration 42 | Crouton.showText(this, R.string.styled_text_message, style); 43 | ``` 44 | 45 | Show custom crouton alert: 46 | 47 | ```java 48 | // Inflate any custom view 49 | View customView = getLayoutInflater().inflate(R.layout.custom_crouton_layout, null); 50 | // Display the view just by calling "show" 51 | Crouton.show(this, customView); 52 | ``` 53 | 54 | and `res/layout/custom_crouton_layout.xml` with the content for the notice: 55 | 56 | ```xml 57 | 58 | 67 | 68 | 72 | 73 | 78 | 79 | 86 | 87 | 96 | 97 | 98 | 99 | 100 | ``` 101 | 102 | That's it! 103 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.codepath.example.croutondemo" 9 | minSdkVersion 8 10 | targetSdkVersion 18 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile 'com.android.support:support-v4:19.1.0' 23 | compile files('libs/crouton-1.8.3.jar') 24 | } 25 | -------------------------------------------------------------------------------- /app/libs/crouton-1.8.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/libs/crouton-1.8.3.jar -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/codepath/example/croutondemo/CroutonMessageActivity.java: -------------------------------------------------------------------------------- 1 | package com.codepath.example.croutondemo; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import android.view.Gravity; 7 | import android.view.LayoutInflater; 8 | import android.view.Menu; 9 | import android.view.View; 10 | import de.keyboardsurfer.android.widget.crouton.Configuration; 11 | import de.keyboardsurfer.android.widget.crouton.Crouton; 12 | import de.keyboardsurfer.android.widget.crouton.Style; 13 | 14 | public class CroutonMessageActivity extends Activity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_crouton_message); 20 | } 21 | 22 | @Override 23 | public boolean onCreateOptionsMenu(Menu menu) { 24 | // Inflate the menu; this adds items to the action bar if it is present. 25 | getMenuInflater().inflate(R.menu.crouton_message, menu); 26 | return true; 27 | } 28 | 29 | public void onSimpleNotice(View v) { 30 | Crouton.showText(this, R.string.simple_text_message, Style.INFO); 31 | } 32 | 33 | public void onStyledNotice(View v) { 34 | Configuration croutonConfiguration = new Configuration.Builder().setDuration(2500).build(); 35 | Style style = new Style.Builder() 36 | .setBackgroundColorValue(Color.parseColor("#daffc0")) 37 | .setGravity(Gravity.CENTER_HORIZONTAL) 38 | .setConfiguration(croutonConfiguration) 39 | .setHeight(150) 40 | .setTextColorValue(Color.parseColor("#323a2c")).build(); 41 | Crouton.showText(this, R.string.styled_text_message, style); 42 | } 43 | 44 | public void onCustomNotice(View v) { 45 | View customView = getLayoutInflater().inflate(R.layout.custom_crouton_layout, null); 46 | Crouton.show(this, customView); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codepath/android-crouton-sample/18abb8c724ed2688838eef98c2283ccbb48cc251/app/src/main/res/drawable/ic_info.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_crouton_message.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 17 | 18 |