HtmlDialog


Source link: https://github.com/jjobes/HtmlDialog

HtmlDialog

HtmlDialog is an Android library that simplifies the display of HTML in a DialogFragment. It is useful for displaying Open Source Licenses, EULAs, Terms of Service pages, etc. Tested on Android 4.0+.

Setup

To add this library to your project, add the following to your builde.gradle:

dependencies {

 compile project(':htmlDialog') 
}

How to Use

(See SampleActivity for a more complete example)

new HtmlDialog.Builder(getFragmentManager())
  .setHtmlResId(R.raw.licenses)
  .build()
  .show();

To set the resource Id of your HTML file:

.setHtmlResId(int)

This is required. Pass in the resource Id of an HTML file that resides /res/raw/ in your main project. In the above example, R.raw.licenses refers to /res/raw/licenses.html in the main project.

To set the title of the dialog:

.setTitle(String)

By default, the dialog will have no title.

To show a negative button at the bottom of the dialog:

.setShowNegativeButton(true)

By default, no negative button is shown.

To specify the negative button text:

.setNegativeButtonText(String)

Make sure to call this if you are showing the negative button.

To show a positive button at the bottom of the dialog:

.setShowPositiveButton(true)

By default, no positive button is shown.

To specify the positive button text:

.setPositiveButtonText(String)

Make sure to call this if you are showing the positive button.

To force the user to click a button:

.setCancelable(false)

This is useful if you are displaying a license agreement.

To specify a listener:

.setListener(new HtmlDialogListener() {

@Override
  public void onNegativeButtonPressed()
  {

  
}

@Override
  public void onPositiveButtonPressed()
  {

  
}

@Override
  public void onDialogCancel()
  {

// This override is optional.

// Called when the user presses the Back button

// or touches outside the dialog.
  
}
 
}
)

Contributing

Contributions are welcome. Please open up an issue in GitHub or submit a PR.

Changelog

v1.1.2

  • Update build.gradle

v1.1.1

  • Changed to Android Studio / Gradle project

v1.1.0

  • removed setShowCloseButton() and setCloseButtonText()
  • added setShowNegativeButton(), setNegativeButtonText()
  • added setShowPositiveButton(), setPositiveButtonText()
  • added setCancelable()
  • added setListener()
  • updated SampleActivity

v1.0.0

  • First release

License

Licensed under the Apache License, Version 2.0

Acknowledgements

This project is based off of Adam Speakman's AndroidLicensesPage.

Resources

Statically typed programming language targeting the JVM and JavaScript.

100% interoperable with Java™

Spotify Web API Wrapper with Retrofit and OkClients just for Android.

This library includes authentication and account token management feature.

Bee

Bee is a QA/Debug tool that works like a widget in any application. The idea is to add some features/options to developer and QA to configure the app, get some information. Bee works like an extra view when the user presses the bee icon.

Catch common Java mistakes as compile-time errors.

Android Studio/IntelliJ IDEA Plugin for Android code generation.

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