Skip to content

Commit

Permalink
V1.0 will be released.
Browse files Browse the repository at this point in the history
  • Loading branch information
sad-adnan committed Mar 12, 2021
1 parent 39172ca commit 2ec34c5
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation project(path: ':CustomToastLib')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,64 @@
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.sadadnan.customtoastlib.CustomToast;

public class MainActivity extends AppCompatActivity {

private Button btn1,btn2,btn3,btn4,btn5;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();

initializeIDs();

clickListeners();
}

private void clickListeners() {
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomToast.ShowSuccessToast(MainActivity.this,false,"Congratulations");
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomToast.ShowErrorToast(MainActivity.this,false,"We are extremely sorry.");
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomToast.ShowInfoToast(MainActivity.this,false,"We have updated your status.");
}
});
btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomToast.showToastWithCustomDrawableAndBG(MainActivity.this,false,"Custom Icon",R.drawable.ic_baseline_auto_delete_24,R.color.toastColor);
}
});
btn5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomToast.showToastWithoutIcon(MainActivity.this,false,"Without icon",R.color.toastColor2);
}
});
}

CustomToast.ShowSuccessToast(this,false,"Congratulations");
private void initializeIDs() {
btn1 = findViewById(R.id.btn1);
btn2 = findViewById(R.id.btn2);
btn3 = findViewById(R.id.btn3);
btn4 = findViewById(R.id.btn4);
btn5 = findViewById(R.id.btn5);
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/drawable-v24/ic_baseline_auto_delete_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15,2l-3.5,0l-1,-1l-5,0l-1,1l-3.5,0l0,2l14,0z"/>
<path android:fillColor="@android:color/white" android:pathData="M16,9c-0.7,0 -1.37,0.1 -2,0.29V5H2v12c0,1.1 0.9,2 2,2h5.68c1.12,2.36 3.53,4 6.32,4c3.87,0 7,-3.13 7,-7C23,12.13 19.87,9 16,9zM16,21c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5s5,2.24 5,5S18.76,21 16,21z"/>
<path android:fillColor="@android:color/white" android:pathData="M16.5,12l-1.5,0l0,5l3.6,2.1l0.8,-1.2l-2.9,-1.7z"/>
</vector>
91 changes: 76 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:layout_margin="20dp"
android:layout_gravity="center"
android:orientation="vertical"
android:gravity="center">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Success Message"
android:textSize="20sp"
android:textStyle="bold"
android:textAlignment="center"
android:textAllCaps="false"
android:gravity="center_horizontal"
app:backgroundTint="@null"
android:background="#1D6A63"
android:layout_margin="10dp"/>
<Button
android:id="@+id/btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Error Message"
android:textSize="20sp"
android:textStyle="bold"
android:textAlignment="center"
android:textAllCaps="false"
android:gravity="center_horizontal"
app:backgroundTint="@null"
android:background="#C23E34"
android:layout_margin="10dp"/>
<Button
android:id="@+id/btn3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Info Message"
android:textSize="20sp"
android:textStyle="bold"
android:textAlignment="center"
android:textAllCaps="false"
android:gravity="center_horizontal"
app:backgroundTint="@null"
android:background="#3F51B5"
android:layout_margin="10dp"/>
<Button
android:id="@+id/btn4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Custom Icon"
android:textSize="20sp"
android:textStyle="bold"
android:textAlignment="center"
android:textAllCaps="false"
android:gravity="center_horizontal"
app:backgroundTint="@null"
android:background="#E91E63"
android:layout_margin="10dp"/>
<Button
android:id="@+id/btn5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Without Icon"
android:textSize="20sp"
android:textStyle="bold"
android:textAlignment="center"
android:textAllCaps="false"
android:gravity="center_horizontal"
app:backgroundTint="@null"
android:background="#6D1A7B"
android:layout_margin="10dp"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="toastColor">#FF5722</color>
<color name="toastColor2">#6D1A7B</color>
</resources>

0 comments on commit 2ec34c5

Please sign in to comment.