├── example ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-hdpi │ │ │ ├── ic_done_white.png │ │ │ ├── ic_warning_white.png │ │ │ ├── ic_info_outline_white.png │ │ │ └── ic_error_outline_white.png │ │ ├── drawable-mdpi │ │ │ ├── ic_done_white.png │ │ │ ├── ic_warning_white.png │ │ │ ├── ic_info_outline_white.png │ │ │ └── ic_error_outline_white.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_done_white.png │ │ │ ├── ic_warning_white.png │ │ │ ├── ic_error_outline_white.png │ │ │ └── ic_info_outline_white.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_done_white.png │ │ │ ├── ic_warning_white.png │ │ │ ├── ic_info_outline_white.png │ │ │ └── ic_error_outline_white.png │ │ ├── drawable-xxxhdpi │ │ │ ├── ic_done_white.png │ │ │ ├── ic_warning_white.png │ │ │ ├── ic_error_outline_white.png │ │ │ └── ic_info_outline_white.png │ │ ├── values │ │ │ ├── styles.xml │ │ │ ├── strings.xml │ │ │ └── colors.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── greco │ │ └── lorenzo │ │ └── com │ │ └── lgsnackbar │ │ └── example │ │ └── MainActivity.java ├── proguard-rules.pro └── build.gradle ├── lgsnackbar ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── colors.xml │ │ ├── drawable-hdpi │ │ │ ├── ic_info_retro.png │ │ │ ├── ic_info_shine.png │ │ │ ├── ic_error_retro.png │ │ │ ├── ic_error_shine.png │ │ │ ├── ic_error_material.png │ │ │ ├── ic_info_material.png │ │ │ ├── ic_success_retro.png │ │ │ ├── ic_success_shine.png │ │ │ ├── ic_warning_retro.png │ │ │ ├── ic_warning_shine.png │ │ │ ├── ic_success_material.png │ │ │ └── ic_warning_material.png │ │ ├── drawable-mdpi │ │ │ ├── ic_info_retro.png │ │ │ ├── ic_info_shine.png │ │ │ ├── ic_error_retro.png │ │ │ ├── ic_error_shine.png │ │ │ ├── ic_error_material.png │ │ │ ├── ic_info_material.png │ │ │ ├── ic_success_retro.png │ │ │ ├── ic_success_shine.png │ │ │ ├── ic_warning_retro.png │ │ │ ├── ic_warning_shine.png │ │ │ ├── ic_success_material.png │ │ │ └── ic_warning_material.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_error_retro.png │ │ │ ├── ic_error_shine.png │ │ │ ├── ic_info_retro.png │ │ │ ├── ic_info_shine.png │ │ │ ├── ic_error_material.png │ │ │ ├── ic_info_material.png │ │ │ ├── ic_success_retro.png │ │ │ ├── ic_success_shine.png │ │ │ ├── ic_warning_retro.png │ │ │ ├── ic_warning_shine.png │ │ │ ├── ic_success_material.png │ │ │ └── ic_warning_material.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_info_retro.png │ │ │ ├── ic_info_shine.png │ │ │ ├── ic_error_retro.png │ │ │ ├── ic_error_shine.png │ │ │ ├── ic_info_material.png │ │ │ ├── ic_success_retro.png │ │ │ ├── ic_success_shine.png │ │ │ ├── ic_warning_retro.png │ │ │ ├── ic_warning_shine.png │ │ │ ├── ic_error_material.png │ │ │ ├── ic_success_material.png │ │ │ └── ic_warning_material.png │ │ └── drawable-xxxhdpi │ │ │ ├── ic_error_retro.png │ │ │ ├── ic_error_shine.png │ │ │ ├── ic_info_retro.png │ │ │ ├── ic_info_shine.png │ │ │ ├── ic_error_material.png │ │ │ ├── ic_info_material.png │ │ │ ├── ic_success_retro.png │ │ │ ├── ic_success_shine.png │ │ │ ├── ic_warning_retro.png │ │ │ ├── ic_warning_shine.png │ │ │ ├── ic_success_material.png │ │ │ └── ic_warning_material.png │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── greco │ │ └── lorenzo │ │ └── com │ │ └── lgsnackbar │ │ ├── core │ │ ├── LGSnackbarAction.java │ │ ├── LGUtils.java │ │ ├── LGSnackbar.java │ │ └── LGSnackbarPresenter.java │ │ ├── style │ │ ├── LGSnackBarStyle.java │ │ ├── LGSnackBarTheme.java │ │ └── LGSnackBarThemeManager.java │ │ └── LGSnackbarManager.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── media ├── demo.gif ├── appetize.png ├── header_logo.png └── themes │ ├── retro │ ├── info.jpg │ ├── error.jpg │ ├── success.jpg │ └── warning.jpg │ ├── shine │ ├── info.jpg │ ├── error.jpg │ ├── success.jpg │ └── warning.jpg │ ├── custom │ ├── error.jpg │ ├── info.jpg │ ├── success.jpg │ └── warning.jpg │ └── material │ ├── info.jpg │ ├── error.jpg │ ├── success.jpg │ └── warning.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .travis.yml ├── .gitignore ├── themes.md ├── LICENSE.md ├── CONTRIBUTING.md ├── gradlew.bat ├── gradlew └── README.md /example/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /lgsnackbar/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example', ':lgsnackbar' 2 | -------------------------------------------------------------------------------- /media/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/demo.gif -------------------------------------------------------------------------------- /media/appetize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/appetize.png -------------------------------------------------------------------------------- /media/header_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/header_logo.png -------------------------------------------------------------------------------- /media/themes/retro/info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/retro/info.jpg -------------------------------------------------------------------------------- /media/themes/shine/info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/shine/info.jpg -------------------------------------------------------------------------------- /media/themes/custom/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/custom/error.jpg -------------------------------------------------------------------------------- /media/themes/custom/info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/custom/info.jpg -------------------------------------------------------------------------------- /media/themes/material/info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/material/info.jpg -------------------------------------------------------------------------------- /media/themes/retro/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/retro/error.jpg -------------------------------------------------------------------------------- /media/themes/retro/success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/retro/success.jpg -------------------------------------------------------------------------------- /media/themes/retro/warning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/retro/warning.jpg -------------------------------------------------------------------------------- /media/themes/shine/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/shine/error.jpg -------------------------------------------------------------------------------- /media/themes/shine/success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/shine/success.jpg -------------------------------------------------------------------------------- /media/themes/shine/warning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/shine/warning.jpg -------------------------------------------------------------------------------- /media/themes/custom/success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/custom/success.jpg -------------------------------------------------------------------------------- /media/themes/custom/warning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/custom/warning.jpg -------------------------------------------------------------------------------- /media/themes/material/error.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/material/error.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /media/themes/material/success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/material/success.jpg -------------------------------------------------------------------------------- /media/themes/material/warning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/media/themes/material/warning.jpg -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LGSnackbar 3 | 4 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-hdpi/ic_done_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-mdpi/ic_done_white.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_warning_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-hdpi/ic_warning_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_warning_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-mdpi/ic_warning_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xhdpi/ic_done_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxhdpi/ic_done_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxxhdpi/ic_done_white.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_info_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_info_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_info_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_info_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_info_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_info_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_info_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_info_shine.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_warning_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xhdpi/ic_warning_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_warning_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxhdpi/ic_warning_white.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_error_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_error_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_error_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_error_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_error_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_error_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_error_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_error_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_error_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_error_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_error_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_error_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_info_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_info_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_info_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_info_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_shine.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_info_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-hdpi/ic_info_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_info_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-mdpi/ic_info_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_warning_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxxhdpi/ic_warning_white.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_error_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_error_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_info_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_info_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_success_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_success_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_success_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_success_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_warning_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_warning_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_warning_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_warning_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_error_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_error_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_info_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_info_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_success_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_success_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_success_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_success_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_warning_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_warning_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_warning_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_warning_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_error_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_error_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_info_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_info_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_success_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_success_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_success_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_success_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_info_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_shine.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-hdpi/ic_error_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-hdpi/ic_error_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-mdpi/ic_error_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-mdpi/ic_error_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_error_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xhdpi/ic_error_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xhdpi/ic_info_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xhdpi/ic_info_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_info_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxhdpi/ic_info_outline_white.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_success_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_success_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-hdpi/ic_warning_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-hdpi/ic_warning_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_success_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_success_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-mdpi/ic_warning_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-mdpi/ic_warning_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_success_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_success_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xhdpi/ic_warning_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_error_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_error_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_info_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_shine.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_retro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_retro.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_shine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_shine.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/ic_error_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxhdpi/ic_error_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_error_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxxhdpi/ic_error_outline_white.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxxhdpi/ic_info_outline_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/example/src/main/res/drawable-xxxhdpi/ic_info_outline_white.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_success_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxhdpi/ic_warning_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_success_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/loregr/LGSnackbar/HEAD/lgsnackbar/src/main/res/drawable-xxxhdpi/ic_warning_material.png -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 48dp 5 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 18 09:22:55 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk8 3 | android: 4 | components: 5 | - tools 6 | - tools 7 | - platform-tools 8 | - build-tools-25.0.1 9 | - android-25 10 | - extra-android-support 11 | - extra-android-m2repository 12 | 13 | script: 14 | - ./gradlew build 15 | before_install: 16 | - chmod +x gradlew 17 | 18 | branches: 19 | only: 20 | - master 21 | - develop -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /build 5 | /captures 6 | .externalNativeBuild 7 | .gradle/* 8 | .idea/* 9 | *.iml 10 | lgsnackbar/build/* 11 | lgsnackbar/lgsnackbar.iml 12 | example/build/* 13 | example/example.iml 14 | 15 | # OS-specific files 16 | .DS_Store 17 | .DS_Store? 18 | ._* 19 | .Spotlight-V100 20 | .Trashes 21 | ehthumbs.db 22 | Thumbs.db 23 | 24 | local.properties* 25 | gradle.properties* 26 | 27 | -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LGSnackbar 3 | Theme 4 | Show an action 5 | success 6 | warning 7 | error 8 | info 9 | custom single snackbar 10 | 11 | 12 | Shine 13 | Material 14 | Retro 15 | Custom 16 | 17 | 18 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/core/LGSnackbarAction.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.core; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by LoreGr on 20/05/2017. 7 | */ 8 | public class LGSnackbarAction { 9 | private final CharSequence text; 10 | private final View.OnClickListener listener; 11 | 12 | public LGSnackbarAction(CharSequence text, View.OnClickListener listener) { 13 | this.text = text; 14 | this.listener = listener; 15 | } 16 | 17 | public CharSequence getText() { 18 | return text; 19 | } 20 | 21 | public View.OnClickListener getListener() { 22 | return listener; 23 | } 24 | } -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/style/LGSnackBarStyle.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.style; 2 | 3 | /** 4 | * Created by LoreGr on 20/05/2017. 5 | */ 6 | public class LGSnackBarStyle { 7 | 8 | private static final String TAG = "LGSnackBarStyle"; 9 | 10 | public int backgroundColor; 11 | public int textColor; 12 | public int actionTextColor; 13 | public int iconID; 14 | 15 | public LGSnackBarStyle(int backgroundColor, int textColor, int actionTextColor, int iconID) { 16 | this.backgroundColor = backgroundColor; 17 | this.textColor = textColor; 18 | this.actionTextColor = actionTextColor; 19 | this.iconID = iconID; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lgsnackbar/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.loregr' 5 | 6 | android { 7 | compileSdkVersion 25 8 | buildToolsVersion "25.0.1" 9 | 10 | defaultConfig { 11 | minSdkVersion 19 12 | targetSdkVersion 25 13 | versionCode 2 14 | versionName "1.0.1" 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | lintOptions { 25 | abortOnError false 26 | } 27 | } 28 | 29 | dependencies { 30 | compile fileTree(include: ['*.jar'], dir: 'libs') 31 | compile 'com.android.support:appcompat-v7:25.3.1' 32 | compile 'com.android.support:design:25.3.1' 33 | } -------------------------------------------------------------------------------- /example/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #106376 4 | #0C5872 5 | #FCCE30 6 | 7 | #126978 8 | #2C9987 9 | #74BC90 10 | #A2D997 11 | #C5F19D 12 | 13 | 14 | #00977C 15 | #E99300 16 | #D42C26 17 | #1E74B4 18 | #7CFF88 19 | #FBCF7F 20 | #FCA47D 21 | #74FEF1 22 | 23 | 24 | -------------------------------------------------------------------------------- /themes.md: -------------------------------------------------------------------------------- 1 | ## Themes 2 | 3 | This library provides some default themes. 4 | 5 | **SHINE:** 6 | 7 | |Success | Warning | Error | Info | 8 | | :-------------: |:-------------:| :-------------:|:-------------:| 9 | | ![logo](media/themes/shine/success.jpg)| ![logo](media/themes/shine/warning.jpg) | ![logo](media/themes/shine/error.jpg)| ![logo](media/themes/shine/info.jpg) 10 | ---- 11 | **MATERIAL:** 12 | 13 | |Success | Warning | Error | Info | 14 | | :-------------: |:-------------:| :-------------:|:-------------:| 15 | | ![logo](media/themes/material/success.jpg)| ![logo](media/themes/material/warning.jpg) | ![logo](media/themes/material/error.jpg)| ![logo](media/themes/material/info.jpg) 16 | ---- 17 | **RETRO:** 18 | 19 | |Success | Warning | Error | Info | 20 | | :-------------: |:-------------:| :-------------:|:-------------:| 21 | | ![logo](media/themes/retro/success.jpg)| ![logo](media/themes/retro/warning.jpg) | ![logo](media/themes/retro/error.jpg)| ![logo](media/themes/retro/info.jpg) 22 | -------------------------------------------------------------------------------- /example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Renzo/Documents/SDK/android_sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /lgsnackbar/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Renzo/Documents/SDK/android_sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.1" 6 | defaultConfig { 7 | applicationId "greco.lorenzo.com.lgsnackbar.example" 8 | minSdkVersion 19 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | lintOptions { 15 | abortOnError false 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(include: ['*.jar'], dir: 'libs') 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile project(':lgsnackbar') 29 | compile 'com.jakewharton:butterknife:8.6.0' 30 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' 31 | compile 'com.github.medyo:fancybuttons:1.8.3' 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Lorenzo Greco 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #323232 6 | #19B491 7 | 8 | 9 | 10 | #4CAF50 11 | #FFC107 12 | #F44336 13 | #2196F3 14 | #FFC107 15 | #4CAF50 16 | #FFC107 17 | #FFC107 18 | 19 | 20 | #88D8B0 21 | #FFCC5C 22 | #FF6F69 23 | #8FD4D9 24 | #bbffffff 25 | #bbffffff 26 | #bbffffff 27 | #bbffffff 28 | 29 | 30 | #36CD84 31 | #F7C858 32 | #FF4E5C 33 | #28DAC2 34 | #1B8C70 35 | #FF7200 36 | #890916 37 | #235379 38 | 39 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/core/LGUtils.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.core; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.util.DisplayMetrics; 6 | 7 | /** 8 | * Created by LoreGr on 20/05/2017. 9 | */ 10 | class LGUtils { 11 | 12 | /** 13 | * This method converts dp unit to equivalent pixels, depending on device density. 14 | * 15 | * @param dp A value in dp (density independent pixels) unit. Which we need to convert into pixels 16 | * @param context Context to get resources and device specific display metrics 17 | * @return A float value to represent px equivalent to dp depending on device density 18 | */ 19 | public static float convertDpToPixel(float dp, Context context){ 20 | Resources resources = context.getResources(); 21 | DisplayMetrics metrics = resources.getDisplayMetrics(); 22 | float px = dp * ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT); 23 | return px; 24 | } 25 | 26 | /** 27 | * This method converts device specific pixels to density independent pixels. 28 | * 29 | * @param px A value in px (pixels) unit. Which we need to convert into db 30 | * @param context Context to get resources and device specific display metrics 31 | * @return A float value to represent dp equivalent to px value 32 | */ 33 | public static float convertPixelsToDp(float px, Context context){ 34 | Resources resources = context.getResources(); 35 | DisplayMetrics metrics = resources.getDisplayMetrics(); 36 | float dp = px / ((float)metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT); 37 | return dp; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/style/LGSnackBarTheme.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.style; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * Created by LoreGr on 20/05/2017. 7 | */ 8 | public class LGSnackBarTheme { 9 | 10 | private static final String TAG = "LGSnackBarTheme"; 11 | 12 | public enum SnackbarStyle { 13 | SUCCESS, 14 | WARNING, 15 | ERROR, 16 | INFO 17 | } 18 | 19 | private LGSnackBarStyle successStyle; 20 | private LGSnackBarStyle warningStyle; 21 | private LGSnackBarStyle errorStyle; 22 | private LGSnackBarStyle infoStyle; 23 | 24 | private int minHeight; 25 | private int duration; 26 | 27 | public LGSnackBarTheme(@NonNull LGSnackBarStyle successStyle, @NonNull LGSnackBarStyle warningStyle, @NonNull LGSnackBarStyle errorStyle, @NonNull LGSnackBarStyle infoStyle, @NonNull int minHeight,@NonNull int duration) { 28 | this.successStyle = successStyle; 29 | this.warningStyle = warningStyle; 30 | this.errorStyle = errorStyle; 31 | this.infoStyle = infoStyle; 32 | this.minHeight = minHeight; 33 | this.duration = duration; 34 | } 35 | 36 | public LGSnackBarStyle getStyle(SnackbarStyle barStyle){ 37 | switch (barStyle) { 38 | case SUCCESS: 39 | return successStyle; 40 | case WARNING: 41 | return warningStyle; 42 | case ERROR: 43 | return errorStyle; 44 | case INFO: 45 | return infoStyle; 46 | } 47 | return null; 48 | } 49 | 50 | public int getMinHeight() { 51 | return minHeight; 52 | } 53 | 54 | public int getDuration() { 55 | return duration; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | First off, thanks for taking the time to contribute! 5 | 6 | If you would like to contribute code to this repository you can do so through GitHub by 7 | forking the repository and sending a pull request or opening an issue. 8 | 9 | When submitting code, please make every effort to follow existing conventions 10 | and style in order to keep the code as readable as possible. Please also make 11 | sure your code compiles, passes the tests and the checkstyle configured for this repository. 12 | 13 | 14 | Some tips that will help you to contribute to this repository: 15 | 16 | * Write clean code and test it. 17 | * Follow the repository code style. 18 | * Write good commit messages. 19 | * Do not send pull requests without checking if the project build is OK in Travis-CI. 20 | * Review if your changes affects the repository documentation and update it. 21 | * Describe the PR content and don't hesitate to add comments to explain us why you've added or changed something. 22 | 23 | Code of conduct 24 | --------------- 25 | 26 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 27 | 28 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 29 | 30 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 31 | 32 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 33 | 34 | This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. 35 | 36 | Instances of abusive, harassing, or otherwise unacceptable behavior can be reported by emailing hello@karumi.com. 37 | 38 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/), version 1.3.0, available at [http://contributor-covenant.org/version/1/3/0/](http://contributor-covenant.org/version/1/3/0/). 39 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/LGSnackbarManager.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar; 2 | 3 | import android.content.Context; 4 | import android.support.design.widget.Snackbar; 5 | import android.util.Log; 6 | 7 | import greco.lorenzo.com.lgsnackbar.core.LGSnackbarAction; 8 | import greco.lorenzo.com.lgsnackbar.core.LGSnackbar; 9 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarStyle; 10 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme; 11 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarThemeManager; 12 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme.SnackbarStyle.SUCCESS; 13 | 14 | /** 15 | * Created by LoreGr on 20/05/2017. 16 | */ 17 | public class LGSnackbarManager { 18 | 19 | private static final String TAG = "LGSnackbar"; 20 | 21 | public static final int NO_ICON_ID = -1; 22 | 23 | private static LGSnackbarManager instance = null; 24 | 25 | private Context appContext; 26 | private LGSnackBarTheme selectedTheme; 27 | 28 | public static void prepare(Context context) { 29 | prepare(context, null, null); 30 | } 31 | 32 | public static void prepare(Context context, LGSnackBarThemeManager.LGSnackbarThemeName themeName) { 33 | prepare(context, themeName, null); 34 | } 35 | 36 | public static void prepare(Context context, LGSnackBarTheme theme) { 37 | prepare(context, null, theme); 38 | } 39 | 40 | public static void prepare(Context context, LGSnackBarThemeManager.LGSnackbarThemeName themeName, LGSnackBarTheme theme) { 41 | if(instance == null) { 42 | instance = new LGSnackbarManager(context, themeName, theme); 43 | }else{ 44 | Log.w(TAG, "prepare: Instance already initialised"); 45 | } 46 | } 47 | 48 | public static void setTheme (LGSnackBarTheme theme) { 49 | if (instance == null){ 50 | Log.e(TAG, "getInstance: you need to call LGSnackbar.prepare() first!"); 51 | return; 52 | } 53 | instance.selectedTheme = theme; 54 | } 55 | 56 | public static void setThemeName (LGSnackBarThemeManager.LGSnackbarThemeName themeName) { 57 | setTheme(LGSnackBarThemeManager.getTheme(instance.appContext, themeName)); 58 | } 59 | 60 | private LGSnackbarManager(Context context, LGSnackBarThemeManager.LGSnackbarThemeName themeName, LGSnackBarTheme theme) { 61 | appContext = context; 62 | if (theme==null) { 63 | selectedTheme = LGSnackBarThemeManager.getTheme(appContext, themeName); 64 | }else{ 65 | selectedTheme = theme; 66 | } 67 | } 68 | 69 | public static void show(LGSnackBarTheme.SnackbarStyle barStyle, CharSequence text){ 70 | show(barStyle, text, null, null); 71 | } 72 | 73 | public static void show(LGSnackBarTheme.SnackbarStyle barStyle, CharSequence text, Snackbar.Callback callback){ 74 | show(barStyle, text, callback, null); 75 | } 76 | 77 | public static void show(LGSnackBarTheme.SnackbarStyle barStyle, CharSequence text, LGSnackbarAction action){ 78 | show(barStyle, text, null, action); 79 | } 80 | 81 | public static void show(LGSnackBarTheme.SnackbarStyle barStyle, CharSequence text, Snackbar.Callback callback, LGSnackbarAction action){ 82 | if (instance == null){ 83 | Log.e(TAG, "getInstance: you need to call LGSnackbar.prepare() first!"); 84 | return; 85 | } 86 | showSnackbar(text, instance.selectedTheme.getStyle(barStyle), instance.selectedTheme.getDuration(), instance.selectedTheme.getMinHeight(), callback, action); 87 | } 88 | 89 | 90 | private static void showSnackbar(CharSequence text, LGSnackBarStyle style, int duration, int minHeight, Snackbar.Callback callback, LGSnackbarAction action) { 91 | new LGSnackbar(instance.appContext, style, text, duration, minHeight, callback, action).show(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/style/LGSnackBarThemeManager.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.style; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v4.content.ContextCompat; 7 | 8 | import greco.lorenzo.com.lgsnackbar.R; 9 | 10 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarThemeManager.LGSnackbarThemeName.MATERIAL; 11 | 12 | /** 13 | * Created by LoreGr on 20/05/2017. 14 | */ 15 | public class LGSnackBarThemeManager { 16 | 17 | private static final String TAG = "LGSnackBarThemeManager"; 18 | 19 | public enum LGSnackbarThemeName { 20 | MATERIAL, 21 | RETRO, 22 | SHINE 23 | } 24 | 25 | public static LGSnackBarTheme getTheme(Context context, LGSnackbarThemeName themeName) { 26 | if (themeName==null){ 27 | themeName = MATERIAL; 28 | } 29 | switch (themeName) { 30 | case MATERIAL: 31 | return materialTheme(context); 32 | case RETRO: 33 | return retroTheme(context); 34 | case SHINE: 35 | return shineTheme(context); 36 | } 37 | return null; 38 | } 39 | 40 | static LGSnackBarTheme materialTheme(Context context) { 41 | LGSnackBarStyle successStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.successMaterial), 42 | Color.WHITE, 43 | ContextCompat.getColor(context, R.color.actionSuccessMaterial), 44 | R.drawable.ic_success_material); 45 | 46 | LGSnackBarStyle warningStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.warningMaterial), 47 | Color.WHITE, 48 | ContextCompat.getColor(context, R.color.actionWarningMaterial), 49 | R.drawable.ic_warning_material); 50 | 51 | LGSnackBarStyle errorStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.errorMaterial), 52 | Color.WHITE, 53 | ContextCompat.getColor(context, R.color.actionErrorMaterial), 54 | R.drawable.ic_error_material); 55 | 56 | LGSnackBarStyle infoStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.infoMaterial), 57 | Color.WHITE, 58 | ContextCompat.getColor(context, R.color.actionInfoMaterial), 59 | R.drawable.ic_info_material); 60 | 61 | return new LGSnackBarTheme(successStyle, warningStyle, errorStyle, infoStyle, 48, Snackbar.LENGTH_LONG); 62 | } 63 | 64 | static LGSnackBarTheme retroTheme(Context context) { 65 | LGSnackBarStyle successStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.successRetro), 66 | Color.WHITE, 67 | ContextCompat.getColor(context, R.color.actionSuccessRetro), 68 | R.drawable.ic_success_retro); 69 | 70 | LGSnackBarStyle warningStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.warningRetro), 71 | Color.WHITE, 72 | ContextCompat.getColor(context, R.color.actionWarningRetro), 73 | R.drawable.ic_warning_retro); 74 | 75 | LGSnackBarStyle errorStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.errorRetro), 76 | Color.WHITE, 77 | ContextCompat.getColor(context, R.color.actionErrorRetro), 78 | R.drawable.ic_error_retro); 79 | 80 | LGSnackBarStyle infoStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.infoRetro), 81 | Color.WHITE, 82 | ContextCompat.getColor(context, R.color.actionInfoRetro), 83 | R.drawable.ic_info_retro); 84 | 85 | return new LGSnackBarTheme(successStyle, warningStyle, errorStyle, infoStyle, 55, Snackbar.LENGTH_LONG); 86 | } 87 | 88 | static LGSnackBarTheme shineTheme(Context context) { 89 | LGSnackBarStyle successStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.successShine), 90 | Color.WHITE, 91 | ContextCompat.getColor(context, R.color.actionSuccessShine), 92 | R.drawable.ic_success_shine); 93 | 94 | LGSnackBarStyle warningStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.warningShine), 95 | Color.WHITE, 96 | ContextCompat.getColor(context, R.color.actionWarningShine), 97 | R.drawable.ic_warning_shine); 98 | 99 | LGSnackBarStyle errorStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.errorShine), 100 | Color.WHITE, 101 | ContextCompat.getColor(context, R.color.actionErrorShine), 102 | R.drawable.ic_error_shine); 103 | 104 | LGSnackBarStyle infoStyle = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.infoShine), 105 | Color.WHITE, 106 | ContextCompat.getColor(context, R.color.actionInfoShine), 107 | R.drawable.ic_info_shine); 108 | 109 | return new LGSnackBarTheme(successStyle, warningStyle, errorStyle, infoStyle, 70, Snackbar.LENGTH_LONG); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/core/LGSnackbar.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.core; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v4.content.ContextCompat; 7 | 8 | import greco.lorenzo.com.lgsnackbar.R; 9 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarStyle; 10 | 11 | /** 12 | * Created by LoreGr on 20/05/2017. 13 | */ 14 | public class LGSnackbar { 15 | 16 | public static final int NO_ICON_ID = -1; 17 | 18 | private final Context context; 19 | 20 | private final LGSnackBarStyle style; 21 | 22 | private final CharSequence text; 23 | private final int duration; 24 | private final float minHeight; 25 | 26 | private final Snackbar.Callback callback; 27 | private final LGSnackbarAction action; 28 | 29 | public LGSnackbar(Context context, LGSnackBarStyle style, CharSequence text, int duration, float minHeight, Snackbar.Callback callback, LGSnackbarAction action) { 30 | this.context = context; 31 | this.style = style; 32 | this.text = text; 33 | this.duration = duration; 34 | this.minHeight = LGUtils.convertDpToPixel(minHeight, context); 35 | this.callback = callback; 36 | this.action = action; 37 | } 38 | 39 | public LGSnackbar(LGSnackbarBuilder builder) { 40 | this.context = builder.context; 41 | this.text = builder.text; 42 | this.duration = builder.duration; 43 | this.minHeight = builder.minHeight; 44 | this.callback = builder.callback; 45 | this.action = builder.action; 46 | this.style = builder.style; 47 | } 48 | 49 | Context getContext() { 50 | return context; 51 | } 52 | 53 | public CharSequence getText() { 54 | return text; 55 | } 56 | 57 | int getDuration() { 58 | return duration; 59 | } 60 | 61 | int getBackgroundColor() { 62 | return style.backgroundColor; 63 | } 64 | 65 | int getActionTextColor() { 66 | return style.actionTextColor; 67 | } 68 | 69 | int getTextColor() { 70 | return style.textColor; 71 | } 72 | 73 | float getMinHeight() { 74 | return minHeight; 75 | } 76 | 77 | int getIconID() { 78 | return style.iconID; 79 | } 80 | 81 | Snackbar.Callback getCallback() { 82 | return callback; 83 | } 84 | 85 | LGSnackbarAction getAction() { 86 | return action; 87 | } 88 | 89 | public void show() { 90 | new LGSnackbarPresenter(this).show(); 91 | } 92 | 93 | public static class LGSnackbarBuilder { 94 | 95 | private final Context context; 96 | 97 | private LGSnackBarStyle style; 98 | 99 | private final CharSequence text; 100 | private int duration; 101 | private float minHeight; 102 | 103 | private Snackbar.Callback callback; 104 | private LGSnackbarAction action; 105 | 106 | public LGSnackbarBuilder(Context context, CharSequence text) { 107 | this.context = context; 108 | this.text = text; 109 | this.style = new LGSnackBarStyle(ContextCompat.getColor(context, R.color.defaultBgColor), 110 | Color.WHITE, 111 | ContextCompat.getColor(context, R.color.defaultActionColor), 112 | NO_ICON_ID); 113 | this.duration = Snackbar.LENGTH_LONG; 114 | this.minHeight = context.getResources().getDimension(R.dimen.default_sb_height); 115 | this.callback = null; 116 | this.action = null; 117 | } 118 | 119 | public LGSnackbarBuilder style(LGSnackBarStyle style) { 120 | this.style = style; 121 | return this; 122 | } 123 | 124 | public LGSnackbarBuilder duration(int duration) { 125 | this.duration = duration; 126 | return this; 127 | } 128 | 129 | public LGSnackbarBuilder backgroundColor(int backgroundColor) { 130 | this.style.backgroundColor = backgroundColor; 131 | return this; 132 | } 133 | 134 | public LGSnackbarBuilder actionTextColor(int actionTextColor) { 135 | this.style.actionTextColor = actionTextColor; 136 | return this; 137 | } 138 | 139 | public LGSnackbarBuilder textColor(int textColor) { 140 | this.style.textColor = textColor; 141 | return this; 142 | } 143 | 144 | public LGSnackbarBuilder minHeightDp(float minHeight) { 145 | this.minHeight = LGUtils.convertDpToPixel(minHeight, context); 146 | return this; 147 | } 148 | 149 | public LGSnackbarBuilder iconID(int iconID) { 150 | this.style.iconID = iconID; 151 | return this; 152 | } 153 | 154 | public LGSnackbarBuilder callback(Snackbar.Callback callback) { 155 | this.callback = callback; 156 | return this; 157 | } 158 | 159 | public LGSnackbarBuilder action(LGSnackbarAction action) { 160 | this.action = action; 161 | return this; 162 | } 163 | 164 | 165 | LGSnackbar build() { 166 | return new LGSnackbar(this); 167 | } 168 | 169 | public void show() { 170 | build().show(); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /lgsnackbar/src/main/java/greco/lorenzo/com/lgsnackbar/core/LGSnackbarPresenter.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.core; 2 | 3 | import android.content.Context; 4 | import android.graphics.PixelFormat; 5 | import android.os.IBinder; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | import android.support.design.widget.CoordinatorLayout; 9 | import android.support.design.widget.Snackbar; 10 | import android.support.v4.view.GravityCompat; 11 | import android.support.v4.view.ViewCompat; 12 | import android.support.v7.view.ContextThemeWrapper; 13 | import android.view.Gravity; 14 | import android.view.View; 15 | import android.view.WindowManager; 16 | import android.widget.FrameLayout; 17 | import android.widget.LinearLayout; 18 | import android.widget.TextView; 19 | 20 | import greco.lorenzo.com.lgsnackbar.R; 21 | 22 | import static greco.lorenzo.com.lgsnackbar.LGSnackbarManager.NO_ICON_ID; 23 | 24 | /** 25 | * Created by LoreGr on 20/05/2017. 26 | */ 27 | class LGSnackbarPresenter { 28 | 29 | private final WindowManager windowManager; 30 | private final Context appplicationContext; 31 | 32 | private LGSnackbar lgSnackbar; 33 | 34 | public LGSnackbarPresenter(@NonNull LGSnackbar lgSnackbar) { 35 | this.lgSnackbar = lgSnackbar; 36 | this.appplicationContext = lgSnackbar.getContext(); 37 | this.windowManager = (WindowManager) appplicationContext.getSystemService(Context.WINDOW_SERVICE); 38 | } 39 | 40 | public void show() { 41 | WindowManager.LayoutParams layoutParams = createDefaultLayoutParams(WindowManager.LayoutParams.TYPE_TOAST, null); 42 | FrameLayout rootFrame = new FrameLayout(appplicationContext) { 43 | @Override 44 | protected void onAttachedToWindow() { 45 | super.onAttachedToWindow(); 46 | onRootViewAvailable(this); 47 | } 48 | 49 | }; 50 | rootFrame.setContentDescription("LGSnackbar"); 51 | windowManager.addView(rootFrame, layoutParams); 52 | } 53 | 54 | private void onRootViewAvailable(final FrameLayout rootView) { 55 | final CoordinatorLayout snackbarContainer = new CoordinatorLayout(new ContextThemeWrapper(appplicationContext, R.style.SnackbarWrapperTheme)) { 56 | @Override 57 | public void onAttachedToWindow() { 58 | super.onAttachedToWindow(); 59 | onSnackbarContainerAttached(rootView, this); 60 | } 61 | }; 62 | windowManager.addView(snackbarContainer, createDefaultLayoutParams(WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, rootView.getWindowToken())); 63 | } 64 | 65 | private void onSnackbarContainerAttached(final View rootView, final CoordinatorLayout snackbarContainer) { 66 | Snackbar snackbar = Snackbar.make(snackbarContainer, lgSnackbar.getText(), lgSnackbar.getDuration()); 67 | View snackbarLayout = snackbar.getView(); 68 | TextView textView = (TextView)snackbarLayout.findViewById(android.support.design.R.id.snackbar_text); 69 | snackbarLayout.setBackgroundColor(lgSnackbar.getBackgroundColor()); 70 | textView.setGravity(Gravity.CENTER_VERTICAL); 71 | textView.setMinimumHeight((int) lgSnackbar.getMinHeight()); 72 | textView.setMaxLines(10); 73 | textView.setTextColor(lgSnackbar.getTextColor()); 74 | textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f)); 75 | 76 | if (lgSnackbar.getIconID()!= NO_ICON_ID) { 77 | textView.setCompoundDrawablesWithIntrinsicBounds(lgSnackbar.getIconID(), 0, 0, 0); 78 | textView.setCompoundDrawablePadding(appplicationContext.getResources().getDimensionPixelOffset(R.dimen.default_margin)); 79 | } 80 | 81 | final Snackbar.Callback callback = lgSnackbar.getCallback(); 82 | snackbar.addCallback(new Snackbar.Callback() { 83 | @Override 84 | public void onDismissed(Snackbar snackbar, int event) { 85 | super.onDismissed(snackbar, event); 86 | if (snackbarContainer.getParent() != null && rootView.getParent() != null) { 87 | windowManager.removeView(snackbarContainer); 88 | windowManager.removeView(rootView); 89 | } 90 | if (callback != null) { 91 | callback.onDismissed(snackbar, event); 92 | } 93 | } 94 | 95 | @Override 96 | public void onShown(Snackbar snackbar) { 97 | super.onShown(snackbar); 98 | if (callback != null) { 99 | callback.onShown(snackbar); 100 | } 101 | } 102 | }); 103 | 104 | 105 | final LGSnackbarAction action = lgSnackbar.getAction(); 106 | if (action != null) { 107 | snackbar.setActionTextColor(lgSnackbar.getActionTextColor()); 108 | snackbar.setAction(action.getText(), action.getListener()); 109 | } 110 | snackbar.show(); 111 | } 112 | 113 | private WindowManager.LayoutParams createDefaultLayoutParams(int type, @Nullable IBinder windowToken) { 114 | WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams(); 115 | layoutParams.format = PixelFormat.TRANSLUCENT; 116 | layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; 117 | layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT; 118 | layoutParams.gravity = GravityCompat.getAbsoluteGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, ViewCompat.LAYOUT_DIRECTION_LTR); 119 | layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 120 | layoutParams.type = type; 121 | layoutParams.token = windowToken; 122 | return layoutParams; 123 | } 124 | } -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 19 | 20 | 26 | 33 | 34 | 39 | 40 | 41 | 42 | 49 | 50 | 57 | 58 | 70 | 71 | 74 | 75 | 87 | 88 | 89 | 97 | 98 | 110 | 111 | 114 | 115 | 127 | 128 | 129 | 130 | 131 | 132 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /example/src/main/java/greco/lorenzo/com/lgsnackbar/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package greco.lorenzo.com.lgsnackbar.example; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.design.widget.Snackbar; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | import android.view.View; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.Spinner; 11 | import android.widget.Toast; 12 | 13 | import butterknife.BindColor; 14 | import butterknife.BindView; 15 | import butterknife.ButterKnife; 16 | import butterknife.OnCheckedChanged; 17 | import butterknife.OnClick; 18 | import butterknife.OnItemSelected; 19 | import greco.lorenzo.com.lgsnackbar.LGSnackbarManager; 20 | import greco.lorenzo.com.lgsnackbar.core.LGSnackbar; 21 | import greco.lorenzo.com.lgsnackbar.core.LGSnackbarAction; 22 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarStyle; 23 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme; 24 | import greco.lorenzo.com.lgsnackbar.style.LGSnackBarThemeManager; 25 | 26 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme.SnackbarStyle.ERROR; 27 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme.SnackbarStyle.INFO; 28 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme.SnackbarStyle.SUCCESS; 29 | import static greco.lorenzo.com.lgsnackbar.style.LGSnackBarTheme.SnackbarStyle.WARNING; 30 | 31 | public class MainActivity extends AppCompatActivity { 32 | 33 | private static final String TAG = "MainActivity"; 34 | 35 | LGSnackBarThemeManager.LGSnackbarThemeName themeName; 36 | LGSnackbarAction mainAction; 37 | 38 | @BindColor(R.color.colorPrimary) 39 | int primaryColor; 40 | @BindColor(R.color.colorAccent) 41 | int accentColor; 42 | 43 | @BindColor(R.color.successCustom) 44 | int successCustomColor; 45 | @BindColor(R.color.warningCustom) 46 | int warningCustomColor; 47 | @BindColor(R.color.errorCustom) 48 | int errorCustomColor; 49 | @BindColor(R.color.infoCustom) 50 | int infoCustomColor; 51 | @BindColor(R.color.actionSuccessCustom) 52 | int actionSuccessCustomColor; 53 | @BindColor(R.color.actionWarningCustom) 54 | int actionWarningCustomColor; 55 | @BindColor(R.color.actionErrorCustom) 56 | int actionErrorCustomColor; 57 | @BindColor(R.color.actionInfoCustom) 58 | int actionInfoCustomColor; 59 | 60 | @BindView(R.id.spinner) 61 | Spinner spinner; 62 | 63 | @Override 64 | protected void onCreate(Bundle savedInstanceState) { 65 | super.onCreate(savedInstanceState); 66 | setContentView(R.layout.activity_main); 67 | ButterKnife.bind(this); 68 | LGSnackbarManager.prepare(getApplicationContext(), LGSnackBarThemeManager.LGSnackbarThemeName.SHINE); 69 | 70 | ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.themes_array, android.R.layout.simple_spinner_item); 71 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 72 | spinner.setAdapter(adapter); 73 | } 74 | 75 | @OnItemSelected (R.id.spinner) 76 | public void onThemeSelected (Spinner spinner, int position) { 77 | switch (position) { 78 | case 0: 79 | themeName = LGSnackBarThemeManager.LGSnackbarThemeName.SHINE; 80 | LGSnackbarManager.setThemeName(themeName); 81 | break; 82 | case 1: 83 | themeName = LGSnackBarThemeManager.LGSnackbarThemeName.MATERIAL; 84 | LGSnackbarManager.setThemeName(themeName); 85 | break; 86 | case 2: 87 | themeName = LGSnackBarThemeManager.LGSnackbarThemeName.RETRO; 88 | LGSnackbarManager.setThemeName(themeName); 89 | break; 90 | case 3: 91 | LGSnackbarManager.setTheme(customTheme()); 92 | break; 93 | } 94 | Log.d(TAG, "onItemSelected: " + position); 95 | } 96 | 97 | @OnCheckedChanged(R.id.action_switch) 98 | public void checkboxToggled (boolean isChecked) { 99 | if (isChecked){ 100 | mainAction = new LGSnackbarAction("Action", new View.OnClickListener() { 101 | @Override 102 | public void onClick(View view) { 103 | Toast.makeText(MainActivity.this, "Action fired", Toast.LENGTH_LONG).show(); 104 | } 105 | }); 106 | }else{ 107 | mainAction = null; 108 | } 109 | } 110 | 111 | @OnClick({R.id.show_success_btn, R.id.show_warning_btn, R.id.show_error_btn, R.id.show_info_btn, R.id.show_custom_btn}) 112 | public void onViewClicked(View view) { 113 | switch (view.getId()) { 114 | case R.id.show_success_btn: 115 | LGSnackbarManager.show(SUCCESS, "Everything is looking good! Awesome!", null, mainAction); 116 | break; 117 | case R.id.show_warning_btn: 118 | LGSnackbarManager.show(WARNING, "Mmmm, maybe we can do something better", null, mainAction); 119 | break; 120 | case R.id.show_error_btn: 121 | LGSnackbarManager.show(ERROR, "Big problems here! Please have a look ASAP", null, mainAction); 122 | break; 123 | case R.id.show_info_btn: 124 | LGSnackbarManager.show(INFO, "You look beautiful today :-)", null, mainAction); 125 | break; 126 | case R.id.show_custom_btn: 127 | new LGSnackbar.LGSnackbarBuilder(getApplicationContext(), "This is a custom bar") 128 | .backgroundColor(primaryColor) 129 | .minHeightDp(50) 130 | .textColor(accentColor) 131 | .show(); 132 | break; 133 | } 134 | } 135 | 136 | 137 | LGSnackBarTheme customTheme() { 138 | LGSnackBarStyle successStyle = new LGSnackBarStyle(successCustomColor, 139 | Color.WHITE, 140 | actionSuccessCustomColor, 141 | R.drawable.ic_done_white); 142 | 143 | LGSnackBarStyle warningStyle = new LGSnackBarStyle(warningCustomColor, 144 | Color.WHITE, 145 | actionWarningCustomColor, 146 | R.drawable.ic_warning_white); 147 | 148 | LGSnackBarStyle errorStyle = new LGSnackBarStyle(errorCustomColor, 149 | Color.WHITE, 150 | actionErrorCustomColor, 151 | R.drawable.ic_error_outline_white); 152 | 153 | LGSnackBarStyle infoStyle = new LGSnackBarStyle(infoCustomColor, 154 | Color.WHITE, 155 | actionInfoCustomColor, 156 | R.drawable.ic_info_outline_white); 157 | 158 | return new LGSnackBarTheme(successStyle, warningStyle, errorStyle, infoStyle, 60, Snackbar.LENGTH_LONG); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![logo](media/header_logo.png) 3 | 4 | 5 | [![travis_CI](https://travis-ci.org/loregr/LGSnackbar.svg?branch=master)](https://travis-ci.org/loregr/LGSnackbar) ![platform](https://img.shields.io/badge/platform-android-green.svg) [![license](https://img.shields.io/badge/license-MIT-red.svg)](./LICENSE.md) [![](https://jitpack.io/v/loregr/lgsnackbar.svg)](https://jitpack.io/#loregr/lgsnackbar) 6 | ![API](https://img.shields.io/badge/minSdkVersion-19-orange.svg?style=flat) 7 | 8 | 9 | An easy to use wrapper of the native Android Snackbar which stays visible across multiple activities. It provides different themes to start with, and allows you to easily manage common scenarios like _**success**, **warning**, **error**, **info**._ 10 | 11 | ## Preview 12 | 13 | Demo video: 14 | 15 | ![logo](media/demo.gif) 16 | 17 | Try it on Appetize: 18 | 19 | [![appetize](media/appetize.png)](https://appetize.io/app/rp93kgkya9b02f4qb0vw2f8h4r?device=nexus5&scale=75&orientation=portrait&osVersion=7.0) 20 | 21 | ## Install 22 | 23 | In your root/build.gradle: 24 | 25 | ```groovy 26 | allprojects { 27 | repositories { 28 | ... 29 | maven { url 'https://jitpack.io' } 30 | } 31 | } 32 | ``` 33 | In your app/build.gradle 34 | 35 | ```groovy 36 | dependencies { 37 | compile 'com.github.loregr:lgsnackbar:1.0.2' 38 | } 39 | ``` 40 | 41 | ## Preparing 42 | 43 | ### Setup with a default theme 44 | 45 | Define your default theme using `LGSnackbarManager.prepare(...)`, in your `Application` class in the `#onCreate()` method. 46 | 47 | 48 | ```java 49 | @Override 50 | public void onCreate() { 51 | super.onCreate(); 52 | LGSnackbarManager.prepare(getApplicationContext(), 53 | LGSnackBarThemeManager.LGSnackbarThemeName.SHINE); 54 | //.... 55 | } 56 | ``` 57 | 58 | **You can check the available themes _[here](./themes.md)_.** 59 | 60 | _Note: You can simply call `LGSnackbarManager.prepare(getApplicationContext())`, in this case `SHINE` theme will be automatically applied._ 61 | 62 | ### Setup with a custom theme 63 | 64 | Create your own `LGSnackbarTheme` by passing 4 `LGSnackBarStyle` instances (one for each scenario of the theme) and the `minHeight` and the `duration` values that you want to apply to the Snackbar. 65 | 66 | 67 | ```java 68 | @Override 69 | public void onCreate() { 70 | super.onCreate(); 71 | LGSnackbarManager.prepare(getApplicationContext(), 72 | customTheme()); 73 | //.... 74 | } 75 | 76 | //... 77 | 78 | LGSnackBarTheme customTheme() { 79 | LGSnackBarStyle successStyle = new LGSnackBarStyle(successCustomColor, 80 | Color.WHITE, 81 | actionSuccessCustomColor, 82 | R.drawable.ic_done_white); 83 | 84 | LGSnackBarStyle warningStyle = new LGSnackBarStyle(warningCustomColor, 85 | Color.WHITE, 86 | actionWarningCustomColor, 87 | R.drawable.ic_warning_white); 88 | 89 | LGSnackBarStyle errorStyle = new LGSnackBarStyle(errorCustomColor, 90 | Color.WHITE, 91 | actionErrorCustomColor, 92 | R.drawable.ic_error_outline_white); 93 | 94 | LGSnackBarStyle infoStyle = new LGSnackBarStyle(infoCustomColor, 95 | Color.WHITE, 96 | actionInfoCustomColor, 97 | R.drawable.ic_info_outline_white); 98 | 99 | return new LGSnackBarTheme(successStyle, warningStyle, errorStyle, infoStyle, 60, Snackbar.LENGTH_LONG); 100 | } 101 | ``` 102 | 103 | ## Usage 104 | 105 | After preparing is done, in order to show a snackbar you can simply call: 106 | 107 | ```java 108 | LGSnackbarManager.show(SUCCESS, "Everything is looking good! Awesome!"); 109 | ``` 110 | 111 | Woooo, done! :-) 112 | 113 | ### Callbacks and actions 114 | 115 | You can add a callback and/or an action to your snackbar by calling: 116 | 117 | _Callback:_ 118 | ```java 119 | LGSnackbarManager.show(SUCCESS, "Everything is looking good! Awesome!", 120 | new Snackbar.Callback() { 121 | @Override 122 | public void onShown(Snackbar sb) { 123 | super.onShown(sb); 124 | // LGSnackbar is now visible 125 | } 126 | 127 | @Override 128 | public void onDismissed(Snackbar transientBottomBar, int event) { 129 | super.onDismissed(transientBottomBar, event); 130 | // LGSnackbar is now hidden 131 | } 132 | }); 133 | ``` 134 | _Action:_ 135 | ```java 136 | LGSnackbarManager.show(SUCCESS, "Everything is looking good! Awesome!", 137 | new LGSnackbarAction("Action", new View.OnClickListener() { 138 | @Override 139 | public void onClick(View view) { 140 | // Action fired 141 | } 142 | })); 143 | ``` 144 | ### Custom snackbar 145 | If for any reason you may need to display a custom snackbar without setting a whole new theme, you can use an `LGSnackbarBuilder` 146 | 147 | ```java 148 | new LGSnackbar.LGSnackbarBuilder(getApplicationContext(), "This is a custom bar") 149 | .duration(Snackbar.LENGTH_LONG) 150 | .actionTextColor(Color.GREEN) 151 | .backgroundColor(Color.GRAY) 152 | .minHeightDp(50) 153 | .textColor(Color.WHITE) 154 | .iconID(R.drawable.ic_info_outline_white) 155 | .callback(null) 156 | .action(null) 157 | .show(); 158 | ``` 159 | 160 | ##### Supported Attributes 161 | 162 | | Attribute | Description | Default value | 163 | | ------------- |-------------| -----| 164 | | style | An _LGSnackBarStyle_ instance | Native Android snackbar style | 165 | | duration | How long to display the message. Either _LENGTH_SHORT_ or _LENGTH_LONG_ | _LENGTH_LONG_ | 166 | | backgroundColor | The color of the snackbar | Native Android color | 167 | | actionTextColor | The color of the text of an action | Native Android color | 168 | | textColor | The color of the text | white | 169 | | minHeightDp | The height of the snackbar when only one line if text is displayed | 48 | 170 | | iconID | The drawable id of the icon | _NO_ICON_ID_ (-1) | 171 | | callback | The snackbar callback | _null_ | 172 | | action | The snackbar action | _null_ | 173 | 174 | ## Issues 175 | 176 | 177 | Feel free to submit issues and features requests. 178 | 179 | ## Contributing 180 | 181 | Contributions are more then welcome. Your contribution may include bug fixing, new features or just new themes. 182 | 183 | Please follow the "fork-and-pull" Git workflow (check [here](./CONTRIBUTING.md) for more). 184 | 185 | 1. **Fork** the repo on GitHub 186 | 2. **Clone** the project to your own machine 187 | 3. **Commit** changes to your own branch 188 | 4. **Push** your work back up to your fork 189 | 5. Submit a **Pull request** so that I can review your changes 190 | 191 | 192 | If you contribute with a new theme, please update also the `themes.md` file. 193 | 194 | _NOTE: Be sure to merge the latest from "upstream" before making a pull request!_ 195 | 196 | ## Author 197 | 198 | Lorenzo Greco 199 | 200 | - [Website](https://lorenzogreco.com) 201 | - [LinkedIn](https://www.linkedin.com/in/lorenzo-greco-61118195/) 202 | 203 | ## License 204 | ``` 205 | MIT License 206 | 207 | Copyright (c) 2017 Lorenzo Greco 208 | 209 | Permission is hereby granted, free of charge, to any person obtaining a copy 210 | of this software and associated documentation files (the "Software"), to deal 211 | in the Software without restriction, including without limitation the rights 212 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 213 | copies of the Software, and to permit persons to whom the Software is 214 | furnished to do so, subject to the following conditions: 215 | 216 | The above copyright notice and this permission notice shall be included in all 217 | copies or substantial portions of the Software. 218 | 219 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 220 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 221 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 222 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 223 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 224 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 225 | SOFTWARE. 226 | ``` 227 | --------------------------------------------------------------------------------