Skip to content

Add My IP to showcase #5867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,11 @@ script:

npm test -- '\/(local|private|react-native)-cli\/'

elif [ "$TEST_TYPE" = build_website ]
then

cd website
$(which npm) install
./setup.sh
if [ "$TRAVIS_PULL_REQUEST" = false ] && [ "$TRAVIS_BRANCH" = master ]; then
# Automatically publish the website
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
./publish.sh
else
# Make sure the website builds without error
node server/generate.js
fi

elif [ "$TEST_TYPE" = e2e ]
then

./scripts/e2e-test.sh

else
echo "Unknown test type: $TEST_TYPE"
exit 1
Expand All @@ -71,11 +58,8 @@ env:
- TEST_TYPE=js
- TEST_TYPE=packager
- TEST_TYPE=cli
- TEST_TYPE=build_website
- TEST_TYPE=e2e
global:
# $GITHUB_TOKEN
- secure: "HlmG8M2DmBUSBh6KH1yVIe/8gR4iibg4WfcHq1x/xYQxGbvleq7NOo04V6eFHnl9cvZCu+PKH0841WLnGR7c4BBf47GVu/o16nXzggPumHKy++lDzxFPlJ1faMDfjg/5vjbAxRUe7D3y98hQSeGHH4tedc8LvTaFLVu7iiGqvjU="
# $APPETIZE_TOKEN
- secure: "egsvVSpszTzrNd6bN62DsVAzMiSZI/OHgdizfPryqvqWBf655ztE6XFQSEFNpuIAzSKDDF25ioT8iPfVsbC1iK6HDWHfmqYxML0L+OoU0gi+hV2oKUBFZDZ1fwSnFoWuBdNdMDpLlUxvJp6N1WyfNOB2dxuZUt8eTt48Hi3+Hpc="
# $S3_TOKEN
Expand Down
2 changes: 1 addition & 1 deletion Examples/TicTacToe/TicTacToeApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ var styles = StyleSheet.create({
textAlign: 'center',
},
newGame: {
backgroundColor: '#887766',
backgroundColor: '#887765',
padding: 20,
borderRadius: 5,
},
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ var event = function(
* interaction patterns, like drag-and-drop.
*
* You can see more example usage in `AnimationExample.js`, the Gratuitous
* Animation App, and [Animations documentation guide](http://facebook.github.io/react-native/docs/animations.html).
* Animation App, and [Animations documentation guide](docs/animations.html).
*
* Note that `Animated` is designed to be fully serializable so that animations
* can be run in a high performance way, independent of the normal JavaScript
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ var ScrollView = React.createClass({
* A RefreshControl component, used to provide pull-to-refresh
* functionality for the ScrollView.
*
* See [RefreshControl](http://facebook.github.io/react-native/docs/refreshcontrol.html).
* See [RefreshControl](docs/refreshcontrol.html).
*/
refreshControl: PropTypes.element,

Expand Down
2 changes: 1 addition & 1 deletion Libraries/PushNotificationIOS/PushNotificationIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var DEVICE_LOCAL_NOTIF_EVENT = 'localNotificationReceived';
* To get up and running, [configure your notifications with Apple](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW6)
* and your server-side system. To get an idea, [this is the Parse guide](https://parse.com/tutorials/ios-push-notifications).
*
* [Manually link](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking) the PushNotificationIOS library
* [Manually link](docs/linking-libraries-ios.html#manual-linking) the PushNotificationIOS library
*
* - Be sure to add the following to your `Header Search Paths`:
* `$(SRCROOT)/../node_modules/react-native/Libraries/PushNotificationIOS`
Expand Down
6 changes: 3 additions & 3 deletions Libraries/ReactIOS/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function warnForStyleProps(props, validAttributes) {
* composite components that aren't directly backed by a native view. This will
* generally include most components that you define in your own app. For more
* information, see [Direct
* Manipulation](/react-native/docs/direct-manipulation.html).
* Manipulation](docs/direct-manipulation.html).
*/
var NativeMethodsMixin = {
/**
Expand All @@ -74,7 +74,7 @@ var NativeMethodsMixin = {
* Note that these measurements are not available until after the rendering
* has been completed in native. If you need the measurements as soon as
* possible, consider using the [`onLayout`
* prop](/react-native/docs/view.html#onlayout) instead.
* prop](docs/view.html#onlayout) instead.
*/
measure: function(callback: MeasureOnSuccessCallback) {
UIManager.measure(
Expand Down Expand Up @@ -108,7 +108,7 @@ var NativeMethodsMixin = {
* This function sends props straight to native. They will not participate in
* future diff process - this means that if you do not include them in the
* next render, they will remain active (see [Direct
* Manipulation](/react-native/docs/direct-manipulation.html)).
* Manipulation](docs/direct-manipulation.html)).
*/
setNativeProps: function(nativeProps: Object) {
if (__DEV__) {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/AlertIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ButtonsArray = Array<{
class AlertIOS {
/**
* Creates a popup to alert the user. See
* [Alert](/react-native/docs/alert.html).
* [Alert](docs/alert.html).
*
* - title: string -- The dialog's title.
* - message: string -- An optional message that appears above the text input.
Expand Down
15 changes: 15 additions & 0 deletions Libraries/Utilities/Dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
'use strict';

var Platform = require('Platform');
var UIManager = require('UIManager');

var invariant = require('invariant');
Expand All @@ -31,7 +32,21 @@ if (dimensions && dimensions.windowPhysicalPixels) {
scale: windowPhysicalPixels.scale,
fontScale: windowPhysicalPixels.fontScale,
};
if (Platform.OS === 'android') {
// Screen and window dimensions are different on android
var screenPhysicalPixels = dimensions.screenPhysicalPixels;
dimensions.screen = {
width: screenPhysicalPixels.width / screenPhysicalPixels.scale,
height: screenPhysicalPixels.height / screenPhysicalPixels.scale,
scale: screenPhysicalPixels.scale,
fontScale: screenPhysicalPixels.fontScale,
};

// delete so no callers rely on this existing
delete dimensions.screenPhysicalPixels;
} else {
dimensions.screen = dimensions.window;
}
// delete so no callers rely on this existing
delete dimensions.windowPhysicalPixels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var currentCentroidY = TouchHistoryMath.currentCentroidY;
* recognize simple multi-touch gestures.
*
* It provides a predictable wrapper of the responder handlers provided by the
* [gesture responder system](/react-native/docs/gesture-responder-system.html).
* [gesture responder system](docs/gesture-responder-system.html).
* For each handler, it provides a new `gestureState` object alongside the
* native event object:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,20 @@ private static void initializeSoLoaderIfNecessary(Context applicationContext) {
}

private static void setDisplayMetrics(Context context) {
DisplayMetrics displayMetrics = new DisplayMetrics();
displayMetrics.setTo(context.getResources().getDisplayMetrics());
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);

DisplayMetrics screenDisplayMetrics = new DisplayMetrics();
screenDisplayMetrics.setTo(displayMetrics);
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

// Get the real display metrics if we are using API level 17 or higher.
// The real metrics include system decor elements (e.g. soft menu bar).
//
// See: http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
if (Build.VERSION.SDK_INT >= 17){
display.getRealMetrics(displayMetrics);

if (Build.VERSION.SDK_INT >= 17) {
display.getRealMetrics(screenDisplayMetrics);
} else {
// For 14 <= API level <= 16, we need to invoke getRawHeight and getRawWidth to get the real dimensions.
// Since react-native only supports API level 16+ we don't have to worry about other cases.
Expand All @@ -330,13 +332,13 @@ private static void setDisplayMetrics(Context context) {
try {
Method mGetRawH = Display.class.getMethod("getRawHeight");
Method mGetRawW = Display.class.getMethod("getRawWidth");
displayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
displayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
screenDisplayMetrics.widthPixels = (Integer) mGetRawW.invoke(display);
screenDisplayMetrics.heightPixels = (Integer) mGetRawH.invoke(display);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
throw new RuntimeException("Error getting real dimensions for API level < 17", e);
}
}
DisplayMetricsHolder.setDisplayMetrics(displayMetrics);
DisplayMetricsHolder.setScreenDisplayMetrics(screenDisplayMetrics);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private KeyboardListener getKeyboardListener() {
private class KeyboardListener implements ViewTreeObserver.OnGlobalLayoutListener {
private final Rect mVisibleViewArea;
private final int mMinKeyboardHeightDetected;

private int mKeyboardHeight = 0;

/* package */ KeyboardListener() {
Expand All @@ -410,7 +410,7 @@ public void onGlobalLayout() {

getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
final int heightDiff =
DisplayMetricsHolder.getDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
// keyboard is now showing, or the keyboard height has changed
mKeyboardHeight = heightDiff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.devsupport.DevSupportManager;
import com.facebook.react.common.ReactConstants;

Expand All @@ -32,16 +33,17 @@ public String getName() {
return "RKExceptionsManager";
}

private String stackTraceToString(ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder();
private String stackTraceToString(String message, ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
for (int i = 0; i < stack.size(); i++) {
ReadableMap frame = stack.getMap(i);
stringBuilder.append(frame.getString("methodName"));
stringBuilder.append("\n ");
stringBuilder.append(new File(frame.getString("file")).getName());
stringBuilder.append(":");
stringBuilder.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") && !frame.isNull("column")) {
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
Expand All @@ -58,14 +60,14 @@ public void reportFatalException(String title, ReadableArray details, int except

@ReactMethod
public void reportSoftException(String title, ReadableArray details, int exceptionId) {
FLog.e(ReactConstants.TAG, title + "\n" + stackTraceToString(details));
FLog.e(ReactConstants.TAG, stackTraceToString(title, details));
}

private void showOrThrowError(String title, ReadableArray details, int exceptionId) {
if (mDevSupportManager.getDevSupportEnabled()) {
mDevSupportManager.showNewJSError(title, details, exceptionId);
} else {
throw new JavascriptException(stackTraceToString(details));
throw new JavascriptException(stackTraceToString(title, details));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,39 @@
/**
* Holds an instance of the current DisplayMetrics so we don't have to thread it through all the
* classes that need it.
* Note: windowDisplayMetrics are deprecated in favor of ScreenDisplayMetrics: window metrics
* are supposed to return the drawable area but there's no guarantee that they correspond to the
* actual size of the {@link ReactRootView}. Moreover, they are not consistent with what iOS
* returns. Screen metrics returns the metrics of the entire screen, is consistent with iOS and
* should be used instead.
*/
public class DisplayMetricsHolder {

private static DisplayMetrics sCurrentDisplayMetrics;
private static DisplayMetrics sWindowDisplayMetrics;
private static DisplayMetrics sScreenDisplayMetrics;

public static void setDisplayMetrics(DisplayMetrics displayMetrics) {
sCurrentDisplayMetrics = displayMetrics;
/**
* @deprecated Use {@link #setScreenDisplayMetrics(DisplayMetrics)} instead. See comment above as
* to why this is not correct to use.
*/
public static void setWindowDisplayMetrics(DisplayMetrics displayMetrics) {
sWindowDisplayMetrics = displayMetrics;
}

public static DisplayMetrics getDisplayMetrics() {
return sCurrentDisplayMetrics;
/**
* @deprecated Use {@link #getScreenDisplayMetrics()} instead. See comment above as to why this
* is not correct to use.
*/
@Deprecated
public static DisplayMetrics getWindowDisplayMetrics() {
return sWindowDisplayMetrics;
}

public static void setScreenDisplayMetrics(DisplayMetrics screenDisplayMetrics) {
sScreenDisplayMetrics = screenDisplayMetrics;
}

public static DisplayMetrics getScreenDisplayMetrics() {
return sScreenDisplayMetrics;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static float toPixelFromDIP(float value) {
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
value,
DisplayMetricsHolder.getDisplayMetrics());
DisplayMetricsHolder.getWindowDisplayMetrics());
}

/**
Expand All @@ -40,7 +40,7 @@ public static float toPixelFromSP(float value) {
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP,
value,
DisplayMetricsHolder.getDisplayMetrics());
DisplayMetricsHolder.getWindowDisplayMetrics());
}

/**
Expand All @@ -54,7 +54,7 @@ public static float toPixelFromSP(double value) {
* Convert from PX to DP
*/
public static float toDIPFromPixel(float value) {
return value / DisplayMetricsHolder.getDisplayMetrics().density;
return value / DisplayMetricsHolder.getWindowDisplayMetrics().density;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static Map<String, Object> getConstants() {
"ScaleAspectFill",
ImageView.ScaleType.CENTER_CROP.ordinal())));

DisplayMetrics displayMetrics = DisplayMetricsHolder.getDisplayMetrics();
DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();
constants.put(
"Dimensions",
MapBuilder.of(
Expand All @@ -106,7 +107,19 @@ public static Map<String, Object> getConstants() {
"fontScale",
displayMetrics.scaledDensity,
"densityDpi",
displayMetrics.densityDpi)));
displayMetrics.densityDpi),
"screenPhysicalPixels",
MapBuilder.of(
"width",
screenDisplayMetrics.widthPixels,
"height",
screenDisplayMetrics.heightPixels,
"scale",
screenDisplayMetrics.density,
"fontScale",
screenDisplayMetrics.scaledDensity,
"densityDpi",
screenDisplayMetrics.densityDpi)));

constants.put(
"StyleConstants",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ReactShadowNode;
Expand All @@ -39,7 +38,7 @@ public abstract class ARTVirtualNode extends ReactShadowNode {
protected final float mScale;

public ARTVirtualNode() {
mScale = DisplayMetricsHolder.getDisplayMetrics().density;
mScale = DisplayMetricsHolder.getWindowDisplayMetrics().density;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
mReactContext = new ReactApplicationContext(RuntimeEnvironment.application);
mReactContext.initializeWithInstance(mCatalystInstanceMock);
DisplayMetrics displayMetrics = mReactContext.getResources().getDisplayMetrics();
DisplayMetricsHolder.setDisplayMetrics(displayMetrics);
DisplayMetricsHolder.setWindowDisplayMetrics(displayMetrics);

UIManagerModule uiManagerModuleMock = mock(UIManagerModule.class);
when(mCatalystInstanceMock.getNativeModule(UIManagerModule.class))
Expand Down
Loading