All Projects → pranavpandey → dynamic-dialogs

pranavpandey / dynamic-dialogs

Licence: Apache-2.0 license
Display improved dialogs and dialog fragments on Android.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to dynamic-dialogs

MultiDialog
MultiDialog utilizes jQuery UI Dialog Widget for a full featured Modalbox / Lightbox application.
Stars: ✭ 23 (-30.3%)
Mutual labels:  dialog
sweet-modal-vue
The sweetest library to happen to modals.
Stars: ✭ 762 (+2209.09%)
Mutual labels:  dialog
react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (+1730.3%)
Mutual labels:  dialog
wui
Collection of GUI widgets for the web
Stars: ✭ 44 (+33.33%)
Mutual labels:  dialog
Variational-Transformer
Variational Transformers for Diverse Response Generation
Stars: ✭ 79 (+139.39%)
Mutual labels:  dialog
MaterialSurface
Google's Material Design UI library for Winform C# ./
Stars: ✭ 34 (+3.03%)
Mutual labels:  dialog
Fingerprint
Android library that simplifies the process of fingerprint authentications.
Stars: ✭ 68 (+106.06%)
Mutual labels:  dialog
AttributionPresenter
An Android library to easily display attribution information of open source libraries.
Stars: ✭ 47 (+42.42%)
Mutual labels:  dialog
fusion
An Easy-to-use Kotlin based Customizable Modules Collection with Material Layouts by BlackBeared.
Stars: ✭ 39 (+18.18%)
Mutual labels:  dialog
FabDialog
🎈 Fab into Dialog Animation on Android
Stars: ✭ 36 (+9.09%)
Mutual labels:  dialog
alert
Cross-platform, isomorphic alert, for Node and browser (previously alert-node)
Stars: ✭ 27 (-18.18%)
Mutual labels:  dialog
vue-modal
Reusable Modal component, supports own custom HTML, text and classes.
Stars: ✭ 29 (-12.12%)
Mutual labels:  dialog
react-redux-modals
This repo created for Medium.com: React/Redux: Modals and Dialogs
Stars: ✭ 30 (-9.09%)
Mutual labels:  dialog
Personal-Emotional-Stylized-Dialog
A Paper List for Personalized, Emotional, and stylized Dialog
Stars: ✭ 112 (+239.39%)
Mutual labels:  dialog
flutter page tracker
flutter埋点、弹窗埋点、页面埋点事件捕获框架,支持普通页面的页面曝光事件(PageView),页面离开事件(PageExit)。支持在TabView和PageView组件中发送页面曝光和页面离开
Stars: ✭ 103 (+212.12%)
Mutual labels:  dialog
react-st-modal
Simple and flexible modal dialog component for React JS
Stars: ✭ 41 (+24.24%)
Mutual labels:  dialog
DEMOS TO MySelf Android
自己平时的一些积累,相当于自己的一个demo库,比较杂,后续会一个一个整理出来
Stars: ✭ 36 (+9.09%)
Mutual labels:  dialog
vue-dialog
A drag-able dialog for Vue.js
Stars: ✭ 21 (-36.36%)
Mutual labels:  dialog
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (+190.91%)
Mutual labels:  dialog
few shot dialogue generation
Dialogue Knowledge Transfer Networks (DiKTNet)
Stars: ✭ 24 (-27.27%)
Mutual labels:  dialog

Dynamic Dialogs

License Build Status Release

A simple library to display dialogs and dialog fragments on Android 4.0 (API 14) and above.

Since v2.0.0, it uses AndroidX so, first migrate your project to AndroidX.
Since v4.1.0, it is dependent on Java 8 due to the dependency on Dynamic Utils.


Contents


Installation

It can be installed by adding the following dependency to your build.gradle file:

dependencies {
    // For AndroidX enabled projects.
    implementation 'com.pranavpandey.android:dynamic-dialogs:4.3.1'

    // For legacy projects.
    implementation 'com.pranavpandey.android:dynamic-dialogs:1.3.0'
}

Usage

It is a library to display dialog and dialog fragments with ease. It has some improvements over appcompat-v7 (or AndroidX) dialogs and shares the same behavior and methods which can be used with any other framework or library.

For a complete reference, please read the documentation.

Setup

First add alertDialogStyle in the base application theme to make dynamic-dialogs working.

<!-- Base application theme. -->
<style name="AppTheme" parent="...">
    <!-- Customize your theme here. -->
    ...
    
    <!-- Add dynamic dialogs style in the base app theme. -->
    <item name="alertDialogStyle">@style/DynamicDialog</item>
</style>

DynamicDialog

It is almost identical to the AppCompatDialog but provides scroll indicators at top and bottom for the custom dialogs also. So, if you are using any scrollable view in your custom dialog like NestedScrollView or RecyclerView, it can be set as root view and the scroll indicators will be added automatically if the view can be scrolled.

new DynamicDialog.Builder(context)
        // Set dialog title.
        .setTitle(...)
        ...
        // Set a custom view.
        .setView(int layoutResId)
        // OR
        setView(View view)
        // Set view root to automatically add scroll dividers.
        .setViewRoot(int viewRootId)
        // OR
        .setViewRoot(View viewRoot)
        // Show the dialog.
        .show();

DynamicDialogFragment

Base dialog fragment to provide all the functionality of DynamicDialog inside a fragment. It can be extended to customise it further by overriding the supported methods.

public CustomDialogFragment extends DynamicDialogFragment {
    
    ...
    
    /**
     * Override this method to customise the dynamic dialog builder before creating the dialog.
     *
     * @param dialogBuilder The current builder to be customised.
     * @param savedInstanceState The saved state of the fragment to restore it later.
     *
     * @return The customised dynamic dialog builder.
     */
    @Override
    protected @NonNull DynamicDialog.Builder onCustomiseBuilder(
            @NonNull DynamicDialog.Builder dialogBuilder, @Nullable Bundle savedInstanceState) {
        // TODO: Customise the dialog here.
        ...
        
        return dialogBuilder;
    }
    
    /**
     * Override this method to customise the dynamic dialog before attaching it with 
     * this fragment.
     *
     * @param alertDialog The current dialog to be customised.
     * @param savedInstanceState The saved state of the fragment to restore it later.
     *
     * @return The customised dynamic dialog.
     */
    protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
            @Nullable Bundle savedInstanceState) {
        // TODO: Customise the dialog builder here.
        ...
        
        return alertDialog;
    }
    
    ...
}

Show dialog

Show the DynamicDialogFragment by using showDialog(fragmentActivity) method.

For better understanding, please check AboutDialogFragment in the sample project.

Dialog state

It will automatically maintain its state on configuration changes (like device rotation, etc.) by calling setRetainInstance(true) in onCreate() method. If you don't want to use this feature (generally, if you are displaying it in onResume() method) then, call setAutoDismiss(true) to dismiss it in onPause() method.

DynamicDialogFragment.newInstance().
        ...
        // Dismiss dialog fragment on configuration changes.
        .setAutoDismiss(true)
        // Show the dialog fragment.
        .showDialog(fragmentActivity);

Dialog builder

To show quick DynamicDialogFragment, you can use its setBuilder(DynamicDialog.Builder) method and pass DynamicDialog.Builder with all the customisations. It will automatically wrap it in a DialogFragment and use showDialog(fragmentActivity) method to display it.

DynamicDialogFragment.newInstance().setBuilder(
        new DynamicDialog.Builder(context)
                // Set dialog title.
                .setTitle(...)
                // Set dialog message.
                .setMessage(...)
                // Set negative button with a click listener.
                .setNegativeButton(..., clickListener))
        // Show the dialog fragment.
        .showDialog(fragmentActivity);

Dialog callbacks

As DialogFragment has required some extra work to get the event callbacks, it already has all the listeners of DynamicDialog.Builder built-in so that there is no extra effort is required.

DynamicDialogFragment.newInstance()
        ...
        // Callback when this dialog fragment is displayed.
        .setOnShowListener(onShowListener)
        // Callback when this dialog fragment has been dismissed.
        .setOnDismissListener(onDismissListener)
        // Callback when this dialog fragment has been canceled.
        .setOnCancelListener(onCancelListener)
        // Callback when a key is pressed in this dialog fragment.
        .setOnKeyListener(onKeyListener)
        // Show the dialog fragment.
        .showDialog(fragmentActivity);
        

For better understanding, please check CustomDialogFragment in the sample project.

Dependency

It depends on the dynamic-utils to perform various internal operations. So, its functions can also be used to perform other useful operations.


Author

Pranav Pandey

GitHub Follow on Twitter Donate via PayPal


License

Copyright 2017-2022 Pranav Pandey
Copyright 2015 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].