This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 517
Add setRemoveFromHtmlSpace function/ cleanup example #37
Merged
dschuermann
merged 5 commits into
SufficientlySecure:master
from
derekcsm:improvement/remove_fromhtml_space
Apr 8, 2016
Merged
Add setRemoveFromHtmlSpace function/ cleanup example #37
dschuermann
merged 5 commits into
SufficientlySecure:master
from
derekcsm:improvement/remove_fromhtml_space
Apr 8, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds the option of having HtmlTextView automatically trim the extra "space" that `Html.fromHtml` sometimes adds to the bottom of text, via a simple `setRemoveFromHtmlSpace(boolean)` method. `setRemoveFromHtmlSpace` must be called before setting text for the trailing space to be trimmed off it there are any, it will not work after text is already set since it just simply sets a value that will cause `removeHtmlBottomPadding` to be used in `setHtmlFromString` in the `HtmlTextView` class. I like this approach more than a constructor because it's explicitly optional, straight forward, and not a breaking change, of-course a constructor could be added, w/ potentialy XML attributes so that it can be used from resources, but for now I don't think it's necessary. I've also cleaned up `MainActivity` in the example app, moved the example html to a string resource, and added `setRemoveFromHtmlSpace` as an example. The `activity_main` layout now also has a slightly darker background from the `HtmlTextView` so that you can clearly see the bounds w/o using developer options "show layout bounds"
Hey 👋 😄 let me know what you think This would fix #19 Note: I haven't updated any version numbers |
@@ -118,7 +126,10 @@ public void setHtmlFromString(String html, ImageGetter imageGetter) { | |||
final HtmlTagHandler htmlTagHandler = new HtmlTagHandler(); | |||
htmlTagHandler.setClickableTableSpan(mClickableTableSpan); | |||
htmlTagHandler.setDrawTableLinkSpan(mDrawTableLinkSpan); | |||
setText(Html.fromHtml(html, htmlImageGetter, htmlTagHandler)); | |||
if (removeFromHtmlSpace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please always use brackets for if-else-statements
looks good besides code style requirements |
Hey @dschuermann I made a few updates yesterday, please let me know how this is. |
Great work thanks! |
released 1.5 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds the option of having HtmlTextView automatically trim the extra "space" that
Html.fromHtml
sometimes adds to the bottom of text, via a simplesetRemoveFromHtmlSpace(boolean)
method.setRemoveFromHtmlSpace
must be called before setting text for the trailing space to be trimmed off it there are any, it will not work after text is already set since it just simply sets a value that will causeremoveHtmlBottomPadding
to be used insetHtmlFromString
in theHtmlTextView
class.I like this approach more than a constructor because it's explicitly optional, straight forward, and not a breaking change, of-course a constructor could be added, w/ potentialy XML attributes so that it can be used from resources, but for now I don't think it's necessary.
I've also cleaned up
MainActivity
in the example app, moved the example html to a string resource, and addedsetRemoveFromHtmlSpace
as an example. Theactivity_main
layout now also has a slightly darker background from theHtmlTextView
so that you can clearly see the bounds w/o using developer options "show layout bounds"