diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java index 3ae572a631f..0db92f806a1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java @@ -9,15 +9,10 @@ package com.facebook.react.bridge; import android.app.Activity; import androidx.annotation.Nullable; -import com.facebook.react.common.annotations.DeprecatedInNewArchitecture; /** * Base class for Catalyst native modules that require access to the {@link ReactContext} instance. */ -@DeprecatedInNewArchitecture( - message = - "ReactContextBaseJavaModule will be deprecated in new Architecture of React Native, use" - + " BaseJavaModule instead") public abstract class ReactContextBaseJavaModule extends BaseJavaModule { public ReactContextBaseJavaModule() { @@ -37,9 +32,10 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule { *
For example, never store the value returned by this method in a member variable. Instead,
* call this method whenever you actually need the Activity and make sure to check for {@code
* null}.
+ *
+ * @deprecated "Use 'getReactApplicationContext.getCurrentActivity() instead."
*/
- @DeprecatedInNewArchitecture(
- message = "Use 'getReactApplicationContext.getCurrentActivity() instead.")
+ @Deprecated(forRemoval = true, since = "0.80.0")
protected @Nullable final Activity getCurrentActivity() {
return getReactApplicationContext().getCurrentActivity();
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt
index b5fdfa79071..94b73cf482f 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt
@@ -54,8 +54,8 @@ constructor(
// Attempt to use the Activity context first in order to get the most up to date
// scheme. This covers the scenario when AppCompatDelegate.setDefaultNightMode()
// is called directly (which can occur in Brownfield apps for example).
- val activity = getCurrentActivity()
- return colorSchemeForCurrentConfiguration(activity ?: getReactApplicationContext())
+ val activity = reactApplicationContext.getCurrentActivity()
+ return colorSchemeForCurrentConfiguration(activity ?: reactApplicationContext)
}
public override fun setColorScheme(style: String) {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java
index f08db0be348..36f18732aaa 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/dialog/DialogModule.java
@@ -230,7 +230,7 @@ public class DialogModule extends NativeDialogManagerAndroidSpec implements Life
* MEMORY LEAKS.
*/
private @Nullable FragmentManagerHelper getFragmentManagerHelper() {
- Activity activity = getCurrentActivity();
+ Activity activity = getReactApplicationContext().getCurrentActivity();
if (activity == null || !(activity instanceof FragmentActivity)) {
return null;
}
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.kt
index 8785bce7880..a0c75cdaa70 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.kt
@@ -47,7 +47,7 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
*/
override fun getInitialURL(promise: Promise) {
try {
- val currentActivity = getCurrentActivity()
+ val currentActivity = getReactApplicationContext().getCurrentActivity()
if (currentActivity == null) {
waitForActivityAndGetInitialURL(promise)
return
@@ -159,7 +159,8 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
override fun openSettings(promise: Promise) {
try {
val intent = Intent()
- val currentActivity: Activity = checkNotNull(getCurrentActivity())
+ val currentActivity: Activity =
+ checkNotNull(getReactApplicationContext().getCurrentActivity())
val selfPackageName = getReactApplicationContext().getPackageName()
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
@@ -243,7 +244,7 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
}
private fun sendOSIntent(intent: Intent, useNewTaskFlag: Boolean) {
- val currentActivity = getCurrentActivity()
+ val currentActivity = getReactApplicationContext().getCurrentActivity()
val selfPackageName = getReactApplicationContext().getPackageName()
val packageManager = getReactApplicationContext().getPackageManager()
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.kt
index bbc018ecdb5..549ae15ad53 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/permissions/PermissionsModule.kt
@@ -175,7 +175,7 @@ public class PermissionsModule(reactContext: ReactApplicationContext?) :
private val permissionAwareActivity: PermissionAwareActivity
get() {
- val activity = getCurrentActivity()
+ val activity = reactApplicationContext.getCurrentActivity()
checkNotNull(activity) { "Tried to use permissions API while not attached to an Activity." }
check(activity is PermissionAwareActivity) {
("Tried to use permissions API but the host Activity doesn't implement PermissionAwareActivity.")
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.kt
index ec8db8a97e9..033ff49cd14 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/share/ShareModule.kt
@@ -44,7 +44,7 @@ public class ShareModule(reactContext: ReactApplicationContext) :
}
val chooser = Intent.createChooser(intent, dialogTitle)
chooser.addCategory(Intent.CATEGORY_DEFAULT)
- val currentActivity = getCurrentActivity()
+ val currentActivity = reactApplicationContext.getCurrentActivity()
if (currentActivity != null) {
currentActivity.startActivity(chooser)
} else {
diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt
index c5547ca8d3a..f85c8cc3454 100644
--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt
@@ -35,7 +35,7 @@ public class StatusBarModule(reactContext: ReactApplicationContext?) :
@Suppress("DEPRECATION")
override fun getTypedExportedConstants(): Map