Skip to content

Commit

Permalink
fbshipit-source-id: da15f69185e724eaf7d4bc78dbc61fcdcb3074d5
Browse files Browse the repository at this point in the history
  • Loading branch information
hramos committed Mar 14, 2020
1 parent 10c3984 commit 07def55
Show file tree
Hide file tree
Showing 18 changed files with 556 additions and 391 deletions.
16 changes: 15 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ jobs:
# Publishes new version onto npm
# Only works on stable branches when a properly tagged commit is pushed
publish_npm_package:
parameters:
publish_npm_args:
type: string
default: --nonightly
executor: reactnativeandroid
steps:
- restore_cache_checkout:
Expand All @@ -615,7 +619,7 @@ jobs:
git config --global user.email "react-native-bot@users.noreply.github.com"
git config --global user.name "npm Deployment Script"
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
- run: node ./scripts/publish-npm.js
- run: node ./scripts/publish-npm.js << parameters.publish_npm_args >>

# -------------------------
# JOBS: Nightly
Expand Down Expand Up @@ -746,3 +750,13 @@ workflows:
- master
jobs:
- nightly_job

- setup:
name: setup_android
checkout_type: android
executor: reactnativeandroid

- publish_npm_package:
publish_npm_args: --nightly
requires:
- setup_android
2 changes: 1 addition & 1 deletion Libraries/Image/RCTAnimatedImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ - (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source
NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];

NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime];
if (delayTimeUnclampedProp != nil) {
if (delayTimeUnclampedProp != nil && [delayTimeUnclampedProp floatValue] != 0.0f) {
frameDuration = [delayTimeUnclampedProp floatValue];
} else {
NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime];
Expand Down
1 change: 0 additions & 1 deletion ReactAndroid/src/main/java/com/facebook/fbreact/specs/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rn_android_library(
react_native_dep("third-party/java/jsr-330:jsr-330"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
":FBReactNativeSpec-jni",
],
exported_deps = [
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ public void run() {
long runStartTime = SystemClock.uptimeMillis();

// All ViewCommands should be executed first as a perf optimization
if (mViewCommandOperations != null) {
for (UIOperation viewCommandOp : mViewCommandOperations) {
if (viewCommandOperations != null) {
for (UIOperation viewCommandOp : viewCommandOperations) {
viewCommandOp.execute();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.facebook.react.views.text;

import android.content.Context;
import android.text.Layout;
import android.text.Spannable;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ReadableMap;
Expand Down Expand Up @@ -95,36 +94,15 @@ public Object updateState(
view.setSpanned(spanned);

int textBreakStrategy =
getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));

// TODO add justificationMode prop into local Data
int justificationMode = Layout.JUSTIFICATION_MODE_NONE;
TextAttributeProps.getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));

return new ReactTextUpdate(
spanned,
state.hasKey("mostRecentEventCount") ? state.getInt("mostRecentEventCount") : -1,
false, // TODO add this into local Data
TextAttributeProps.getTextAlignment(props),
textBreakStrategy,
justificationMode);
}

private int getTextBreakStrategy(@Nullable String textBreakStrategy) {
int androidTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
if (textBreakStrategy != null) {
switch (textBreakStrategy) {
case "simple":
androidTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
break;
case "balanced":
androidTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED;
break;
default:
androidTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
break;
}
}
return androidTextBreakStrategy;
TextAttributeProps.getJustificationMode(props));
}

@Override
Expand Down Expand Up @@ -154,7 +132,8 @@ public long measure(
widthMode,
height,
heightMode,
mReactTextViewManagerCallback);
mReactTextViewManagerCallback,
attachmentsPositions);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ public class TextAttributeProps {
private static final String PROP_TEXT_TRANSFORM = "textTransform";

private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
private static final int DEFAULT_JUSTIFICATION_MODE =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE;

private static final int DEFAULT_BREAK_STRATEGY =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;

protected boolean mIsAttachment = false;
protected float mAttachmentWidth = Float.NaN;
protected float mAttachmentHeight = Float.NaN;
protected float mLineHeight = Float.NaN;
protected boolean mIsColorSet = false;
protected boolean mAllowFontScaling = true;
Expand All @@ -54,10 +56,7 @@ public class TextAttributeProps {
protected float mLineHeightInput = UNSET;
protected float mLetterSpacingInput = Float.NaN;
protected int mTextAlign = Gravity.NO_GRAVITY;
protected int mTextBreakStrategy =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;
protected int mJustificationMode =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE;

protected TextTransform mTextTransform = TextTransform.UNSET;

protected float mTextShadowOffsetDx = 0;
Expand Down Expand Up @@ -126,14 +125,10 @@ public TextAttributeProps(ReactStylesDiffMap props) {
setFontVariant(getArrayProp(ViewProps.FONT_VARIANT));
setIncludeFontPadding(getBooleanProp(ViewProps.INCLUDE_FONT_PADDING, true));
setTextDecorationLine(getStringProp(ViewProps.TEXT_DECORATION_LINE));
setTextBreakStrategy(getStringProp(ViewProps.TEXT_BREAK_STRATEGY));
setTextShadowOffset(props.hasKey(PROP_SHADOW_OFFSET) ? props.getMap(PROP_SHADOW_OFFSET) : null);
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));
}

// TODO T63645393 add support for RTL
Expand Down Expand Up @@ -161,16 +156,15 @@ public static int getTextAlignment(ReactStylesDiffMap props) {
return textAlignment;
}

private void setIsAttachment(boolean isAttachment) {
mIsAttachment = isAttachment;
}

private void setAttachmentWidth(float attachmentWidth) {
mAttachmentWidth = attachmentWidth;
}
public static int getJustificationMode(ReactStylesDiffMap props) {
@Nullable
String textAlignPropValue =
props.hasKey(ViewProps.TEXT_ALIGN) ? props.getString(ViewProps.TEXT_ALIGN) : null;

private void setAttachmentHeight(float attachmentHeight) {
mAttachmentHeight = attachmentHeight;
if ("justify".equals(textAlignPropValue) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return Layout.JUSTIFICATION_MODE_INTER_WORD;
}
return DEFAULT_JUSTIFICATION_MODE;
}

private boolean getBooleanProp(String name, boolean defaultValue) {
Expand Down Expand Up @@ -357,23 +351,6 @@ public void setTextDecorationLine(@Nullable String textDecorationLineString) {
}
}

public void setTextBreakStrategy(@Nullable String textBreakStrategy) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return;
}

if (textBreakStrategy == null || "highQuality".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
} else if ("simple".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
} else if ("balanced".equals(textBreakStrategy)) {
mTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED;
} else {
throw new JSApplicationIllegalArgumentException(
"Invalid textBreakStrategy: " + textBreakStrategy);
}
}

public void setTextShadowOffset(ReadableMap offsetMap) {
mTextShadowOffsetDx = 0;
mTextShadowOffsetDy = 0;
Expand Down Expand Up @@ -418,6 +395,24 @@ public void setTextTransform(@Nullable String textTransform) {
}
}

public static int getTextBreakStrategy(@Nullable String textBreakStrategy) {
int androidTextBreakStrategy = DEFAULT_BREAK_STRATEGY;
if (textBreakStrategy != null) {
switch (textBreakStrategy) {
case "simple":
androidTextBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE;
break;
case "balanced":
androidTextBreakStrategy = Layout.BREAK_STRATEGY_BALANCED;
break;
default:
androidTextBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY;
break;
}
}
return androidTextBreakStrategy;
}

/**
* Return -1 if the input string is not a valid numeric fontWeight (100, 200, ..., 900), otherwise
* return the weight.
Expand Down
Loading

0 comments on commit 07def55

Please sign in to comment.