Export latest Android changes

This commit is contained in:
Martin Konicek 2015-09-17 14:33:23 +01:00
parent 3b4845f93c
commit 27ab039b6a
32 changed files with 685 additions and 792 deletions

View File

@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
@ -24,11 +24,11 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:23.0.1'
// Depend on pre-built React Native
compile 'com.facebook.react:react-native:0.11.+'
// Depend on React Native source.
// This is useful for testing your changes when working on React Native.
// compile project(':ReactAndroid')

View File

@ -0,0 +1 @@
android.useDeprecatedNdk=true

View File

@ -24,11 +24,11 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
// Depend on pre-built React Native
compile 'com.facebook.react:react-native:0.11.+'
// Depend on React Native source.
// This is useful for testing your changes when working on React Native.
// compile project(':ReactAndroid')

View File

@ -0,0 +1 @@
android.useDeprecatedNdk=true

View File

@ -24,11 +24,11 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
// Depend on pre-built React Native
compile 'com.facebook.react:react-native:0.11.+'
// Depend on React Native source.
// This is useful for testing your changes when working on React Native.
// compile project(':ReactAndroid')

View File

@ -0,0 +1 @@
android.useDeprecatedNdk=true

View File

@ -196,8 +196,8 @@ task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
@ -231,7 +231,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.facebook.fresco:fresco:0.6.1'
compile 'com.facebook.fresco:imagepipeline-okhttp:0.6.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'

View File

@ -1,6 +1,8 @@
VERSION_NAME=0.11.1-SNAPSHOT
VERSION_NAME=0.12.0-SNAPSHOT
GROUP=com.facebook.react
POM_NAME=ReactNative
POM_ARTIFACT_ID=react-native
POM_PACKAGING=aar
android.useDeprecatedNdk=true

View File

@ -7,53 +7,54 @@
*/
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
// @generated SignedSource<<153b6759d2dd8fe8cf6d58a422450b96>>
// @generated SignedSource<<638f16255d86b878b0377e1070cc2b44>>
package com.facebook.csslayout;
import java.util.Arrays;
/**
* Where the output of {@link LayoutEngine#layoutNode(CSSNode, float)} will go in the CSSNode.
*/
public class CSSLayout {
public static final int POSITION_LEFT = 0;
public static final int POSITION_TOP = 1;
public static final int POSITION_RIGHT = 2;
public static final int POSITION_BOTTOM = 3;
public float top;
public float left;
public float right;
public float bottom;
public float width = CSSConstants.UNDEFINED;
public float height = CSSConstants.UNDEFINED;
public static final int DIMENSION_WIDTH = 0;
public static final int DIMENSION_HEIGHT = 1;
public float[] position = new float[4];
public float[] dimensions = new float[2];
public CSSDirection direction = CSSDirection.LTR;
/**
* This should always get called before calling {@link LayoutEngine#layoutNode(CSSNode, float)}
*/
public void resetResult() {
left = 0;
top = 0;
right = 0;
bottom = 0;
width = CSSConstants.UNDEFINED;
height = CSSConstants.UNDEFINED;
Arrays.fill(position, 0);
Arrays.fill(dimensions, CSSConstants.UNDEFINED);
direction = CSSDirection.LTR;
}
public void copy(CSSLayout layout) {
left = layout.left;
top = layout.top;
right = layout.right;
bottom = layout.bottom;
width = layout.width;
height = layout.height;
position[POSITION_LEFT] = layout.position[POSITION_LEFT];
position[POSITION_TOP] = layout.position[POSITION_TOP];
position[POSITION_RIGHT] = layout.position[POSITION_RIGHT];
position[POSITION_BOTTOM] = layout.position[POSITION_BOTTOM];
dimensions[DIMENSION_WIDTH] = layout.dimensions[DIMENSION_WIDTH];
dimensions[DIMENSION_HEIGHT] = layout.dimensions[DIMENSION_HEIGHT];
direction = layout.direction;
}
@Override
public String toString() {
return "layout: {" +
"left: " + left + ", " +
"top: " + top + ", " +
"width: " + width + ", " +
"height: " + height +
"left: " + position[POSITION_LEFT] + ", " +
"top: " + position[POSITION_TOP] + ", " +
"width: " + dimensions[DIMENSION_WIDTH] + ", " +
"height: " + dimensions[DIMENSION_HEIGHT] + ", " +
"direction: " + direction +
"}";
}

View File

@ -7,7 +7,7 @@
*/
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
// @generated SignedSource<<c3a1298e36789dcda4cc2776d48646a7>>
// @generated SignedSource<<560f2fd13ec8e1100a71958529146055>>
package com.facebook.csslayout;
@ -17,6 +17,13 @@ import java.util.ArrayList;
import com.facebook.infer.annotation.Assertions;
import static com.facebook.csslayout.CSSLayout.DIMENSION_HEIGHT;
import static com.facebook.csslayout.CSSLayout.DIMENSION_WIDTH;
import static com.facebook.csslayout.CSSLayout.POSITION_BOTTOM;
import static com.facebook.csslayout.CSSLayout.POSITION_LEFT;
import static com.facebook.csslayout.CSSLayout.POSITION_RIGHT;
import static com.facebook.csslayout.CSSLayout.POSITION_TOP;
/**
* A CSS Node. It has a style object you can manipulate at {@link #style}. After calling
* {@link #calculateLayout()}, {@link #layout} will be filled with the results of the layout.
@ -59,6 +66,9 @@ public class CSSNode {
public int lineIndex = 0;
/*package*/ CSSNode nextAbsoluteChild;
/*package*/ CSSNode nextFlexChild;
private @Nullable ArrayList<CSSNode> mChildren;
private @Nullable CSSNode mParent;
private @Nullable MeasureFunction mMeasureFunction = null;
@ -296,61 +306,61 @@ public class CSSNode {
}
public void setPositionTop(float positionTop) {
if (!valuesEqual(style.positionTop, positionTop)) {
style.positionTop = positionTop;
if (!valuesEqual(style.position[POSITION_TOP], positionTop)) {
style.position[POSITION_TOP] = positionTop;
dirty();
}
}
public void setPositionBottom(float positionBottom) {
if (!valuesEqual(style.positionBottom, positionBottom)) {
style.positionBottom = positionBottom;
if (!valuesEqual(style.position[POSITION_BOTTOM], positionBottom)) {
style.position[POSITION_BOTTOM] = positionBottom;
dirty();
}
}
public void setPositionLeft(float positionLeft) {
if (!valuesEqual(style.positionLeft, positionLeft)) {
style.positionLeft = positionLeft;
if (!valuesEqual(style.position[POSITION_LEFT], positionLeft)) {
style.position[POSITION_LEFT] = positionLeft;
dirty();
}
}
public void setPositionRight(float positionRight) {
if (!valuesEqual(style.positionRight, positionRight)) {
style.positionRight = positionRight;
if (!valuesEqual(style.position[POSITION_RIGHT], positionRight)) {
style.position[POSITION_RIGHT] = positionRight;
dirty();
}
}
public void setStyleWidth(float width) {
if (!valuesEqual(style.width, width)) {
style.width = width;
if (!valuesEqual(style.dimensions[DIMENSION_WIDTH], width)) {
style.dimensions[DIMENSION_WIDTH] = width;
dirty();
}
}
public void setStyleHeight(float height) {
if (!valuesEqual(style.height, height)) {
style.height = height;
if (!valuesEqual(style.dimensions[DIMENSION_HEIGHT], height)) {
style.dimensions[DIMENSION_HEIGHT] = height;
dirty();
}
}
public float getLayoutX() {
return layout.left;
return layout.position[POSITION_LEFT];
}
public float getLayoutY() {
return layout.top;
return layout.position[POSITION_TOP];
}
public float getLayoutWidth() {
return layout.width;
return layout.dimensions[DIMENSION_WIDTH];
}
public float getLayoutHeight() {
return layout.height;
return layout.dimensions[DIMENSION_HEIGHT];
}
public CSSDirection getLayoutDirection() {
@ -368,14 +378,14 @@ public class CSSNode {
* Get this node's width, as defined in the style.
*/
public float getStyleWidth() {
return style.width;
return style.dimensions[DIMENSION_WIDTH];
}
/**
* Get this node's height, as defined in the style.
*/
public float getStyleHeight() {
return style.height;
return style.dimensions[DIMENSION_HEIGHT];
}
/**

View File

@ -7,7 +7,7 @@
*/
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
// @generated SignedSource<<ec76950a22dda1c6e98eafc15ccf7cd3>>
// @generated SignedSource<<2fc400ad927a17e1b13430210531ce86>>
package com.facebook.csslayout;
@ -30,13 +30,17 @@ public class CSSStyle {
public Spacing padding = new Spacing();
public Spacing border = new Spacing();
public float positionTop = CSSConstants.UNDEFINED;
public float positionBottom = CSSConstants.UNDEFINED;
public float positionLeft = CSSConstants.UNDEFINED;
public float positionRight = CSSConstants.UNDEFINED;
public float[] position = {
CSSConstants.UNDEFINED,
CSSConstants.UNDEFINED,
CSSConstants.UNDEFINED,
CSSConstants.UNDEFINED,
};
public float width = CSSConstants.UNDEFINED;
public float height = CSSConstants.UNDEFINED;
public float[] dimensions = {
CSSConstants.UNDEFINED,
CSSConstants.UNDEFINED,
};
public float minWidth = CSSConstants.UNDEFINED;
public float minHeight = CSSConstants.UNDEFINED;

View File

@ -1,7 +1,7 @@
The source of truth for css-layout is: https://github.com/facebook/css-layout
The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/7104f7c8eb6c160a8d10badc08f9b981bb65e19c
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/f51c2d004de7744f9cefb98aa2a9c1c22168d49c
There is generated code in:
- README (this file)

View File

@ -1,7 +1,7 @@
The source of truth for css-layout is: https://github.com/facebook/css-layout
The code here should be kept in sync with GitHub.
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/7104f7c8eb6c160a8d10badc08f9b981bb65e19c
HEAD at the time this code was synced: https://github.com/facebook/css-layout/commit/f51c2d004de7744f9cefb98aa2a9c1c22168d49c
There is generated code in:
- README.facebook (this file)

View File

@ -7,7 +7,7 @@
*/
// NOTE: this file is auto-copied from https://github.com/facebook/css-layout
// @generated SignedSource<<6853e87a84818f1abb6573aee7d6bd55>>
// @generated SignedSource<<fcf3439e46c4c76e42357c348a9ffe99>>
package com.facebook.csslayout;
@ -58,8 +58,22 @@ public class Spacing {
*/
public static final int ALL = 8;
private static final int[] sFlagsMap = {
1, /*LEFT*/
2, /*TOP*/
4, /*RIGHT*/
8, /*BOTTOM*/
16, /*VERTICAL*/
32, /*HORIZONTAL*/
64, /*START*/
128, /*END*/
256, /*ALL*/
};
private final float[] mSpacing = newFullSpacingArray();
@Nullable private float[] mDefaultSpacing = null;
private int mValueFlags = 0;
private boolean mHasAliasesSet;
/**
* Set a spacing value.
@ -73,6 +87,18 @@ public class Spacing {
public boolean set(int spacingType, float value) {
if (!FloatUtil.floatsEqual(mSpacing[spacingType], value)) {
mSpacing[spacingType] = value;
if (CSSConstants.isUndefined(value)) {
mValueFlags &= ~sFlagsMap[spacingType];
} else {
mValueFlags |= sFlagsMap[spacingType];
}
mHasAliasesSet =
(mValueFlags & sFlagsMap[ALL]) != 0 ||
(mValueFlags & sFlagsMap[VERTICAL]) != 0 ||
(mValueFlags & sFlagsMap[HORIZONTAL]) != 0;
return true;
}
return false;
@ -103,18 +129,28 @@ public class Spacing {
* @param spacingType one of {@link #LEFT}, {@link #TOP}, {@link #RIGHT}, {@link #BOTTOM}
*/
public float get(int spacingType) {
int secondType = spacingType == TOP || spacingType == BOTTOM ? VERTICAL : HORIZONTAL;
float defaultValue = spacingType == START || spacingType == END ? CSSConstants.UNDEFINED : 0;
return
!CSSConstants.isUndefined(mSpacing[spacingType])
? mSpacing[spacingType]
: !CSSConstants.isUndefined(mSpacing[secondType])
? mSpacing[secondType]
: !CSSConstants.isUndefined(mSpacing[ALL])
? mSpacing[ALL]
: mDefaultSpacing != null
? mDefaultSpacing[spacingType]
: defaultValue;
float defaultValue = (mDefaultSpacing != null)
? mDefaultSpacing[spacingType]
: (spacingType == START || spacingType == END ? CSSConstants.UNDEFINED : 0);
if (mValueFlags == 0) {
return defaultValue;
}
if ((mValueFlags & sFlagsMap[spacingType]) != 0) {
return mSpacing[spacingType];
}
if (mHasAliasesSet) {
int secondType = spacingType == TOP || spacingType == BOTTOM ? VERTICAL : HORIZONTAL;
if ((mValueFlags & sFlagsMap[secondType]) != 0) {
return mSpacing[secondType];
} else if ((mValueFlags & sFlagsMap[ALL]) != 0) {
return mSpacing[ALL];
}
}
return defaultValue;
}
/**
@ -128,6 +164,18 @@ public class Spacing {
return mSpacing[spacingType];
}
/**
* Try to get start value and fallback to given type if not defined. This is used privately
* by the layout engine as a more efficient way to fetch direction-aware values by
* avoid extra method invocations.
*/
float getWithFallback(int spacingType, int fallbackType) {
return
(mValueFlags & sFlagsMap[spacingType]) != 0
? mSpacing[spacingType]
: get(fallbackType);
}
private static float[] newFullSpacingArray() {
return new float[] {
CSSConstants.UNDEFINED,

View File

@ -42,7 +42,6 @@ set -e # exit if any command fails
echo "Making github project..."
pushd $GITHUB
COMMIT_ID=$(git rev-parse HEAD)
make
popd
SRC=$GITHUB/src/java/src/com/facebook/csslayout

View File

@ -20,6 +20,8 @@ public interface ReadableArray {
boolean getBoolean(int index);
double getDouble(int index);
int getInt(int index);
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
int getColorInt(int index);
String getString(int index);
ReadableArray getArray(int index);
ReadableMap getMap(int index);

View File

@ -20,6 +20,8 @@ public interface ReadableMap {
boolean getBoolean(String name);
double getDouble(String name);
int getInt(String name);
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
int getColorInt(String name);
String getString(String name);
ReadableArray getArray(String name);
ReadableMap getMap(String name);

View File

@ -44,4 +44,10 @@ public class ReadableNativeArray extends NativeArray implements ReadableArray {
public int getInt(int index) {
return (int) getDouble(index);
}
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
@Override
public int getColorInt(int index) {
return (int) (long) getDouble(index);
}
}

View File

@ -51,6 +51,11 @@ public class ReadableNativeMap extends NativeMap implements ReadableMap {
return (int) getDouble(name);
}
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
@Override
public int getColorInt(String name) {
return (int) (long) getDouble(name);
}
/**
* Implementation of a {@link ReadableNativeMap} iterator in native memory.
*/

View File

@ -23,7 +23,6 @@ import com.facebook.react.bridge.ReadableMap;
*/
public class BaseViewPropertyApplicator {
private static final String PROP_BACKGROUND_COLOR = ViewProps.BACKGROUND_COLOR;
private static final String PROP_DECOMPOSED_MATRIX = "decomposedMatrix";
private static final String PROP_DECOMPOSED_MATRIX_ROTATE = "rotate";
private static final String PROP_DECOMPOSED_MATRIX_SCALE_X = "scaleX";
@ -55,7 +54,7 @@ public class BaseViewPropertyApplicator {
props.put(PROP_ACCESSIBILITY_LABEL, UIProp.Type.STRING);
props.put(PROP_ACCESSIBILITY_COMPONENT_TYPE, UIProp.Type.STRING);
props.put(PROP_ACCESSIBILITY_LIVE_REGION, UIProp.Type.STRING);
props.put(PROP_BACKGROUND_COLOR, UIProp.Type.STRING);
props.put(ViewProps.BACKGROUND_COLOR, UIProp.Type.STRING);
props.put(PROP_IMPORTANT_FOR_ACCESSIBILITY, UIProp.Type.STRING);
props.put(PROP_OPACITY, UIProp.Type.NUMBER);
props.put(PROP_ROTATION, UIProp.Type.NUMBER);
@ -73,13 +72,9 @@ public class BaseViewPropertyApplicator {
}
public static void applyCommonViewProperties(View view, CatalystStylesDiffMap props) {
if (props.hasKey(PROP_BACKGROUND_COLOR)) {
String backgroundString = props.getString(PROP_BACKGROUND_COLOR);
if (backgroundString == null) {
view.setBackgroundColor(Color.TRANSPARENT);
} else {
view.setBackgroundColor(CSSColorUtil.getColor(backgroundString));
}
if (props.hasKey(ViewProps.BACKGROUND_COLOR)) {
final int backgroundColor = props.getColorInt(ViewProps.BACKGROUND_COLOR, Color.TRANSPARENT);
view.setBackgroundColor(backgroundColor);
}
if (props.hasKey(PROP_DECOMPOSED_MATRIX)) {
ReadableMap decomposedMatrix = props.getMap(PROP_DECOMPOSED_MATRIX);

View File

@ -67,6 +67,17 @@ public class CatalystStylesDiffMap {
return mBackingMap.isNull(name) ? restoreNullToDefaultValue : (int) mBackingMap.getDouble(name);
}
// Colors have values between 0x00000000 and 0xFFFFFFFF, which fits in an integer, but is sent as
// a double over the bridge. Because color values can be higher than Integer.MAX_VALUE, it is not
// correct to convert doubles to int directly, since they can be truncated to Integer.MAX_VALUE
// instead of being converted to negative values. Converting from double to long maintains the
// initial value, and is then correctly converted to int. This is the expected behavior according
// to the java spec, see http://stackoverflow.com/questions/10641559 for more.
public int getColorInt(String name, int restoreNullToDefaultValue) {
return mBackingMap.isNull(name) ? restoreNullToDefaultValue :
(int) (long) mBackingMap.getDouble(name);
}
@Nullable
public String getString(String name) {
return mBackingMap.getString(name);

View File

@ -36,7 +36,8 @@ public @interface UIProp {
NUMBER("number"),
STRING("String"),
MAP("Map"),
ARRAY("Array");
ARRAY("Array"),
COLOR("Color");
private final String mType;

View File

@ -11,9 +11,10 @@ package com.facebook.react.views.image;
import javax.annotation.Nullable;
import android.graphics.Color;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
@ -76,11 +77,11 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
view.setBorderRadius(props.getFloat(PROP_BORDER_RADIUS, 0.0f));
}
if (props.hasKey(PROP_TINT_COLOR)) {
String tintColorString = props.getString(PROP_TINT_COLOR);
if (tintColorString == null) {
if (props.isNull(PROP_TINT_COLOR)) {
view.clearColorFilter();
} else {
view.setColorFilter(CSSColorUtil.getColor(tintColorString));
final int tintColor = props.getColorInt(PROP_TINT_COLOR, Color.TRANSPARENT);
view.setColorFilter(tintColor);
}
}
view.maybeUpdateView();

View File

@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.BoringLayout;
import android.text.Layout;
@ -31,7 +32,6 @@ import com.facebook.csslayout.CSSConstants;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.PixelUtil;
@ -307,21 +307,19 @@ public class ReactTextShadowNode extends ReactShadowNode {
markUpdated();
}
if (styles.hasKey(ViewProps.COLOR)) {
String colorString = styles.getString(ViewProps.COLOR);
if (colorString == null) {
if (styles.isNull(ViewProps.COLOR)) {
mIsColorSet = false;
} else {
mColor = CSSColorUtil.getColor(colorString);
mColor = styles.getColorInt(ViewProps.COLOR, Color.TRANSPARENT);
mIsColorSet = true;
}
markUpdated();
}
if (styles.hasKey(ViewProps.BACKGROUND_COLOR)) {
String colorString = styles.getString(ViewProps.BACKGROUND_COLOR);
if (colorString == null) {
if (styles.isNull(ViewProps.BACKGROUND_COLOR)) {
mIsBackgroundColorSet = false;
} else {
mBackgroundColor = CSSColorUtil.getColor(colorString);
mBackgroundColor = styles.getColorInt(ViewProps.BACKGROUND_COLOR, Color.TRANSPARENT);
mIsBackgroundColorSet = true;
}
markUpdated();

View File

@ -13,6 +13,7 @@ import javax.annotation.Nullable;
import java.util.Map;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.SystemClock;
import android.text.Editable;
@ -31,7 +32,6 @@ import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.BaseViewPropertyApplicator;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ThemedReactContext;
@ -53,6 +53,10 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
private static final int FOCUS_TEXT_INPUT = 1;
private static final int BLUR_TEXT_INPUT = 2;
@UIProp(UIProp.Type.STRING)
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.NUMBER)
public static final String PROP_FONT_SIZE = ViewProps.FONT_SIZE;
@UIProp(UIProp.Type.BOOLEAN)
@ -65,7 +69,7 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
public static final String PROP_TEXT_ALIGN_VERTICAL = "textAlignVertical";
@UIProp(UIProp.Type.STRING)
public static final String PROP_TEXT_INPUT_HINT = "placeholder";
@UIProp(UIProp.Type.STRING)
@UIProp(UIProp.Type.COLOR)
public static final String PROP_TEXT_INPUT_HINT_COLOR = "placeholderTextColor";
@UIProp(UIProp.Type.NUMBER)
public static final String PROP_TEXT_INPUT_NUMLINES = ViewProps.NUMBER_OF_LINES;
@ -77,8 +81,10 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
public static final String PROP_TEXT_INPUT_PASSWORD = "password";
@UIProp(UIProp.Type.BOOLEAN)
public static final String PROP_TEXT_INPUT_EDITABLE = "editable";
@UIProp(UIProp.Type.STRING)
@UIProp(UIProp.Type.COLOR)
public static final String PROP_TEXT_INPUT_UNDERLINE_COLOR = "underlineColorAndroid";
@UIProp(UIProp.Type.NUMBER)
public static final String PROP_TEST_ID = "testID";
private static final String KEYBOARD_TYPE_EMAIL_ADDRESS = "email-address";
private static final String KEYBOARD_TYPE_NUMERIC = "numeric";
@ -93,6 +99,7 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
ReactEditText editText = new ReactEditText(context);
int inputType = editText.getInputType();
editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
editText.setTextSize(
TypedValue.COMPLEX_UNIT_PX,
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)));
@ -185,12 +192,11 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
//Prevents flickering color while waiting for JS update.
if (props.hasKey(ViewProps.COLOR)) {
final String colorStr = props.getString(ViewProps.COLOR);
if (colorStr != null) {
final int color = CSSColorUtil.getColor(colorStr);
view.setTextColor(color);
} else {
if (props.isNull(ViewProps.COLOR)) {
view.setTextColor(DefaultStyleValuesUtil.getDefaultTextColor(view.getContext()));
} else {
final int textColor = props.getColorInt(ViewProps.COLOR, Color.TRANSPARENT);
view.setTextColor(textColor);
}
}
@ -199,25 +205,21 @@ public class ReactTextInputManager extends ViewManager<ReactEditText, ReactTextI
}
if (props.hasKey(PROP_TEXT_INPUT_HINT_COLOR)) {
final String colorStr = props.getString(PROP_TEXT_INPUT_HINT_COLOR);
if (colorStr != null) {
final int color = CSSColorUtil.getColor(colorStr);
view.setHintTextColor(color);
} else {
if (props.isNull(PROP_TEXT_INPUT_HINT_COLOR)) {
view.setHintTextColor(DefaultStyleValuesUtil.getDefaultTextColorHint(view.getContext()));
// We need to invalidate in order to force EditText to update hint color.
// see updateTextColors() method in TextView.java
view.invalidate();
} else {
final int hintColor = props.getColorInt(PROP_TEXT_INPUT_HINT_COLOR, Color.TRANSPARENT);
view.setHintTextColor(hintColor);
}
}
if (props.hasKey(PROP_TEXT_INPUT_UNDERLINE_COLOR)) {
String colorStr = props.getString(PROP_TEXT_INPUT_UNDERLINE_COLOR);
if (colorStr != null) {
int color = CSSColorUtil.getColor(colorStr);
view.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
} else {
if (props.isNull(PROP_TEXT_INPUT_UNDERLINE_COLOR)) {
view.getBackground().clearColorFilter();
} else {
final int underlineColor =
props.getColorInt(PROP_TEXT_INPUT_UNDERLINE_COLOR, Color.TRANSPARENT);
view.getBackground().setColorFilter(underlineColor, PorterDuff.Mode.SRC_IN);
}
}

View File

@ -32,7 +32,6 @@ import com.facebook.react.views.text.ReactTextShadowNode;
/* package */ class ReactTextInputShadowNode extends ReactTextShadowNode implements
CSSNode.MeasureFunction {
public static final String PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT = "mostRecentEventCount";
private static final int MEASURE_SPEC = View.MeasureSpec.makeMeasureSpec(
ViewGroup.LayoutParams.WRAP_CONTENT,
View.MeasureSpec.UNSPECIFIED);
@ -105,8 +104,9 @@ import com.facebook.react.views.text.ReactTextShadowNode;
mFontSize = (int) Math.ceil(PixelUtil.toPixelFromSP(fontSize));
}
if (styles.hasKey(PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT)) {
mJsEventCount = styles.getInt(PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT, 0);
if (styles.hasKey(ReactTextInputManager.PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT)) {
mJsEventCount =
styles.getInt(ReactTextInputManager.PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT, 0);
}
if (styles.hasKey(ReactTextInputManager.PROP_TEXT_INPUT_NUMLINES)) {

View File

@ -24,16 +24,13 @@ import android.view.View;
import com.facebook.react.R;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.UIProp;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.toolbar.events.ToolbarClickEvent;
import com.facebook.react.uimanager.ViewGroupManager;
/**
* Manages instances of Toolbar.
@ -48,11 +45,11 @@ public class ReactToolbarManager extends ViewGroupManager<Toolbar> {
public static final String PROP_NAV_ICON = "navIcon";
@UIProp(UIProp.Type.STRING)
public static final String PROP_SUBTITLE = "subtitle";
@UIProp(UIProp.Type.STRING)
@UIProp(UIProp.Type.COLOR)
public static final String PROP_SUBTITLE_COLOR = "subtitleColor";
@UIProp(UIProp.Type.STRING)
public static final String PROP_TITLE = "title";
@UIProp(UIProp.Type.STRING)
@UIProp(UIProp.Type.COLOR)
public static final String PROP_TITLE_COLOR = "titleColor";
@UIProp(UIProp.Type.ARRAY)
public static final String PROP_ACTIONS = "actions";
@ -81,23 +78,15 @@ public class ReactToolbarManager extends ViewGroupManager<Toolbar> {
toolbar.setSubtitle(props.getString(PROP_SUBTITLE));
}
if (props.hasKey(PROP_SUBTITLE_COLOR)) {
String color = props.getString(PROP_SUBTITLE_COLOR);
if (color != null) {
toolbar.setSubtitleTextColor(CSSColorUtil.getColor(color));
} else {
toolbar.setSubtitleTextColor(defaultColors[1]);
}
final int subtitleColor = props.getColorInt(PROP_SUBTITLE_COLOR, defaultColors[1]);
toolbar.setSubtitleTextColor(subtitleColor);
}
if (props.hasKey(PROP_TITLE)) {
toolbar.setTitle(props.getString(PROP_TITLE));
}
if (props.hasKey(PROP_TITLE_COLOR)) {
String color = props.getString(PROP_TITLE_COLOR);
if (color != null) {
toolbar.setTitleTextColor(CSSColorUtil.getColor(color));
} else {
toolbar.setTitleTextColor(defaultColors[0]);
}
final int titleColor = props.getColorInt(PROP_TITLE_COLOR, defaultColors[0]);
toolbar.setTitleTextColor(titleColor);
}
if (props.hasKey(PROP_NAV_ICON)) {
String navIcon = props.getString(PROP_NAV_ICON);

View File

@ -21,7 +21,7 @@ import android.util.TypedValue;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.SoftAssertions;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.ViewProps;
/**
* Utility class that helps with converting android drawable description used in JS to an actual
@ -60,11 +60,10 @@ import com.facebook.react.uimanager.CSSColorUtil;
throw new JSApplicationIllegalArgumentException("Ripple drawable is not available on " +
"android API <21");
}
String colorName = drawableDescriptionDict.hasKey("color") ?
drawableDescriptionDict.getString("color") : null;
int color;
if (colorName != null) {
color = CSSColorUtil.getColor(colorName);
if (drawableDescriptionDict.hasKey(ViewProps.COLOR) &&
!drawableDescriptionDict.isNull(ViewProps.COLOR)) {
color = drawableDescriptionDict.getColorInt(ViewProps.COLOR);
} else {
if (context.getTheme().resolveAttribute(
android.R.attr.colorControlHighlight,

View File

@ -238,7 +238,7 @@ import com.facebook.csslayout.Spacing;
*/
private int getFullBorderColor() {
return (mBorderColor != null && !CSSConstants.isUndefined(mBorderColor.getRaw(Spacing.ALL))) ?
(int) mBorderColor.getRaw(Spacing.ALL) : DEFAULT_BORDER_COLOR;
(int) (long) mBorderColor.getRaw(Spacing.ALL) : DEFAULT_BORDER_COLOR;
}
private void drawRectangularBackgroundWithBorders(Canvas canvas) {
@ -296,6 +296,7 @@ import com.facebook.csslayout.Spacing;
}
private int getBorderColor(int position) {
return mBorderColor != null ? (int) mBorderColor.get(position) : DEFAULT_BORDER_COLOR;
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
return mBorderColor != null ? (int) (long) mBorderColor.get(position) : DEFAULT_BORDER_COLOR;
}
}

View File

@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Map;
import android.graphics.Color;
import android.os.Build;
import android.view.View;
@ -23,8 +24,8 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.uimanager.BaseViewPropertyApplicator;
import com.facebook.react.uimanager.CSSColorUtil;
import com.facebook.react.uimanager.CatalystStylesDiffMap;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.PointerEvents;
@ -32,7 +33,6 @@ import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIProp;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.common.annotations.VisibleForTesting;
/**
* View manager for AndroidViews (plain React Views).
@ -103,9 +103,13 @@ public class ReactViewManager extends ViewGroupManager<ReactViewGroup> {
for (int i = 0; i < SPACING_TYPES.length; i++) {
String key = PROPS_BORDER_COLOR[i];
if (props.hasKey(key)) {
String color = props.getString(key);
float colorFloat = color == null ? CSSConstants.UNDEFINED : CSSColorUtil.getColor(color);
view.setBorderColor(SPACING_TYPES[i], colorFloat);
float color = CSSConstants.UNDEFINED;
if (!props.isNull(PROPS_BORDER_COLOR[i])) {
// Check CatalystStylesDiffMap#getColorInt() to see why this is needed
int colorInt = props.getColorInt(PROPS_BORDER_COLOR[i], Color.TRANSPARENT);
color = colorInt;
}
view.setBorderColor(SPACING_TYPES[i], color);
}
}

View File

@ -6,7 +6,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'de.undercouch:gradle-download-task:1.2'
// NOTE: Do not place your application dependencies here; they belong