A small library replicating the new dialogs in android L.

Related tags

Dialog L-Dialogs
Overview

L-Dialogs


A small library replicating the new dialogs in android L.

"Screenshot 1"


Set Up (Android Studio):

Download the aar here: https://www.dropbox.com/s/276bhapr2g50cak/ldialogs.aar?dl=0

Maven central support will be coming soon.

You can rename the aar and then place it in the libs directory of your project.

Go into your build.gradle and add the following:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'uk.me.lewisdeane.ldialogs:RENAMED_FILE_NAME_HERE@aar'
}

repositories{
    flatDir{
        dirs 'libs'
    }
}

Usage

##Normal Dialogs

You should now be able to access the class CustomDialog from one of your java files.

To create a new CustomDialog we need to use a builder as so:

// Create the builder with required paramaters - Context, Title, Positive Text
CustomDialog.Builder builder = new CustomDialog.Builder(Context context, String title, String positiveText);

// Now we can any of the following methods.
builder.content(String content);
builder.negativeText(String negativeText);
builder.darkTheme(boolean isDark);
builder.typeface(Typeface typeface);
builder.titleTextSize(int size);
builder.contentTextSize(int size);
builder.buttonTextSize(int size);
builder.titleAlignment(Alignment alignment); // Use either Alignment.LEFT, Alignment.CENTER or Alignment.RIGHT
builder.titleColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.contentColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.positiveColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.negativeColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.positiveBackground(Drawable drawable); // int res parameter version also available.
builder.rightToLeft(boolean rightToLeft); // Enables right to left positioning for languages that may require so.

// Now we can build the dialog.
CustomDialog customDialog = builder.build();

// Show the dialog.
customDialog.show();

To handle the button clicks you can use the following code:

customDialog.setClickListener(new CustomDialog.ClickListener() {
            @Override
            public void onConfirmClick() {

            }

            @Override
            public void onCancelClick() {

            }
        });

If you want to set a custom view in the dialog you can use the following method.

customDialog.setCustomView(View customView);

Then do what you need to do with the custom views content in onConfirmClick or onCancelClick.

##List Dialogs

To use the CustomListDialog we need to use a builder again, this is done as follows:

// Create list dialog with required parameters - context, title, and our array of items to fill the list.
CustomListDialog.Builder builder = new CustomListDialog.Builder(Context context, String title, String[] items);

// Now again we can use some extra methods on the builder to customise it more.
builder.darkTheme(boolean isDark);
builder.typeface(Typeface typeface);
builder.titleAlignment(Alignment alignment); // Use either Alignment.LEFT, Alignment.CENTER or Alignment.RIGHT
builder.itemAlignment(Alignment alignment); // Use either Alignment.LEFT, Alignment.CENTER or Alignment.RIGHT
builder.titleColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.itemColor(String hex); // int res, or int colorRes parameter versions available as well.
builder.titleTextSize(int size);
builder.itemTextSize(int size);
builder.rightToLeft(boolean rightToLeft); // Enables right to left positioning for languages that may require so.

// Now we can build our dialog.
CustomListDialog customListDialog = builder.build();

// Finally we can show it.
customListDialog.show();

In order to recieve the click events from the dialog, simply use the following method on your customListDialog:

customListDialog.setListClickListener(new CustomListDialog.ListClickListener() {
            @Override
            public void onListItemSelected(int i, String[] strings, String s) {
                // i is the position clicked.
                // strings is the array of items in the list.
                // s is the item selected.
            }
        });

To add a listview selector use the following code:

StateListDrawable selector = new StateListDrawable();
selector.addState(new int[]{android.R.attr.state_pressed}, new ColorDrawable(R.color.color1));
selector.addState(new int[]{-android.R.attr.state_pressed}, new ColorDrawable(R.color.color2));

// The important part:
customListDialog.getListView().setSelector(selector);

This library will be updated often, enjoy!

Comments
  • Custom Views as content (req)

    Custom Views as content (req)

    Hey, first of all, great lib. I was wondering if it's possible to add custom views to the dialog. I would really like to add images to the dialog. One way of doing that with the default dialogs in Android was to use setView() and set an ImageView, so maybe you can do something similar.

    Thanks.

    opened by gijsdewit 6
  • User input

    User input

    hi there i like this library but i have a question is it possible to have the user enter or modify information in the dialog ? Lets say change the title ?

    opened by CristianSarac 5
  • Content, Buttons alignment, Typeface

    Content, Buttons alignment, Typeface

    Since my language is right to left, I've added content and buttons alignment.

    CustomDialog.Builder builder = new CustomDialog.Builder(Context context, String title, String positiveText); builder.rightToLeft(true); //or builder.mTitleAlignment (Alignment.RIGHT); builder.mContentAlignment(Alignment.RIGHT); builder.mButtonsAlignment(Alignment.LEFT);

    //I've added typeface for builder too.

    Typeface tf = Typeface.createFromAsset(this.getResources() .getAssets(), "Custom.ttf"); builder.typeFace(tf);

    opened by alirezaafkar 4
  • Dialog appers black on 2.3 Gingerbread even as darktheme ist set to false

    Dialog appers black on 2.3 Gingerbread even as darktheme ist set to false

    android-l-dialog

     CustomDialog.Builder builder = new CustomDialog.Builder(this, "Bestätigen","Hinzufügen abbrechen");
            builder.negativeText("Schließen");
            builder.darkTheme(false);
            builder.content("Möchtest du das Hinzufügen einer neuen Prüfung wirklich abbrechen?");
            builder.titleAlignment(BaseDialog.Alignment.LEFT); // Use either Alignment.LEFT, Alignment.CENTER or Alignment.RIGHT
            builder.titleColor(R.color.app_blau); // int res, or int colorRes parameter versions available as well.#
            CustomDialog customDialog = builder.build();
            customDialog.show();
    

    Any fix or are you not support Android before ICS?

    opened by MDXDave 4
  • Crash on init, please help

    Crash on init, please help

    08-18 13:23:15.023: E/AndroidRuntime(1508): FATAL EXCEPTION: main 08-18 13:23:15.023: E/AndroidRuntime(1508): Process: com.salut.jumbo, PID: 1508 08-18 13:23:15.023: E/AndroidRuntime(1508): android.view.InflateException: Binary XML file line #25: Error inflating class android.support.v7.internal.widget.ActionBarView 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createView(LayoutInflater.java:620) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:814) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.rInflate(LayoutInflater.java:745) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 08-18 13:23:15.023: E/AndroidRuntime(1508): at uk.me.lewisdeane.ldialogs.CustomDialog.init(CustomDialog.java:55) 08-18 13:23:15.023: E/AndroidRuntime(1508): at uk.me.lewisdeane.ldialogs.CustomDialog.(CustomDialog.java:48) 08-18 13:23:15.023: E/AndroidRuntime(1508): at some.package.SomeFragment$1.onClick(SomeFragment.java:27) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.View.performClick(View.java:4438) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.View$PerformClick.run(View.java:18422) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.os.Handler.handleCallback(Handler.java:733) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.os.Handler.dispatchMessage(Handler.java:95) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.os.Looper.loop(Looper.java:136) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.app.ActivityThread.main(ActivityThread.java:5017) 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Method.invokeNative(Native Method) 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Method.invoke(Method.java:515) 08-18 13:23:15.023: E/AndroidRuntime(1508): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 08-18 13:23:15.023: E/AndroidRuntime(1508): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 08-18 13:23:15.023: E/AndroidRuntime(1508): at dalvik.system.NativeStart.main(Native Method) 08-18 13:23:15.023: E/AndroidRuntime(1508): Caused by: java.lang.reflect.InvocationTargetException 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Constructor.constructNative(Native Method) 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createView(LayoutInflater.java:594) 08-18 13:23:15.023: E/AndroidRuntime(1508): ... 22 more 08-18 13:23:15.023: E/AndroidRuntime(1508): Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createView(LayoutInflater.java:620) 08-18 13:23:15.023: E/AndroidRuntime(1508): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.support.v7.internal.widget.ActionBarView.(ActionBarView.java:218) 08-18 13:23:15.023: E/AndroidRuntime(1508): ... 25 more 08-18 13:23:15.023: E/AndroidRuntime(1508): Caused by: java.lang.reflect.InvocationTargetException 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Constructor.constructNative(Native Method) 08-18 13:23:15.023: E/AndroidRuntime(1508): at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.view.LayoutInflater.createView(LayoutInflater.java:594) 08-18 13:23:15.023: E/AndroidRuntime(1508): ... 32 more 08-18 13:23:15.023: E/AndroidRuntime(1508): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f010012 a=-1} 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.content.res.Resources.loadDrawable(Resources.java:2068) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.widget.ImageView.(ImageView.java:129) 08-18 13:23:15.023: E/AndroidRuntime(1508): at android.widget.ImageView.(ImageView.java:119) 08-18 13:23:15.023: E/AndroidRuntime(1508): ... 35 more

    opened by aldefy 4
  • Can't reorder positive/negative text

    Can't reorder positive/negative text

    In your screenshots, the light example has the negative to the left of the positive and the dark example has one over the other. How do you code it so the negative is to the left? The default appears to be vertical but I can't find any options for horizontal. I went through the code but can't find any options to use.

    opened by easycheese 3
  • Adding a custom View

    Adding a custom View

    I tried adding a layout file to the method and it kept flagging an error... then i tried using the .seContentView() still it kept flagging an error... which makes me confused...by "customView" what do you actually mean?....

    opened by 1baga 3
  • Light theme issue

    Light theme issue

    Hey mate, This is an awesome library. But, I am unable to do so although i commented mDarkTheme, passed false value in it. Since, I am using eclipse had to copy your src files, style and other values in my project. All worked good except this Light theme issue. :( Thanks for this lib. :) :+1:

    opened by Chirag-Galani 2
  • Colors should be int and not String

    Colors should be int and not String

    It should be possible to set the color with a resource id.

        public Builder positiveColor(@ColorRes int colorResId) {
            this.mPositiveColour = mContext.getResources().getColor(colorResId);
            return this;
        }
    
    opened by StephaneBg 2
  • Click events

    Click events

    I'm new to this so how exactly to handle click events for CustomDialogs. I have 3 dialogs and if I implement CustomDialog.ClickListener and then onConfirmClick() & onCancelClick(), all confirm and cancel buttons from all dialogs use the same method & functionality..

    opened by ghost 2
  • Can't show dialog

    Can't show dialog

    When i try to show CustomListDialog I receive such error: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application at this line: customListDialog.show(); What I did wrong? Android API 16

    opened by ZheKOs 1
  • Setting <item name=true for > API 19 causes dialog to mess up.">

    Setting true for > API 19 causes dialog to mess up.

    When setting the following value in the "values-v21" styles file, it causes the dialog to mess up and look weird.

    true

    try it and you will see what I mean.

    screenshot_2015-06-26-14-32-10

    opened by IamJackppot 0
  • Gradle problem

    Gradle problem

    dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'uk.me.lewisdeane.ldialogs:ldialog@aar' }

    repositories{ flatDir{ dirs 'libs' }

    }

    Error:

    Error:Failed to resolve: uk.me.lewisdeane.ldialogs:ldialog: Open File

    Android Studio version 1.1.0

    opened by cliffgr 4
  • Added android-maven plugin

    Added android-maven plugin

    With android-maven plugin L-Dialogs can now be installed in the local maven repository:

    gradle install
    

    In addition its now possible to get it as a maven dependency: https://jitpack.io/#jitpack/L-Dialogs/1.0

    once these changes are included in a new release.

    opened by jitpack 0
  • Button not aligned in same row

    Button not aligned in same row

    CustomDialog.Builder builder = new CustomDialog.Builder(context, "Discard Item ?", "Discard");

        builder.darkTheme(false);
        builder.positiveColor(context.getResources().getColor(R.color.theme_default_primary));
        builder.negativeColor(context.getResources().getColor(R.color.theme_default_primary));
        builder.negativeText("Cancel");
        CustomDialog customDialog = builder.build();
    
        customDialog.show();
        return customDialog;
    

    While using the above code, I get two button stacked up instead showing in one row.

    opened by sayoojvalsan 2
  • How to make buttons align in a row?

    How to make buttons align in a row?

    I'm using this code:

    CustomDialog.Builder builder = new CustomDialog.Builder(
                                this, "تأیید", "عنوان");
    builder.content("بایستی دوباره وارد شوید...")
                                .negativeText("خروج")
                                .titleAlignment(BaseDialog.Alignment.RIGHT)
                                .contentAlignment(BaseDialog.Alignment.RIGHT)
                                .positiveColorRes(R.color.text_color)
                                .build().show();
    

    The buttons are shown in a column a the right (like the standard dark themed titled "Factory Reset"). How can I make them aligned in a row (like the standard permission dialog)?

    opened by mahmouxd 0
Owner
Lewis Deane
Lewis Deane
📱 An Android Library for 💫fluid, 😍beautiful, 🎨custom Dialogs.

Aesthetic Dialogs for Android ?? ?? Android Library for ?? fluid, ?? beautiful, ?? custom Dialogs. Table of Contents: Introduction Types of Dialog Dar

Gabriel TEKOMBO 538 Dec 14, 2022
😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Material Dialogs View Releases and Changelogs Modules The core module is the fundamental module that you need in order to use this library. The others

Aidan Follestad 19.5k Dec 29, 2022
Backport of Material dialogs with easy-to-use API based on DialogFragment

StyledDialogs for Android Demo app: Features: Compatible with Material Design Guidelines Same look for Android 2.2+ Built on top of standard DialogFra

Avast 2.2k Dec 29, 2022
Backport of Material dialogs with easy-to-use API based on DialogFragment

StyledDialogs for Android Demo app: Features: Compatible with Material Design Guidelines Same look for Android 2.2+ Built on top of standard DialogFra

Avast 2.2k Nov 29, 2022
⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.

Sheets Sleek dialogs and bottom-sheets for quick use in your app. Choose one of the available sheets or build custom sheets on top of the existing fun

Maximilian Keppeler 838 Dec 30, 2022
Sleek dialogs and bottom-sheets for quick use in your app

⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.

Maximilian Keppeler 835 Dec 25, 2022
An Android library for displaying a dialog where it presents new features in the app.

WhatIsNewDialog What is new dialog for Android is used for presenting new features in the the app. It can be used in the activity starts, from menu or

NonZeroApps 22 Aug 23, 2022
GenericDialog 1.3 0.0 Java A new AlertDialog for Android is here...!!

GenericDialog A new AlertDialog for Android is here...!! Getting Started Installation Add this into your root build.gradle file: allprojects { reposi

Jaidev Naik 22 Sep 6, 2022
Extremely useful library to validate EditText inputs whether by using just the validator for your custom view or using library's extremely resizable & customisable dialog

Extremely useful library for validating EditText inputs whether by using just the validator (OtpinVerification) for your custom view or using library's extremely resizable & customisable dialog (OtpinDialogCreator)

Ehma Ugbogo 17 Oct 25, 2022
Make your native android Dialog Fancy and Gify. A library that takes the standard Android Dialog to the next level with a variety of styling options and Gif's. Style your dialog from code.

FancyGifDialog-Android Prerequisites Add this in your root build.gradle file (not your module build.gradle file): allprojects { repositories { ...

Shashank Singhal 522 Jan 2, 2023
LicensesDialog is an open source library to display licenses of third-party libraries in an Android app.

LicensesDialog LicensesDialog is an open source library to display licenses of third-party libraries in an Android app. Download Download the latest R

PSDev 817 Dec 30, 2022
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

Keisuke Kobayashi 553 Nov 23, 2022
Android library that allows applications to add dialog-based slider widgets to their settings

Android Slider Preference Library Overview Slider represents a float between 0.0 and 1.0 Access with SliderPreference.getValue() or SharedPreferences.

Jay Petacat 135 Nov 29, 2022
An Android library that provides a simple implementation of a DialogFragment

SimpleDialogFragment An Android library that provides a simple implementation of a DialogFragment. Are you tired of creating a new DialogFragment for

Julien Arzul 32 Oct 2, 2020
Android library to show "Rate this app" dialog

Android-RateThisApp Android-RateThisApp is an library to show "Rate this app" dialog. The library monitors the following status How many times is the

Keisuke Kobayashi 553 Nov 23, 2022
A simple library to show custom dialog with animation in android

SmartDialog A simple library to show custom dialog in android Step 1. Add the JitPack repository to your build file allprojects { repositories {

claudysoft 9 Aug 18, 2022
An easy-to-use Android library that will help you to take screenshots of specif views of your app and save them to external storage (Including API 29 Q+ with Scope Storage)

???? English | ???? Português (pt-br) ???? English: An easy to use Library that will help you to take screenshots ?? of the views in your app Step 1.

Thyago Neves Silvestre 2 Dec 25, 2021
An beautiful and easy to use dialog library for Android

An beautiful and easy to use dialog library for Android

ShouHeng 22 Nov 8, 2022
CuteDialog- Android Custom Material Dialog Library

A Custom Material Design Dialog Library for Android Purpose CuteDialog is a Highly Customizable Material Design Android Library. CuteDialog allows dev

CuteLibs - Smart & Beautiful Android Libraries 7 Dec 7, 2022