android-ktx
android-ktx copied to clipboard
Add SpannableString.overlay and .overlayAll to apply spans to substrings
The overlay methods will apply a provided span to matching
substrings of the receiver. In .overlay
, it will apply to
only the first matching occurrence, while .overlayAll
will
apply the span to all matching occurrences of the substring.
Because spans are not copyable, you provide a spanBuilder
lambda
to generate a new span to apply to each occurrence.
This supports case-insensitive matching.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here (e.g. I signed it!
) and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to
go/cla#troubleshoot
. - The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
CLAs look good, thanks!
Thanks! I just expanded the tests to get a little more coverage and a bit more specificity of each case. We now test the following for both methods:
- No matches
- Multiple matches
- Case sensitivity
- Start index
- Multiple different spans applied successfully
This is great. Thank you.
My biggest concern here is that the only thing Kotlin-specific is the fact that this is an extension function instead of a static method. I'm going to try to get this into the normal support library somewhere and then we can just hang it as an extension and alias.
Okay, sounds awesome, thanks!