Skip to content

Commit

Permalink
Kotlinify modules/core interfaces (facebook#45787)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#45787

# Changelog:
[Internal] -

As in the title.

Reviewed By: cortinico

Differential Revision: D60377675
  • Loading branch information
rshest authored and facebook-github-bot committed Jul 30, 2024
1 parent 1c1c833 commit ef53e10
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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?
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class PermissionsModule(reactContext: ReactApplicationContext?) :
* [permissionAwareActivity.shouldShowRequestPermissionRationale].
*/
override public fun shouldShowRequestPermissionRationale(
permission: String?,
permission: String,
promise: Promise
): Unit {
try {
Expand Down

0 comments on commit ef53e10

Please sign in to comment.