-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,188 @@ | ||
# EasyToast | ||
[![platform](https://img.shields.io/badge/platform-Android-yellow.svg)](https://www.android.com) | ||
[![API](https://img.shields.io/badge/API-16%2B-brightgreen.svg?style=plastic)](https://android-arsenal.com/api?level=16) | ||
An Android library that takes the standard Android Toast to the next level with built-in icons from font-awesome and many styling options that gives your app and user experience an extra awesome feeling! | ||
|
||
|
||
<table> | ||
<tr> | ||
<td> | ||
<center> | ||
Success Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/success.png" width="250"> | ||
</center> | ||
</td> | ||
<td> | ||
<center> | ||
Info Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/info.png" width="250"> | ||
</center> | ||
</td> | ||
<td> | ||
<center> | ||
Error Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/error.png" width="250"> | ||
</center> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<center> | ||
Warning Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/warning.png" width="250"> | ||
</center> | ||
</td> | ||
<td> | ||
<center> | ||
Default Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/default.png" width="250"> | ||
</center> | ||
</td> | ||
<td> | ||
<center> | ||
Confusing Toast</br> | ||
<img src="https://raw.githubusercontent.com/naseemali925/EasyToast/master/images/confusing.png" width="250"> | ||
</center> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
## Prerequisites | ||
|
||
Add this in your root `build.gradle` file (**not** your module `build.gradle` file): | ||
|
||
```gradle | ||
allprojects { | ||
repositories { | ||
... | ||
maven { url "https://jitpack.io" } | ||
} | ||
} | ||
``` | ||
|
||
## Dependency | ||
|
||
Add this to your module's `build.gradle` file (make sure the version matches the JitPack badge above): | ||
|
||
```gradle | ||
dependencies { | ||
... | ||
compile 'com.github.naseemali925:EasyToast:0.0.1' | ||
} | ||
``` | ||
## Usage | ||
|
||
Each method always returns a `Toast` object, so you can customize the Toast much more. **DON'T FORGET THE `show()` METHOD!** | ||
|
||
**To display an default Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.DEFAULT,true); | ||
``` | ||
**To display a success Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.SUCCESS,true); | ||
``` | ||
**To display an info Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.INFO,true); | ||
``` | ||
**To display a warning Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.WARNING,true); | ||
``` | ||
**To display the error Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.ERROR,true); | ||
``` | ||
**To display the confusing Toast:** | ||
|
||
``` java | ||
EasyToast.makeText(this,"Hello World !",EasyToast.LENGTH_LONG,FancyToast.CONFUSING,true); | ||
``` | ||
**You can also remove the android icon on top-right corner by passing last parameter false.** | ||
``` java | ||
EasyToast.makeText(yourContext, "I'm a Toast", duration, type, boolen value).show(); | ||
``` | ||
|
||
## With The Builder Pattern | ||
|
||
```java | ||
EasyToast easyToast=new ToastBuilder(this) | ||
.textSize(16) | ||
.textColor(Color.WHITE) | ||
.showTopIcon(true) | ||
.leftIcon(FA.FA_CHECK) | ||
.typeface(someTypeface) | ||
.topIcon(FA.FA_ANGELLIST) | ||
.text("That's An Easy Toast") | ||
.type(EasyToast.SUCCESS) | ||
.build(); | ||
easyToast.show(); | ||
``` | ||
|
||
## Use Icons From Font Awesome | ||
|
||
Use The **FA** Class To Access And Use The Icon | ||
```java | ||
FA.FA_CHECK | ||
FA.FA_BELL | ||
. | ||
. | ||
. | ||
//Choose Any From 900+ Icons | ||
|
||
//Or Use A Drawable | ||
EasyToast easyToast=new ToastBuilder(this) | ||
.textColor(Color.WHITE) | ||
.leftIcon(R.drawable.some_drawable) | ||
.topIcon(R.drawable.some_drawable) | ||
.text("That's An Easy Toast") | ||
.type(EasyToast.SUCCESS) | ||
.build(); | ||
easyToast.show(); | ||
``` | ||
|
||
## Use Font Awesome With Other Views | ||
```java | ||
FA.with(context).initialize(); | ||
LinearLayout vGroup=(LinearLayout)findViewById(...); | ||
FA.addTo(vGroup);// It Will Add Font Awesome To All ChildViews That Supports Text(TextView,EditText,Button) | ||
FA.addTo(SomeTextView);// Adds Font Awesome To This TextView | ||
FA.addTo(SomeButton);// Adds Font Awesome To This Button | ||
FA.addTo(SomeEditText);// Adds Font Awesome To This EditText | ||
//Wanna Use Font-Awesome Icons Along Text | ||
someTextViewWithFA.setText("This Is A BUS "+FA.FA_BUS); | ||
|
||
``` | ||
|
||
## Contributing | ||
|
||
Please fork this repository and contribute back using | ||
[pull requests](https://github.com/naseemali925/EasyToast/pulls). | ||
|
||
Any contributions, large or small, major features, bug fixes, are welcomed and appreciated | ||
but will be thoroughly reviewed . | ||
|
||
### Contact - Let's become friend | ||
- [Twitter](https://twitter.com/thisismenaseem) | ||
- [Github](https://github.com/naseemali925) | ||
- [Linkedin](https://www.linkedin.com/in/naseem-ali-86842b144/) | ||
- [Facebook](https://www.facebook.com/naseem.ali.1466) | ||
|
||
# License | ||
|
||
MIT License | ||
|
||
Copyright (c) 2017 Naseem Ali | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the license conditions. |