1 package abi47_0_0.com.facebook.react.uimanager;
2 
3 import androidx.annotation.Nullable;
4 import abi47_0_0.com.facebook.react.bridge.Callback;
5 import abi47_0_0.com.facebook.react.bridge.Dynamic;
6 import abi47_0_0.com.facebook.react.bridge.ReactApplicationContext;
7 import abi47_0_0.com.facebook.react.bridge.ReactMethod;
8 import abi47_0_0.com.facebook.react.bridge.ReadableArray;
9 import abi47_0_0.com.facebook.react.bridge.ReadableMap;
10 import abi47_0_0.com.facebook.react.bridge.WritableMap;
11 import abi47_0_0.com.facebook.react.module.annotations.ReactModule;
12 import abi47_0_0.com.facebook.react.uimanager.events.EventDispatcher;
13 import java.util.List;
14 
15 class ReaUiImplementationProvider extends UIImplementationProvider {
16 
17   @Override
createUIImplementation( ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs)18   UIImplementation createUIImplementation(
19       ReactApplicationContext reactContext,
20       ViewManagerRegistry viewManagerRegistry,
21       EventDispatcher eventDispatcher,
22       int minTimeLeftInFrameForNonBatchedOperationMs) {
23     return new ReanimatedUIImplementation(
24         reactContext,
25         viewManagerRegistry,
26         eventDispatcher,
27         minTimeLeftInFrameForNonBatchedOperationMs);
28   }
29 }
30 
31 @ReactModule(name = UIManagerModule.NAME)
32 public class ReanimatedUIManager extends UIManagerModule {
33 
ReanimatedUIManager( ReactApplicationContext reactContext, List<ViewManager> viewManagersList, int minTimeLeftInFrameForNonBatchedOperationMs)34   public ReanimatedUIManager(
35       ReactApplicationContext reactContext,
36       List<ViewManager> viewManagersList,
37       int minTimeLeftInFrameForNonBatchedOperationMs) {
38     super(
39         reactContext,
40         viewManagersList,
41         new ReaUiImplementationProvider(),
42         minTimeLeftInFrameForNonBatchedOperationMs);
43   }
44 
onBatchComplete()45   public void onBatchComplete() {
46     super.onBatchComplete();
47   }
48 
49   @Override
canOverrideExistingModule()50   public boolean canOverrideExistingModule() {
51     return true;
52   }
53 
54   @ReactMethod(isBlockingSynchronousMethod = true)
getConstantsForViewManager(@ullable String viewManagerName)55   public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) {
56     return super.getConstantsForViewManager(viewManagerName);
57   }
58 
59   @ReactMethod(isBlockingSynchronousMethod = true)
getDefaultEventTypes()60   public WritableMap getDefaultEventTypes() {
61     return super.getDefaultEventTypes();
62   }
63 
64   /** Unregisters a new root view. */
65   @ReactMethod
removeRootView(int rootViewTag)66   public void removeRootView(int rootViewTag) {
67     super.removeRootView(rootViewTag);
68   }
69 
70   @ReactMethod
createView(int tag, String className, int rootViewTag, ReadableMap props)71   public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
72     super.createView(tag, className, rootViewTag, props);
73   }
74 
75   @ReactMethod
updateView(final int tag, final String className, final ReadableMap props)76   public void updateView(final int tag, final String className, final ReadableMap props) {
77     super.updateView(tag, className, props);
78   }
79 
80   /**
81    * Interface for adding/removing/moving views within a parent view from JS.
82    *
83    * @param viewTag the view tag of the parent view
84    * @param moveFrom a list of indices in the parent view to move views from
85    * @param moveTo parallel to moveFrom, a list of indices in the parent view to move views to
86    * @param addChildTags a list of tags of views to add to the parent
87    * @param addAtIndices parallel to addChildTags, a list of indices to insert those children at
88    * @param removeFrom a list of indices of views to permanently remove. The memory for the
89    *     corresponding views and data structures should be reclaimed.
90    */
91   @ReactMethod
manageChildren( int viewTag, @Nullable ReadableArray moveFrom, @Nullable ReadableArray moveTo, @Nullable ReadableArray addChildTags, @Nullable ReadableArray addAtIndices, @Nullable ReadableArray removeFrom)92   public void manageChildren(
93       int viewTag,
94       @Nullable ReadableArray moveFrom,
95       @Nullable ReadableArray moveTo,
96       @Nullable ReadableArray addChildTags,
97       @Nullable ReadableArray addAtIndices,
98       @Nullable ReadableArray removeFrom) {
99     super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
100   }
101 
102   /**
103    * Interface for fast tracking the initial adding of views. Children view tags are assumed to be
104    * in order
105    *
106    * @param viewTag the view tag of the parent view
107    * @param childrenTags An array of tags to add to the parent in order
108    */
109   @ReactMethod
setChildren(int viewTag, ReadableArray childrenTags)110   public void setChildren(int viewTag, ReadableArray childrenTags) {
111     super.setChildren(viewTag, childrenTags);
112   }
113 
114   /**
115    * Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
116    * This resolves to a simple {@link #manageChildren} call, but React doesn't have enough info in
117    * JS to formulate it itself.
118    *
119    * @deprecated This method will not be available in Fabric UIManager class.
120    */
121   @ReactMethod
122   @Deprecated
replaceExistingNonRootView(int oldTag, int newTag)123   public void replaceExistingNonRootView(int oldTag, int newTag) {
124     super.replaceExistingNonRootView(oldTag, newTag);
125   }
126 
127   /**
128    * Method which takes a container tag and then releases all subviews for that container upon
129    * receipt.
130    *
131    * @param containerTag the tag of the container for which the subviews must be removed
132    * @deprecated This method will not be available in Fabric UIManager class.
133    */
134   @ReactMethod
135   @Deprecated
removeSubviewsFromContainerWithID(int containerTag)136   public void removeSubviewsFromContainerWithID(int containerTag) {
137     super.removeSubviewsFromContainerWithID(containerTag);
138   }
139 
140   /**
141    * Determines the location on screen, width, and height of the given view and returns the values
142    * via an async callback.
143    */
144   @ReactMethod
measure(int reactTag, Callback callback)145   public void measure(int reactTag, Callback callback) {
146     super.measure(reactTag, callback);
147   }
148 
149   /**
150    * Determines the location on screen, width, and height of the given view relative to the device
151    * screen and returns the values via an async callback. This is the absolute position including
152    * things like the status bar
153    */
154   @ReactMethod
measureInWindow(int reactTag, Callback callback)155   public void measureInWindow(int reactTag, Callback callback) {
156     super.measureInWindow(reactTag, callback);
157   }
158 
159   /**
160    * Measures the view specified by tag relative to the given ancestorTag. This means that the
161    * returned x, y are relative to the origin x, y of the ancestor view. Results are stored in the
162    * given outputBuffer. We allow ancestor view and measured view to be the same, in which case the
163    * position always will be (0, 0) and method will only measure the view dimensions.
164    *
165    * <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
166    * window which can cause unexpected results when measuring relative to things like ScrollViews
167    * that can have offset content on the screen.
168    */
169   @ReactMethod
measureLayout( int tag, int ancestorTag, Callback errorCallback, Callback successCallback)170   public void measureLayout(
171       int tag, int ancestorTag, Callback errorCallback, Callback successCallback) {
172     super.measureLayout(tag, ancestorTag, errorCallback, successCallback);
173   }
174 
175   /**
176    * Like {@link #measure} and {@link #measureLayout} but measures relative to the immediate parent.
177    *
178    * <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
179    * window which can cause unexpected results when measuring relative to things like ScrollViews
180    * that can have offset content on the screen.
181    *
182    * @deprecated this method will not be available in FabricUIManager class.
183    */
184   @ReactMethod
185   @Deprecated
measureLayoutRelativeToParent( int tag, Callback errorCallback, Callback successCallback)186   public void measureLayoutRelativeToParent(
187       int tag, Callback errorCallback, Callback successCallback) {
188     super.measureLayoutRelativeToParent(tag, errorCallback, successCallback);
189   }
190 
191   /**
192    * Find the touch target child native view in the supplied root view hierarchy, given a react
193    * target location.
194    *
195    * <p>This method is currently used only by Element Inspector DevTool.
196    *
197    * @param reactTag the tag of the root view to traverse
198    * @param point an array containing both X and Y target location
199    * @param callback will be called if with the identified child view react ID, and measurement
200    *     info. If no view was found, callback will be invoked with no data.
201    */
202   @ReactMethod
findSubviewIn( final int reactTag, final ReadableArray point, final Callback callback)203   public void findSubviewIn(
204       final int reactTag, final ReadableArray point, final Callback callback) {
205     super.findSubviewIn(reactTag, point, callback);
206   }
207 
208   /**
209    * Check if the first shadow node is the descendant of the second shadow node
210    *
211    * @deprecated this method will not be available in FabricUIManager class.
212    */
213   @ReactMethod
214   @Deprecated
viewIsDescendantOf( final int reactTag, final int ancestorReactTag, final Callback callback)215   public void viewIsDescendantOf(
216       final int reactTag, final int ancestorReactTag, final Callback callback) {
217     super.viewIsDescendantOf(reactTag, ancestorReactTag, callback);
218   }
219 
220   @ReactMethod
setJSResponder(int reactTag, boolean blockNativeResponder)221   public void setJSResponder(int reactTag, boolean blockNativeResponder) {
222     super.setJSResponder(reactTag, blockNativeResponder);
223   }
224 
225   @ReactMethod
clearJSResponder()226   public void clearJSResponder() {
227     super.clearJSResponder();
228   }
229 
230   @ReactMethod
dispatchViewManagerCommand( int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs)231   public void dispatchViewManagerCommand(
232       int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) {
233     super.dispatchViewManagerCommand(reactTag, commandId, commandArgs);
234   }
235 
236   /**
237    * Show a PopupMenu.
238    *
239    * @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
240    *     needs to be the tag of a native view (shadow views can not be anchors)
241    * @param items the menu items as an array of strings
242    * @param error will be called if there is an error displaying the menu
243    * @param success will be called with the position of the selected item as the first argument, or
244    *     no arguments if the menu is dismissed
245    */
246   @ReactMethod
showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success)247   public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
248     super.showPopupMenu(reactTag, items, error, success);
249   }
250 
251   @ReactMethod
dismissPopupMenu()252   public void dismissPopupMenu() {
253     super.dismissPopupMenu();
254   }
255 
256   /**
257    * LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled
258    * explicitly in order to avoid regression in existing application written for iOS using this API.
259    *
260    * <p>Warning : This method will be removed in future version of React Native, and layout
261    * animation will be enabled by default, so always check for its existence before invoking it.
262    *
263    * <p>TODO(9139831) : remove this method once layout animation is fully stable.
264    *
265    * @param enabled whether layout animation is enabled or not
266    */
267   @ReactMethod
setLayoutAnimationEnabledExperimental(boolean enabled)268   public void setLayoutAnimationEnabledExperimental(boolean enabled) {
269     super.setLayoutAnimationEnabledExperimental(enabled);
270   }
271 
272   /**
273    * Configure an animation to be used for the native layout changes, and native views creation. The
274    * animation will only apply during the current batch operations.
275    *
276    * <p>TODO(7728153) : animating view deletion is currently not supported.
277    *
278    * @param config the configuration of the animation for view addition/removal/update.
279    * @param success will be called when the animation completes, or when the animation get
280    *     interrupted. In this case, callback parameter will be false.
281    * @param error will be called if there was an error processing the animation
282    */
283   @ReactMethod
configureNextLayoutAnimation(ReadableMap config, Callback success, Callback error)284   public void configureNextLayoutAnimation(ReadableMap config, Callback success, Callback error) {
285     super.configureNextLayoutAnimation(config, success, error);
286   }
287 
288   @ReactMethod
sendAccessibilityEvent(int tag, int eventType)289   public void sendAccessibilityEvent(int tag, int eventType) {
290     super.sendAccessibilityEvent(tag, eventType);
291   }
292 }
293