Skip to content

Commit

Permalink
Fix Light Toasty text color, Add support for KitKat
Browse files Browse the repository at this point in the history
  • Loading branch information
Prathamesh More committed Aug 15, 2019
1 parent c80cb1c commit 8cc50ba
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "com.prathameshmore.toasty"
minSdkVersion 22
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file added app/release/app.aab
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.prathameshmore.toastylibrary.Toasty;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
<string name="info">Info Toast</string>
<string name="light">Light Toast</string>
<string name="dark">Dark Toast</string>
<string name="github">Star on GitHub</string>
<string name="github">How to use?</string>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.4.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions toasty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ android {


defaultConfig {
minSdkVersion 22
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionCode 2
versionName "1.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
19 changes: 11 additions & 8 deletions toasty/src/main/java/com/prathameshmore/toastylibrary/Colors.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

public interface Colors {

String PRIMARY = "#0069D9"; // Primary
String SECONDARY = "#FFFFFF";
String SUCCESS = "#218838"; // Green color for success
String DANGER = "#C82333"; // Red color for danger
String WARNING = "#E0A800"; // Yellow color for warning
String INFO = "#138496"; // Blue
String LIGHT = "#E2E6EA"; // Light
String DARK = "#23272B"; // Dark

String TEXT_COLOR = "#ffffff";
String DARK_TEXT = "#000000";

String PRIMARY = "#1866B9";
String SECONDARY = "#5A6268";
String SUCCESS = "#338542";
String DANGER = "#922A32";
String WARNING = "#C49919";
String INFO = "#2C8F9D";
String LIGHT = "#F8F9FA";
String DARK = "#23272B";


}
24 changes: 10 additions & 14 deletions toasty/src/main/java/com/prathameshmore/toastylibrary/Toasty.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,53 +42,49 @@ private void init() {
createView();
}

public void myToasty() {

}

public void primaryToasty(Context context, String text, int duration, int position) {
toastyType(context,text, duration, Colors.PRIMARY, position);
toastyType(context,text, duration, Colors.PRIMARY, position, Colors.TEXT_COLOR);
}

public void secondaryToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.SECONDARY, position);
toastyType(context, text, duration, Colors.SECONDARY, position, Colors.TEXT_COLOR);
}

public void infoToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.INFO, position);
toastyType(context, text, duration, Colors.INFO, position,Colors.TEXT_COLOR);
}

public void lightToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.LIGHT, position);
toastyType(context, text, duration, Colors.LIGHT, position,Colors.DARK_TEXT);
}

public void darkToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.DARK, position);
toastyType(context, text, duration, Colors.DARK, position,Colors.TEXT_COLOR);
}

public void successToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.SUCCESS, position);
toastyType(context, text, duration, Colors.SUCCESS, position,Colors.TEXT_COLOR);
}

public void dangerToasty(Context context, String text, int duration, int position) {
toastyType(context, text, duration, Colors.DANGER, position);
toastyType(context, text, duration, Colors.DANGER, position,Colors.TEXT_COLOR);
}

public void warningToasty(Context context, String text, int duration, int position) {
toastyType(context, text,duration, Colors.WARNING, position);
toastyType(context, text,duration, Colors.WARNING, position,Colors.TEXT_COLOR);
}

private void createView() {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.toasty_layout, null);
}

private Toast toastyType(Context context, String text, int duration, String type, int position) {
private Toast toastyType(Context context, String text, int duration, String type, int position, String textColor) {
init();
TextView toastyText = view.findViewById(R.id.text);
LinearLayout linearLayout = view.findViewById(R.id.linear_layout);
linearLayout.setBackground(toastyBackground(type));
toastyText.setTextColor(Color.parseColor(Colors.TEXT_COLOR));
toastyText.setTextColor(Color.parseColor(textColor));
toastyText.setText(text);
toast.setDuration(duration);
toast.setGravity(position,0,Toasty.Y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class ToastyBackground {

public Drawable toastyBackground(String color) {
RoundRectShape rectShape = new RoundRectShape(new float[] {75.0F, 75.0F, 75.0F, 75.0F, 75.0F, 75.0F, 75.0F, 75.0F},null,null);
RoundRectShape rectShape = new RoundRectShape(new float[] {10.0F, 10.0F, 10.0F, 10.0F, 10.0F, 10.0F, 10.0F, 10.0F},null,null);
ShapeDrawable shapeDrawable = new ShapeDrawable();
shapeDrawable.setShape(rectShape);
shapeDrawable.getPaint().setColor(Color.parseColor(color));
Expand Down
2 changes: 1 addition & 1 deletion toasty/src/main/res/layout/toasty_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textSize="20sp"
android:gravity="center"
android:padding="10dp"
android:layout_gravity="center" />
Expand Down

0 comments on commit 8cc50ba

Please sign in to comment.