diff --git a/README.md b/README.md
index b7568b8..fa95741 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Add this to your module's `build.gradle` file:
```gradle
dependencies {
...
- implementation 'com.github.Dan629pl:nordan-material-dialog-android:1.0.4'
+ implementation 'com.github.Dan629pl:nordan-material-dialog-android:1.0.5'
}
```
Nordan Alert Dialog
diff --git a/app/build.gradle b/app/build.gradle
index 8b795a5..cc08055 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
minSdkVersion 24
targetSdkVersion 30
versionCode 1
- versionName "Nordan Material Dialog v1.0.1"
+ versionName "Nordan Material Dialog v1.0.5"
}
buildTypes {
diff --git a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java
index e312488..927a644 100644
--- a/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java
+++ b/app/src/main/java/com/nordan/dialog/NordanAlertDialog.java
@@ -2,15 +2,19 @@
import android.app.Activity;
import android.app.Dialog;
+import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.Window;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
+
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textview.MaterialTextView;
+
import java.util.Optional;
+
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import pl.droidsonroids.gif.GifImageView;
@@ -26,11 +30,13 @@ public static class Builder {
private String negativeBtnText;
private Activity activity;
private Animation animation;
- private int icon;
+ private int headerIconResource;
+ private int dialogAccentColor;
+ private Bitmap headerIconDrawable;
private boolean isGif;
private NordanAlertDialogListener positiveListener;
private NordanAlertDialogListener negativeListener;
- private int backgroundColor;
+ private int headerColor;
private boolean isCancelable;
private DialogType dialogType;
@@ -48,8 +54,13 @@ public Builder setDialogType(DialogType dialogType) {
return this;
}
- public Builder setBackgroundColor(int bgColor) {
- this.backgroundColor = bgColor;
+ public Builder setDialogAccentColor(int color) {
+ this.dialogAccentColor = color;
+ return this;
+ }
+
+ public Builder setHeaderColor(int bgColor) {
+ this.headerColor = bgColor;
return this;
}
@@ -69,7 +80,13 @@ public Builder setNegativeBtnText(String negativeBtnText) {
}
public Builder setIcon(int icon, boolean isGif) {
- this.icon = icon;
+ this.headerIconResource = icon;
+ this.isGif = isGif;
+ return this;
+ }
+
+ public Builder setIcon(Bitmap icon, boolean isGif) {
+ this.headerIconDrawable = icon;
this.isGif = isGif;
return this;
}
@@ -139,15 +156,15 @@ public Dialog build() {
} else {
setCustomDialog(dialog, iconImg, view);
}
- if (positiveBtnText != null) {
+ if (positiveBtnText != null && !positiveBtnText.isEmpty()) {
positiveButton.setText(positiveBtnText);
}
- if (negativeBtnText != null) {
+ if (negativeBtnText != null && !negativeBtnText.isEmpty()) {
negativeButton.setText(negativeBtnText);
} else {
negativeButton.setVisibility(View.GONE);
}
- if (positiveListener != null) {
+ if (positiveListener != null && positiveBtnText != null && !positiveBtnText.isEmpty()) {
positiveButton.setOnClickListener(click -> {
positiveListener.onClick();
dialog.dismiss();
@@ -155,7 +172,7 @@ public Dialog build() {
} else {
positiveButton.setOnClickListener(click -> dialog.dismiss());
}
- if (negativeListener != null) {
+ if (negativeListener != null && negativeBtnText != null && !negativeBtnText.isEmpty()) {
negativeButton.setVisibility(View.VISIBLE);
negativeButton.setOnClickListener(view1 -> {
negativeListener.onClick();
@@ -164,6 +181,10 @@ public Dialog build() {
} else {
negativeButton.setOnClickListener(click -> dialog.dismiss());
}
+ if (dialogAccentColor > 0) {
+ positiveButton.setBackgroundColor(activity.getColor(dialogAccentColor));
+ negativeButton.setTextColor(activity.getColor(dialogAccentColor));
+ }
return dialog;
}
@@ -199,20 +220,20 @@ private void setInformationDialog(GifImageView iconImg, View view) {
private void setCustomDialog(Dialog dialog, GifImageView iconImg, View view) {
RelativeLayout relativeHeader = dialog.findViewById(R.id.relative_header);
- if (icon == 0 && backgroundColor == 0) {
+ if (headerIconResource == 0 && headerColor == 0 && headerIconDrawable == null) {
relativeHeader.setVisibility(View.GONE);
return;
}
- if (icon != 0) {
- iconImg.setImageResource(icon);
+ if (headerIconResource != 0) {
+ iconImg.setImageResource(headerIconResource);
iconImg.setVisibility(View.VISIBLE);
if (isGif) {
relativeHeader.getLayoutParams().height = 250;
iconImg.setScaleType(ScaleType.CENTER_CROP);
}
}
- if (backgroundColor != 0) {
- view.setBackgroundColor(backgroundColor);
+ if (headerColor != 0) {
+ view.setBackgroundColor(headerColor);
}
}
diff --git a/app/src/main/java/com/nordan/dialog/NordanLoadingDialog.java b/app/src/main/java/com/nordan/dialog/NordanLoadingDialog.java
index 5c8d164..250d456 100644
--- a/app/src/main/java/com/nordan/dialog/NordanLoadingDialog.java
+++ b/app/src/main/java/com/nordan/dialog/NordanLoadingDialog.java
@@ -5,8 +5,12 @@
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.Window;
+import android.widget.ProgressBar;
+
import com.google.android.material.textview.MaterialTextView;
+
import java.util.Optional;
+
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -14,6 +18,10 @@
public class NordanLoadingDialog {
public static Dialog createLoadingDialog(Activity activity, String loadingText) {
+ return createLoadingDialog(activity, loadingText, 0);
+ }
+
+ public static Dialog createLoadingDialog(Activity activity, String loadingText, int accentColor) {
Dialog loadingDialog = new Dialog(activity);
loadingDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Optional.ofNullable(loadingDialog.getWindow())
@@ -21,6 +29,10 @@ public static Dialog createLoadingDialog(Activity activity, String loadingText)
loadingDialog.setCancelable(false);
loadingDialog.setContentView(R.layout.nordan_loading_dialog);
((MaterialTextView) loadingDialog.findViewById(R.id.loading_text)).setText(loadingText);
+ ProgressBar loadingBar = loadingDialog.findViewById(R.id.progress_bar);
+ if (accentColor > 0) {
+ loadingBar.getIndeterminateDrawable().setColorFilter(activity.getColor(accentColor), android.graphics.PorterDuff.Mode.MULTIPLY);
+ }
return loadingDialog;
}
}
diff --git a/app/src/main/res/layout/nordan_alert_dialog.xml b/app/src/main/res/layout/nordan_alert_dialog.xml
index bab98b3..64d5fc4 100644
--- a/app/src/main/res/layout/nordan_alert_dialog.xml
+++ b/app/src/main/res/layout/nordan_alert_dialog.xml
@@ -34,38 +34,38 @@
android:visibility="gone" />
-
+
+ android:id="@+id/message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/title"
+ android:layout_marginTop="10dp"
+ android:elegantTextHeight="true"
+ android:fontFamily="@font/product_sans_regular"
+ android:gravity="center"
+ android:paddingLeft="10dp"
+ android:paddingRight="10dp"
+ android:text="@string/dialog_message"
+ android:textAlignment="center"
+ android:textSize="16sp" />
+ android:id="@+id/negativeBtn"
+ style="@style/NordanDialogButtonTextTheme"
+ android:layout_weight="50"
+ android:text="@android:string/cancel" />
-
-
-
-
+
-
-
+ android:layout_centerInParent="true"
+ app:cardBackgroundColor="@android:color/white"
+ app:cardCornerRadius="10dp"
+ app:cardUseCompatPadding="true">
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/style.xml b/app/src/main/res/values/style.xml
index 8d96752..c9dfe00 100644
--- a/app/src/main/res/values/style.xml
+++ b/app/src/main/res/values/style.xml
@@ -5,30 +5,27 @@
- @color/colorRed
-
-
-
-
-
-
+
+
+
+
-
\ No newline at end of file