mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Split NativeLinking into NativeIntentManager and NativeLinkingManager
Summary: The iOS and Android NativeModules are very different. It's better to split the two interfaces, than to have one merged interface. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D24324247 fbshipit-source-id: 097273829ffc719eff006ed2dde55f0dd6bd7d95
This commit is contained in:
committed by
Facebook GitHub Bot
parent
20e7a40b9c
commit
56c363e39a
+2
-8
@@ -20,14 +20,11 @@ import com.facebook.react.bridge.ReactModuleWithSpec;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
|
||||
public abstract class NativeLinkingSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
|
||||
public NativeLinkingSpec(ReactApplicationContext reactContext) {
|
||||
public abstract class NativeIntentAndroidSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
|
||||
public NativeIntentAndroidSpec(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public abstract void addListener(String eventName);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void canOpenURL(String url, Promise promise);
|
||||
|
||||
@@ -40,9 +37,6 @@ public abstract class NativeLinkingSpec extends ReactContextBaseJavaModule imple
|
||||
@ReactMethod
|
||||
public abstract void openURL(String url, Promise promise);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void removeListeners(double count);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void sendIntent(String action, ReadableArray extras, Promise promise);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
*
|
||||
* <p>Generated by an internal genrule from Flow types.
|
||||
*
|
||||
* @generated
|
||||
* @nolint
|
||||
*/
|
||||
|
||||
package com.facebook.fbreact.specs;
|
||||
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReactModuleWithSpec;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
|
||||
public abstract class NativeLinkingManagerSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
|
||||
public NativeLinkingManagerSpec(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public abstract void addListener(String eventName);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void canOpenURL(String url, Promise promise);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void getInitialURL(Promise promise);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void openSettings(Promise promise);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void openURL(String url, Promise promise);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void removeListeners(double count);
|
||||
}
|
||||
+61
-20
@@ -1469,6 +1469,54 @@ namespace facebook {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeIntentAndroidSpecJSI_getInitialURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "getInitialURL", "(Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeIntentAndroidSpecJSI_canOpenURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "canOpenURL", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeIntentAndroidSpecJSI_openURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "openURL", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeIntentAndroidSpecJSI_openSettings(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "openSettings", "(Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeIntentAndroidSpecJSI_sendIntent(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "sendIntent", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
|
||||
NativeIntentAndroidSpecJSI::NativeIntentAndroidSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
||||
: JavaTurboModule(params) {
|
||||
|
||||
methodMap_["getInitialURL"] = MethodMetadata {0, __hostFunction_NativeIntentAndroidSpecJSI_getInitialURL};
|
||||
|
||||
|
||||
methodMap_["canOpenURL"] = MethodMetadata {1, __hostFunction_NativeIntentAndroidSpecJSI_canOpenURL};
|
||||
|
||||
|
||||
methodMap_["openURL"] = MethodMetadata {1, __hostFunction_NativeIntentAndroidSpecJSI_openURL};
|
||||
|
||||
|
||||
methodMap_["openSettings"] = MethodMetadata {0, __hostFunction_NativeIntentAndroidSpecJSI_openSettings};
|
||||
|
||||
|
||||
methodMap_["sendIntent"] = MethodMetadata {2, __hostFunction_NativeIntentAndroidSpecJSI_sendIntent};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
@@ -1578,57 +1626,50 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_getInitialURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_getInitialURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "getInitialURL", "(Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_canOpenURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_canOpenURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "canOpenURL", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_openURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_openURL(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "openURL", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_openSettings(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_openSettings(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "openSettings", "(Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_sendIntent(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, PromiseKind, "sendIntent", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;Lcom/facebook/react/bridge/Promise;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_addListener(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "addListener", "(Ljava/lang/String;)V", args, count);
|
||||
}
|
||||
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
static facebook::jsi::Value __hostFunction_NativeLinkingManagerSpecJSI_removeListeners(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
||||
return static_cast<JavaTurboModule&>(turboModule).invokeJavaMethod(rt, VoidKind, "removeListeners", "(D)V", args, count);
|
||||
}
|
||||
|
||||
|
||||
NativeLinkingSpecJSI::NativeLinkingSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
||||
NativeLinkingManagerSpecJSI::NativeLinkingManagerSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
||||
: JavaTurboModule(params) {
|
||||
|
||||
methodMap_["getInitialURL"] = MethodMetadata {0, __hostFunction_NativeLinkingSpecJSI_getInitialURL};
|
||||
methodMap_["getInitialURL"] = MethodMetadata {0, __hostFunction_NativeLinkingManagerSpecJSI_getInitialURL};
|
||||
|
||||
|
||||
methodMap_["canOpenURL"] = MethodMetadata {1, __hostFunction_NativeLinkingSpecJSI_canOpenURL};
|
||||
methodMap_["canOpenURL"] = MethodMetadata {1, __hostFunction_NativeLinkingManagerSpecJSI_canOpenURL};
|
||||
|
||||
|
||||
methodMap_["openURL"] = MethodMetadata {1, __hostFunction_NativeLinkingSpecJSI_openURL};
|
||||
methodMap_["openURL"] = MethodMetadata {1, __hostFunction_NativeLinkingManagerSpecJSI_openURL};
|
||||
|
||||
|
||||
methodMap_["openSettings"] = MethodMetadata {0, __hostFunction_NativeLinkingSpecJSI_openSettings};
|
||||
methodMap_["openSettings"] = MethodMetadata {0, __hostFunction_NativeLinkingManagerSpecJSI_openSettings};
|
||||
|
||||
|
||||
methodMap_["sendIntent"] = MethodMetadata {2, __hostFunction_NativeLinkingSpecJSI_sendIntent};
|
||||
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeLinkingManagerSpecJSI_addListener};
|
||||
|
||||
|
||||
methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeLinkingSpecJSI_addListener};
|
||||
|
||||
|
||||
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeLinkingSpecJSI_removeListeners};
|
||||
methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeLinkingManagerSpecJSI_removeListeners};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -465,6 +465,20 @@ namespace facebook {
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
/**
|
||||
* C++ class for module 'IntentAndroid'
|
||||
*/
|
||||
|
||||
class JSI_EXPORT NativeIntentAndroidSpecJSI : public JavaTurboModule {
|
||||
public:
|
||||
NativeIntentAndroidSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
||||
|
||||
};
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
/**
|
||||
@@ -524,12 +538,12 @@ namespace facebook {
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
/**
|
||||
* C++ class for module 'Linking'
|
||||
* C++ class for module 'LinkingManager'
|
||||
*/
|
||||
|
||||
class JSI_EXPORT NativeLinkingSpecJSI : public JavaTurboModule {
|
||||
class JSI_EXPORT NativeLinkingManagerSpecJSI : public JavaTurboModule {
|
||||
public:
|
||||
NativeLinkingSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
||||
NativeLinkingManagerSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
||||
|
||||
};
|
||||
} // namespace react
|
||||
|
||||
@@ -15,7 +15,7 @@ import android.net.Uri;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.provider.Settings;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.fbreact.specs.NativeLinkingSpec;
|
||||
import com.facebook.fbreact.specs.NativeIntentAndroidSpec;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
@@ -26,7 +26,7 @@ import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
/** Intent module. Launch other activities or open URLs. */
|
||||
@ReactModule(name = IntentModule.NAME)
|
||||
public class IntentModule extends NativeLinkingSpec {
|
||||
public class IntentModule extends NativeIntentAndroidSpec {
|
||||
|
||||
public static final String NAME = "IntentAndroid";
|
||||
|
||||
@@ -237,14 +237,4 @@ public class IntentModule extends NativeLinkingSpec {
|
||||
|
||||
getReactApplicationContext().startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(String eventName) {
|
||||
// iOS only
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListeners(double count) {
|
||||
// iOS only
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user