• Stars
    star
    558
  • Rank 77,486 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Compatibility library for Android's Html class. [DEPRECATED]

HtmlCompat

Compaibility library for Android's Html class.

DEPRECATED

Google has introduced the official HtmlCompat library as part of AndroidX. This library will no longer be updated or maintained; please use the official library.

Why?

Nougat introduced improvements to the Html class for converting HTML to spannables. Unfortunately, these new features lay within the Android SDK itself. This means that the behavior in which HTML is converted is subject to the version of Android that the user is running.

HtmlCompat attempts to address this problem by providing developers with a compatibility library. All logic for converting HTML is enclosed within this library and can be bundled within an app. This means that the presentation is agnostic to the version of Android of the device.

How can I use it?

Download the latest AAR or grab from Bintray using Gradle:

dependencies {
    compile 'com.pixplicity.htmlcompat:library:[VERSION_HERE]'
}

Download

Important: Specify the latest version from Bintray as [VERSION_HERE].

Sample code:

Spanned fromHtml = HtmlCompat.fromHtml(context, source, 0);
// You may want to provide an ImageGetter, TagHandler and SpanCallback:
//Spanned fromHtml = HtmlCompat.fromHtml(context, source, 0,
//        imageGetter, tagHandler, spanCallback);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(fromHtml);

What’s supported?

All the latest functionality from the current Html for Android Nougat is included in this library. While this may continue to be improved in the future, currently, the following tags are supported out of the box:

  • <br>
  • <p>
  • <ul>
  • <li>
  • <div>
  • <span>
  • <strong>, <b>
  • <em>, <i>
  • <u>
  • <s>, <strike>, <del>
  • <cite>
  • <dfn>
  • <big>
  • <small>
  • <font>
  • <blockquote>
  • <tt>
  • <a>
  • <sup>
  • <sub>
  • <h1>, <h2>, <h3>, <h4>, <h5>, <h6>
  • <img>

The following CSS inline styles are supported:

  • text-align
  • color
  • background, background-color
  • text-decoration

All CSS color declarations as defined here are supported.

What’s added?

A few new features have been added to the interface to ease the life of the developer:

  • Callbacks into ImageGetter and TagHandler provide the tag attributes;
  • SpanCallback can be registered so the implementor may be informed of new spans; this allows for spans to be modified;
  • All CSS color declarations have been added.

What’s next?

We’re looking to support more tags and styles in future releases. Feel free to contribute with pull requests or by reporting issues on the GitHub project page.

This library has become obsolete, in favor of the official HtmlCompat library as part of AndroidX. This library will no longer be updated or maintained; please use the official library.

Made with by Pixplicity

License

   Copyright 2017 Pixplicity

   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.

More Repositories

1

MultiViewPager

The MultiViewPager is an extension of the support-v4 library's ViewPager that allows the pages to be wider or narrower than the ViewPager itself. It takes care of aligning the pages next to each other, and always keeping the selected page centered.
Java
908
star
2

EasyPrefs

A small library containing a wrapper/helper for the Shared Preferences of android.
Java
419
star
3

letterpress

Custom fonts without writing code.
Java
135
star
4

humpty-dumpty-android

Simple file dump utility for Android
Shell
104
star
5

gene-rate

Generate a better rating for your Android app
Java
67
star
6

android-custom-components

Custom Components for Android
Java
21
star
7

Proguard-rules

Proguard rules for commonly used libraries
19
star
8

sync-demo

Sync Demo
Java
16
star
9

android-bluetooth-demo

This project demonstrates communicating with a bluetooth device in an Android app.
Java
16
star
10

PoorIntentions

Illustrates invalid back stacks on Android and offers a resolution
Kotlin
11
star
11

adb-control

ADB Control for Root app
Java
6
star
12

HaldCLUT

C/C++ generator for Hald Color Lookup Tables
C
4
star
13

castdemo

Google Cast Demo
Java
4
star
14

ChoiceGridView

Variant of Android's GridView that has improved handling for multiselection.
Java
3
star
15

StandardSmashdown

The official Standard Rules for Smashdown Ping-Pong
3
star
16

gimbal-proximity

Fork and improvement of Gimbal Proximity SDK sample app
Java
3
star
17

flutter_animation_motion

Companion app for my "Animation and motion in Flutter" presentation, showcasing what the framework has to offer to developers for creating simple and yet beautiful animations.
Dart
3
star
18

multi-window-demo

Demo of Android N's Multi-Window mode
Java
2
star
19

weardemo

Java
2
star
20

overlay-android-bug

Demo of a bug in Android 7.1.2 (Nougat) on a Nexus 6P
Java
2
star
21

animation-demo

Java
1
star
22

nougat-photo

A very basic no-frills implementation of using the default camera to return a photo, compatible with Android Nougat.
Java
1
star
23

PriorityAlert

Java
1
star
24

HeadphoneData

Java
1
star
25

resource-converter

Java
1
star