{"id":13786928,"url":"https://github.com/pranavpandey/dynamic-dialogs","last_synced_at":"2025-04-22T10:21:54.496Z","repository":{"id":43961784,"uuid":"100310372","full_name":"pranavpandey/dynamic-dialogs","owner":"pranavpandey","description":"Display improved dialogs and dialog fragments on Android.","archived":false,"fork":false,"pushed_at":"2025-03-05T19:13:32.000Z","size":3240,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T22:23:34.410Z","etag":null,"topics":["android","dialog","dialog-fragment","library","material-design"],"latest_commit_sha":null,"homepage":"https://dynamic.pranavpandey.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pranavpandey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"pranavpandey","patreon":"pranavpandey","open_collective":"pranavpandeydev","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/pranavpandeydev"]}},"created_at":"2017-08-14T21:19:37.000Z","updated_at":"2025-03-05T19:13:36.000Z","dependencies_parsed_at":"2023-12-10T15:03:48.616Z","dependency_job_id":"d73be383-c735-4231-9bea-617b3422aa0b","html_url":"https://github.com/pranavpandey/dynamic-dialogs","commit_stats":{"total_commits":227,"total_committers":1,"mean_commits":227.0,"dds":0.0,"last_synced_commit":"a6182a75edb1e4828c6e31eb0393ab8629a8175f"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-dialogs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-dialogs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-dialogs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pranavpandey%2Fdynamic-dialogs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pranavpandey","download_url":"https://codeload.github.com/pranavpandey/dynamic-dialogs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249206647,"owners_count":21230027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","dialog","dialog-fragment","library","material-design"],"created_at":"2024-08-03T20:00:22.058Z","updated_at":"2025-04-16T16:31:34.769Z","avatar_url":"https://github.com/pranavpandey.png","language":"Java","funding_links":["https://github.com/sponsors/pranavpandey","https://patreon.com/pranavpandey","https://opencollective.com/pranavpandeydev","paypal.me/pranavpandeydev","https://paypal.me/pranavpandeydev"],"categories":["Library"],"sub_categories":[],"readme":"\u003cimg src=\"./graphics/icon.png\" height=\"160\"\u003e\n\n# Dynamic Dialogs\n\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg?)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![Build Status](https://travis-ci.org/pranavpandey/dynamic-dialogs.svg?branch=master)](https://travis-ci.org/pranavpandey/dynamic-dialogs)\n[![Release](https://img.shields.io/maven-central/v/com.pranavpandey.android/dynamic-dialogs)](https://search.maven.org/artifact/com.pranavpandey.android/dynamic-dialogs)\n\n**A simple library to display dialogs and dialog fragments on Android 4.0 (API 14) and above.**\n\n\u003e [!IMPORTANT]\n\u003e Since v2.0.0, it uses [AndroidX][androidx] so, first [migrate][androidx-migrate] your\nproject to AndroidX.\n\u003cbr/\u003eSince v4.1.0, it is dependent on Java 8 due to the dependency on\n[Dynamic Utils](https://github.com/pranavpandey/dynamic-utils).\n\u003cbr/\u003eSince v4.4.1, it is targeting Java 17 to provide maximum compatibility.\n\u003cbr/\u003eSince v4.5.0, the minimum SDK is Android 4.4 (API 19) to comply with the latest policies.\n\n\u003cimg src=\"./graphics/preview.png\"\u003e\n\n---\n\n## Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Setup](#setup)\n    - [DynamicDialog](#dynamicdialog)\n    - [DynamicDialogFragment](#dynamicdialogfragment)\n        - [Show dialog](#show-dialog)\n        - [Dialog state](#dialog-state)\n        - [Dialog builder](#dialog-builder)\n        - [Dialog callbacks](#dialog-callbacks)\n    - [Dependency](#dependency)\n- [License](#license)\n\n---\n\n## Installation\n\nIt can be installed by adding the following dependency to your `build.gradle` file:\n\n```groovy\ndependencies {\n    // For AndroidX enabled projects.\n    implementation 'com.pranavpandey.android:dynamic-dialogs:4.5.0'\n\n    // For legacy projects.\n    implementation 'com.pranavpandey.android:dynamic-dialogs:1.3.0'\n}\n```\n\n---\n\n## Usage\n\nIt is a library to display dialog and dialog fragments with ease. It has some improvements \nover `appcompat-v7` (or AndroidX) dialogs and shares the same behavior and methods which can be \nused with any other framework or library. \n\n\u003e For a complete reference, please read the [documentation][documentation].\n\n### Setup\n\nFirst add `alertDialogStyle` in the base application theme to make `dynamic-dialogs` working.\n\n```xml\n\u003c!-- Base application theme. --\u003e\n\u003cstyle name=\"AppTheme\" parent=\"...\"\u003e\n    \u003c!-- Customize your theme here. --\u003e\n    ...\n    \n    \u003c!-- Add dynamic dialogs style in the base app theme. --\u003e\n    \u003citem name=\"alertDialogStyle\"\u003e@style/DynamicDialog\u003c/item\u003e\n\u003c/style\u003e\n```\n\n### DynamicDialog\n\nIt is almost identical to the `AppCompatDialog` but provides scroll indicators at top and bottom \nfor the custom dialogs also. So, if you are using any scrollable view in your custom dialog like\n`NestedScrollView` or `RecyclerView`, it can be set as `root view` and the scroll indicators will be \nadded automatically if the view can be scrolled.\n \n```java\nnew DynamicDialog.Builder(context)\n        // Set dialog title.\n        .setTitle(...)\n        ...\n        // Set a custom view.\n        .setView(int layoutResId)\n        // OR\n        setView(View view)\n        // Set view root to automatically add scroll dividers.\n        .setViewRoot(int viewRootId)\n        // OR\n        .setViewRoot(View viewRoot)\n        // Show the dialog.\n        .show();\n``` \n\n### DynamicDialogFragment\n\nBase dialog fragment to provide all the functionality of `DynamicDialog` inside a fragment. It can \nbe extended to customise it further by overriding the supported methods.\n\n```java\npublic CustomDialogFragment extends DynamicDialogFragment {\n    \n    ...\n    \n    /**\n     * Override this method to customise the dynamic dialog builder before creating the dialog.\n     *\n     * @param dialogBuilder The current builder to be customised.\n     * @param savedInstanceState The saved state of the fragment to restore it later.\n     *\n     * @return The customised dynamic dialog builder.\n     */\n    @Override\n    protected @NonNull DynamicDialog.Builder onCustomiseBuilder(\n            @NonNull DynamicDialog.Builder dialogBuilder, @Nullable Bundle savedInstanceState) {\n        // TODO: Customise the dialog here.\n        ...\n        \n        return dialogBuilder;\n    }\n    \n    /**\n     * Override this method to customise the dynamic dialog before attaching it with \n     * this fragment.\n     *\n     * @param alertDialog The current dialog to be customised.\n     * @param savedInstanceState The saved state of the fragment to restore it later.\n     *\n     * @return The customised dynamic dialog.\n     */\n    protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,\n            @Nullable Bundle savedInstanceState) {\n        // TODO: Customise the dialog builder here.\n        ...\n        \n        return alertDialog;\n    }\n    \n    ...\n}\n```\n\n#### Show dialog\n\nShow the `DynamicDialogFragment` by using `showDialog(fragmentActivity)` method.\n\n\u003e For better understanding, please check `AboutDialogFragment` in the `sample` project.\n\n#### Dialog state\n\nIt will automatically maintain its state on configuration changes (like device rotation, etc.) \nby calling `setRetainInstance(true)` in `onCreate()` method. If you don't want to use this feature \n(generally, if you are displaying it in `onResume()` method) then, call `setAutoDismiss(true)` to \ndismiss it in `onPause()` method.\n\n```java\nDynamicDialogFragment.newInstance().\n        ...\n        // Dismiss dialog fragment on configuration changes.\n        .setAutoDismiss(true)\n        // Show the dialog fragment.\n        .showDialog(fragmentActivity);\n\n```\n\n#### Dialog builder\n\nTo show quick `DynamicDialogFragment`, you can use its `setBuilder(DynamicDialog.Builder)` method\nand pass `DynamicDialog.Builder` with all the customisations. It will automatically wrap it in a \n`DialogFragment` and use `showDialog(fragmentActivity)` method to display it.\n\n```java\nDynamicDialogFragment.newInstance().setBuilder(\n        new DynamicDialog.Builder(context)\n                // Set dialog title.\n                .setTitle(...)\n                // Set dialog message.\n                .setMessage(...)\n                // Set negative button with a click listener.\n                .setNegativeButton(..., clickListener))\n        // Show the dialog fragment.\n        .showDialog(fragmentActivity);\n```\n\n#### Dialog callbacks\n\nAs `DialogFragment` has required some extra work to get the event callbacks, it already has all the \nlisteners of `DynamicDialog.Builder` built-in so that there is no extra effort is required.\n\n```java\nDynamicDialogFragment.newInstance()\n        ...\n        // Callback when this dialog fragment is displayed.\n        .setOnShowListener(onShowListener)\n        // Callback when this dialog fragment has been dismissed.\n        .setOnDismissListener(onDismissListener)\n        // Callback when this dialog fragment has been canceled.\n        .setOnCancelListener(onCancelListener)\n        // Callback when a key is pressed in this dialog fragment.\n        .setOnKeyListener(onKeyListener)\n        // Show the dialog fragment.\n        .showDialog(fragmentActivity);\n        \n```\n\n\u003e For better understanding, please check `CustomDialogFragment` in the `sample` project.\n\n### Dependency\n\nIt depends on the [dynamic-utils][dynamic-utils] to perform various internal operations. So, its \nfunctions can also be used to perform other useful operations.\n\n---\n\n## Author\n\nPranav Pandey\n\n[![GitHub](https://img.shields.io/github/followers/pranavpandey?label=GitHub\u0026style=social)](https://github.com/pranavpandey)\n[![Follow on Twitter](https://img.shields.io/twitter/follow/pranavpandeydev?label=Follow\u0026style=social)](https://twitter.com/intent/follow?screen_name=pranavpandeydev)\n[![Donate via PayPal](https://img.shields.io/static/v1?label=Donate\u0026message=PayPal\u0026color=blue)](https://paypal.me/pranavpandeydev)\n\n---\n\n## License\n\n    Copyright 2017-2024 Pranav Pandey\n    Copyright 2015 The Android Open Source Project\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n[androidx]: https://developer.android.com/jetpack/androidx\n[androidx-migrate]: https://developer.android.com/jetpack/androidx/migrate\n[documentation]: https://pranavpandey.github.io/dynamic-dialogs\n[dynamic-utils]: https://github.com/pranavpandey/dynamic-utils\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-dialogs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpranavpandey%2Fdynamic-dialogs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpranavpandey%2Fdynamic-dialogs/lists"}