GithubHelp home page GithubHelp logo

khalidelsayed / android-styled-dialogs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avast/android-styled-dialogs

0.0 1.0 0.0 993 KB

A simple library for styling Android dialogs in the Holo theme. It also removes boilerplate code for displaying simple dialogs.

Home Page: http://gplus.to/InmiteDev

License: Apache License 2.0

android-styled-dialogs's Introduction

StyledDialogs for Android

This library makes styling and using dialogs a piece of cake.

Screenshot of the dialogs

Features:

  • Compatible with Holo style and Android Design Guidelines
  • Change style for all dialogs only by changing a few color resources
  • Same look for Android 2.2+
  • Same API as native Android DialogFragments
  • SimpleDialogFragment class, which makes displaying simple dialogs a one line of code

How to include it in your project:

With Maven:

<dependency>
	<groupId>eu.inmite.android.lib</groupId>
	<artifactId>android-styled-dialogs</artifactId>
	<version>1.0.1</version>
	<type>apklib</type>
</dependency>

Or:

  • clone the project
  • add it as library project in your IDE
  • include latest support library

How to style all dialogs:

Add following into your application theme:

<item name="sdlDialogStyle">@style/DialogStyleLight.Custom</item>

or

<item name="sdlDialogStyle">@style/DialogStyleDark.Custom</item>

Define your dialog style, example for light theme:

<style name="DialogStyleLight.Custom">
	<!-- anything can be left out: -->
	<item name="titleTextColor">@color/dialog_title_text</item>
	<item name="titleSeparatorColor">@color/dialog_title_separator</item>
	<item name="messageTextColor">@color/dialog_message_text</item>
	<item name="buttonTextColor">@color/dialog_button_text</item>
	<item name="buttonSeparatorColor">@color/dialog_button_separator</item>
	<item name="buttonBackgroundColorNormal">@color/dialog_button_normal</item>
	<item name="buttonBackgroundColorPressed">@color/dialog_button_pressed</item>
	<item name="buttonBackgroundColorFocused">@color/dialog_button_focused</item>
	<item name="dialogBackground">@drawable/dialog_background</item>
</style>

How to create simple dialogs:

Easy:

Dialog with a simple message and Close button:

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

Dialog with a title, message and Close button:

SimpleDialogFragment.createBuilder(this, getSupportFragmentManager()).setTitle(R.string.title).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.

How to react on cancelling the dialog:

Implement interface ISimpleDialogCancelListener in your Activity/Fragment.

How to create all other DialogFragments:

Extend BaseDialogFragment and look at demo app implementation. It shows two types of those implementations:

  • FavoriteCharacterDialogFragment shows a list in the dialog using extending BaseDialogFragment
  • JayneHatDialogFragment shows a custom view in the dialog using extending SimpleDialogFragment

Wishlist

The library could be improved with more common dialogs. Pull requests are encouraged!

Possible candidates:

  • date picker (spinners or calendar)
  • time picker
  • edittext dialog
  • password dialog
  • ...

android-styled-dialogs's People

Contributors

davidvavra avatar tomas-vondracek avatar tomaskypta avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.