Simple and easy Android Custom Dialogs
You can download the latest sample APK from this repo here: https://github.com/gupta1anubhav/Custom-Dialog-Box/blob/master/sample/sample.apk
The Gradle dependency is available via jitpack.
The minimum API level supported by this library is API 14, Android 4.0 (ICE_CREAM_SANDWICH)
Add JitPack to your repositories in build.gradle (Module:Project):
allprojects{
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
and add the library to your dependencies in build.gradle (Module: app):
implementation 'com.github.gupta1anubhav:Custom-Dialog-Box:v1.0'
new CustomDialog.Builder(thisActivity)
.setTitle("Hello !")
.setContent("This is basic CustomDialog :)", 3)
// Customizing (You can find more in Wiki)
//.setBtnConfirmText("Check!")
//.setBtnConfirmTextColor("#de413e")
//.setBtnCancelText("Cancel")
//.setBtnCancelTextColor("#de413e")
//.setCancelable(true) // Default value is false
//.onConfirm(new CustomDialog.BtnCallback() {
// @Override
// public void onClick(@NonNull CustomDialog dialog, @NonNull CustomDialog.BtnAction which) {
// // Do something
// }
//})
//.setBtnCancelText("Cancel", false)
//.onCancel(new CustomDialog.BtnCallback() {
// @Override
// public void onClick(@NonNull CustomDialog dialog, @NonNull CustomDialog.BtnAction which) {
// // Do something
// }
//})
.show(); // Must be called at the end
new CustomDialog.Builder(thisActivity)
.setContent("This is progress CustomDialog :)", 7)
// .showProgress must be set true if you want ProgressDialog
.showProgress(true) // Default GIF is in the library (R.raw.simple_dialog_progress_default)
//.setProgressGIF(R.raw.simple_dialog_progress_default)
.setBtnCancelText("Cancel")
.setBtnCancelTextColor("#2861b0")
// Customizing (You can find more in Wiki)
//.setBtnCancelText("Cancel", false)
//.setBtnCancelTextColor(R.color.colorPrimary)
//.setBtnCancelShowTime(2000)
//.onCancel(new CustomDialog.BtnCallback() {
// @Override
// public void onClick(@NonNull CustomDialog dialog, @NonNull CustomDialog.BtnAction which) {
// // thisActivity.finish();
// }
//})
//.showProgress(true)
.show(); // Must be called at the end
new CustomDialog.Builder(thisActivity)
.setTitle("Hello !", true)
.setContent("This is guide CustomDialog :)\n\n- You can pinch the view !")
.setGuideImage(R.drawable.image_guide_pinch)
.setGuideImageSizeDp(150, 150)
.setPermanentCheck(Pref.PREFERENCE_NAME, Pref.KEY_FIRST_WELCOME)
.onConfirm(new CustomDialog.BtnCallbackWithPermanentCheck() {
@Override
public void onClick(@NonNull CustomDialog dialog, @NonNull CustomDialog.BtnAction which, boolean isPermanentChecked) {
if( isPermanentChecked )
setBtnGuideReset(true);
}
})
.setBtnConfirmText("Check!")
.setBtnConfirmTextColor("#e6b115")
// I thought cancel button is not necessary, it's unavailable unless there're requests
// Customizing (You can find more in Wiki)
//.setTitle("Hello !", true)
//.setBtnPermanentCheckText("다시 보지 않기", true)
//.setGuideImagePaddingDp(10)
//.setGuideImageSizeDp(100, 100)
.showIfPermanentValueIsFalse(); // Must be called at the end (if permanentCheck is necessary)
new CustomDialog.Builder(thisActivity)
.setTitle("This is Title :)")
// If the customView is long enough, CustomDialog will put your layout in the ScrollView automatically
.setCustomView(R.layout.gupta1anubhav_simple_dialog_test_layout_custom_long)
.setBtnConfirmText("Check!")
.setBtnConfirmTextSizeDp(16)
.setBtnConfirmTextColor("#1fd1ab")
.setBtnCancelText("Cancel", false)
.setBtnCancelTextColor("#555555")
.show(); // Must be called at the end
MIT License
Copyright (c) 2018 Anubhav Gupta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.