Use correct spans in shadow nodes

Differential Revision: D2529951

fb-gh-sync-id: d3bfbe9ea4b9c0cd405a2e0fb9a3176274f0c9fa
This commit is contained in:
Andrei Coman 2015-10-10 02:16:00 -07:00 committed by facebook-github-bot-7
parent c86966c150
commit 9f1dab69c1
2 changed files with 9 additions and 11 deletions

View File

@ -73,7 +73,13 @@ public class ReactTextShadowNode extends ReactShadowNode {
this.what = what;
}
public void execute(SpannableStringBuilder sb) {
sb.setSpan(what, start, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
// All spans will automatically extend to the right of the text, but not the left - except
// for spans that start at the beginning of the text.
int spanFlags = Spannable.SPAN_EXCLUSIVE_INCLUSIVE;
if (start == 0) {
spanFlags = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
}
sb.setSpan(what, start, end, spanFlags);
}
}

View File

@ -56,6 +56,8 @@ public class ReactTextInputManager extends
public static final String PROP_TEXT_INPUT_TEXT = "text";
@UIProp(UIProp.Type.NUMBER)
public static final String PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT = "mostRecentEventCount";
@UIProp(UIProp.Type.COLOR)
public static final String PROP_TEXT_INPUT_COLOR = ViewProps.COLOR;
private static final String KEYBOARD_TYPE_EMAIL_ADDRESS = "email-address";
private static final String KEYBOARD_TYPE_NUMERIC = "numeric";
@ -157,16 +159,6 @@ public class ReactTextInputManager extends
(int) Math.ceil(PixelUtil.toPixelFromSP(fontSize)));
}
// Prevents flickering color while waiting for JS update.
@ReactProp(name = ViewProps.COLOR, customType = "Color")
public void setColor(ReactEditText view, @Nullable Integer color) {
if (color == null) {
view.setTextColor(DefaultStyleValuesUtil.getDefaultTextColor(view.getContext()));
} else {
view.setTextColor(color);
}
}
@ReactProp(name = "placeholder")
public void setPlaceholder(ReactEditText view, @Nullable String placeholder) {
view.setHint(placeholder);