From fe43eb80439ada25996c49de3ac42dbfe0e56a62 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 16 May 2020 15:35:26 +0200 Subject: [PATCH 1/3] Add getButton() function to access dialog buttons --- README.md | 12 ++++++++++++ .../materialstyleddialogs/MaterialStyledDialog.kt | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 889a4b9..f5e7818 100644 --- a/README.md +++ b/README.md @@ -381,6 +381,18 @@ new MaterialStyledDialog.Builder(this)
+### Get the buttons of the dialog +If you need to access the buttons of your dialog, you can achieve it like this: +```kotlin +val dialog = MaterialStyledDialog.Builder(this) + .setTitle("Awesome!") + .setDescription("This is a sample description.") + .show() + +dialog.positiveButton().text = "Positive" +dialog.negativeButton().text = "Negative" +``` + ## License Copyright 2016-2020 Javier Santos diff --git a/library/src/main/java/com/github/javiersantos/materialstyleddialogs/MaterialStyledDialog.kt b/library/src/main/java/com/github/javiersantos/materialstyleddialogs/MaterialStyledDialog.kt index 054686c..b1d7ae5 100644 --- a/library/src/main/java/com/github/javiersantos/materialstyleddialogs/MaterialStyledDialog.kt +++ b/library/src/main/java/com/github/javiersantos/materialstyleddialogs/MaterialStyledDialog.kt @@ -17,7 +17,10 @@ import androidx.appcompat.widget.AppCompatImageView import androidx.core.content.res.ResourcesCompat import com.afollestad.materialdialogs.DialogCallback import com.afollestad.materialdialogs.MaterialDialog +import com.afollestad.materialdialogs.WhichButton +import com.afollestad.materialdialogs.actions.getActionButton import com.afollestad.materialdialogs.customview.customView +import com.afollestad.materialdialogs.internal.button.DialogActionButton import com.github.javiersantos.materialstyleddialogs.UtilsAnimation.startAnimation import com.github.javiersantos.materialstyleddialogs.UtilsLibrary.dpToPixels import com.github.javiersantos.materialstyleddialogs.UtilsLibrary.getColor @@ -167,6 +170,11 @@ class MaterialStyledDialog( return contentView } + fun positiveButton() = builder.dialog?.getActionButton(WhichButton.POSITIVE) + fun negativeButton() = builder.dialog?.getActionButton(WhichButton.NEGATIVE) + @Deprecated("Neutral button is deprecated in the parent library: https://github.com/afollestad/material-dialogs") + fun neutralButton() = builder.dialog?.getActionButton(WhichButton.NEUTRAL) + class Builder(var context: Context) : IBuilder { var dialog: MaterialDialog? = null From 225a0d33c5b7ea6320d1de79d8f7eabf8f4feb69 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 16 May 2020 15:38:46 +0200 Subject: [PATCH 2/3] Update version to 3.1 --- README.md | 2 +- app/build.gradle | 4 ++-- library/build.gradle | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f5e7818..3b74d20 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ And add the library to your module **build.gradle**: ```gradle dependencies { - implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0' + implementation 'com.github.javiersantos:MaterialStyledDialogs:3.1' } ``` diff --git a/app/build.gradle b/app/build.gradle index c7a4055..7eb2e49 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.github.javiersantos.materialstyleddialogs.demo" minSdkVersion 16 targetSdkVersion 29 - versionCode 300 - versionName "3.0.0" + versionCode 310 + versionName "3.1.0" } buildTypes { release { diff --git a/library/build.gradle b/library/build.gradle index b6f6122..ac4a8cd 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -9,8 +9,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 29 - versionCode 300 - versionName "3.0.0" + versionCode 310 + versionName "3.1.0" } buildTypes { release { From 7e5764c83d317513616a76042b65f69f475dbd95 Mon Sep 17 00:00:00 2001 From: Marc Auberer Date: Sat, 16 May 2020 15:55:21 +0200 Subject: [PATCH 3/3] Fix version number --- README.md | 2 +- app/build.gradle | 4 ++-- library/build.gradle | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b74d20..3be46e8 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ And add the library to your module **build.gradle**: ```gradle dependencies { - implementation 'com.github.javiersantos:MaterialStyledDialogs:3.1' + implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0.1' } ``` diff --git a/app/build.gradle b/app/build.gradle index 7eb2e49..f00a2b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.github.javiersantos.materialstyleddialogs.demo" minSdkVersion 16 targetSdkVersion 29 - versionCode 310 - versionName "3.1.0" + versionCode 301 + versionName "3.0.1" } buildTypes { release { diff --git a/library/build.gradle b/library/build.gradle index ac4a8cd..c5df2e9 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -9,8 +9,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 29 - versionCode 310 - versionName "3.1.0" + versionCode 301 + versionName "3.0.1" } buildTypes { release {