Skip to content

Commit 94937c5

Browse files
New Version v20.2.2
1 parent 42a638b commit 94937c5

File tree

32 files changed

+40
-20
lines changed

32 files changed

+40
-20
lines changed
Binary file not shown.
Binary file not shown.

.gradle/7.4/fileHashes/fileHashes.bin

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
170 Bytes
Binary file not shown.
Binary file not shown.

.gradle/file-system.probe

0 Bytes
Binary file not shown.

.idea/workspace.xml

+3-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
![](https://github.com/TutorialsAndroid/KAlertDialog/blob/master/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png)
22

3-
# New version released v20.2.1 on 18-10-2022
3+
# New version released v20.2.2 on 18-10-2022
44
## Changelogs
55
- Fixed issue in button not changing color in NORMAL_TYPE dialog
6+
- Now you can hide confirm and cancel button on alert dialog type change
67
### Read the changes in README
78

89
Alert Dialog ![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat) [![Known Vulnerabilities](https://snyk.io/test/github/TutorialsAndroid/KAlertDialog/badge.svg?targetFile=library%2Fbuild.gradle)](https://snyk.io/test/github/TutorialsAndroid/KAlertDialog?targetFile=library%2Fbuild.gradle) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-KAlertDiaog-blue.svg?style=flat)](https://android-arsenal.com/details/1/7588) [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -67,7 +68,7 @@ Add it in your root build.gradle at the end of repositories:
6768
Step 2. Add the dependency
6869

6970
dependencies {
70-
implementation 'com.github.TutorialsAndroid:KAlertDialog:v20.2.1'
71+
implementation 'com.github.TutorialsAndroid:KAlertDialog:v20.2.2'
7172
}
7273

7374
## Usage
@@ -336,6 +337,26 @@ And if you want to hide Title Text and Content Text of alert dialog
336337
.setTitleText("Are you sure?") //just don't write this line if you want to hide title text
337338
.setContentText("Won't be able to recover this file!") // don't write this line if you want to hide content text
338339

340+
And if you want to hide Title Text and Content Text on alert type change
341+
342+
new KAlertDialog(this, KAlertDialog.WARNING_TYPE)
343+
.setTitleText("Are you sure?")
344+
.setContentText("Won't be able to recover this file!")
345+
.showCancelButton(true)
346+
.setCancelClickListener("No,cancel plx!", sDialog ->
347+
sDialog.setTitleText(null)
348+
.setContentText("Your imaginary file is safe :)")
349+
.showCancelButton(false)
350+
.setConfirmClickListener("OK", null)
351+
.changeAlertType(KAlertDialog.ERROR_TYPE))
352+
.setConfirmClickListener("Yes,delete it!",sDialog ->
353+
sDialog.setTitleText("Deleted!")
354+
.showCancelButton(false)
355+
.setContentText(null)
356+
.setConfirmClickListener("OK",null)
357+
.changeAlertType(KAlertDialog.SUCCESS_TYPE))
358+
.show();
359+
339360
**Change** the dialog style upon confirming:
340361

341362
new KAlertDialog(this, KAlertDialog.WARNING_TYPE, 0)
Binary file not shown.
Binary file not shown.

library/src/main/java/com/developer/kalert/KAlertDialog.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public KAlertDialog setTitleText(String text) {
272272

273273
mTitleText = text;
274274
if (mTitleTextView != null && mTitleText != null) {
275-
showTitleText();
275+
showTitleText(true);
276276
if (titleTextSize != 0) {
277277
mTitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, spToPx(titleTextSize, getContext()));
278278
}
@@ -284,6 +284,8 @@ public KAlertDialog setTitleText(String text) {
284284
}else {
285285
mTitleTextView.setText(Html.fromHtml(mTitleText));
286286
}
287+
} else {
288+
showTitleText(false);
287289
}
288290
return this;
289291
}
@@ -300,11 +302,11 @@ public KAlertDialog setTitleTextGravity(int gravity) {
300302
return this;
301303
}
302304

303-
private void showTitleText() {
305+
private void showTitleText(boolean isShow) {
304306
mShowTitleText = true;
305307
if (mTitleTextView != null) {
306-
mTitleTextView.setVisibility(View.VISIBLE);
307-
mContentTextView.setAutoLinkMask(Linkify.ALL);
308+
mTitleTextView.setVisibility( isShow ? View.VISIBLE : GONE );
309+
mTitleTextView.setAutoLinkMask(Linkify.ALL);
308310
}
309311
}
310312

@@ -400,7 +402,7 @@ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable>
400402
public KAlertDialog setContentText(String text) {
401403
mContentText = text;
402404
if (mContentTextView != null && mContentText != null) {
403-
showContentText();
405+
showContentText(true);
404406
if (contentTextSize != 0) {
405407
mContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, spToPx(contentTextSize, getContext()));
406408
}
@@ -419,6 +421,8 @@ public KAlertDialog setContentText(String text) {
419421
}else {
420422
mContentTextView.setText(Html.fromHtml(mContentText));
421423
}
424+
} else {
425+
showContentText(false);
422426
}
423427
return this;
424428
}
@@ -461,10 +465,10 @@ private KAlertDialog dialogContentFont(String path) {
461465
return this;
462466
}
463467

464-
private void showContentText () {
468+
private void showContentText (boolean isShow) {
465469
mShowContent = true;
466470
if (mContentTextView != null) {
467-
mContentTextView.setVisibility(View.VISIBLE);
471+
mContentTextView.setVisibility(isShow ? View.VISIBLE : GONE);
468472
mContentTextView.setAutoLinkMask(Linkify.ALL);
469473
}
470474
}

sample/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.developer.kalert.alert"
88
minSdkVersion 19
99
targetSdkVersion 33
10-
versionCode 27
11-
versionName "20.2.0"
10+
versionCode 29
11+
versionName "20.2.2"
1212
}
1313

1414

Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Tue Oct 18 14:05:31 IST 2022
1+
#Tue Oct 18 14:57:15 IST 2022
22
base.0=D\:\\Projects\\AndroidLibraries\\KAlertDialog-master\\sample\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
33
renamed.0=classes.dex
44
path.0=classes.dex
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)