mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Kotlinify modules/core interfaces (#45787)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45787 # Changelog: [Internal] - As in the title. Reviewed By: cortinico Differential Revision: D60377675 fbshipit-source-id: 80670c6a996ea3bbc4adce9733be0e0f81223514
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3c6ea7e7ce
commit
4d647be848
+4
-6
@@ -5,19 +5,17 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.core;
|
||||
|
||||
package com.facebook.react.modules.core
|
||||
/**
|
||||
* Interface used by {@link DeviceEventManagerModule} to delegate hardware back button events. It's
|
||||
* Interface used by [DeviceEventManagerModule] to delegate hardware back button events. It's
|
||||
* suppose to provide a default behavior since it would be triggered in the case when JS side
|
||||
* doesn't want to handle back press events.
|
||||
*/
|
||||
public interface DefaultHardwareBackBtnHandler {
|
||||
|
||||
public fun interface DefaultHardwareBackBtnHandler {
|
||||
/**
|
||||
* By default, all onBackPress() calls should not execute the default backpress handler and should
|
||||
* instead propagate it to the JS instance. If JS doesn't want to handle the back press itself, it
|
||||
* shall call back into native to invoke this function which should execute the default handler
|
||||
*/
|
||||
void invokeDefaultOnBackPressed();
|
||||
public fun invokeDefaultOnBackPressed()
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
|
||||
@DoNotStrip
|
||||
public interface JSTimers extends JavaScriptModule {
|
||||
void callTimers(WritableArray timerIDs);
|
||||
|
||||
void callIdleCallbacks(double frameTime);
|
||||
|
||||
void emitTimeDriftWarning(String warningMessage);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.JavaScriptModule
|
||||
import com.facebook.react.bridge.WritableArray
|
||||
|
||||
@DoNotStrip
|
||||
public interface JSTimers : JavaScriptModule {
|
||||
public fun callTimers(timerIDs: WritableArray)
|
||||
|
||||
public fun callIdleCallbacks(frameTime: Double)
|
||||
|
||||
public fun emitTimeDriftWarning(warningMessage: String)
|
||||
}
|
||||
+7
-8
@@ -5,33 +5,32 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.core;
|
||||
package com.facebook.react.modules.core
|
||||
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableArray
|
||||
|
||||
/** An interface used by {@link JavaTimerManager} to access and call JS timers from Java. */
|
||||
/** An interface used by [JavaTimerManager] to access and call JS timers from Java. */
|
||||
public interface JavaScriptTimerExecutor {
|
||||
|
||||
/**
|
||||
* Calls the JS callback(s) associated with the timer ID(s). Also unregisters the callback if the
|
||||
* timer isn't recurring (e.g. unregisters for setTimeout, doesn't for setInterval).
|
||||
*
|
||||
* @param timerIDs An array of timer handles to call. Accepts an array as an optimization, to
|
||||
* avoid unnecessary JNI calls.
|
||||
* avoid unnecessary JNI calls.
|
||||
*/
|
||||
void callTimers(WritableArray timerIDs);
|
||||
public fun callTimers(timerIDs: WritableArray)
|
||||
|
||||
/**
|
||||
* Invoke the JS callback registered with `requestIdleCallback`.
|
||||
*
|
||||
* @param frameTime The amount of time left in the frame, in ms.
|
||||
*/
|
||||
void callIdleCallbacks(double frameTime);
|
||||
public fun callIdleCallbacks(frameTime: Double)
|
||||
|
||||
/**
|
||||
* Shows a warning message in development when environment times are out of sync.
|
||||
*
|
||||
* @param warningMessage The message to show
|
||||
*/
|
||||
void emitTimeDriftWarning(String warningMessage);
|
||||
public fun emitTimeDriftWarning(warningMessage: String)
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
/**
|
||||
* Interface used to denote activities that can forward permission requests and call {@link
|
||||
* PermissionListener}s with the permission request results.
|
||||
*/
|
||||
public interface PermissionAwareActivity {
|
||||
|
||||
/** See {@link Activity#checkPermission}. */
|
||||
int checkPermission(String permission, int pid, int uid);
|
||||
|
||||
/** See {@link Activity#checkSelfPermission}. */
|
||||
int checkSelfPermission(String permission);
|
||||
|
||||
/** See {@link Activity#shouldShowRequestPermissionRationale}. */
|
||||
boolean shouldShowRequestPermissionRationale(String permission);
|
||||
|
||||
/** See {@link Activity#requestPermissions}. */
|
||||
void requestPermissions(String[] permissions, int requestCode, PermissionListener listener);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core
|
||||
|
||||
/**
|
||||
* Interface used to denote activities that can forward permission requests and call
|
||||
* [PermissionListener] with the permission request results.
|
||||
*/
|
||||
public interface PermissionAwareActivity {
|
||||
/** See [Activity.checkPermission]. */
|
||||
public fun checkPermission(permission: String, pid: Int, uid: Int): Int
|
||||
|
||||
/** See [Activity.checkSelfPermission]. */
|
||||
public fun checkSelfPermission(permission: String): Int
|
||||
|
||||
/** See [Activity.shouldShowRequestPermissionRationale]. */
|
||||
public fun shouldShowRequestPermissionRationale(permission: String): Boolean
|
||||
|
||||
/** See [Activity.requestPermissions]. */
|
||||
public fun requestPermissions(
|
||||
permissions: Array<String>,
|
||||
requestCode: Int,
|
||||
listener: PermissionListener?
|
||||
)
|
||||
}
|
||||
+9
-9
@@ -5,21 +5,21 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.modules.core;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
package com.facebook.react.modules.core
|
||||
/**
|
||||
* Interface used by activities to delegate permission request results. Classes implementing this
|
||||
* class will be notified whenever there's a result for a permission request.
|
||||
*/
|
||||
public interface PermissionListener {
|
||||
|
||||
public fun interface PermissionListener {
|
||||
/**
|
||||
* Method called whenever there's a result to a permission request. It is forwarded from {@link
|
||||
* Activity#onRequestPermissionsResult}.
|
||||
* Method called whenever there's a result to a permission request. It is forwarded from
|
||||
* [Activity.onRequestPermissionsResult].
|
||||
*
|
||||
* @return boolean Whether the PermissionListener can be removed.
|
||||
*/
|
||||
boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults);
|
||||
public fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
): Boolean
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
|
||||
/** Module that handles global application events. */
|
||||
@DoNotStrip
|
||||
public interface RCTNativeAppEventEmitter extends JavaScriptModule {
|
||||
void emit(String eventName, @Nullable Object data);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* 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.modules.core
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.JavaScriptModule
|
||||
|
||||
/** Module that handles global application events. */
|
||||
@DoNotStrip
|
||||
public fun interface RCTNativeAppEventEmitter : JavaScriptModule {
|
||||
public fun emit(eventName: String, data: Any?)
|
||||
}
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class PermissionsModule(reactContext: ReactApplicationContext?) :
|
||||
* [permissionAwareActivity.shouldShowRequestPermissionRationale].
|
||||
*/
|
||||
override public fun shouldShowRequestPermissionRationale(
|
||||
permission: String?,
|
||||
permission: String,
|
||||
promise: Promise
|
||||
): Unit {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user