Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avast/android-styled-dialogs
Backport of Material dialogs with easy-to-use API based on DialogFragment
https://github.com/avast/android-styled-dialogs
Last synced: 6 days ago
JSON representation
Backport of Material dialogs with easy-to-use API based on DialogFragment
- Host: GitHub
- URL: https://github.com/avast/android-styled-dialogs
- Owner: avast
- License: apache-2.0
- Created: 2013-05-25T07:35:52.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-05-28T09:10:03.000Z (over 5 years ago)
- Last Synced: 2024-11-30T14:06:12.087Z (13 days ago)
- Language: Java
- Homepage:
- Size: 1.58 MB
- Stars: 2,148
- Watchers: 139
- Forks: 450
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome - android-styled-dialogs - Backport of Material dialogs with easy-to-use API based on DialogFragment (etc)
- awesome - android-styled-dialogs - Backport of Material dialogs with easy-to-use API based on DialogFragment (etc)
README
# StyledDialogs for Android
[![Build Status](https://travis-ci.org/avast/android-styled-dialogs.svg?branch=master)](https://travis-ci.org/avast/android-styled-dialogs) [![License](https://img.shields.io/badge/license-Apache%202-green.svg?style=flat)](https://github.com/avast/android-styled-dialogs/blob/master/LICENSE.txt) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-StyledDialogs-green.svg?style=flat)](https://android-arsenal.com/details/1/143)![Screenshot of the dialogs](graphics/screenshot-small.png)
Demo app:Features:
- Compatible with **Material Design Guidelines**
- Same look for **Android 2.2+**
- Built on top of standard **DialogFragment**
- Supports stacked buttons, neutral button, callbacks even after rotation
- Light and dark theme
- Contains even more specialized dialogs: List, Progress, Time&Date Picker, Custom, ...## How to include it in your project:
```groovy
dependencies {
compile 'com.avast:android-styled-dialogs:2.3.3'
}
```
Hosted in [jcenter](https://bintray.com/avast/android/styled-dialogs/): [ ![Download](https://api.bintray.com/packages/avast/android/styled-dialogs/images/download.svg) ](https://bintray.com/avast/android/styled-dialogs/_latestVersion)[Looking for Holo dialogs?](https://github.com/inmite/android-styled-dialogs/tree/holo)
## How to style all dialogs:
It uses standard Material colors, for example like this:
```xml
<item name="colorPrimary">@color/indigo</item>
<item name="colorPrimaryDark">@color/indigo_dark</item>
<item name="colorAccent">@color/pink</item>```
For dark theme, inherit from `Theme.AppCompat`. Or you can force dark theme per individual dialog using `useDarkTheme()` builder method.
You can also force light theme per individual dialog using `useLightTheme()` builder method.## How to create simple dialogs:
Easy:
### Dialog with a simple message only:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();
```### Dialog with a title, message and two buttons:
```java
SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).setMessage(R.string.message).setPositiveButtonText(R.string.positive_button).setNegativeButtonText(R.string.negative_button).show();
```
### How to react on button press in your Activity/Fragment:Simply implement interface `ISimpleDialogListener` in your Activity/Fragment. Listener's callbacks have `requestCode` parameter - you can use it if you have more dialogs in one Activity/Fragment.
For Fragments use `setTargetFragment()` method in the builder.
It's not possible to use normal Java callbacks, because they are lost after device rotation.
### How to react on cancelling the dialog:
Implement interface `ISimpleDialogCancelListener` in your Activity/Fragment.
## How to create custom DialogFragments:
Extend `BaseDialogFragment`.
Have a look at [JayneHatDialogFragment](https://github.com/avast/android-styled-dialogs/blob/master/demo/src/main/java/com/avast/dialogs/JayneHatDialogFragment.java) for a practical example.
## Contributing
Pull requests are welcomed!
Please set your Android Studio formatting to [our code style](https://github.com/avast/android-styled-dialogs/blob/master/code-formatting-config.xml).
## Why 'Dialogs'?
Theodor Dialogs was a famous Czech painter, uncle of [Jára Cimrman](http://en.wikipedia.org/wiki/J%C3%A1ra_Cimrman). Jára Cimrman was a playwright, philosopher, inventor, teacher, poet, mathematician and more but he lacked painting skills. That's why Theodor was helping him with many projects. Just like Android and this library do.
See [**our other Czech personalities**](http://inmite.github.io) who help with [#AndroidDev](https://plus.google.com/s/%23AndroidDev).