Skip to content

Commit 9397b11

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Make ToastModule internal (#50741)
Summary: This class can be internalized as part of the initiative to reduce the public API surface. I've checked there are [no relevant OSS usages](https://github.com/search?type=code&q=NOT+is%3Afork+NOT+org%3Afacebook+NOT+repo%3Areact-native-tvos%2Freact-native-tvos+NOT+repo%3Anuagoz%2Freact-native+NOT+repo%3A2lambda123%2Freact-native+NOT+repo%3Abeanchips%2Ffacebookreactnative+NOT+repo%3AfabOnReact%2Freact-native-notes+NOT+user%3Ahuntie+NOT+user%3Acortinico+NOT+repo%3AMaxdev18%2Fpowersync_app+NOT+repo%3Acarter-0%2Finstagram-decompiled+NOT+repo%3Am0mosenpai%2Finstadamn+NOT+repo%3AA-Star100%2FA-Star100-AUG2-2024+NOT+repo%3Alclnrd%2Fdetox-scrollview-reproductible+NOT+repo%3ADionisisChytiris%2FWorldWiseTrivia_Main+NOT+repo%3Apast3l%2Fhi2+NOT+repo%3AoneDotpy%2FCaribouQuest+NOT+repo%3Abejayoharen%2Fdailytodo+NOT+repo%3Amolangning%2Freversing-discord+NOT+repo%3AScottPrzy%2Freact-native+NOT+repo%3Agabrieldonadel%2Freact-native-visionos+NOT+repo%3AGabriel2308%2FTestes-Soft+NOT+repo%3Adawnzs03%2FflakyBuild+NOT+repo%3Acga2351%2Fcode+NOT+repo%3Astreeg%2Ftcc+NOT+repo%3Asoftware-mansion-labs%2Freact-native-swiftui+NOT+repo%3Apkcsecurity%2Fdecompiled-lightbulb+com.facebook.react.modules.toast.ToastModule). GH results are mostly forks and some very old repos (~8, 9 old) ## Changelog: [INTERNAL] - Make com.facebook.react.modules.toast.ToastModule internal Pull Request resolved: #50741 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: cortinico Differential Revision: D73089456 Pulled By: rshest fbshipit-source-id: 0cee12c92e5356c75a7c8b1b1b3c652c9bfce6be
1 parent 6182795 commit 9397b11

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,19 +3164,6 @@ public final class com/facebook/react/modules/systeminfo/ReactNativeVersion {
31643164
public static final field VERSION Ljava/util/Map;
31653165
}
31663166

3167-
public final class com/facebook/react/modules/toast/ToastModule : com/facebook/fbreact/specs/NativeToastAndroidSpec {
3168-
public static final field Companion Lcom/facebook/react/modules/toast/ToastModule$Companion;
3169-
public static final field NAME Ljava/lang/String;
3170-
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
3171-
public fun getTypedExportedConstants ()Ljava/util/Map;
3172-
public fun show (Ljava/lang/String;D)V
3173-
public fun showWithGravity (Ljava/lang/String;DD)V
3174-
public fun showWithGravityAndOffset (Ljava/lang/String;DDDD)V
3175-
}
3176-
3177-
public final class com/facebook/react/modules/toast/ToastModule$Companion {
3178-
}
3179-
31803167
public final class com/facebook/react/modules/websocket/WebSocketModule : com/facebook/fbreact/specs/NativeWebSocketModuleSpec {
31813168
public static final field Companion Lcom/facebook/react/modules/websocket/WebSocketModule$Companion;
31823169
public static final field NAME Ljava/lang/String;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import com.facebook.react.module.annotations.ReactModule
1717

1818
/** [NativeModule] that allows JS to show an Android Toast. */
1919
@ReactModule(name = NativeToastAndroidSpec.NAME)
20-
public class ToastModule(reactContext: ReactApplicationContext) :
20+
internal class ToastModule(reactContext: ReactApplicationContext) :
2121
NativeToastAndroidSpec(reactContext) {
2222

23-
public override fun getTypedExportedConstants(): Map<String, Any> =
23+
override fun getTypedExportedConstants(): Map<String, Any> =
2424
mutableMapOf(
2525
DURATION_SHORT_KEY to Toast.LENGTH_SHORT,
2626
DURATION_LONG_KEY to Toast.LENGTH_LONG,
@@ -29,17 +29,13 @@ public class ToastModule(reactContext: ReactApplicationContext) :
2929
GRAVITY_CENTER to (Gravity.CENTER_HORIZONTAL or Gravity.CENTER_VERTICAL),
3030
)
3131

32-
public override fun show(message: String?, durationDouble: Double) {
32+
override fun show(message: String?, durationDouble: Double) {
3333
val duration = durationDouble.toInt()
3434
UiThreadUtil.runOnUiThread(
3535
Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
3636
}
3737

38-
public override fun showWithGravity(
39-
message: String?,
40-
durationDouble: Double,
41-
gravityDouble: Double
42-
) {
38+
override fun showWithGravity(message: String?, durationDouble: Double, gravityDouble: Double) {
4339
val duration = durationDouble.toInt()
4440
val gravity = gravityDouble.toInt()
4541
UiThreadUtil.runOnUiThread(
@@ -50,7 +46,7 @@ public class ToastModule(reactContext: ReactApplicationContext) :
5046
})
5147
}
5248

53-
public override fun showWithGravityAndOffset(
49+
override fun showWithGravityAndOffset(
5450
message: String?,
5551
durationDouble: Double,
5652
gravityDouble: Double,
@@ -69,8 +65,8 @@ public class ToastModule(reactContext: ReactApplicationContext) :
6965
})
7066
}
7167

72-
public companion object {
73-
public const val NAME: String = NativeToastAndroidSpec.NAME
68+
companion object {
69+
const val NAME: String = NativeToastAndroidSpec.NAME
7470
private const val DURATION_SHORT_KEY = "SHORT"
7571
private const val DURATION_LONG_KEY = "LONG"
7672
private const val GRAVITY_TOP_KEY = "TOP"

0 commit comments

Comments
 (0)