Skip to content

Commit

Permalink
Added Title, Content, Button background and text colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
hishd committed Jun 10, 2020
1 parent 6605588 commit 374ec4c
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 14 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

1 change: 1 addition & 0 deletions animdialog/src/main/assets/information.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"v":"5.5.1","fr":60,"ip":0,"op":30,"w":180,"h":180,"nm":"informaiton","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"head","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[89,53,0],"to":[0,-2.833,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":7,"s":[89,36,0],"to":[0,0,0],"ti":[0,-2.833,0]},{"t":14,"s":[89,53,0]}],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":7,"s":[80,130,100]},{"t":14,"s":[100,100,100]}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0.52],[-0.2,0.45],[-0.35,0.35],[-0.44,0.2],[-0.52,0],[-0.44,-0.2],[-0.35,-0.35],[-0.2,-0.44],[0,-0.52],[0.2,-0.44],[0.35,-0.35],[0.45,-0.2],[0.52,0],[0.45,0.2],[0.35,0.35],[0.2,0.45]],"o":[[0,-0.52],[0.2,-0.44],[0.35,-0.35],[0.45,-0.2],[0.52,0],[0.45,0.2],[0.35,0.35],[0.2,0.45],[0,0.52],[-0.2,0.45],[-0.35,0.35],[-0.44,0.2],[-0.52,0],[-0.44,-0.2],[-0.35,-0.35],[-0.2,-0.44]],"v":[[-3.769,0.001],[-3.469,-1.459],[-2.649,-2.649],[-1.459,-3.469],[0.001,-3.769],[1.451,-3.469],[2.651,-2.649],[3.471,-1.459],[3.771,0.001],[3.471,1.451],[2.651,2.651],[1.451,3.471],[0.001,3.771],[-1.459,3.471],[-2.649,2.651],[-3.469,1.451]],"c":true},"ix":2},"nm":"패스 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"칠 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"변형"}],"nm":"Path","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":90,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"body","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[89.308,106,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.61,-0.52],[0.94,0],[0.61,0.52],[0,0.91],[0,0],[-0.61,0.52],[-0.95,0],[-0.61,-0.52],[0,-0.91]],"o":[[0,0.91],[-0.61,0.52],[-0.95,0],[-0.61,-0.52],[0,0],[0,-0.91],[0.61,-0.52],[0.94,0],[0.61,0.52],[0,0]],"v":[[3.243,7.57],[2.333,9.72],[0.003,10.5],[-2.337,9.72],[-3.247,7.57],[-3.247,-7.57],[-2.337,-9.72],[0.003,-10.5],[2.333,-9.72],[3.243,-7.57]],"c":true},"ix":2},"nm":"패스 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"칠 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"변형"}],"nm":"Path","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":90,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Oval","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[90,90,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[52,52],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"타원 패스 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0.274509996176,0.576470971107,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"칠 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[300,300],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"변형"}],"nm":"Oval","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":90,"st":0,"bm":0}],"markers":[]}
79 changes: 75 additions & 4 deletions animdialog/src/main/java/com/hishd/animdialog/AnimDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.airbnb.lottie.LottieAnimationView;
Expand All @@ -19,9 +22,56 @@ public class AnimDialog extends Dialog {
TextView txtTitle;
TextView txtContent;
Button btn1, btn2;
RelativeLayout rootLayout;
Context context;

public AnimDialog(Context context) {
super(context);
this.context = context;
}

public AnimDialog setBackgroundColor(int color) {
Drawable background = rootLayout.getBackground();
if (background instanceof ShapeDrawable) {
((ShapeDrawable) background).getPaint().setColor(context.getColor(color));
} else if (background instanceof GradientDrawable) {
((GradientDrawable) background).setColor(context.getColor(color));
} else if (background instanceof ColorDrawable) {
((ColorDrawable) background).setColor(context.getColor(color));
}
return this;
}

public AnimDialog setButton1BackgroundColor(int color) {

if (btn1 == null)
return this;

Drawable btn1Background = btn1.getBackground();
if (btn1Background instanceof ShapeDrawable) {
((ShapeDrawable) btn1Background).getPaint().setColor(context.getColor(color));
} else if (btn1Background instanceof GradientDrawable) {
((GradientDrawable) btn1Background).setColor(context.getColor(color));
} else if (btn1Background instanceof ColorDrawable) {
((ColorDrawable) btn1Background).setColor(context.getColor(color));
}
return this;
}

public AnimDialog setButton2BackgroundColor(int color) {

if (btn2 == null)
return this;

Drawable btn2Background = btn2.getBackground();
if (btn2Background instanceof ShapeDrawable) {
((ShapeDrawable) btn2Background).getPaint().setColor(context.getColor(color));
} else if (btn2Background instanceof GradientDrawable) {
((GradientDrawable) btn2Background).setColor(context.getColor(color));
} else if (btn2Background instanceof ColorDrawable) {
((ColorDrawable) btn2Background).setColor(context.getColor(color));
}
return this;
}

public AnimDialog setImage(Drawable drawable) {
Expand All @@ -43,15 +93,28 @@ public AnimDialog setTitle(String title) {
return this;
}

public AnimDialog setTitleColor(int color) {
if (txtTitle != null)
txtTitle.setTextColor(context.getColor(color));
return this;
}

public AnimDialog setContent(String content) {
if (txtContent != null)
txtContent.setText(content);
return this;
}

public AnimDialog setButton1(String buttonText, int textColor, final AnimOnClickListener animOnClickListener) {
public AnimDialog setContentColor(int color) {
if (txtContent != null)
txtContent.setTextColor(context.getColor(color));
return this;
}

public AnimDialog setButton1(String buttonText, int textColor, boolean allCaps, final AnimOnClickListener animOnClickListener) {
if (btn1 != null) {
btn1.setText(buttonText);
btn1.setAllCaps(allCaps);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -65,9 +128,10 @@ public void onClick(View v) {
return this;
}

public AnimDialog setButton2(String buttonText, int textColor, final AnimOnClickListener animOnClickListener) {
public AnimDialog setButton2(String buttonText, int textColor, boolean allCaps, final AnimOnClickListener animOnClickListener) {
if (btn2 != null) {
btn2.setText(buttonText);
btn2.setAllCaps(allCaps);
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -83,8 +147,10 @@ public void onClick(View v) {

public AnimDialog createAnimatedSingleDialog() {
setContentView(R.layout.layout_animated_single);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
lotteView = findViewById(R.id.lotteView);
lotteView.setAnimation("");
lotteView.setAnimation("information.json");
rootLayout = findViewById(R.id.rootLayout);
txtTitle = findViewById(R.id.txtTitle);
txtContent = findViewById(R.id.txtContent);
btn1 = findViewById(R.id.btn1);
Expand All @@ -95,6 +161,7 @@ public AnimDialog createAnimatedDualDialog() {
setContentView(R.layout.layout_animated_dual);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
lotteView = findViewById(R.id.lotteView);
rootLayout = findViewById(R.id.rootLayout);
txtTitle = findViewById(R.id.txtTitle);
txtContent = findViewById(R.id.txtContent);
btn1 = findViewById(R.id.btn1);
Expand All @@ -104,6 +171,8 @@ public AnimDialog createAnimatedDualDialog() {

public AnimDialog createNonAnimatedSingleDialog() {
setContentView(R.layout.layout_non_animated_single);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
rootLayout = findViewById(R.id.rootLayout);
img = findViewById(R.id.img);
txtTitle = findViewById(R.id.txtTitle);
txtContent = findViewById(R.id.txtContent);
Expand All @@ -113,6 +182,8 @@ public AnimDialog createNonAnimatedSingleDialog() {

public AnimDialog createNonAnimatedDualDialog() {
setContentView(R.layout.layout_non_animated_dual);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
rootLayout = findViewById(R.id.rootLayout);
img = findViewById(R.id.img);
txtTitle = findViewById(R.id.txtTitle);
txtContent = findViewById(R.id.txtContent);
Expand All @@ -122,7 +193,7 @@ public AnimDialog createNonAnimatedDualDialog() {
}


public interface AnimOnClickListener{
public interface AnimOnClickListener {
void onClicked(Dialog dialog);
}
}
1 change: 0 additions & 1 deletion animdialog/src/main/res/drawable/round_button_blue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<stroke android:color="#4153FF" android:width="2dp"/>
<solid android:color="#4153FF"/>
<corners android:radius="10dp"></corners>

Expand Down
1 change: 1 addition & 0 deletions animdialog/src/main/res/layout/layout_animated_dual.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions animdialog/src/main/res/layout/layout_animated_single.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion animdialog/src/main/res/layout/layout_non_animated_dual.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/round_layout"
Expand All @@ -9,7 +10,7 @@
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:padding="@dimen/_5sdp"
android:padding="@dimen/_20sdp"
android:scaleType="fitCenter" />

<TextView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/round_layout"
Expand All @@ -9,7 +10,7 @@
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="@dimen/_100sdp"
android:padding="@dimen/_5sdp"
android:padding="@dimen/_20sdp"
android:scaleType="fitCenter" />

<TextView
Expand Down
30 changes: 24 additions & 6 deletions app/src/main/java/com/hishd/animationdialog/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public void onClick(View v) {
new AnimDialog(MainActivity.this)
.createAnimatedSingleDialog()
.setAnimation("loading.json")
.setBackgroundColor(R.color.color1)
.setButton1BackgroundColor(R.color.button1)
.setTitle("Loading Mail")
.setTitleColor(R.color.color_title)
.setContentColor(R.color.color_text)
.setContent("Example content to illustrate a loading animation")
.setButton1("OK", 0, new AnimDialog.AnimOnClickListener() {
.setButton1("OK", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked OK", Toast.LENGTH_SHORT).show();
Expand All @@ -50,16 +54,21 @@ public void onClick(View v) {
new AnimDialog(MainActivity.this)
.createAnimatedDualDialog()
.setAnimation("location.json")
.setBackgroundColor(R.color.color3)
.setButton1BackgroundColor(R.color.button1)
.setButton2BackgroundColor(R.color.button2)
.setTitleColor(R.color.color_title)
.setContentColor(R.color.color_text)
.setTitle("Loading Location")
.setContent("Example content to illustrate a Location animation")
.setButton1("OK", 0, new AnimDialog.AnimOnClickListener() {
.setButton1("OK", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked OK", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
})
.setButton2("Cancel", 0, new AnimDialog.AnimOnClickListener() {
.setButton2("Cancel", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked Cancel", Toast.LENGTH_SHORT).show();
Expand All @@ -74,9 +83,13 @@ public void onClick(View v) {
new AnimDialog(MainActivity.this)
.createNonAnimatedSingleDialog()
.setImage(getDrawable(R.drawable.profile_blank))
.setButton1BackgroundColor(R.color.button3)
.setBackgroundColor(R.color.color3)
.setTitleColor(R.color.color_title)
.setContentColor(R.color.color_text)
.setTitle("Loading Contacts")
.setContent("Example content to illustrate a sample non anim dialog.")
.setButton1("OK", 0, new AnimDialog.AnimOnClickListener() {
.setButton1("OK", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked OK", Toast.LENGTH_SHORT).show();
Expand All @@ -91,16 +104,21 @@ public void onClick(View v) {
new AnimDialog(MainActivity.this)
.createNonAnimatedDualDialog()
.setImage(getDrawable(R.drawable.dummy_image))
.setButton1BackgroundColor(R.color.button1)
.setButton2BackgroundColor(R.color.button4)
.setBackgroundColor(R.color.color1)
.setTitleColor(R.color.color_title)
.setContentColor(R.color.color_text)
.setTitle("Loading Images")
.setContent("Example content to illustrate a sample non anim dialog.")
.setButton1("OK", 0, new AnimDialog.AnimOnClickListener() {
.setButton1("OK", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked OK", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
})
.setButton2("Cancel", 0, new AnimDialog.AnimOnClickListener() {
.setButton2("Cancel", 0, false, new AnimDialog.AnimOnClickListener() {
@Override
public void onClicked(Dialog dialog) {
Toast.makeText(getApplicationContext(), "Clicked Cancel", Toast.LENGTH_SHORT).show();
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
<color name="colorAccent">#48FFEE</color>
<color name="color1">#69FFF1</color>
<color name="color3">#69C3FF</color>
<color name="color_title">#0113E3</color>
<color name="color_text">#595959</color>

<color name="button1">#4153FF</color>
<color name="button2">#A85B1C</color>
<color name="button3">#31981C</color>
<color name="button4">#632BB8</color>
</resources>
Binary file added images/animdialog.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 374ec4c

Please sign in to comment.