Skip to content

Commit

Permalink
Stable API - Make ClipboardModule internal (#47413)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47413

This class should not be accessed directly, therefore I'm making it internal.
Technically breaking but I verified that there are no meaningful usages in OSS:
https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+com.facebook.react.modules.clipboard.ClipboardModule

Changelog:
[Android] [Breaking] - Stable API - Make `ClipboardModule` internal

Reviewed By: mdvacca

Differential Revision: D65479065

fbshipit-source-id: 1c534cafffdb27b808553eec7346e21fe4f38c24
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 6, 2024
1 parent d352a99 commit 10f6d5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
11 changes: 0 additions & 11 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -3066,17 +3066,6 @@ public final class com/facebook/react/modules/camera/ImageStoreManager : com/fac
public final class com/facebook/react/modules/camera/ImageStoreManager$Companion {
}

public final class com/facebook/react/modules/clipboard/ClipboardModule : com/facebook/fbreact/specs/NativeClipboardSpec {
public static final field Companion Lcom/facebook/react/modules/clipboard/ClipboardModule$Companion;
public static final field NAME Ljava/lang/String;
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun getString (Lcom/facebook/react/bridge/Promise;)V
public fun setString (Ljava/lang/String;)V
}

public final class com/facebook/react/modules/clipboard/ClipboardModule$Companion {
}

public final class com/facebook/react/modules/common/ModuleDataCleaner {
public static final field INSTANCE Lcom/facebook/react/modules/common/ModuleDataCleaner;
public static final fun cleanDataFromModules (Lcom/facebook/react/bridge/ReactContext;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import com.facebook.react.module.annotations.ReactModule

/** A module that allows JS to get/set clipboard contents. */
@ReactModule(name = NativeClipboardSpec.NAME)
public class ClipboardModule(context: ReactApplicationContext) : NativeClipboardSpec(context) {
internal class ClipboardModule(context: ReactApplicationContext) : NativeClipboardSpec(context) {

private val clipboardService: ClipboardManager
get() =
getReactApplicationContext().getSystemService(ReactApplicationContext.CLIPBOARD_SERVICE)
as ClipboardManager

public override fun getString(promise: Promise) {
override fun getString(promise: Promise) {
try {
val clipboard = clipboardService
val clipData = clipboard.primaryClip
Expand All @@ -38,12 +38,12 @@ public class ClipboardModule(context: ReactApplicationContext) : NativeClipboard
}
}

public override fun setString(text: String?) {
override fun setString(text: String?) {
val clipdata: ClipData = ClipData.newPlainText(null, text)
clipboardService.setPrimaryClip(clipdata)
}

public companion object {
public const val NAME: String = NativeClipboardSpec.NAME
companion object {
const val NAME: String = NativeClipboardSpec.NAME
}
}

0 comments on commit 10f6d5a

Please sign in to comment.