SimpleDialogFragments


Source link: https://github.com/eltos/SimpleDialogFragments

SimpleDialogFragments

    SimpleDialogFragments Library is a collection of easy to use and extendable DialogFragment's for Android. It is fully compatible with rotation changes and can be implemented with only a few lines of code.

A new approach of result handling ensures data integrity over rotation changes, that many other libraries lack.

Version history and JavaDoc API
Screenshots
Demo APK

Features

  • Common dialogs like
  • Alert dialogs with optional checkbox
  • Input dialogs with suggestions and validations
  • Filterable single- / multi-choice dialogs
  • Color pickers
  • Form dialogs
  • Date and time pickers
  • Customizable and extendable dialogs
  • Material design
  • Easy resut handling even after rotation changes
  • Persistant on rotation

Usage

In your build.gradle file *:

dependencies {

  compile 'com.github.eltos:simpledialogfragment:2.2' 
}

Examples

Alert dialog

SimpleDialog.build()

 .title(R.string.hello)

 .msg(R.string.hello_world)

 .show(this);

Choice dialog

int[] data = new int[]{
R.string.choice_A, R.string.choice_B, R.string.choice_C
}
;  SimpleListDialog.build()

  .title(R.string.select_one)

  .choiceMode(ListView.CHOICE_MODE_SINGLE_DIRECT)

  .items(getBaseContext(), data)

  .show(this, LIST_DIALOG);

Color picker

SimpleColorDialog.build()

.title(R.string.pick_a_color)

.colorPreset(Color.RED)

.allowCustom(true)

.show(this, COLOR_DIALOG);

Form dialog

SimpleFormDialog.build()

  .title(R.string.register)

  .msg(R.string.please_fill_in_form)

  .fields(

 Input.name(USERNAME).required().hint(R.string.username).validatePatternAlphanumeric(),

 Input.password(PASSWORD).required().max(20).validatePatternStrongPassword(),

 Input.email(EMAIL).required(),

 Input.plain(COUNTRY).hint(R.string.country)

.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)

.suggest(R.array.countries_locale).forceSuggestion(),

 Check.box(null).label(R.string.terms_accept).required()

  )

  .show(this, REGISTRATION_DIALOG);

See Wiki for more examples.

Receive Results

Let the hosting Activity or Fragment implement the SimpleDialog.OnDialogResultListener

@Override public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {

  if (which == BUTTON_POSITIVE && PASSWORD_DIALOG.equals(dialogTag)){

String pw = extras.getString(SimpleInputDialogFragment.TEXT);

// ...

return true;
  
}

  if (which == BUTTON_POSITIVE && LIST_DIALOG.equals(dialogTag)){

ArrayList<Integer> pos = extras.getIntegerArrayList(SimpleListDialog.SELECTED_POSITIONS);

// ...

return true;
  
}

  if (which == BUTTON_POSITIVE && REGISTRATION_DIALOG.equals(dialogTag)){

String username = extras.getString(USERNAME);

String password = extras.getString(PASSWORD);

// ...

return true;
  
}

  // ...
  return false; 
}
 

Make sure to check the demo application.

License

Copyright 2017 Philipp Niedermayer ( github.com/eltos)

Licensed under the Apache License 2.0

You may only use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software in compliance with the License. For more information visit http://www.apache.org/licenses/LICENSE-2.0
The above copyright notice alongside a copy of the Apache License shall be included in all copies or substantial portions of the Software not only in source code but also in a license listing accessible by the user.

I would appreciate if you could send me an email when you release an application that uses this library. Thanks!

Resources

This Android library allows to scan Wifi single or multiple times and get connect the scanned wifi.

Launch your Android emulators (Genymotion and AVDs) via Spotlight: ⌘ + Space

Lightweight audiowave progressbar.

A java.util.Queue interface implementation that stores directly to SqliteDb.

Simple WebView to detect click on an image.

This library tries to simplify the process of getting the degrees to north.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes