Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceEventManagerModule.java->.kt #45813

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3128,7 +3128,7 @@ public abstract interface class com/facebook/react/modules/common/ModuleDataClea
public abstract fun clearSensitiveData ()V
}

public class com/facebook/react/modules/core/ChoreographerCompat {
public final class com/facebook/react/modules/core/ChoreographerCompat {
public fun <init> ()V
}

Expand All @@ -3140,13 +3140,18 @@ public abstract interface class com/facebook/react/modules/core/DefaultHardwareB
public abstract fun invokeDefaultOnBackPressed ()V
}

public class com/facebook/react/modules/core/DeviceEventManagerModule : com/facebook/fbreact/specs/NativeDeviceEventManagerSpec {
public final class com/facebook/react/modules/core/DeviceEventManagerModule : com/facebook/fbreact/specs/NativeDeviceEventManagerSpec {
public static final field Companion Lcom/facebook/react/modules/core/DeviceEventManagerModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/modules/core/DefaultHardwareBackBtnHandler;)V
public fun emitHardwareBackPressed ()V
public fun emitNewIntentReceived (Landroid/net/Uri;)V
public final fun emitHardwareBackPressed ()V
public final fun emitNewIntentReceived (Landroid/net/Uri;)V
public fun invokeDefaultBackPressHandler ()V
}

public final class com/facebook/react/modules/core/DeviceEventManagerModule$Companion {
}

public abstract interface class com/facebook/react/modules/core/DeviceEventManagerModule$RCTDeviceEventEmitter : com/facebook/react/bridge/JavaScriptModule {
public abstract fun emit (Ljava/lang/String;Ljava/lang/Object;)V
}
Expand Down Expand Up @@ -3208,10 +3213,12 @@ public abstract interface class com/facebook/react/modules/core/RCTNativeAppEven
}

public final class com/facebook/react/modules/core/ReactChoreographer {
public static fun getInstance ()Lcom/facebook/react/modules/core/ReactChoreographer;
public static fun initialize (Lcom/facebook/react/internal/ChoreographerProvider;)V
public fun postFrameCallback (Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;Landroid/view/Choreographer$FrameCallback;)V
public fun removeFrameCallback (Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;Landroid/view/Choreographer$FrameCallback;)V
public static final field Companion Lcom/facebook/react/modules/core/ReactChoreographer$Companion;
public synthetic fun <init> (Lcom/facebook/react/internal/ChoreographerProvider;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public static final fun getInstance ()Lcom/facebook/react/modules/core/ReactChoreographer;
public static final fun initialize (Lcom/facebook/react/internal/ChoreographerProvider;)V
public final fun postFrameCallback (Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;Landroid/view/Choreographer$FrameCallback;)V
public final fun removeFrameCallback (Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;Landroid/view/Choreographer$FrameCallback;)V
}

public final class com/facebook/react/modules/core/ReactChoreographer$CallbackType : java/lang/Enum {
Expand All @@ -3220,10 +3227,16 @@ public final class com/facebook/react/modules/core/ReactChoreographer$CallbackTy
public static final field NATIVE_ANIMATED_MODULE Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;
public static final field PERF_MARKERS Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;
public static final field TIMERS_EVENTS Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;
public static fun values ()[Lcom/facebook/react/modules/core/ReactChoreographer$CallbackType;
}

public final class com/facebook/react/modules/core/ReactChoreographer$Companion {
public final fun getInstance ()Lcom/facebook/react/modules/core/ReactChoreographer;
public final fun initialize (Lcom/facebook/react/internal/ChoreographerProvider;)V
}

public final class com/facebook/react/modules/core/TimingModule : com/facebook/fbreact/specs/NativeTimingSpec, com/facebook/react/modules/core/JavaScriptTimerExecutor {
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/devsupport/interfaces/DevSupportManager;)V
public fun callIdleCallbacks (D)V
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.view.Choreographer

public class ChoreographerCompat {

@Deprecated("Use Choreographer.FrameCallback instead")
public abstract class FrameCallback : Choreographer.FrameCallback
}
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,64 @@
/*
* 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.net.Uri
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.JavaScriptModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.module.annotations.ReactModule

/** Native module that handles device hardware events like hardware back presses. */
@ReactModule(name = com.facebook.fbreact.specs.NativeDeviceEventManagerSpec.NAME)
public class DeviceEventManagerModule(
reactContext: ReactApplicationContext?,
backBtnHandler: DefaultHardwareBackBtnHandler
) : com.facebook.fbreact.specs.NativeDeviceEventManagerSpec(reactContext) {
@DoNotStrip
public fun interface RCTDeviceEventEmitter : JavaScriptModule {
public fun emit(eventName: String, data: Any?)
}

private val invokeDefaultBackPressRunnable: Runnable = Runnable {
UiThreadUtil.assertOnUiThread()
backBtnHandler.invokeDefaultOnBackPressed()
}

/** Sends an event to the JS instance that the hardware back has been pressed. */
public fun emitHardwareBackPressed() {
val reactApplicationContext: ReactApplicationContext? =
getReactApplicationContextIfActiveOrWarn()
reactApplicationContext?.emitDeviceEvent("hardwareBackPress", null)
}

/** Sends an event to the JS instance that a new intent was received. */
public fun emitNewIntentReceived(uri: Uri) {
val reactApplicationContext: ReactApplicationContext? =
getReactApplicationContextIfActiveOrWarn()
val map = Arguments.createMap()
map.putString("url", uri.toString())
reactApplicationContext?.emitDeviceEvent("url", map)
}

/**
* Invokes the default back handler for the host of this catalyst instance. This should be invoked
* if JS does not want to handle the back press itself.
*/
override fun invokeDefaultBackPressHandler() {
// There should be no need to check if the catalyst instance is alive. After initialization
// the thread instances cannot be null, and scheduling on a thread after ReactApplicationContext
// teardown is a noop.
getReactApplicationContext().runOnUiQueueThread(invokeDefaultBackPressRunnable)
}

public companion object {
public const val NAME: String = com.facebook.fbreact.specs.NativeDeviceEventManagerSpec.NAME
}
}

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.

Loading
Loading