-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Adding Hyphenation Frequency prop for Text component #29157
Conversation
Base commit: e75557b |
Base commit: e75557b |
I can't confirm that this will get approved (I don't have context on the Android side), but we've been following a pattern of the platform prefixes being |
thanks a lot @TheSavior . Changes are included in 4500095. I'm fixing the same issue also in #29059. I have no prerogative for the PR to be merged, but just hope to get a better insight in the react-native project and write more relevant pr in the future.. Thanks a lot. Fabrizio |
This seems pretty reasonable to me :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@fabriziobertoglio1987 I'm working on testing internally and having some conversations about the prefix. While I'm doing that, could you issue a PR to the docs site to add documentation for the new prop? https://github.com/facebook/react-native-website/tree/master/docs |
UPDATE 30/06/2020 I notice now that 0fda91f does not include the latest changes. Tomorrow I will work on testing this functionality on Android API < 23 and add changes from 14709f8 to master if required (in a separate pull request). Additionally I noticed my errors in #29070. Sorry for this, I did a mistake. I will fix #29070 and not make any errors in my future pull request. Thanks a lot and sorry for disturbing. I understand now that ReactNative Core team is very busy and I should deliver higher quality code. OLD MESSAGE 26/06/2020 Thanks a lot @JoshuaGross I added the docs and also added a new commit to this Pull Request 14709f8 as setHyphenationFrequency android method is available only from API 23+. I decided to write this PR as a solution of #28279 to give users more control on the Text Component. I don't work on iOS and I had the impression that I tested on RNTester example emulator API 28. #28940 unluckily denies me to test this changes on my API 19 emulator. I am on cellular data right now and can not download another Android 22 image to test the code changes from 14709f8 on devices < Android 23, but I believe the logic will work as the same logic is used with react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java Lines 551 to 555 in ce0edca
I'll work on this and let you know. I remain available. Thanks a lot. I wish you a good day. Fabrizio |
This pull request was successfully merged by @fabriziobertoglio1987 in 0fda91f. When will my fix make it into a release? | Upcoming Releases |
@fabriziobertoglio1987 Thank you for following up on this! The amendment is being merged in. |
Summary: JoshuaGross This issue fixes #28279 as discussed in #29157 (comment) Avoid calling [setHyphenationFrequency](https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int)) on Android Sdk < 23. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - do not call setHyphenationFrequency on AndroidSdk < 23 Pull Request resolved: #29258 Test Plan: | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | <img src="https://user-images.githubusercontent.com/24992535/86214122-05bf0e00-bb7b-11ea-93b5-2174812bfec9.png" width="300" height="" />| <img src="https://user-images.githubusercontent.com/24992535/86214130-08216800-bb7b-11ea-9fc0-68b28638bf57.png" width="300" height="" /> | The warning displayed with `adb logcat | grep -P "ReactTextAnchorViewManager"` ![image](https://user-images.githubusercontent.com/24992535/86214242-34d57f80-bb7b-11ea-9945-30ae25332bfb.png) I remain available to do improvements. Thanks a lot. Fabrizio. Reviewed By: JoshuaGross Differential Revision: D22337095 Pulled By: mdvacca fbshipit-source-id: d0943397af180929c48044ccbc7a9388549021b8
Following same implementation used with underlineColorAndroid https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L470 https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js#L203 While with other components (for example prop android_ripple), we use the android_ prefix to denote platform specific props. facebook#29157 (comment) https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/Pressable/Pressable.js#L177 In the case of TextInput we already have Platform Logic that detects Android/iOS platform. https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1268 For this reason TextInput component does not use android_ props and instead uses this naming convention underlineColorAndroid. To be noted that the prop underlineColorAndroid is passed to both iOS and Android version, while other props have platform specific logic for android and iOS. https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1334 https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1293 Example of a prop that have a specific value on Android and is different from iOS https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1271 I decided to follow the same solution used in underlineColorAndroid.
Following same implementation used with underlineColorAndroid https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L470 https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js#L203 While with other components (for example prop android_ripple), we use the android_ prefix to denote platform specific props. facebook#29157 (comment) https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/Pressable/Pressable.js#L177 In the case of TextInput we already have Platform Logic that detects Android/iOS platform. https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1268 For this reason TextInput component does not use android_ props and instead uses this naming convention underlineColorAndroid. To be noted that the prop underlineColorAndroid is passed to both iOS and Android version, while other props have platform specific logic for android and iOS. https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1334 https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1293 Example of a prop that have a specific value on Android and is different from iOS https://github.com/fabriziobertoglio1987/react-native/blob/15810e96d90e18dbd424666338fdec0127d403ed/Libraries/Components/TextInput/TextInput.js#L1271 I decided to follow the same solution used in underlineColorAndroid.
Summary
This issue fixes #28279
android_hyphenationFrequency prop for Android Text component which sets the frequency of automatic hyphenation to use when determining word breaks.
Changelog
[Android] [Fixed] - Adding Hyphenation Frequency prop for Text component
Test Plan
More info are available in the android docs. I will add the documentation to the docs later once the pull request is taken in consideration for merging.
I remain available to do improvements. Thanks a lot. Fabrizio.