mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Migrate ReactApplicationContext to Kotlin (#52208)
Summary: Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/52208 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D77209812 Pulled By: cortinico fbshipit-source-id: 2dae094d363e60efe05b4f2b3d55f0f84d921495
This commit is contained in:
1 parent
252e1345bf
commit
d3495fd162
3 files changed
+22
-27
No files matched your search
-25
@@ -1,25 +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.bridge;
|
||||
|
||||
import android.content.Context;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
|
||||
/**
|
||||
* A context wrapper that always wraps Android Application {@link Context} and {@link
|
||||
* CatalystInstance} by extending {@link ReactContext}
|
||||
*/
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public abstract class ReactApplicationContext extends ReactContext {
|
||||
// We want to wrap ApplicationContext, since there is no easy way to verify that application
|
||||
// context is passed as a param, we use {@link Context#getApplicationContext} to ensure that
|
||||
// the context we're wrapping is in fact an application context.
|
||||
public ReactApplicationContext(Context context) {
|
||||
super(context.getApplicationContext());
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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.bridge
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* A context wrapper that always wraps Android Application [Context] and [CatalystInstance] by
|
||||
* extending [ReactContext].
|
||||
*/
|
||||
public abstract class ReactApplicationContext(context: Context) :
|
||||
// We want to wrap ApplicationContext, since there is no easy way to verify that application
|
||||
// context is passed as a param, we use [Context.getApplicationContext] to ensure that
|
||||
// the context we're wrapping is in fact an application context.
|
||||
ReactContext(context.applicationContext)
|
||||
+2
-2
@@ -9,6 +9,7 @@ package com.facebook.react.modules.clipboard
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import com.facebook.fbreact.specs.NativeClipboardSpec
|
||||
import com.facebook.react.bridge.Promise
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
@@ -20,8 +21,7 @@ internal class ClipboardModule(context: ReactApplicationContext) : NativeClipboa
|
||||
|
||||
private val clipboardService: ClipboardManager
|
||||
get() =
|
||||
getReactApplicationContext().getSystemService(ReactApplicationContext.CLIPBOARD_SERVICE)
|
||||
as ClipboardManager
|
||||
getReactApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
|
||||
override fun getString(promise: Promise) {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user