Now that 3.1.0 removes configurationFromJson, users cannot create their own TwitterTextConfiguration. I used to initialize my TwitterTextConfiguration using JSON but the feature is removed. I have to use the builder, but I can't create TwitterTextWeightedRange because its methods are private.
class Example {
private val DEFAULT_VERSION: Int = 3;
private val DEFAULT_WEIGHTED_LENGTH: Int = 140;
private val DEFAULT_SCALE: Int = 100;
private val DEFAULT_WEIGHT: Int = 200;
private val DEFAULT_EMOJI_PARSING_ENABLED: Boolean = true;
private val DEFAULT_TRANSFORMED_URL_LENGTH: Int = 23;
private val DEFAULT_RANGES: java.util.List[TwitterTextWeightedRange] = new java.util.ArrayList(
// value setStart is not a member of com.twitter.twittertext.TwitterTextConfiguration.TwitterTextWeightedRange
new TwitterTextWeightedRange().setStart(0).setEnd(4351).setWeight(100),
)
override def getMyOwnTwitterTextConfig: TwitterTextConfiguration = {
new TwitterTextConfiguration.Builder()
.setVersion(DEFAULT_VERSION)
.setMaxWeightedTweetLength(DEFAULT_WEIGHTED_LENGTH)
.setScale(DEFAULT_SCALE)
.setDefaultWeight(DEFAULT_WEIGHT)
.setEmojiParsingEnabled(DEFAULT_EMOJI_PARSING_ENABLED)
.setRanges(DEFAULT_RANGES)
.setTransformedURLLength(DEFAULT_TRANSFORMED_URL_LENGTH)
.build();
}
}
Expected behavior
User can initialize their own TwitterTextWeightedRange.
Actual behavior
The setStart method of TwitterTextWeightedRange is private so user can't build their own TwitterTextConfiguration with custom ranges. I propose
exposing the methods or constructor of TwitterTextWeightedRange,
OR exposing the DEFAULT_ values in TwitterTextConfiguration.
Steps to reproduce the behavior
Please list all relevant steps to reproduce the observed behavior.
Comments
Honestly I don't need to customize all the fields. I just want to change the MaxWeightedTweetLength from the default configuration. So another solution is exposing the default builder.
public static Builder getDefaultBuilder() {
return new TwitterTextConfiguration.Builder()
.setVersion(DEFAULT_VERSION)
.setMaxWeightedTweetLength(DEFAULT_WEIGHTED_LENGTH)
.setScale(DEFAULT_SCALE)
.setDefaultWeight(DEFAULT_WEIGHT)
.setEmojiParsingEnabled(DEFAULT_EMOJI_PARSING_ENABLED)
.setRanges(DEFAULT_RANGES)
.setTransformedURLLength(DEFAULT_TRANSFORMED_URL_LENGTH)
}
Now that 3.1.0 removes
configurationFromJson
, users cannot create their ownTwitterTextConfiguration
. I used to initialize myTwitterTextConfiguration
using JSON but the feature is removed. I have to use the builder, but I can't createTwitterTextWeightedRange
because its methods are private.Expected behavior
User can initialize their own
TwitterTextWeightedRange
.Actual behavior
The
setStart
method ofTwitterTextWeightedRange
is private so user can't build their ownTwitterTextConfiguration
with custom ranges. I proposeTwitterTextWeightedRange
,DEFAULT_
values inTwitterTextConfiguration
.Steps to reproduce the behavior
Please list all relevant steps to reproduce the observed behavior.
Comments
Honestly I don't need to customize all the fields. I just want to change the
MaxWeightedTweetLength
from the default configuration. So another solution is exposing the default builder.