Files
react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.java
T
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00

143 lines
4.8 KiB
Java

/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.uimanager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.events.TouchEventType;
import java.util.Map;
/**
* Constants exposed to JS from {@link UIManagerModule}.
*/
/* package */ class UIManagerModuleConstants {
public static final String ACTION_DISMISSED = "dismissed";
public static final String ACTION_ITEM_SELECTED = "itemSelected";
/* package */ static Map getBubblingEventTypeConstants() {
return MapBuilder.builder()
.put(
"topChange",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onChange", "captured", "onChangeCapture")))
.put(
"topSelect",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of("bubbled", "onSelect", "captured", "onSelectCapture")))
.put(
TouchEventType.START.getJSEventName(),
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onTouchStart",
"captured",
"onTouchStartCapture")))
.put(
TouchEventType.MOVE.getJSEventName(),
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onTouchMove",
"captured",
"onTouchMoveCapture")))
.put(
TouchEventType.END.getJSEventName(),
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onTouchEnd",
"captured",
"onTouchEndCapture")))
.put(
TouchEventType.CANCEL.getJSEventName(),
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled",
"onTouchCancel",
"captured",
"onTouchCancelCapture")))
.build();
}
/* package */ static Map getDirectEventTypeConstants() {
final String rn = "registrationName";
return MapBuilder.builder()
.put("topContentSizeChange", MapBuilder.of(rn, "onContentSizeChange"))
.put("topLayout", MapBuilder.of(rn, "onLayout"))
.put("topLoadingError", MapBuilder.of(rn, "onLoadingError"))
.put("topLoadingFinish", MapBuilder.of(rn, "onLoadingFinish"))
.put("topLoadingStart", MapBuilder.of(rn, "onLoadingStart"))
.put("topSelectionChange", MapBuilder.of(rn, "onSelectionChange"))
.put("topMessage", MapBuilder.of(rn, "onMessage"))
// Scroll events are added as per task T22348735.
// Subject for further improvement.
.put("topScrollBeginDrag", MapBuilder.of(rn, "onScrollBeginDrag"))
.put("topScrollEndDrag", MapBuilder.of(rn, "onScrollEndDrag"))
.put("topScroll", MapBuilder.of(rn, "onScroll"))
.put("topMomentumScrollBegin", MapBuilder.of(rn, "onMomentumScrollBegin"))
.put("topMomentumScrollEnd", MapBuilder.of(rn, "onMomentumScrollEnd"))
.build();
}
public static Map<String, Object> getConstants() {
Map<String, Object> constants = MapBuilder.newHashMap();
constants.put(
"UIView",
MapBuilder.of(
"ContentMode",
MapBuilder.of(
"ScaleAspectFit",
ImageView.ScaleType.FIT_CENTER.ordinal(),
"ScaleAspectFill",
ImageView.ScaleType.CENTER_CROP.ordinal(),
"ScaleAspectCenter",
ImageView.ScaleType.CENTER_INSIDE.ordinal())));
constants.put(
"StyleConstants",
MapBuilder.of(
"PointerEventsValues",
MapBuilder.of(
"none",
PointerEvents.NONE.ordinal(),
"boxNone",
PointerEvents.BOX_NONE.ordinal(),
"boxOnly",
PointerEvents.BOX_ONLY.ordinal(),
"unspecified",
PointerEvents.AUTO.ordinal())));
constants.put(
"PopupMenu",
MapBuilder.of(
ACTION_DISMISSED,
ACTION_DISMISSED,
ACTION_ITEM_SELECTED,
ACTION_ITEM_SELECTED));
constants.put(
"AccessibilityEventTypes",
MapBuilder.of(
"typeWindowStateChanged",
AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
"typeViewClicked",
AccessibilityEvent.TYPE_VIEW_CLICKED));
return constants;
}
}