Skip to content

Commit d3495fd

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Migrate ReactApplicationContext to Kotlin (facebook#52208)
Summary: Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin Pull Request resolved: facebook#52208 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D77209812 Pulled By: cortinico fbshipit-source-id: 2dae094d363e60efe05b4f2b3d55f0f84d921495
1 parent 252e134 commit d3495fd

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.bridge
9+
10+
import android.content.Context
11+
12+
/**
13+
* A context wrapper that always wraps Android Application [Context] and [CatalystInstance] by
14+
* extending [ReactContext].
15+
*/
16+
public abstract class ReactApplicationContext(context: Context) :
17+
// We want to wrap ApplicationContext, since there is no easy way to verify that application
18+
// context is passed as a param, we use [Context.getApplicationContext] to ensure that
19+
// the context we're wrapping is in fact an application context.
20+
ReactContext(context.applicationContext)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package com.facebook.react.modules.clipboard
99

1010
import android.content.ClipData
1111
import android.content.ClipboardManager
12+
import android.content.Context
1213
import com.facebook.fbreact.specs.NativeClipboardSpec
1314
import com.facebook.react.bridge.Promise
1415
import com.facebook.react.bridge.ReactApplicationContext
@@ -20,8 +21,7 @@ internal class ClipboardModule(context: ReactApplicationContext) : NativeClipboa
2021

2122
private val clipboardService: ClipboardManager
2223
get() =
23-
getReactApplicationContext().getSystemService(ReactApplicationContext.CLIPBOARD_SERVICE)
24-
as ClipboardManager
24+
getReactApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
2525

2626
override fun getString(promise: Promise) {
2727
try {

0 commit comments

Comments
 (0)