From 85e33aaf908996e99220bff4a2bdbbdf7c0d12b0 Mon Sep 17 00:00:00 2001 From: Tadeu Valentt Date: Sun, 25 Mar 2018 20:39:22 -0700 Subject: [PATCH] Prevents android crash due to unsupported ellipsize mode Summary: Fixes #18474 This allows use clip as ellipsize mode for truncated text on android Added a test to RNTester, so it can be tested from there: 1. Run RNTester project 2. Navigate to `` tests 3. Scroll down to "Ellipsize mode" examples 4. Check the default behavior being applied when the value is set to "clip" [ANDROID] [BUGFIX] [Text] - Prevents android crash due to unsupported "clip" ellipsize mode Closes https://github.com/facebook/react-native/pull/18540 Differential Revision: D7396379 Pulled By: mdvacca fbshipit-source-id: 6c4b223731143c5081b3d12a3c740d1e375bd586 --- RNTester/js/TextExample.android.js | 3 +++ .../facebook/react/views/text/ReactTextAnchorViewManager.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/RNTester/js/TextExample.android.js b/RNTester/js/TextExample.android.js index 0b0bf195f68fb7..b912337827a279 100644 --- a/RNTester/js/TextExample.android.js +++ b/RNTester/js/TextExample.android.js @@ -453,6 +453,9 @@ class TextExample extends React.Component<{}> { This very long text should be truncated with dots in the beginning. + + This very long text should be clipped and this will not be visible. + diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java index 71ba5eef46095f..776bce7ccdc565 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java @@ -52,6 +52,8 @@ public void setEllipsizeMode(ReactTextView view, @Nullable String ellipsizeMode) view.setEllipsizeLocation(TextUtils.TruncateAt.START); } else if (ellipsizeMode.equals("middle")) { view.setEllipsizeLocation(TextUtils.TruncateAt.MIDDLE); + } else if (ellipsizeMode.equals("clip")) { + view.setEllipsizeLocation(null); } else { throw new JSApplicationIllegalArgumentException("Invalid ellipsizeMode: " + ellipsizeMode); }