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

Fast JSON parser for Java projects. The following scalar types are supported:

  • String
  • boolean/Boolean
  • int/Integer
  • long/Long
  • float/Float
  • double/Double

If a json field is another dictionary, it can be represented by another model class. That model class must also have the @JsonType annotation.

Lists of objects are supported either as Java Lists or Queues.

Mimicry is a tiny Android library (actually just one class) to format items in a ListAdapter to display as a grid.

Why not just use a GridView? Because a MimicryAdapter can be used with other ListAdapters!

Encryption is a simple way to create encrypted strings to Android project.

SnappyDB is a key-value database for Android it's an alternative for SQLite if you want to use a NoSQL approach.

It allows you to store and get primitive types, but also a Serializable object or array in a type-safe way.

SnappyDB can outperform SQLite in read/write operations.

AppRate for Android is a library that allows your users to rate your application in a non intrusive way. A window with options to rate, remind later or reject is displayed according to your configuration

Android @Properties provides a simple way to read a .properties from assets folder.

You just have to extends from AssetsProperties and use @Property annotation to invoke the automatic property mapping.

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