Skip to content

Commit

Permalink
Merge pull request #21 from JamesEllerbee/alert-on
Browse files Browse the repository at this point in the history
Add 'Notifications On' chocobar
  • Loading branch information
Pradyuman7 authored Oct 5, 2021
2 parents 3e5eb37 + f897b3b commit c9b6fe8
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
![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)



Expand Down
25 changes: 16 additions & 9 deletions app/src/main/java/com/pd/snickers/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ public void onClick(View v) {
}
});

findViewById(R.id.button_off_notification).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ChocoBar.builder().setView(v).centerText().setDuration(ChocoBar.LENGTH_LONG).black().show();
}
});

findViewById(R.id.button_love).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -95,8 +88,22 @@ public void onClick(View v) {
}
});

findViewById(R.id.button_off_notification).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ChocoBar.builder().setView(v).centerText().setDuration(ChocoBar.LENGTH_LONG).black().show();
}
});


findViewById(R.id.button_on_notification).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ChocoBar.builder()
.setView(v)
.centerText()
.setDuration(ChocoBar.LENGTH_LONG)
.notificationsOn().show();
}
});
}

}
61 changes: 39 additions & 22 deletions app/src/main/res/layout/content_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,10 @@
app:layout_constraintHorizontal_bias="0.0"
android:layout_width="match_parent"/>

<Button
android:text="@string/black_chocobar"
android:layout_height="wrap_content"
android:layout_below="@+id/button_bad"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_off_notification"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:layout_constraintTop_toBottomOf="@+id/button_bad"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@+id/button_custom"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.0"
android:layout_width="match_parent"/>

<Button
android:text="@string/love_chocobar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@+id/button_bad"
android:id="@+id/button_love"
app:layout_constraintTop_toBottomOf="@+id/button_custom"
Expand All @@ -183,18 +164,54 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.0"
android:layout_width="match_parent"/>
/>

<Button
android:text="@string/customized_chocobar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_off_notification"
android:layout_below="@+id/button_love"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_custom"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:layout_constraintTop_toBottomOf="@+id/button_love"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/button_on_notification"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"/>

<Button
android:text="@string/black_chocobar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@+id/button_custom"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/button_off_notification"
app:layout_constraintTop_toBottomOf="@+id/button_custom"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@+id/button_on_notification"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintHorizontal_bias="0.0" />

<Button
android:text="@string/notifications_on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button_off_notification"
android:id="@+id/button_on_notification"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
app:layout_constraintTop_toBottomOf="@+id/button_off_notification"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
<string name="gray_bad_chocobar">GRAY BAD CHOCOBAR</string>
<string name="black_chocobar">BLACK CHOCOBAR</string>
<string name="love_chocobar">Love Chocobar</string>
<string name="notifications_on">NOTIFICATIONS ON</string>
</resources>
11 changes: 8 additions & 3 deletions chocobar/src/main/java/com/pd/chocobar/ChocoBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ private enum Type {
GOOD(Color.parseColor("#C5BEBE"), R.drawable.good_mark, Color.WHITE, "GRAY_GOOD"),
BAD(Color.parseColor("#C5BEBE"), R.drawable.bad_mark, Color.WHITE, "GRAY_BAD"),
BLACK(Color.parseColor("#000000"), R.drawable.off_notification_mark, Color.WHITE, "Black"),
LOVE(Color.parseColor("#E8290B"), R.drawable.ic_love, Color.BLACK, "LOVE");
LOVE(Color.parseColor("#E8290B"), R.drawable.ic_love, Color.BLACK, "LOVE"),
NOTIFICATION_ON(Color.parseColor("#000000"), R.drawable.on_notification_mark, Color.WHITE, "NOTIFICATIONS ON");

private Integer color;
private Integer iconResId;
Expand Down Expand Up @@ -102,7 +103,6 @@ private Snackbar make() {
builder.actionClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {

}
};

Expand Down Expand Up @@ -170,7 +170,6 @@ else if (builder.actionTextColor != null)
else
text.setTypeface(textTypeface);


if (builder.textColor == null)
builder.textColor = builder.type.getStandardTextColor();

Expand Down Expand Up @@ -436,6 +435,12 @@ public Snackbar black() {
return make();
}

public Snackbar notificationsOn()
{
type = Type.NOTIFICATION_ON;
return make();
}

private Snackbar make() {
if (view == null)
throw new IllegalStateException("ChocoBar Error: You must set an Activity or a View before making a snack");
Expand Down
9 changes: 9 additions & 0 deletions chocobar/src/main/res/drawable/on_notification_mark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z"/>
</vector>

0 comments on commit c9b6fe8

Please sign in to comment.