Skip to content

API to disable span support#24

Open
dnkoutso wants to merge 1 commit intomasterfrom
dimitris/android-dep
Open

API to disable span support#24
dnkoutso wants to merge 1 commit intomasterfrom
dimitris/android-dep

Conversation

@dnkoutso
Copy link

This mode unlocks the ability for consumers to disable span support. This enables writing pure unit tests that do not depend on SpannableStringBuilder which otherwise would require Robolectric to run and make the tests much much slower.

Fixed all warnings too.

@loganj @ChrisRenke @rjrjr

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch from 796b309 to 3f8ace2 Compare March 11, 2016 18:55
private int curCharIndex;

/**
* When enabled, span support is disabled. This can be useful for unit tests that don't want
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might need a bit help to word this better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first sentence is redundant with field name. Just keep the second sentence ("This can be useful...").

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch from 3f8ace2 to 42ef4ee Compare March 11, 2016 18:56

/** Set whether span support is enabled or not. */
@SuppressWarnings("UnusedDeclaration") // Public API.
public void setDisableSpanSupport(boolean disableSpanSupport) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invert: setSpanSupportEnabled. default to true.

javadoc should indicate default. move javadoc from field to this method.

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch from 42ef4ee to 03832d3 Compare March 11, 2016 19:10
import static java.util.regex.Matcher.quoteReplacement;
import static java.util.regex.Pattern.quote;

public class SimpleEditable implements Editable {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final. definitely not public. needs javadoc.

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch from 03832d3 to 40375f6 Compare March 11, 2016 19:20
* Default is <code>true</code>.
*/
@SuppressWarnings("UnusedDeclaration") // Public API.
public void setSpanSupportEnabled(boolean spanSupportedEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered just making this variable final, and having new factory methods for it? There'd be a lot of method proliferation I guess.

I was thinking of something like Phrase.stubSpan().from(...) or Phrase.stubSpanFrom(...) or something. That way you just have a small amount of code to add across a lot of tests.

I'd just like someone to avoid running into this method in their normal Phrase usage.

@pforhan
Copy link
Contributor

pforhan commented Mar 14, 2016

LGTM

/**
* This can be useful for unit tests that don't want to use {@link SpannableStringBuilder}
* which can cause a stub exception or be no-op.
* Default is <code>true</code>.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should change that since I switched it, it should say <code>false</code>

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch 2 times, most recently from bdc9261 to d57d3d8 Compare March 16, 2016 19:00
@pforhan
Copy link
Contributor

pforhan commented Oct 29, 2019

We should merge this, just noticed we've been using it for a looong time right off this commit.

We may want to pursue some sort of "default" span enabled setting that would enable even easier test writing

@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch from d57d3d8 to ad818ca Compare October 30, 2019 18:51
@dnkoutso dnkoutso force-pushed the dimitris/android-dep branch 2 times, most recently from a876d9b to 663ca14 Compare October 30, 2019 20:01
@pforhan pforhan mentioned this pull request May 28, 2020
@pforhan
Copy link
Contributor

pforhan commented Apr 6, 2022

@edenman we should get this in for a release

@pforhan
Copy link
Contributor

pforhan commented Apr 6, 2022

@dnkoutso want to rebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants