Dotykacka/android-styled-dialogs


Backport of Material dialogs with easy-to-use API based on DialogFragment

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.Dotykacka:android-styled-dialogs:2.3.4'
	}
	dependencies {
		implementation("com.github.Dotykacka:android-styled-dialogs:2.3.4")
	}
	<dependency>
	    <groupId>com.github.Dotykacka</groupId>
	    <artifactId>android-styled-dialogs</artifactId>
	    <version>2.3.4</version>
	</dependency>

                            
    libraryDependencies += "com.github.Dotykacka" % "android-styled-dialogs" % "2.3.4"
        
        

                            
    :dependencies [[com.github.Dotykacka/android-styled-dialogs "2.3.4"]]
        
        

Readme


StyledDialogs for Android

Build Status License Android Arsenal

Screenshot of the dialogs

Demo app:

<a href="https://play.google.com/store/apps/details?id=com.avast.dialogs"><img src="http://www.android.com/images/brand/get_it_on_play_logo_small.png" alt="Get it on Google Play" /></a>

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:

repositories {
        maven { url "https://jitpack.io" }
}

dependencies {
	compile 'com.github.frogggias:android-styled-dialogs:2.3.5'
}

Hosted in

Looking for Holo dialogs?

How to style all dialogs:

It uses standard Material colors, for example like this:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/indigo</item>
        <item name="colorPrimaryDark">@color/indigo_dark</item>
        <item name="colorAccent">@color/pink</item>
</style>

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:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setMessage(R.string.message).show();

Dialog with a title, message and two buttons:

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 for a practical example.

Contributing

Pull requests are welcomed!

Please set your Android Studio formatting to our code style.

Why 'Dialogs'?

<img src="http://img.radio.cz/pictures/osobnosti/cimrman_jarax.jpg" width="70" align="right"/>

Theodor Dialogs was a famous Czech painter, uncle of Jára 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 who help with #AndroidDev.