Serialize and de-serialize text attachments for Android

Summary:
This diff implements serialization and deserialization of text attachments as part of the calculation of layout of text components
changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20087251

fbshipit-source-id: dbcbd22f856aadace14343205548154ea80c8464
This commit is contained in:
David Vacca
2020-02-28 22:43:14 -08:00
committed by Facebook Github Bot
parent 58d683a688
commit 17a62b72b7
3 changed files with 25 additions and 0 deletions
@@ -62,6 +62,8 @@ public class ViewProps {
public static final String START = "start";
public static final String END = "end";
public static final String IS_ATTACHMENT = "isAttachment";
public static final String AUTO = "auto";
public static final String NONE = "none";
public static final String BOX_NONE = "box-none";
@@ -35,6 +35,9 @@ public class TextAttributeProps {
private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
protected boolean mIsAttachment = false;
protected float mAttachmentWidth;
protected float mAttachmentHeight;
protected float mLineHeight = Float.NaN;
protected boolean mIsColorSet = false;
protected boolean mAllowFontScaling = true;
@@ -126,6 +129,21 @@ public class TextAttributeProps {
setTextShadowRadius(getIntProp(PROP_SHADOW_RADIUS, 1));
setTextShadowColor(getIntProp(PROP_SHADOW_COLOR, DEFAULT_TEXT_SHADOW_COLOR));
setTextTransform(getStringProp(PROP_TEXT_TRANSFORM));
setAttachmentHeight(getFloatProp(ViewProps.HEIGHT, UNSET));
setAttachmentWidth(getFloatProp(ViewProps.WIDTH, UNSET));
setIsAttachment(getBooleanProp(ViewProps.IS_ATTACHMENT, false));
}
private void setIsAttachment(boolean isAttachment) {
mIsAttachment = isAttachment;
}
private void setAttachmentWidth(float attachmentWidth) {
mAttachmentWidth = attachmentWidth;
}
private void setAttachmentHeight(float attachmentHeight) {
mAttachmentHeight = attachmentHeight;
}
private boolean getBooleanProp(String name, boolean defaultValue) {