Add maven jitpack.io
and dependencies
in build.gradle (Project)
:
// build.gradle project
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// build.gradle app/module
dependencies {
...
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.github.gzeinnumer:DialogAndroid:version'
implementation 'com.github.gzeinnumer:SimpleMaterialStyle:last-vesion'
//check on https://github.com/gzeinnumer/SimpleMaterialStyle
}
- ConfirmDialog
- InfoDialog
- NumberPickerDialog
- LoadingDialog
- SingleDatePickerDialog
- MultiDatePickerDialog
- TimeDialog
- DebugDialog
First Step. Use MaterialComponents
in your style :
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
<style name="CustomDialogStyle" parent="Theme.MaterialComponents.Light.Dialog">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowMinWidthMajor">80%</item>
<item name="android:windowMinWidthMinor">80%</item>
<item name="android:windowEnterAnimation">@anim/anim_in</item>
<item name="android:windowExitAnimation">@anim/anim_out</item>
</style>
Add This Line to res/color.xml
. Important
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#6200EE</color>
<color name="colorPrimaryDark">#3700B3</color>
<color name="colorAccent">#03DAC5</color>
</resources>
If you want to change default font, add custom_font.ttf
to your res
directory res->font
.
Than add this style
to your style.xml
/themes.xml
If you want to change default margin in dialog, add dimens.xml
to your res
directory res->value->dimens.xml
.
Dialog with 1 Title, 1 Content, 1 Negative Button, 1 Positive Button.
new ConfirmDialog(getSupportFragmentManager())
.setTitle("ini title")
.setContent("ini content")
.onCancelPressedCallBack(new ConfirmDialog.OnCancelPressed() {
@Override
public void onCancelPressed() {
Toast.makeText(MainActivity.this, "Cancel", Toast.LENGTH_SHORT).show();
}
})
.onOkPressedCallBack(new ConfirmDialog.OnOkPressed() {
@Override
public void onOkPressed() {
Toast.makeText(MainActivity.this, "Ok", Toast.LENGTH_SHORT).show();
}
})
.show();
or you can write code like this :
ConfirmDialog dialog = new ConfirmDialog(getSupportFragmentManager())
.setTitle("ini title")
.setContent("ini content");
dialog.onCancelPressedCallBack(new ConfirmDialog.OnCancelPressed() {
@Override
public void onCancelPressed() {
Toast.makeText(MainActivity.this, "Cancel", Toast.LENGTH_SHORT).show();
}
});
dialog.onOkPressedCallBack(new ConfirmDialog.OnOkPressed() {
@Override
public void onOkPressed() {
Toast.makeText(MainActivity.this, "Ok", Toast.LENGTH_SHORT).show();
}
});
dialog.show();
To enable CanceledOnTouchOutside
:
new ConfirmDialog(getSupportFragmentManager())
.setCanceledOnTouchOutside(true)
Preview :
You can Customize your dialog UI. ReadMore.
Dialog with 1 Title, 1 Content, 1 Positif Button.
Code :
new InfoDialog(getSupportFragmentManager())
.setDialogType(DialogType.DialogSuccess)
.setTitle("ini title")
.setContent("ini content")
.onOkPressedCallBack(new InfoDialog.OnOkPressed() {
@Override
public void onOkPressed() {
Toast.makeText(MainActivity.this, "Ok", Toast.LENGTH_SHORT).show();
}
})
.show();
To enable CanceledOnTouchOutside
:
new InfoDialog(getSupportFragmentManager())
.setCanceledOnTouchOutside(true)
To set auto Click Button Ok :
new InfoDialog(getSupportFragmentManager())
.autoDismisOnSecond(10)
Preview :
You can Customize your dialog UI. ReadMore.
Dialog with 1 Title, 1 Content, 1 Positif Button, 1 Negatif Button, 1 EditText, 1 Add Button, 1 Substract Button.
Code :
new NumberPickerDialog(getSupportFragmentManager())
.setLastValue(12)
.setTitle("ini title")
.setContent("ini content")
.onOkPressedCallBack(new NumberPickerDialog.OnOkPressed() {
@Override
public void onOkPressed(int value) {
Toast.makeText(MainActivity.this, "Nilai nya " + value, Toast.LENGTH_SHORT).show();
}
})
.onCancelPressedCallBack(new NumberPickerDialog.OnCancelPressed() {
@Override
public void onCancelPressed() {
Toast.makeText(MainActivity.this, "Cancel", Toast.LENGTH_SHORT).show();
}
})
.show();
To enable CanceledOnTouchOutside
:
new NumberPickerDialog(getSupportFragmentManager())
.setCanceledOnTouchOutside(true)
Preview :
You can Customize your dialog UI. ReadMore.
Dialog with 1 Title, 1 Animation Loading that you can use.
Code :
LoadingDialog loadingDialog = new LoadingDialog(getSupportFragmentManager())
.setContent("ini content");
loadingDialog.show();
loadingDialog.dismis();
Preview :
You can Customize your dialog UI. ReadMore.
Dialog with Calender like in material.io that you can use to pick single
date.
Code :
new SingleDatePickerDialog(getSupportFragmentManager())
.setTimeZone("GMT")
.setTitle("Pilih tanggal")
.setSelectedToday(true)
.setTimeFormat("dd/MM/yyyy") //pastikan polanya sama
.setStartDate("1/08/2020") //pastikan polanya sama
.setEndDate("31/12/2020") //pastikan polanya sama
.onOkPressedCallBack(new SingleDatePickerDialog.OnOkPressed() {
@Override
public void onOkPressed(String value) {
Toast.makeText(MainActivity.this, value, Toast.LENGTH_SHORT).show();
}
})
.build()
.show();
setTimeZone()
optional . default valueGMT
.setTimeFormat()
optional. default valuedd-MM-yyyy
.setStartDate()
optional.setEndDate()
optional.
Preview :
![]() |
![]() |
---|
![]() |
---|
You can Customize your dialog UI. ReadMore.
Dialog with Calender like in material.io that you can use to pick date with range.
Code :
new MultiDatePickerDialog(getSupportFragmentManager())
.setTimeZone("GMT")
.setTitle("Pilih tanggal")
.setTimeFormat("dd/MM/yyyy") //pastikan 3 pola ini sama
.setStartDate("1/08/2020") //pastikan 3 pola ini sama
.setEndDate("31/12/2020") //pastikan 3 pola ini sama
.onOkPressedCallBack(new MultiDatePickerDialog.OnOkPressed() {
@Override
public void onOkPressed(String firstDate, String secondDate) {
Toast.makeText(MainActivity.this, firstDate + " - " + secondDate, Toast.LENGTH_SHORT).show();
}
})
.build()
.show();
setTimeZone()
optional . default valueGMT
.setTimeFormat()
optional. default valuedd-MM-yyyy
.setStartDate()
optional.setEndDate()
optional.
Preview :
![]() |
![]() |
---|
![]() |
---|
You can Customize your dialog UI. ReadMore.
Dialog with Calender like in material.io that you can use to pick date with range.
Code :
new TimeDialog(getSupportFragmentManager())
.setTitle("Time")
.setHour(17)
.setMinute(17)
.setTimeFormat(TimeFormat.CLOCK_24H) //TimeFormat.CLOCK_12H
.addOnPositiveButtonClickListener(new TimeDialogPositiveCallBack() {
@Override
public void timeResult(int hours, int minutes) {
Toast.makeText(MainActivity.this, hours+":"+minutes, Toast.LENGTH_SHORT).show();
}
})
.build()
.show();
setTitle()
optional . default valuePick Time
.setHour()
optional. default value0
.setMinute()
optional. default value0
.setTimeFormat()
optional. default valueTimeFormat.CLOCK_12H
.
Preview :
![]() |
![]() |
---|---|
TimeFormat.CLOCK_12H |
TimeFormat.CLOCK_24H |
Dialog for debug.
Code :
new DebugDialog(getSupportFragmentManager())
.setAnimationStyle(R.style.CustomDialogStyle)
.setContent(DumpJSON.msg1)
.onOkPressedCallBack(() -> {
//ok action
})
.show();
- 1.0.5
- First Release
- 1.0.6
- Add Custom Animation
- 1.0.7
- SetDefault Animation
- 1.0.9
- Fix Animation
- 2.0.0
- Enable or disable TextAllCaps
- 2.0.1
- Bugs Fixing
- 2.0.2
- add enable
CanceledOnTouchOutside
- add enable
- 2.0.3
- Bugs Fixing Style
- 2.0.4
- Color
- 2.1.1
- Add Auto Click
- 2.1.2
- Bug Fixing
- 2.1.5
- Bug Fixing
- 2.1.6
- Bug Fixing
- 2.1.9
- Bug Fixing
- 2.2.1
- Bug Fixing
- 2.2.2
- Change color method
- 3.0.0
- Support SDK 16
- 3.1.0
- Spesial Button Color Contained
- 3.1.1
- More Space Button Parent
- 3.2.0
- Time Picker
- 3.2.1
- Bug Fixing
- 3.2.2
- Bug Fixing
- 3.2.3
- Bug Fixing
- 3.2.4
- Remove Default Animation and Color
- 3.2.5
- Bug Color
- 3.2.6
- Bug Color
- 3.2.7
- Bug Color
- 3.2.8
- Bug Fixing
- 3.2.9
- Bug Fixing
- 3.3.0
- Remove Space From Button
- 3.3.1
- Add CharSequence to Title and Content
- 3.3.2
- Improve Space Between TextButton
- 3.3.3
- Spesial For Debug Dialog
- 3.3.4
- New Space
- 3.3.5
- Space
- 3.3.7
- Copy Text From DebugDialog
- 3.3.8
- Remove Dot
You can sent your constibution to branch
open-pull
.
Copyright 2020 M. Fadli Zein