Skip to content

Commit

Permalink
Remove unsupported values for android_hyphenationFrequency
Browse files Browse the repository at this point in the history
Summary:
hyphenationStrategy must be one of one of Layout#HYPHENATION_FREQUENCY_NONE, Layout#HYPHENATION_FREQUENCY_NORMAL, Layout#HYPHENATION_FREQUENCY_FULL: (https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int))

Thus "high" and "balanced" are not only redundant, but actually don't do what the value indicates - Layout#BREAK_STRATEGY_BALANCED (constant value: 2) and Layout#BREAK_STRATEGY_HIGH_QUALITY (constant value: 1) are only meant to be used for android:breakStrategy

Changelog:
[Android][Changed] - Remove `"high"` and `"balanced"` as values for `android_hyphenationFrequency` on `Text`

Reviewed By: JoshuaGross

Differential Revision: D30531096

fbshipit-source-id: 1a0b6e733bb21ce6b2f104a2025a79c16de3cfea
  • Loading branch information
genkikondo authored and facebook-github-bot committed Aug 26, 2021
1 parent 8f7e23a commit a0d30b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
8 changes: 1 addition & 7 deletions Libraries/Text/TextProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ export type TextProps = $ReadOnly<{|
* Set hyphenation strategy on Android.
*
*/
android_hyphenationFrequency?: ?(
| 'normal'
| 'none'
| 'full'
| 'high'
| 'balanced'
),
android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),
children?: ?Node,

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public void setAndroidHyphenationFrequency(ReactTextView view, @Nullable String
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
} else if (frequency.equals("full")) {
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
} else if (frequency.equals("balanced")) {
view.setHyphenationFrequency(Layout.BREAK_STRATEGY_BALANCED);
} else if (frequency.equals("high")) {
view.setHyphenationFrequency(Layout.BREAK_STRATEGY_HIGH_QUALITY);
} else if (frequency.equals("normal")) {
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
} else {
Expand Down
14 changes: 3 additions & 11 deletions packages/rn-tester/js/examples/Text/TextExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,15 @@ class TextExample extends React.Component<{...}> {
<RNTesterBlock title="Hyphenation">
<Text android_hyphenationFrequency="normal">
<Text style={{color: 'red'}}>Normal: </Text>
WillHaveAnHyphenWhenBreakingForNewLine
WillHaveAHyphenWhenBreakingForNewLine
</Text>
<Text android_hyphenationFrequency="none">
<Text style={{color: 'red'}}>None: </Text>
WillNotHaveAnHyphenWhenBreakingForNewLine
WillNotHaveAHyphenWhenBreakingForNewLine
</Text>
<Text android_hyphenationFrequency="full">
<Text style={{color: 'red'}}>Full: </Text>
WillHaveAnHyphenWhenBreakingForNewLine
</Text>
<Text android_hyphenationFrequency="high">
<Text style={{color: 'red'}}>High: </Text>
WillHaveAnHyphenWhenBreakingForNewLine
</Text>
<Text android_hyphenationFrequency="balanced">
<Text style={{color: 'red'}}>Balanced: </Text>
WillHaveAnHyphenWhenBreakingForNewLine
WillHaveAHyphenWhenBreakingForNewLine
</Text>
</RNTesterBlock>
<RNTesterBlock title="Padding">
Expand Down

0 comments on commit a0d30b8

Please sign in to comment.