Skip to content

Commit

Permalink
Merge pull request #26 from JamesEllerbee/24-improve-documentation
Browse files Browse the repository at this point in the history
24 Improve Documentation
  • Loading branch information
Pradyuman7 authored Oct 9, 2021
2 parents 289b24b + db3652d commit 9551835
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 96 deletions.
144 changes: 144 additions & 0 deletions Documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
## Usage

Chocobar has several built-in types which specifies color, icon, text, and text color.

Each method always returns a `Snackbar` object, so you can customize the Snackbar further and much more.

Check out the following examples:

- To display a `green` ChocoBar:

``` java
ChocoBar.builder().setActivity(v)
.setText("GREEN")
.setDuration(ChocoBar.LENGTH_SHORT)
.green() // built-in green ChocoBar
.show();
```

- To display an `orange` Chocobar

``` java
ChocoBar.builder().setActivity(v)
.setText("ORANGE")
.setDuration(ChocoBar.LENGTH_SHORT)
.orange() // built-in orange ChocoBar
.show();
```
- To display a `red` ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("RED")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
.red() // built-in red ChocoBar
.show();
```

- To display a `cyan` Chocobar:

``` java
ChocoBar.builder().setView(v)
.setText("CYAN")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
.cyan() // built-in cyan ChocoBar
.show();
```

- To display a `gray` ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("GRAY_GOOD")
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.good()
.show();

ChocoBar.builder().setView(v)
.setText("GRAY_BAD")
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.bad()
.show();
```

- To display a `love` ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("Love")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
.love() // built-in red ChocoBar
.show();
```

- To display a `default` ChocoBar that provides an action:

``` java
ChocoBar.builder().setActivity(v)
.setActionText("ACTION")
.setActionClickListener(v1 ->
Toast.makeText(MainActivity.this,"You clicked",Toast.LENGTH_LONG).show();)
.setText("This is a default ChocoBar")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.build()
.show();
```

- To display a `black` ChocoBar:

```java
ChocoBar.builder()
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.black() // built-in black ChocoBar
.show());
```

- To display a `notifications on` Chocobar:

```java
ChocoBar.builder()
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.notificationsOn() // built-in notifications on ChocoBar
.show());
```

- To display a `blocked` Chocobar:

```java
ChocoBar.builder()
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.blocked() // built-in blocked on ChocoBar
.show());
```

- You can also create highly customized ChocoBars:

``` java
ChocoBar.builder().setBackgroundColor(Color.parseColor("#00bfff"))
.setTextSize(18)
.setTextColor(Color.parseColor("#FFFFFF"))
.setTextTypefaceStyle(Typeface.ITALIC)
.setText("This is a custom Chocobar")
.setMaxLines(4)
.centerText()
.setActionText("ChocoBar")
.setActionTextColor(Color.parseColor("#66FFFFFF"))
.setActionTextSize(20)
.setActionTextTypefaceStyle(Typeface.BOLD)
.setIcon(R.mipmap.ic_launcher)
.setActivity(MainActivity.this)
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.build()
.show();
```
98 changes: 6 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@
![screenshot 2018-12-31 at 4 26 00 am](https://user-images.githubusercontent.com/37071007/68586351-d6fb0700-04c7-11ea-8133-dd0e14fcd8c8.png)
![screenshot 2018-12-31 at 4 26 00 am](https://user-images.githubusercontent.com/37071007/68586380-e5e1b980-04c7-11ea-95eb-612167d59448.png)
![Love Chocobar](https://user-images.githubusercontent.com/35525781/96970060-c012c080-1530-11eb-926c-59edd1844413.png)
![Screenshot_1633403711](https://user-images.githubusercontent.com/26584526/135955251-1a5ef862-8e84-4571-9685-33b70ade14bd.png)
![image](https://user-images.githubusercontent.com/26584526/136639395-7a70f775-b5d3-4ad4-8b4f-d0ce91490c18.png)
![image](https://user-images.githubusercontent.com/26584526/136639381-19bfd6f0-a34e-49f9-8b7e-4e34c4e02ba7.png)

## Documentation
[Find how to use the built-in Chocobars here](Documentation.md)

## Prerequisites

Add this in your root `build.gradle` file (**not** your module `build.gradle` file):


```gradle
allprojects {
repositories {
Expand All @@ -76,99 +79,10 @@ dependencies {
}
```

## Usage

Each method always returns a `Snackbar` object, so you can customize the Snackbar and much more. Check out the following examples:

- To display a green ChocoBar:

``` java
ChocoBar.builder().setActivity(MainActivity.this)
.setText("GREEN")
.setDuration(ChocoBar.LENGTH_SHORT)
.green() // in built green ChocoBar
.show();
```
- To display a red ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("RED")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
.red() // in built red ChocoBar
.show();
```
- To display a gray ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("GRAY_GOOD")
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.good()
.show();

ChocoBar.builder().setView(v)
.setText("GRAY_BAD")
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.bad()
.show();
```

- To display a love ChocoBar:

``` java
ChocoBar.builder().setView(v)
.setText("Love")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
.love() // in built red ChocoBar
.show();
```
- To display a simple ChocoBar with a button and some action on clicking the button.

``` java
ChocoBar.builder().setActivity(MainActivity.this).setActionText("ACTION")
.setActionClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"You clicked",Toast.LENGTH_LONG).show();
}
})
.setText("This is a normal ChocoBar")
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.build()
.show();
```
- You can also create custom ChocoBars with tons of customizations like this:
``` java
ChocoBar.builder().setBackgroundColor(Color.parseColor("#00bfff"))
.setTextSize(18)
.setTextColor(Color.parseColor("#FFFFFF"))
.setTextTypefaceStyle(Typeface.ITALIC)
.setText("This is a custom Chocobar")
.setMaxLines(4)
.centerText()
.setActionText("ChocoBar")
.setActionTextColor(Color.parseColor("#66FFFFFF"))
.setActionTextSize(20)
.setActionTextTypefaceStyle(Typeface.BOLD)
.setIcon(R.mipmap.ic_launcher)
.setActivity(MainActivity.this)
.setDuration(ChocoBar.LENGTH_INDEFINITE)
.build()
.show();

```

## Pull Request

Have some new ideas or found a bug? Do not hesitate to open an `issue` and make a `pull request`.

## License

**ChocoBar** is under [![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT). See the [LICENSE](LICENSE.md) file for more info.
**ChocoBar** is under [![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT). See the [LICENSE](LICENSE.md) file for more info.
11 changes: 10 additions & 1 deletion app/src/main/java/com/pd/snickers/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

findViewById(R.id.button_default).setOnClickListener(v -> ChocoBar.builder()
Expand Down Expand Up @@ -106,6 +107,14 @@ protected void onCreate(Bundle savedInstanceState) {
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.notificationsOn().show());
.notificationsOn()
.show());

findViewById(R.id.button_blocked).setOnClickListener(v -> ChocoBar.builder()
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.blocked()
.show());
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/content_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@
android:text="@string/blocked_chocobar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_off_notification"
android:layout_below="@+id/button_on_notification"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_blocked"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:layout_constraintTop_toBottomOf="@+id/button_off_notification"
app:layout_constraintTop_toBottomOf="@+id/button_on_notification"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
Expand Down
1 change: 0 additions & 1 deletion chocobar/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<application
android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>

0 comments on commit 9551835

Please sign in to comment.