Add support for phone numbers, and for highlighting only pre-tagged matches #36
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.
Phone number support is provided using the phone number data detector. Some refactoring of existing code streamlined this enhancement.
There is also the addition of a flag that prevents matches that do not already have a link attribute from being decorated and made tappable. I needed this because the phone number data detector will match text like "phone number 508-555-1234" rather than just "508-555-1234" and I wanted patterns like the latter highlighted. Similarly, words like "toll free" are also picked up if they precede a phone number.
I had already written code in my own project to find and decorate just the phone numbers, so it made sense to add support to this class to honor pre-set links and their text and ignore matches without a pre-set link.
The use case for the latter part is a string with several phone numbers, not all of which are callable (e.g. a FAX number). By pre-decorating the callable numbers only, and setting the new
ignoreMatchesWithoutLinkAttribute
flag, only those matching text ranges already having a link are decorated by the class.I also updated the demo app.